mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 20:47:56 +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:
@@ -33,6 +33,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
) -> DispatchResult {
|
||||
let class_details = Class::<T, I>::get(&class).ok_or(Error::<T, I>::UnknownClass)?;
|
||||
ensure!(!class_details.is_frozen, Error::<T, I>::Frozen);
|
||||
ensure!(!T::Locker::is_locked(class, instance), Error::<T, I>::Locked);
|
||||
|
||||
let mut details =
|
||||
Asset::<T, I>::get(&class, &instance).ok_or(Error::<T, I>::UnknownClass)?;
|
||||
|
||||
@@ -43,7 +43,7 @@ pub mod weights;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::traits::{
|
||||
BalanceStatus::Reserved, Currency, EnsureOriginWithArg, ReservableCurrency,
|
||||
tokens::Locker, BalanceStatus::Reserved, Currency, EnsureOriginWithArg, ReservableCurrency,
|
||||
};
|
||||
use frame_system::Config as SystemConfig;
|
||||
use sp_runtime::{
|
||||
@@ -108,6 +108,9 @@ pub mod pallet {
|
||||
Self::ClassId,
|
||||
>;
|
||||
|
||||
/// Locker trait to enable Locking mechanism downstream.
|
||||
type Locker: Locker<Self::ClassId, Self::InstanceId>;
|
||||
|
||||
/// The basic amount of funds that must be reserved for an asset class.
|
||||
#[pallet::constant]
|
||||
type ClassDeposit: Get<DepositBalanceOf<Self, I>>;
|
||||
@@ -352,6 +355,8 @@ pub mod pallet {
|
||||
Unapproved,
|
||||
/// The named owner has not signed ownership of the class is acceptable.
|
||||
Unaccepted,
|
||||
/// The asset instance is locked.
|
||||
Locked,
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
|
||||
@@ -91,6 +91,7 @@ impl Config for Test {
|
||||
type Currency = Balances;
|
||||
type CreateOrigin = AsEnsureOriginWithArg<frame_system::EnsureSigned<u64>>;
|
||||
type ForceOrigin = frame_system::EnsureRoot<u64>;
|
||||
type Locker = ();
|
||||
type ClassDeposit = ConstU64<2>;
|
||||
type InstanceDeposit = ConstU64<1>;
|
||||
type MetadataDepositBase = ConstU64<1>;
|
||||
|
||||
Reference in New Issue
Block a user