|
@@ -7,6 +7,7 @@
|
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
|
|
|
|
|
use frame_support::dispatch::{DispatchError, DispatchResult};
|
|
|
+use frame_support::ensure;
|
|
|
use frame_support::traits::{Currency, Get, LockIdentifier, LockableCurrency, WithdrawReasons};
|
|
|
use sp_arithmetic::traits::Zero;
|
|
|
use sp_std::marker::PhantomData;
|
|
@@ -152,11 +153,10 @@ impl<
|
|
|
return Ok(());
|
|
|
}
|
|
|
|
|
|
- let usable_balance = <pallet_balances::Module<T>>::usable_balance(account_id);
|
|
|
-
|
|
|
- if new_stake > current_stake + usable_balance {
|
|
|
- return Err(DispatchError::Other("Not enough balance for a new stake."));
|
|
|
- }
|
|
|
+ ensure!(
|
|
|
+ Self::is_enough_balance_for_stake(account_id, new_stake),
|
|
|
+ DispatchError::Other("Not enough balance for a new stake.")
|
|
|
+ );
|
|
|
|
|
|
Self::lock(account_id, new_stake);
|
|
|
|
|
@@ -175,7 +175,7 @@ impl<
|
|
|
account_id: &<T as frame_system::Trait>::AccountId,
|
|
|
amount: <T as pallet_balances::Trait>::Balance,
|
|
|
) -> bool {
|
|
|
- <pallet_balances::Module<T>>::usable_balance(account_id) >= amount
|
|
|
+ <pallet_balances::Module<T>>::free_balance(account_id) >= amount
|
|
|
}
|
|
|
|
|
|
fn lock_id() -> LockIdentifier {
|