mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 02:08:02 +00:00
Move LockableCurrency trait to fungibles::Lockable and deprecate LockableCurrency (#12798)
* WIP move LockableCurrency to fungibles * rename Lockable and LockIdentifier to funginbles::* * fix imports further * change Lockable from fungible to fungibles * reintroduce LockableCurrency but marked as deprecated * fix imports * fix imports * cargo fmt * add allow deprecated warnings * remove unused benchmark import * fix some of the docs * fix failing doctest check * reexport LockIdentifier and LockableCurrency from support/traits * reexport LockIdentifier and LockableCurrency from support/traits * allow using deprecated re-export * replace LockableCurrency and LockIdentifier with a module alias * Update frame/support/src/traits/tokens/fungibles/lockable.rs * Update frame/staking/src/pallet/mod.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update frame/support/src/traits.rs Co-authored-by: Squirrel <gilescope@gmail.com> * REVERT removing fungibles::Lockable import Co-authored-by: parity-processbot <> Co-authored-by: Squirrel <gilescope@gmail.com>
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
//! - [`ReservableCurrency`](frame_support::traits::ReservableCurrency):
|
||||
//! - [`NamedReservableCurrency`](frame_support::traits::NamedReservableCurrency):
|
||||
//! Functions for dealing with assets that can be reserved from an account.
|
||||
//! - [`LockableCurrency`](frame_support::traits::LockableCurrency): Functions for
|
||||
//! - [`Lockable`](frame_support::traits::fungibles::Lockable): Functions for
|
||||
//! dealing with accounts that allow liquidity restrictions.
|
||||
//! - [`Imbalance`](frame_support::traits::Imbalance): Functions for handling
|
||||
//! imbalances between total issuance in the system and account balances. Must be used when a
|
||||
@@ -113,13 +113,13 @@
|
||||
//! # fn main() {}
|
||||
//! ```
|
||||
//!
|
||||
//! The Staking pallet uses the `LockableCurrency` trait to lock a stash account's funds:
|
||||
//! The Staking pallet uses the `fungibles::Lockable` trait to lock a stash account's funds:
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::traits::{WithdrawReasons, LockableCurrency};
|
||||
//! use frame_support::traits::{WithdrawReasons, fungibles, fungibles::Lockable};
|
||||
//! use sp_runtime::traits::Bounded;
|
||||
//! pub trait Config: frame_system::Config {
|
||||
//! type Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;
|
||||
//! type Currency: fungibles::Lockable<Self::AccountId, Moment=Self::BlockNumber>;
|
||||
//! }
|
||||
//! # struct StakingLedger<T: Config> {
|
||||
//! # stash: <T as frame_system::Config>::AccountId,
|
||||
@@ -171,11 +171,13 @@ use frame_support::{
|
||||
ensure,
|
||||
pallet_prelude::DispatchResult,
|
||||
traits::{
|
||||
tokens::{fungible, BalanceStatus as Status, DepositConsequence, WithdrawConsequence},
|
||||
tokens::{
|
||||
fungible, fungibles, BalanceStatus as Status, DepositConsequence, WithdrawConsequence,
|
||||
},
|
||||
Currency, DefensiveSaturating, ExistenceRequirement,
|
||||
ExistenceRequirement::{AllowDeath, KeepAlive},
|
||||
Get, Imbalance, LockIdentifier, LockableCurrency, NamedReservableCurrency, OnUnbalanced,
|
||||
ReservableCurrency, SignedImbalance, StoredMap, TryDrop, WithdrawReasons,
|
||||
Get, Imbalance, NamedReservableCurrency, OnUnbalanced, ReservableCurrency, SignedImbalance,
|
||||
StoredMap, TryDrop, WithdrawReasons,
|
||||
},
|
||||
WeakBoundedVec,
|
||||
};
|
||||
@@ -662,7 +664,7 @@ impl BitOr for Reasons {
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
pub struct BalanceLock<Balance> {
|
||||
/// An identifier for this lock. Only one lock may be in existence for each identifier.
|
||||
pub id: LockIdentifier,
|
||||
pub id: fungibles::LockIdentifier,
|
||||
/// The amount which the free balance may not drop below when this lock is in effect.
|
||||
pub amount: Balance,
|
||||
/// If true, then the lock remains in effect even for payment of transaction fees.
|
||||
@@ -2131,7 +2133,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> LockableCurrency<T::AccountId> for Pallet<T, I>
|
||||
impl<T: Config<I>, I: 'static> fungibles::Lockable<T::AccountId> for Pallet<T, I>
|
||||
where
|
||||
T::Balance: MaybeSerializeDeserialize + Debug,
|
||||
{
|
||||
@@ -2142,7 +2144,7 @@ where
|
||||
// Set a lock on the balance of `who`.
|
||||
// Is a no-op if lock amount is zero or `reasons` `is_none()`.
|
||||
fn set_lock(
|
||||
id: LockIdentifier,
|
||||
id: fungibles::LockIdentifier,
|
||||
who: &T::AccountId,
|
||||
amount: T::Balance,
|
||||
reasons: WithdrawReasons,
|
||||
@@ -2164,7 +2166,7 @@ where
|
||||
// Extend a lock on the balance of `who`.
|
||||
// Is a no-op if lock amount is zero or `reasons` `is_none()`.
|
||||
fn extend_lock(
|
||||
id: LockIdentifier,
|
||||
id: fungibles::LockIdentifier,
|
||||
who: &T::AccountId,
|
||||
amount: T::Balance,
|
||||
reasons: WithdrawReasons,
|
||||
@@ -2193,7 +2195,7 @@ where
|
||||
Self::update_locks(who, &locks[..]);
|
||||
}
|
||||
|
||||
fn remove_lock(id: LockIdentifier, who: &T::AccountId) {
|
||||
fn remove_lock(id: fungibles::LockIdentifier, who: &T::AccountId) {
|
||||
let mut locks = Self::locks(who);
|
||||
locks.retain(|l| l.id != id);
|
||||
Self::update_locks(who, &locks[..]);
|
||||
|
||||
@@ -28,15 +28,15 @@ macro_rules! decl_tests {
|
||||
use frame_support::{
|
||||
assert_noop, assert_storage_noop, assert_ok, assert_err,
|
||||
traits::{
|
||||
LockableCurrency, LockIdentifier, WithdrawReasons,
|
||||
fungibles, fungibles::Lockable, WithdrawReasons,
|
||||
Currency, ReservableCurrency, ExistenceRequirement::AllowDeath
|
||||
}
|
||||
};
|
||||
use pallet_transaction_payment::{ChargeTransactionPayment, Multiplier};
|
||||
use frame_system::RawOrigin;
|
||||
|
||||
const ID_1: LockIdentifier = *b"1 ";
|
||||
const ID_2: LockIdentifier = *b"2 ";
|
||||
const ID_1: fungibles::LockIdentifier = *b"1 ";
|
||||
const ID_2: fungibles::LockIdentifier = *b"2 ";
|
||||
|
||||
pub const CALL: &<$test as frame_system::Config>::RuntimeCall =
|
||||
&RuntimeCall::Balances(pallet_balances::Call::transfer { dest: 0, value: 0 });
|
||||
|
||||
Reference in New Issue
Block a user