From 8ac1630a1694b89b9af56071b7d7abcc4d3a4e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 11 Apr 2023 00:33:25 +0200 Subject: [PATCH 1/4] HoldReason: Improve usage `HoldReason` was switched recently to use the `composite_enum` attribute that will merge the enums from all pallets in the runtime to `RuntimeHoldReason`. `pallet-nis` was still requiring that the variant was passed as constant to call `hold`. The proper implementation is to use the `HoldReason` from inside the pallet directly when calling `hold`. This is done by adding a `RuntimeHoldReason` as type to the `Config` trait and requiring that `Currency` is using the same reason. Besides that the pr changes the name `HoldIdentifier` in `pallet_balances::Config` to `RuntimeHoldReason`. --- bin/node-template/runtime/src/lib.rs | 2 +- bin/node/runtime/src/lib.rs | 15 ++--------- frame/alliance/src/mock.rs | 2 +- frame/assets/src/mock.rs | 2 +- frame/atomic-swap/src/tests.rs | 2 +- frame/babe/src/mock.rs | 2 +- frame/balances/src/impl_fungible.rs | 2 +- frame/balances/src/lib.rs | 6 ++--- frame/balances/src/tests/mod.rs | 2 +- frame/beefy/src/mock.rs | 2 +- frame/bounties/src/tests.rs | 2 +- frame/child-bounties/src/tests.rs | 2 +- frame/contracts/src/tests.rs | 2 +- frame/conviction-voting/src/tests.rs | 2 +- frame/democracy/src/tests.rs | 2 +- .../election-provider-multi-phase/src/mock.rs | 2 +- frame/elections-phragmen/src/lib.rs | 2 +- frame/examples/basic/src/tests.rs | 2 +- frame/executive/src/lib.rs | 2 +- frame/fast-unstake/src/mock.rs | 2 +- frame/grandpa/src/mock.rs | 2 +- frame/identity/src/tests.rs | 2 +- frame/indices/src/mock.rs | 2 +- frame/lottery/src/mock.rs | 2 +- frame/multisig/src/tests.rs | 2 +- frame/nfts/src/mock.rs | 2 +- frame/nicks/src/lib.rs | 2 +- frame/nis/src/lib.rs | 26 +++++++++---------- frame/nis/src/mock.rs | 16 +++--------- .../nomination-pools/benchmarking/src/mock.rs | 2 +- frame/nomination-pools/src/mock.rs | 2 +- .../nomination-pools/test-staking/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/preimage/src/mock.rs | 2 +- frame/proxy/src/tests.rs | 2 +- frame/recovery/src/mock.rs | 2 +- frame/referenda/src/mock.rs | 2 +- frame/root-offences/src/mock.rs | 2 +- frame/scored-pool/src/mock.rs | 2 +- frame/session/benchmarking/src/mock.rs | 2 +- frame/society/src/mock.rs | 2 +- frame/staking/src/mock.rs | 2 +- frame/state-trie-migration/src/lib.rs | 2 +- frame/tips/src/tests.rs | 2 +- .../asset-tx-payment/src/mock.rs | 2 +- frame/transaction-payment/src/mock.rs | 2 +- frame/transaction-storage/src/mock.rs | 2 +- frame/treasury/src/tests.rs | 2 +- frame/uniques/src/mock.rs | 2 +- frame/utility/src/tests.rs | 2 +- frame/vesting/src/mock.rs | 2 +- frame/whitelist/src/mock.rs | 2 +- 52 files changed, 68 insertions(+), 91 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 3dcf1b5564dec..349401615ab40 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -245,7 +245,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 433ca8e8b839e..052ffd2400bf5 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -59,7 +59,6 @@ use pallet_nis::WithMaximumOf; use pallet_session::historical as pallet_session_historical; pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; -use scale_info::TypeInfo; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_grandpa::AuthorityId as GrandpaId; @@ -436,15 +435,6 @@ parameter_types! { pub const MaxReserves: u32 = 50; } -/// A reason for placing a hold on funds. -#[derive( - Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo, -)] -pub enum HoldReason { - /// The NIS Pallet has reserved it for a non-fungible receipt. - Nis, -} - impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; @@ -457,7 +447,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = HoldReason; + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = ConstU32<1>; } @@ -1500,7 +1490,6 @@ parameter_types! { pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5); pub Target: Perquintill = Perquintill::zero(); pub const NisPalletId: PalletId = PalletId(*b"py/nis "); - pub const NisHoldReason: HoldReason = HoldReason::Nis; } impl pallet_nis::Config for Runtime { @@ -1524,7 +1513,7 @@ impl pallet_nis::Config for Runtime { type IntakePeriod = IntakePeriod; type MaxIntakeWeight = MaxIntakeWeight; type ThawThrottle = ThawThrottle; - type HoldReason = NisHoldReason; + type RuntimeHoldReason = RuntimeHoldReason; } parameter_types! { diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 848f6b2a00557..23ee20490665e 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 3926d2fa8b010..09d2bd2296088 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = (); type FreezeIdentifier = (); type MaxHolds = (); type MaxFreezes = (); diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 7437d62a99c95..53ccd64bb2731 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -64,7 +64,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 94e748d0bca52..dd48f4547dc00 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -146,7 +146,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/balances/src/impl_fungible.rs b/frame/balances/src/impl_fungible.rs index f8f8fe17ae0ef..03c40bb3a8401 100644 --- a/frame/balances/src/impl_fungible.rs +++ b/frame/balances/src/impl_fungible.rs @@ -207,7 +207,7 @@ impl, I: 'static> fungible::Mutate for Pallet { impl, I: 'static> fungible::MutateHold for Pallet {} impl, I: 'static> fungible::InspectHold for Pallet { - type Reason = T::HoldIdentifier; + type Reason = T::RuntimeHoldReason; fn total_balance_on_hold(who: &T::AccountId) -> T::Balance { Self::account(who).reserved diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index dcf602cd5e0bf..0a99b2222b7e2 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -254,8 +254,8 @@ pub mod pallet { /// Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/` type ReserveIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy; - /// The ID type for holds. - type HoldIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy; + /// The overarching hold reason. + type RuntimeHoldReason: Parameter + Member + MaxEncodedLen + Ord + Copy; /// The ID type for freezes. type FreezeIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy; @@ -430,7 +430,7 @@ pub mod pallet { _, Blake2_128Concat, T::AccountId, - BoundedVec, T::MaxHolds>, + BoundedVec, T::MaxHolds>, ValueQuery, >; diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index 68e7e82035b0e..ce7ffc35c37ec 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -135,7 +135,7 @@ impl Config for Test { type MaxReserves = ConstU32<2>; type ReserveIdentifier = TestId; type WeightInfo = (); - type HoldIdentifier = TestId; + type RuntimeHoldReason = TestId; type FreezeIdentifier = TestId; type MaxFreezes = ConstU32<2>; type MaxHolds = ConstU32<2>; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index ceb95263e2436..2175e3ada53e1 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -161,7 +161,7 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); type FreezeIdentifier = (); type MaxFreezes = (); diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index ef3da7564874e..fd5020dead446 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -102,7 +102,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } parameter_types! { diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index a936312aec868..a8f0e16ea2136 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -105,7 +105,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } parameter_types! { diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index bae6c1946e183..0efc1e9e708f0 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -321,7 +321,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index f33e511a164f6..1ea3a56adacb7 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -94,7 +94,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 06fde5129c6d0..dd726004648ef 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -146,7 +146,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } parameter_types! { diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 8c18777606048..4f6c888783ea0 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -256,7 +256,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index d83c94db139a4..89797e7678b6b 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1250,7 +1250,7 @@ mod tests { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index d9a8a4e8e1cdc..f4aab9fa47394 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -89,7 +89,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index aad1de11d2c7b..e872c98c6a78b 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -895,7 +895,7 @@ mod tests { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = ConstU32<1>; - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = ConstU32<1>; } diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index fbe6c4592bf67..16f3f983cf443 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -91,7 +91,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index a7359f6896db7..42be572582876 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -144,7 +144,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index ba9749172e5f6..83035c402a7dc 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 8bd05d04ab4e1..f54e4dfa088dc 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -78,7 +78,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 7afd0e319db34..d89c9d6890ee2 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -91,7 +91,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index 7e7f1668026a2..cc0fbc8098936 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index e2856a07b994c..79f0b341e9fd3 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -90,7 +90,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 92865c773d886..7a7b33051b22e 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -297,7 +297,7 @@ mod tests { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 9cac5f4b616e7..73d72b491496c 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -217,12 +217,10 @@ pub mod pallet { + FunMutate + FunBalanced + FunHoldInspect - + FunHoldMutate; + + FunHoldMutate; - /// The identifier of the hold reason. - - #[pallet::constant] - type HoldReason: Get<>::Reason>; + /// Overarching hold reason. + type RuntimeHoldReason: Member + MaxEncodedLen + From; /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to /// `From`. @@ -569,14 +567,14 @@ pub mod pallet { |q| -> Result<(u32, BalanceOf), DispatchError> { let queue_full = q.len() == T::MaxQueueLen::get() as usize; ensure!(!queue_full || q[0].amount < amount, Error::::BidTooLow); - T::Currency::hold(&T::HoldReason::get(), &who, amount)?; + T::Currency::hold(&HoldReason::NftReceipt.into(), &who, amount)?; // queue is let mut bid = Bid { amount, who: who.clone() }; let net = if queue_full { sp_std::mem::swap(&mut q[0], &mut bid); let _ = T::Currency::release( - &T::HoldReason::get(), + &HoldReason::NftReceipt.into(), &bid.who, bid.amount, BestEffort, @@ -637,7 +635,7 @@ pub mod pallet { queue.remove(pos); let new_len = queue.len() as u32; - T::Currency::release(&T::HoldReason::get(), &bid.who, bid.amount, BestEffort)?; + T::Currency::release(&HoldReason::NftReceipt.into(), &bid.who, bid.amount, BestEffort)?; Queues::::insert(duration, queue); QueueTotals::::mutate(|qs| { @@ -729,7 +727,7 @@ pub mod pallet { let dropped = receipt.proportion.is_zero(); if amount > on_hold { - T::Currency::release(&T::HoldReason::get(), &who, on_hold, Exact)?; + T::Currency::release(&HoldReason::NftReceipt.into(), &who, on_hold, Exact)?; let deficit = amount - on_hold; // Try to transfer deficit from pot to receipt owner. summary.receipts_on_hold.saturating_reduce(on_hold); @@ -744,7 +742,7 @@ pub mod pallet { // Transfer excess of `on_hold` to the pot if we have now fully compensated for // the receipt. T::Currency::transfer_on_hold( - &T::HoldReason::get(), + &HoldReason::NftReceipt.into(), &who, &our_account, on_hold, @@ -760,7 +758,7 @@ pub mod pallet { )?; summary.receipts_on_hold.saturating_reduce(on_hold); } - T::Currency::release(&T::HoldReason::get(), &who, amount, Exact)?; + T::Currency::release(&HoldReason::NftReceipt.into(), &who, amount, Exact)?; } if dropped { @@ -852,7 +850,7 @@ pub mod pallet { ensure!(owner == who, Error::::NotOwner); // Unreserve and transfer the funds to the pot. - let reason = T::HoldReason::get(); + let reason = HoldReason::NftReceipt.into(); let us = Self::account_id(); T::Currency::transfer_on_hold(&reason, &who, &us, on_hold, Exact, Free, Polite) .map_err(|_| Error::::Unfunded)?; @@ -903,7 +901,7 @@ pub mod pallet { )?; // Transfer the funds from the pot to the owner and reserve - let reason = T::HoldReason::get(); + let reason = HoldReason::NftReceipt.into(); let us = Self::account_id(); T::Currency::transfer_and_hold(&reason, &us, &who, amount, Exact, Expendable, Polite)?; @@ -959,7 +957,7 @@ pub mod pallet { let mut item = Receipts::::get(index).ok_or(TokenError::UnknownAsset)?; let (owner, on_hold) = item.owner.take().ok_or(Error::::AlreadyCommunal)?; - let reason = T::HoldReason::get(); + let reason = HoldReason::NftReceipt.into(); T::Currency::transfer_on_hold(&reason, &owner, dest, on_hold, Exact, OnHold, Polite)?; item.owner = Some((dest.clone(), on_hold)); diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index 0ca6690936818..60aa0f756e9c6 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -19,7 +19,6 @@ use crate::{self as pallet_nis, Perquintill, WithMaximumOf}; -use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ ord_parameter_types, parameter_types, traits::{ @@ -30,7 +29,6 @@ use frame_support::{ PalletId, }; use pallet_balances::{Instance1, Instance2}; -use scale_info::TypeInfo; use sp_core::{ConstU128, H256}; use sp_runtime::{ testing::Header, @@ -95,17 +93,10 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = HoldIdentifier; + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = ConstU32<1>; } -#[derive( - Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo, -)] -pub enum HoldIdentifier { - Nis, -} - impl pallet_balances::Config for Test { type Balance = u128; type DustRemoval = (); @@ -122,7 +113,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -133,7 +124,6 @@ parameter_types! { pub const MinReceipt: Perquintill = Perquintill::from_percent(1); pub const ThawThrottle: (Perquintill, u64) = (Perquintill::from_percent(25), 5); pub static MaxIntakeWeight: Weight = Weight::from_parts(2_000_000_000_000, 0); - pub const HoldReason: HoldIdentifier = HoldIdentifier::Nis; } ord_parameter_types! { @@ -161,7 +151,7 @@ impl pallet_nis::Config for Test { type MaxIntakeWeight = MaxIntakeWeight; type MinReceipt = MinReceipt; type ThawThrottle = ThawThrottle; - type HoldReason = HoldReason; + type RuntimeHoldReason = RuntimeHoldReason; } // This function basically just builds a genesis storage key/value store according to diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index cffb712ea2ae5..d94c63d1bf5b5 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -77,7 +77,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 6d83ef61de793..817f190b0ee93 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -198,7 +198,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 9726f5e6dad27..a9c64508564cd 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -88,7 +88,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 668d88e0bf3d0..ed0c6c7ea4433 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -76,7 +76,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 5054a77a8123f..7c645da2c51d8 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -86,7 +86,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index f3771083c4dd4..54b76413bcff4 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -90,7 +90,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } impl pallet_utility::Config for Test { diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 5c190e2a241a5..523dd3aa3e8dc 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -88,7 +88,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index cdedb79556f35..1a43257cb94e1 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -122,7 +122,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } parameter_types! { diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 828551e4d9c19..3cf1f7e6ddd77 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -123,7 +123,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index f10a1320ef83c..83bc939e8230d 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -93,7 +93,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index b7671255f68fb..3b027492e0a6a 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -86,7 +86,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 9f72febc2106e..6075f14da1248 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -95,7 +95,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index c2f559a9780eb..5a473f8ebdc58 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -159,7 +159,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 1f6266d999825..05ca21c1de752 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1130,7 +1130,7 @@ mod mock { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index b2d97de18312f..b582e09f1bc2b 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -99,7 +99,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } parameter_types! { diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs index be7baaf2b370e..740915023a32d 100644 --- a/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -122,7 +122,7 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index 741f094481c38..28d57065eca18 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -115,7 +115,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 3a87d8eaea707..27a73ba3cedb9 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -86,7 +86,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 67b21ff6252a8..0659c2f5941b1 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -92,7 +92,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index bad393a489582..e783f0b7cf4d9 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -84,7 +84,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index d23c57e69bec5..071dde9fe693b 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -188,7 +188,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 1adb36b730b1a..31f35bbdab604 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -82,7 +82,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } parameter_types! { diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index d644cd661ec9f..63e7e9976badd 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -88,7 +88,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } From f857901d54dbb71a75436ff028d39774bbfbe514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 11 Apr 2023 21:13:37 +0200 Subject: [PATCH 2/4] Update frame/nis/src/lib.rs Co-authored-by: Oliver Tale-Yazdi --- frame/nis/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 73d72b491496c..4e6d90045bae2 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -216,7 +216,6 @@ pub mod pallet { type Currency: FunInspect + FunMutate + FunBalanced - + FunHoldInspect + FunHoldMutate; /// Overarching hold reason. From 564282e96af01f836dd50ca7081c6d4eb4d4c65a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 11 Apr 2023 21:24:17 +0200 Subject: [PATCH 3/4] Review comment --- frame/nis/src/lib.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 4e6d90045bae2..098de80c6ed31 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -162,11 +162,7 @@ pub mod pallet { use frame_support::{ pallet_prelude::*, traits::{ - fungible::{ - self, - hold::{Inspect as FunHoldInspect, Mutate as FunHoldMutate}, - Balanced as FunBalanced, - }, + fungible::{self, hold::Mutate as FunHoldMutate, Balanced as FunBalanced}, nonfungible::{Inspect as NftInspect, Transfer as NftTransfer}, tokens::{ Fortitude::Polite, @@ -219,7 +215,7 @@ pub mod pallet { + FunHoldMutate; /// Overarching hold reason. - type RuntimeHoldReason: Member + MaxEncodedLen + From; + type RuntimeHoldReason: From; /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to /// `From`. From 9d0200be4a87d3ca1d751fd17b48a76ef01bcb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 24 May 2023 11:27:35 +0200 Subject: [PATCH 4/4] Fixes --- bin/node/runtime/src/lib.rs | 3 +- client/executor/benches/bench.rs | 1 - frame/asset-rate/src/mock.rs | 2 +- .../test-staking-e2e/src/mock.rs | 2 +- frame/examples/dev-mode/src/tests.rs | 2 +- frame/nft-fractionalization/src/lib.rs | 28 +++++++++++++------ frame/nft-fractionalization/src/mock.rs | 14 ++-------- frame/statement/src/mock.rs | 2 +- test-utils/runtime/src/lib.rs | 2 +- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index e2e1977f0a818..abbae624fe0b6 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1606,7 +1606,6 @@ parameter_types! { pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction"); pub NewAssetSymbol: BoundedVec = (*b"FRAC").to_vec().try_into().unwrap(); pub NewAssetName: BoundedVec = (*b"Frac").to_vec().try_into().unwrap(); - pub const NftFractionalizationHoldReason: HoldReason = HoldReason::NftFractionalization; } impl pallet_nft_fractionalization::Config for Runtime { @@ -1624,7 +1623,7 @@ impl pallet_nft_fractionalization::Config for Runtime { type Nfts = Nfts; type PalletId = NftFractionalizationPalletId; type WeightInfo = pallet_nft_fractionalization::weights::SubstrateWeight; - type HoldReason = NftFractionalizationHoldReason; + type RuntimeHoldReason = RuntimeHoldReason; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } diff --git a/client/executor/benches/bench.rs b/client/executor/benches/bench.rs index 38ae58adb615b..66a82a175221d 100644 --- a/client/executor/benches/bench.rs +++ b/client/executor/benches/bench.rs @@ -25,7 +25,6 @@ use sc_executor_common::{ }; use sc_executor_wasmtime::InstantiationStrategy; use sc_runtime_test::wasm_binary_unwrap as test_runtime; -use sp_wasm_interface::HostFunctions as _; use std::sync::{ atomic::{AtomicBool, AtomicUsize, Ordering}, Arc, diff --git a/frame/asset-rate/src/mock.rs b/frame/asset-rate/src/mock.rs index 9775b7a747926..2d90fcfecd79e 100644 --- a/frame/asset-rate/src/mock.rs +++ b/frame/asset-rate/src/mock.rs @@ -77,7 +77,7 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = (); type MaxFreezes = (); diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 490179e91ddda..da7ccf6dce9ce 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -126,7 +126,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type MaxHolds = ConstU32<1>; type MaxFreezes = traits::ConstU32<1>; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type WeightInfo = (); } diff --git a/frame/examples/dev-mode/src/tests.rs b/frame/examples/dev-mode/src/tests.rs index e2f06ddda6cd7..6b18b4183eab7 100644 --- a/frame/examples/dev-mode/src/tests.rs +++ b/frame/examples/dev-mode/src/tests.rs @@ -83,7 +83,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = (); } diff --git a/frame/nft-fractionalization/src/lib.rs b/frame/nft-fractionalization/src/lib.rs index e1c8b8fea8907..459d89f5a8146 100644 --- a/frame/nft-fractionalization/src/lib.rs +++ b/frame/nft-fractionalization/src/lib.rs @@ -63,8 +63,8 @@ pub mod pallet { sp_runtime::traits::{AccountIdConversion, StaticLookup}, traits::{ fungible::{ - hold::{Inspect as HoldInspectFungible, Mutate as HoldMutateFungible}, - Inspect as InspectFungible, Mutate as MutateFungible, + hold::Mutate as HoldMutateFungible, Inspect as InspectFungible, + Mutate as MutateFungible, }, fungibles::{ metadata::{MetadataDeposit, Mutate as MutateMetadata}, @@ -96,11 +96,10 @@ pub mod pallet { /// The currency mechanism, used for paying for deposits. type Currency: InspectFungible + MutateFungible - + HoldInspectFungible - + HoldMutateFungible; + + HoldMutateFungible; - #[pallet::constant] - type HoldReason: Get<>::Reason>; + /// Overarching hold reason. + type RuntimeHoldReason: From; /// The deposit paid by the user locking an NFT. The deposit is returned to the original NFT /// owner when the asset is unified and the NFT is unlocked. @@ -201,6 +200,14 @@ pub mod pallet { NftNotFractionalized, } + /// A reason for the pallet placing a hold on funds. + #[pallet::composite_enum] + pub enum HoldReason { + /// Reserved for a fractionalized NFT. + #[codec(index = 0)] + Fractionalized, + } + #[pallet::call] impl Pallet { /// Lock the NFT and mint a new fungible asset. @@ -239,7 +246,7 @@ pub mod pallet { let pallet_account = Self::get_pallet_account(); let deposit = T::Deposit::get(); - T::Currency::hold(&T::HoldReason::get(), &nft_owner, deposit)?; + T::Currency::hold(&HoldReason::Fractionalized.into(), &nft_owner, deposit)?; Self::do_lock_nft(nft_collection_id, nft_id)?; Self::do_create_asset(asset_id.clone(), pallet_account.clone())?; Self::do_mint_asset(asset_id.clone(), &beneficiary, fractions)?; @@ -303,7 +310,12 @@ pub mod pallet { let asset_creator = details.asset_creator; Self::do_burn_asset(asset_id.clone(), &who, details.fractions)?; Self::do_unlock_nft(nft_collection_id, nft_id, &beneficiary)?; - T::Currency::release(&T::HoldReason::get(), &asset_creator, deposit, BestEffort)?; + T::Currency::release( + &HoldReason::Fractionalized.into(), + &asset_creator, + deposit, + BestEffort, + )?; Self::deposit_event(Event::NftUnified { nft_collection: nft_collection_id, diff --git a/frame/nft-fractionalization/src/mock.rs b/frame/nft-fractionalization/src/mock.rs index 05fbadb039398..62ff3df5b1a0f 100644 --- a/frame/nft-fractionalization/src/mock.rs +++ b/frame/nft-fractionalization/src/mock.rs @@ -20,7 +20,6 @@ use super::*; use crate as pallet_nft_fractionalization; -use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ construct_runtime, parameter_types, traits::{AsEnsureOriginWithArg, ConstU32, ConstU64}, @@ -28,7 +27,6 @@ use frame_support::{ }; use frame_system::EnsureSigned; use pallet_nfts::PalletFeatures; -use scale_info::TypeInfo; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -83,13 +81,6 @@ impl frame_system::Config for Test { type MaxConsumers = ConstU32<16>; } -#[derive( - Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo, -)] -pub enum HoldIdentifier { - NftFractionalization, -} - impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); @@ -100,7 +91,7 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = HoldIdentifier; + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = ConstU32<1>; type FreezeIdentifier = (); type MaxFreezes = (); @@ -169,7 +160,6 @@ parameter_types! { pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction"); pub NewAssetSymbol: BoundedVec = (*b"FRAC").to_vec().try_into().unwrap(); pub NewAssetName: BoundedVec = (*b"Frac").to_vec().try_into().unwrap(); - pub const HoldReason: HoldIdentifier = HoldIdentifier::NftFractionalization; } impl Config for Test { @@ -189,7 +179,7 @@ impl Config for Test { type StringLimit = StringLimit; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); - type HoldReason = HoldReason; + type RuntimeHoldReason = RuntimeHoldReason; } // Build genesis storage according to the mock runtime. diff --git a/frame/statement/src/mock.rs b/frame/statement/src/mock.rs index f4d9360c9a6c0..8b9e7a1a7d965 100644 --- a/frame/statement/src/mock.rs +++ b/frame/statement/src/mock.rs @@ -91,7 +91,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = (); } diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index c93d5c4e5694b..8d77439f16455 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -394,7 +394,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = ConstU32<1>; }