Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 9d0200b

Browse files
committed
Fixes
1 parent 15f2b9b commit 9d0200b

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

bin/node/runtime/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,6 @@ parameter_types! {
16061606
pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction");
16071607
pub NewAssetSymbol: BoundedVec<u8, StringLimit> = (*b"FRAC").to_vec().try_into().unwrap();
16081608
pub NewAssetName: BoundedVec<u8, StringLimit> = (*b"Frac").to_vec().try_into().unwrap();
1609-
pub const NftFractionalizationHoldReason: HoldReason = HoldReason::NftFractionalization;
16101609
}
16111610

16121611
impl pallet_nft_fractionalization::Config for Runtime {
@@ -1624,7 +1623,7 @@ impl pallet_nft_fractionalization::Config for Runtime {
16241623
type Nfts = Nfts;
16251624
type PalletId = NftFractionalizationPalletId;
16261625
type WeightInfo = pallet_nft_fractionalization::weights::SubstrateWeight<Runtime>;
1627-
type HoldReason = NftFractionalizationHoldReason;
1626+
type RuntimeHoldReason = RuntimeHoldReason;
16281627
#[cfg(feature = "runtime-benchmarks")]
16291628
type BenchmarkHelper = ();
16301629
}

client/executor/benches/bench.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use sc_executor_common::{
2525
};
2626
use sc_executor_wasmtime::InstantiationStrategy;
2727
use sc_runtime_test::wasm_binary_unwrap as test_runtime;
28-
use sp_wasm_interface::HostFunctions as _;
2928
use std::sync::{
3029
atomic::{AtomicBool, AtomicUsize, Ordering},
3130
Arc,

frame/asset-rate/src/mock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl pallet_balances::Config for Test {
7777
type MaxLocks = ();
7878
type MaxReserves = ();
7979
type ReserveIdentifier = [u8; 8];
80-
type HoldIdentifier = ();
80+
type RuntimeHoldReason = RuntimeHoldReason;
8181
type FreezeIdentifier = ();
8282
type MaxHolds = ();
8383
type MaxFreezes = ();

frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl pallet_balances::Config for Runtime {
126126
type AccountStore = System;
127127
type MaxHolds = ConstU32<1>;
128128
type MaxFreezes = traits::ConstU32<1>;
129-
type HoldIdentifier = ();
129+
type RuntimeHoldReason = RuntimeHoldReason;
130130
type FreezeIdentifier = ();
131131
type WeightInfo = ();
132132
}

frame/examples/dev-mode/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl pallet_balances::Config for Test {
8383
type WeightInfo = ();
8484
type FreezeIdentifier = ();
8585
type MaxFreezes = ();
86-
type HoldIdentifier = ();
86+
type RuntimeHoldReason = RuntimeHoldReason;
8787
type MaxHolds = ();
8888
}
8989

frame/nft-fractionalization/src/lib.rs

+20-8
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ pub mod pallet {
6363
sp_runtime::traits::{AccountIdConversion, StaticLookup},
6464
traits::{
6565
fungible::{
66-
hold::{Inspect as HoldInspectFungible, Mutate as HoldMutateFungible},
67-
Inspect as InspectFungible, Mutate as MutateFungible,
66+
hold::Mutate as HoldMutateFungible, Inspect as InspectFungible,
67+
Mutate as MutateFungible,
6868
},
6969
fungibles::{
7070
metadata::{MetadataDeposit, Mutate as MutateMetadata},
@@ -96,11 +96,10 @@ pub mod pallet {
9696
/// The currency mechanism, used for paying for deposits.
9797
type Currency: InspectFungible<Self::AccountId>
9898
+ MutateFungible<Self::AccountId>
99-
+ HoldInspectFungible<Self::AccountId>
100-
+ HoldMutateFungible<Self::AccountId>;
99+
+ HoldMutateFungible<Self::AccountId, Reason = Self::RuntimeHoldReason>;
101100

102-
#[pallet::constant]
103-
type HoldReason: Get<<Self::Currency as HoldInspectFungible<Self::AccountId>>::Reason>;
101+
/// Overarching hold reason.
102+
type RuntimeHoldReason: From<HoldReason>;
104103

105104
/// The deposit paid by the user locking an NFT. The deposit is returned to the original NFT
106105
/// owner when the asset is unified and the NFT is unlocked.
@@ -201,6 +200,14 @@ pub mod pallet {
201200
NftNotFractionalized,
202201
}
203202

203+
/// A reason for the pallet placing a hold on funds.
204+
#[pallet::composite_enum]
205+
pub enum HoldReason {
206+
/// Reserved for a fractionalized NFT.
207+
#[codec(index = 0)]
208+
Fractionalized,
209+
}
210+
204211
#[pallet::call]
205212
impl<T: Config> Pallet<T> {
206213
/// Lock the NFT and mint a new fungible asset.
@@ -239,7 +246,7 @@ pub mod pallet {
239246

240247
let pallet_account = Self::get_pallet_account();
241248
let deposit = T::Deposit::get();
242-
T::Currency::hold(&T::HoldReason::get(), &nft_owner, deposit)?;
249+
T::Currency::hold(&HoldReason::Fractionalized.into(), &nft_owner, deposit)?;
243250
Self::do_lock_nft(nft_collection_id, nft_id)?;
244251
Self::do_create_asset(asset_id.clone(), pallet_account.clone())?;
245252
Self::do_mint_asset(asset_id.clone(), &beneficiary, fractions)?;
@@ -303,7 +310,12 @@ pub mod pallet {
303310
let asset_creator = details.asset_creator;
304311
Self::do_burn_asset(asset_id.clone(), &who, details.fractions)?;
305312
Self::do_unlock_nft(nft_collection_id, nft_id, &beneficiary)?;
306-
T::Currency::release(&T::HoldReason::get(), &asset_creator, deposit, BestEffort)?;
313+
T::Currency::release(
314+
&HoldReason::Fractionalized.into(),
315+
&asset_creator,
316+
deposit,
317+
BestEffort,
318+
)?;
307319

308320
Self::deposit_event(Event::NftUnified {
309321
nft_collection: nft_collection_id,

frame/nft-fractionalization/src/mock.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
use super::*;
2121
use crate as pallet_nft_fractionalization;
2222

23-
use codec::{Decode, Encode, MaxEncodedLen};
2423
use frame_support::{
2524
construct_runtime, parameter_types,
2625
traits::{AsEnsureOriginWithArg, ConstU32, ConstU64},
2726
BoundedVec, PalletId,
2827
};
2928
use frame_system::EnsureSigned;
3029
use pallet_nfts::PalletFeatures;
31-
use scale_info::TypeInfo;
3230
use sp_core::H256;
3331
use sp_runtime::{
3432
testing::Header,
@@ -83,13 +81,6 @@ impl frame_system::Config for Test {
8381
type MaxConsumers = ConstU32<16>;
8482
}
8583

86-
#[derive(
87-
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo,
88-
)]
89-
pub enum HoldIdentifier {
90-
NftFractionalization,
91-
}
92-
9384
impl pallet_balances::Config for Test {
9485
type Balance = u64;
9586
type DustRemoval = ();
@@ -100,7 +91,7 @@ impl pallet_balances::Config for Test {
10091
type MaxLocks = ();
10192
type MaxReserves = ConstU32<50>;
10293
type ReserveIdentifier = [u8; 8];
103-
type HoldIdentifier = HoldIdentifier;
94+
type RuntimeHoldReason = RuntimeHoldReason;
10495
type MaxHolds = ConstU32<1>;
10596
type FreezeIdentifier = ();
10697
type MaxFreezes = ();
@@ -169,7 +160,6 @@ parameter_types! {
169160
pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction");
170161
pub NewAssetSymbol: BoundedVec<u8, StringLimit> = (*b"FRAC").to_vec().try_into().unwrap();
171162
pub NewAssetName: BoundedVec<u8, StringLimit> = (*b"Frac").to_vec().try_into().unwrap();
172-
pub const HoldReason: HoldIdentifier = HoldIdentifier::NftFractionalization;
173163
}
174164

175165
impl Config for Test {
@@ -189,7 +179,7 @@ impl Config for Test {
189179
type StringLimit = StringLimit;
190180
#[cfg(feature = "runtime-benchmarks")]
191181
type BenchmarkHelper = ();
192-
type HoldReason = HoldReason;
182+
type RuntimeHoldReason = RuntimeHoldReason;
193183
}
194184

195185
// Build genesis storage according to the mock runtime.

frame/statement/src/mock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl pallet_balances::Config for Test {
9191
type ReserveIdentifier = [u8; 8];
9292
type FreezeIdentifier = ();
9393
type MaxFreezes = ();
94-
type HoldIdentifier = ();
94+
type RuntimeHoldReason = RuntimeHoldReason;
9595
type MaxHolds = ();
9696
}
9797

test-utils/runtime/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ impl pallet_balances::Config for Runtime {
394394
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
395395
type FreezeIdentifier = ();
396396
type MaxFreezes = ();
397-
type HoldIdentifier = ();
397+
type RuntimeHoldReason = RuntimeHoldReason;
398398
type MaxHolds = ConstU32<1>;
399399
}
400400

0 commit comments

Comments
 (0)