--- a/pallets/app-promotion/src/lib.rs +++ b/pallets/app-promotion/src/lib.rs @@ -234,7 +234,7 @@ QueryKind = ValueQuery, >; - /// Stores amount of stakes for an `Account`. + /// Stores number of stake records for an `Account`. /// /// * **Key** - Staker account. /// * **Value** - Amount of stakes. @@ -242,7 +242,7 @@ pub type StakesPerAccount = StorageMap<_, Blake2_128Concat, T::AccountId, u8, ValueQuery>; - /// Stores amount of stakes for an `Account`. + /// Pending unstake records for an `Account`. /// /// * **Key** - Staker account. /// * **Value** - Amount of stakes. @@ -263,7 +263,8 @@ StorageValue; #[pallet::storage] - pub(crate) type IsMigrated = StorageValue; + pub(crate) type UpgradedToReserves = + StorageValue; #[pallet::hooks] impl Hooks> for Pallet { @@ -296,12 +297,12 @@ consumed_weight += weight; }; - if >::get() { + if >::get() { add_weight(1, 0, Weight::zero()); return consumed_weight; } else { add_weight(1, 1, Weight::zero()); - >::set(true); + >::set(true); } >::drain().for_each(|(_, v)| { add_weight(1, 1, Weight::zero()); @@ -319,7 +320,7 @@ #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, &'static str> { use sp_std::collections::btree_map::BTreeMap; - if >::get() { + if >::get() { return Ok(Default::default()); } // Staker -> (total amount of reserved balance, reserved by promotion); @@ -346,7 +347,7 @@ fn post_upgrade(pre_state: Vec) -> Result<(), &'static str> { use sp_std::collections::btree_map::BTreeMap; - if >::get() { + if >::get() { return Ok(()); } @@ -807,26 +808,6 @@ pub fn account_id() -> T::AccountId { T::PalletId::get().into_account_truncating() } - - // /// Unlocks the balance that was locked by the pallet. - // /// - // /// - `staker`: staker account. - // /// - `amount`: amount of unlocked funds. - // fn unlock_balance(staker: &T::AccountId, amount: BalanceOf) -> DispatchResult { - // let locked_balance = Self::get_locked_balance(staker) - // .map(|l| l.amount) - // .ok_or(>::IncorrectLockedBalanceOperation)?; - - // // It is understood that we cannot unlock more funds than were locked by staking. - // // Therefore, if implemented correctly, this error should not occur. - // Self::set_lock_unchecked( - // staker, - // locked_balance - // .checked_sub(&amount) - // .ok_or(ArithmeticError::Underflow)?, - // ); - // Ok(()) - // } /// Adds the balance to locked by the pallet. ///