--- a/pallets/app-promotion/src/lib.rs +++ b/pallets/app-promotion/src/lib.rs @@ -101,7 +101,7 @@ Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key, PalletId, weights::Weight, }; use frame_system::pallet_prelude::*; -use sp_runtime::DispatchError; + use sp_runtime::DispatchError; #[pallet::config] pub trait Config: @@ -109,8 +109,11 @@ { /// Type to interact with the native token type Currency: MutateFreeze - + Mutate - + ExtendedLockableCurrency::Currency as Inspect>::Balance>; + + Mutate + + ExtendedLockableCurrency< + Self::AccountId, + Balance = <::Currency as Inspect>::Balance, + >; /// Type for interacting with collections type CollectionHandler: CollectionHandler< @@ -130,7 +133,9 @@ /// Freeze identifier used by the pallet #[pallet::constant] - type FreezeIdentifier: Get<<::Currency as InspectFreeze>::Id>; + type FreezeIdentifier: Get< + <::Currency as InspectFreeze>::Id, + >; /// In relay blocks. #[pallet::constant] @@ -215,7 +220,7 @@ /// Errors caused by insufficient staked balance. InsufficientStakedBalance, /// Errors caused by incorrect state of a staker in context of the pallet. - InconsistencyState + InconsistencyState, } /// Stores the total staked amount. @@ -833,25 +838,26 @@ ) -> DispatchResult { ensure_signed(origin)?; - stakers.into_iter().try_for_each(|s| -> Result<_, DispatchError> { - if let Some(lock) = Self::get_locked_balance(&s) { - - if let Some(_) = Self::get_frozen_balance(&s) { - return Err(Error::::InconsistencyState.into()) + stakers + .into_iter() + .try_for_each(|s| -> Result<_, DispatchError> { + if let Some(lock) = Self::get_locked_balance(&s) { + if let Some(_) = Self::get_frozen_balance(&s) { + return Err(Error::::InconsistencyState.into()); + } + + <::Currency as LockableCurrency>::remove_lock( + LOCK_IDENTIFIER, + &s, + ); + + Self::set_freeze_unchecked(&s, lock.amount); + Ok(()) + } else { + Ok(()) } - - <::Currency as LockableCurrency>::remove_lock( - LOCK_IDENTIFIER, - &s, - ); + })?; - Self::set_freeze_unchecked(&s, lock.amount); - Ok(()) - } else { - Ok(()) - } - })?; - Ok(()) } }