mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 06:57:58 +00:00
Dependency Injection Trait Locker for Uniques Pallet (#11025)
* Create a dependency injection trait named Locker that can be implemented downstream to enable locking of an asset. Use case defined in RMRK substrate pallet PR76 * Formatting * Change impl Locker function name to is_locked * Remove unused import * Add docstring header * Remove impl_locker file and add Locker trait to frame_support::traits * Expose Locker from frame_support::traits::misc * Formatting * Move to tokens folder * Move to tokens folder * Format and remove Locker from misc traits * Punctuation * Update frame/support/src/traits/tokens/misc.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
@@ -27,7 +27,7 @@ pub use tokens::{
|
||||
},
|
||||
fungible, fungibles,
|
||||
imbalance::{Imbalance, OnUnbalanced, SignedImbalance},
|
||||
BalanceStatus, ExistenceRequirement, WithdrawReasons,
|
||||
BalanceStatus, ExistenceRequirement, Locker, WithdrawReasons,
|
||||
};
|
||||
|
||||
mod members;
|
||||
|
||||
@@ -27,5 +27,5 @@ pub mod nonfungibles;
|
||||
pub use imbalance::Imbalance;
|
||||
pub use misc::{
|
||||
AssetId, Balance, BalanceConversion, BalanceStatus, DepositConsequence, ExistenceRequirement,
|
||||
WithdrawConsequence, WithdrawReasons,
|
||||
Locker, WithdrawConsequence, WithdrawReasons,
|
||||
};
|
||||
|
||||
@@ -179,3 +179,19 @@ pub trait BalanceConversion<InBalance, AssetId, OutBalance> {
|
||||
type Error;
|
||||
fn to_asset_balance(balance: InBalance, asset_id: AssetId) -> Result<OutBalance, Self::Error>;
|
||||
}
|
||||
|
||||
/// Trait to handle asset locking mechanism to ensure interactions with the asset can be implemented
|
||||
/// downstream to extend logic of Uniques current functionality.
|
||||
pub trait Locker<ClassId, InstanceId> {
|
||||
/// Check if the asset should be locked and prevent interactions with the asset from executing.
|
||||
fn is_locked(class: ClassId, instance: InstanceId) -> bool;
|
||||
}
|
||||
|
||||
impl<ClassId, InstanceId> Locker<ClassId, InstanceId> for () {
|
||||
// Default will be false if not implemented downstream.
|
||||
// Note: The logic check in this function must be constant time and consistent for benchmarks
|
||||
// to work.
|
||||
fn is_locked(_class: ClassId, _instance: InstanceId) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user