mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 12:41:07 +00:00
* Some work * Fixes * Tests builds * Fixes * Fixes * Fixes * Fixes * Fixes * Formatting * Formatting * Fix * Fixes * Fixes * Fixes * Fixes * Update Cargo.lock * Bump * Fixes
This commit is contained in:
@@ -635,16 +635,10 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
winning_ranges
|
||||
.into_iter()
|
||||
.map(|range| {
|
||||
let mut final_winner = Default::default();
|
||||
swap(
|
||||
&mut final_winner,
|
||||
winning[range as u8 as usize]
|
||||
.as_mut()
|
||||
.expect("none values are filtered out in previous logic; qed"),
|
||||
);
|
||||
let (bidder, para, amount) = final_winner;
|
||||
(bidder, para, amount, range)
|
||||
.filter_map(|range| {
|
||||
winning[range as u8 as usize]
|
||||
.take()
|
||||
.map(|(bidder, para, amount)| (bidder, para, amount, range))
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
@@ -633,6 +633,16 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
Ok(self.validate(who, call, info, len).map(|_| ())?)
|
||||
}
|
||||
|
||||
// <weight>
|
||||
// The weight of this logic is included in the `attest` dispatchable.
|
||||
// </weight>
|
||||
|
||||
@@ -858,7 +858,7 @@ mod tests {
|
||||
use sp_keystore::{testing::KeyStore, KeystoreExt};
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput},
|
||||
DispatchResult,
|
||||
};
|
||||
|
||||
@@ -1323,7 +1323,8 @@ mod tests {
|
||||
let payload = (0u32, 1u64, 0u64, 49u64);
|
||||
let valid_signature =
|
||||
crypto::create_ed25519_signature(&payload.encode(), pubkey.clone());
|
||||
let invalid_signature = MultiSignature::default();
|
||||
let invalid_signature =
|
||||
MultiSignature::decode(&mut TrailingZeroInput::zeroes()).unwrap();
|
||||
|
||||
// Invalid signature
|
||||
assert_noop!(
|
||||
@@ -1882,6 +1883,7 @@ mod benchmarking {
|
||||
use super::{Pallet as Crowdloan, *};
|
||||
use frame_support::{assert_ok, traits::OnInitialize};
|
||||
use frame_system::RawOrigin;
|
||||
use sp_core::crypto::UncheckedFrom;
|
||||
use sp_runtime::traits::{Bounded, CheckedSub};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
@@ -1960,7 +1962,7 @@ mod benchmarking {
|
||||
let head_data = T::Registrar::worst_head_data();
|
||||
let validation_code = T::Registrar::worst_validation_code();
|
||||
|
||||
let verifier = account("verifier", 0, 0);
|
||||
let verifier = MultiSigner::unchecked_from(account::<[u8; 32]>("verifier", 0, 0));
|
||||
|
||||
CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?;
|
||||
@@ -2048,7 +2050,7 @@ mod benchmarking {
|
||||
let head_data = T::Registrar::worst_head_data();
|
||||
let validation_code = T::Registrar::worst_validation_code();
|
||||
|
||||
let verifier: MultiSigner = account("verifier", 0, 0);
|
||||
let verifier = MultiSigner::unchecked_from(account::<[u8; 32]>("verifier", 0, 0));
|
||||
|
||||
CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?;
|
||||
|
||||
@@ -29,10 +29,9 @@ where
|
||||
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
|
||||
{
|
||||
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
|
||||
<pallet_balances::Pallet<R>>::resolve_creating(
|
||||
&<pallet_authorship::Pallet<R>>::author(),
|
||||
amount,
|
||||
);
|
||||
if let Some(author) = <pallet_authorship::Pallet<R>>::author() {
|
||||
<pallet_balances::Pallet<R>>::resolve_creating(&author, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ pub mod pallet {
|
||||
|
||||
// The account that will be used to payout participants of the DOT purchase process.
|
||||
#[pallet::storage]
|
||||
pub(super) type PaymentAccount<T: Config> = StorageValue<_, T::AccountId, ValueQuery>;
|
||||
pub(super) type PaymentAccount<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;
|
||||
|
||||
// The statement purchasers will need to sign to participate.
|
||||
#[pallet::storage]
|
||||
@@ -290,12 +290,14 @@ pub mod pallet {
|
||||
///
|
||||
/// We reverify all assumptions about the state of an account, and complete the process.
|
||||
///
|
||||
/// Origin must match the configured `PaymentAccount`.
|
||||
/// Origin must match the configured `PaymentAccount` (if it is not configured then this
|
||||
/// will always fail with `BadOrigin`).
|
||||
#[pallet::weight(T::DbWeight::get().reads_writes(4, 2))]
|
||||
pub fn payout(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
||||
// Payments must be made directly by the `PaymentAccount`.
|
||||
let payment_account = ensure_signed(origin)?;
|
||||
ensure!(payment_account == PaymentAccount::<T>::get(), DispatchError::BadOrigin);
|
||||
let test_against = PaymentAccount::<T>::get().ok_or(DispatchError::BadOrigin)?;
|
||||
ensure!(payment_account == test_against, DispatchError::BadOrigin);
|
||||
|
||||
// Account should not have a vesting schedule.
|
||||
ensure!(
|
||||
@@ -363,7 +365,7 @@ pub mod pallet {
|
||||
pub fn set_payment_account(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
||||
T::ConfigurationOrigin::ensure_origin(origin)?;
|
||||
// Possibly this is worse than having the caller account be the payment account?
|
||||
PaymentAccount::<T>::set(who.clone());
|
||||
PaymentAccount::<T>::put(who.clone());
|
||||
Self::deposit_event(Event::<T>::PaymentAccountSet(who));
|
||||
Ok(())
|
||||
}
|
||||
@@ -712,7 +714,7 @@ mod tests {
|
||||
Origin::signed(configuration_origin()),
|
||||
payment_account.clone()
|
||||
));
|
||||
assert_eq!(PaymentAccount::<Test>::get(), payment_account);
|
||||
assert_eq!(PaymentAccount::<Test>::get(), Some(payment_account));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1111,7 +1111,7 @@ mod benchmarking {
|
||||
trigger_onboard {
|
||||
// get a parachain into a bad state where they did not onboard
|
||||
let (para, _) = register_a_parathread::<T>(1);
|
||||
Leases::<T>::insert(para, vec![Some((T::AccountId::default(), BalanceOf::<T>::default()))]);
|
||||
Leases::<T>::insert(para, vec![Some((account::<T::AccountId>("lease_insert", 0, 0), BalanceOf::<T>::default()))]);
|
||||
assert!(T::Registrar::is_parathread(para));
|
||||
let caller = whitelisted_caller();
|
||||
}: _(RawOrigin::Signed(caller), para)
|
||||
|
||||
Reference in New Issue
Block a user