@@ -63,8 +63,8 @@ pub mod pallet {
63
63
sp_runtime:: traits:: { AccountIdConversion , StaticLookup } ,
64
64
traits:: {
65
65
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 ,
68
68
} ,
69
69
fungibles:: {
70
70
metadata:: { MetadataDeposit , Mutate as MutateMetadata } ,
@@ -96,11 +96,10 @@ pub mod pallet {
96
96
/// The currency mechanism, used for paying for deposits.
97
97
type Currency : InspectFungible < Self :: AccountId >
98
98
+ MutateFungible < Self :: AccountId >
99
- + HoldInspectFungible < Self :: AccountId >
100
- + HoldMutateFungible < Self :: AccountId > ;
99
+ + HoldMutateFungible < Self :: AccountId , Reason = Self :: RuntimeHoldReason > ;
101
100
102
- # [ pallet :: constant ]
103
- type HoldReason : Get < < Self :: Currency as HoldInspectFungible < Self :: AccountId > > :: Reason > ;
101
+ /// Overarching hold reason.
102
+ type RuntimeHoldReason : From < HoldReason > ;
104
103
105
104
/// The deposit paid by the user locking an NFT. The deposit is returned to the original NFT
106
105
/// owner when the asset is unified and the NFT is unlocked.
@@ -201,6 +200,14 @@ pub mod pallet {
201
200
NftNotFractionalized ,
202
201
}
203
202
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
+
204
211
#[ pallet:: call]
205
212
impl < T : Config > Pallet < T > {
206
213
/// Lock the NFT and mint a new fungible asset.
@@ -239,7 +246,7 @@ pub mod pallet {
239
246
240
247
let pallet_account = Self :: get_pallet_account ( ) ;
241
248
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) ?;
243
250
Self :: do_lock_nft ( nft_collection_id, nft_id) ?;
244
251
Self :: do_create_asset ( asset_id. clone ( ) , pallet_account. clone ( ) ) ?;
245
252
Self :: do_mint_asset ( asset_id. clone ( ) , & beneficiary, fractions) ?;
@@ -303,7 +310,12 @@ pub mod pallet {
303
310
let asset_creator = details. asset_creator ;
304
311
Self :: do_burn_asset ( asset_id. clone ( ) , & who, details. fractions ) ?;
305
312
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
+ ) ?;
307
319
308
320
Self :: deposit_event ( Event :: NftUnified {
309
321
nft_collection : nft_collection_id,
0 commit comments