Companion #10403: Remove Default for AccountId (#4500)

* 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:
Gavin Wood
2021-12-14 08:17:26 +01:00
committed by GitHub
parent bd5721fbf5
commit ca72ad636c
32 changed files with 257 additions and 234 deletions
+7 -5
View File
@@ -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));
});
}