@@ -44,9 +44,16 @@ use frame_support::{
4444 ord_parameter_types, parameter_types,
4545 traits:: {
4646 fungible, fungibles,
47- tokens:: { imbalance:: ResolveAssetTo , nonfungibles_v2:: Inspect } ,
48- AsEnsureOriginWithArg , ConstBool , ConstU128 , ConstU32 , ConstU64 , ConstU8 , InstanceFilter ,
49- TransformOrigin ,
47+ tokens:: {
48+ asset_ops:: {
49+ common_asset_kinds:: Instance , common_strategies:: Bytes , AssetDefinition ,
50+ InspectMetadata ,
51+ } ,
52+ imbalance:: ResolveAssetTo ,
53+ nonfungibles_v2:: Inspect ,
54+ } ,
55+ AsEnsureOriginWithArg , ConstBool , ConstU128 , ConstU32 , ConstU64 , ConstU8 , Equals ,
56+ InstanceFilter , TransformOrigin ,
5057 } ,
5158 weights:: { ConstantMultiplier , Weight , WeightToFee as _} ,
5259 BoundedVec , PalletId ,
@@ -56,19 +63,21 @@ use frame_system::{
5663 EnsureRoot , EnsureSigned , EnsureSignedBy ,
5764} ;
5865use pallet_asset_conversion_tx_payment:: SwapAssetAdapter ;
66+ use pallet_nft_fractionalization:: { FractionalizedName , FractionalizedSymbol } ;
5967use pallet_nfts:: { DestroyWitness , PalletFeatures } ;
6068use parachains_common:: {
6169 impls:: DealWithFees , message_queue:: * , AccountId , AssetIdForTrustBackedAssets , AuraId , Balance ,
6270 BlockNumber , CollectionId , Hash , Header , ItemId , Nonce , Signature , AVERAGE_ON_INITIALIZE_RATIO ,
6371 NORMAL_DISPATCH_RATIO ,
6472} ;
73+ use scale_info:: prelude:: { format, string:: String } ;
6574use sp_api:: impl_runtime_apis;
6675use sp_core:: { crypto:: KeyTypeId , OpaqueMetadata } ;
6776use sp_runtime:: {
6877 create_runtime_str, generic, impl_opaque_keys,
6978 traits:: { AccountIdConversion , BlakeTwo256 , Block as BlockT , Saturating , Verify } ,
7079 transaction_validity:: { TransactionSource , TransactionValidity } ,
71- ApplyExtrinsicResult , Perbill , Permill , RuntimeDebug ,
80+ ApplyExtrinsicResult , DispatchError , Perbill , Permill , RuntimeDebug ,
7281} ;
7382#[ cfg( feature = "std" ) ]
7483use sp_version:: NativeVersion ;
@@ -839,23 +848,39 @@ impl pallet_uniques::Config for Runtime {
839848
840849parameter_types ! {
841850 pub const NftFractionalizationPalletId : PalletId = PalletId ( * b"fraction" ) ;
842- pub NewAssetSymbol : BoundedVec <u8 , AssetsStringLimit > = ( * b"FRAC" ) . to_vec( ) . try_into( ) . unwrap( ) ;
843- pub NewAssetName : BoundedVec <u8 , AssetsStringLimit > = ( * b"Frac" ) . to_vec( ) . try_into( ) . unwrap( ) ;
851+ }
852+
853+ pub struct FractionalizedNfts ;
854+ impl AssetDefinition < Instance > for FractionalizedNfts {
855+ type Id = <Nfts as AssetDefinition < Instance > >:: Id ;
856+ }
857+ impl InspectMetadata < Instance , Bytes < FractionalizedName > > for FractionalizedNfts {
858+ fn inspect_metadata (
859+ ( collection_id, item_id) : & Self :: Id ,
860+ _frac_name : Bytes < FractionalizedName > ,
861+ ) -> Result < Vec < u8 > , DispatchError > {
862+ Ok ( format ! ( "Frac {collection_id}-{item_id}" ) . into_bytes ( ) )
863+ }
864+ }
865+ impl InspectMetadata < Instance , Bytes < FractionalizedSymbol > > for FractionalizedNfts {
866+ fn inspect_metadata (
867+ _instance_id : & Self :: Id ,
868+ _frac_name : Bytes < FractionalizedSymbol > ,
869+ ) -> Result < Vec < u8 > , DispatchError > {
870+ Ok ( String :: from ( "FRAC" ) . into_bytes ( ) )
871+ }
844872}
845873
846874impl pallet_nft_fractionalization:: Config for Runtime {
847875 type RuntimeEvent = RuntimeEvent ;
848876 type Deposit = AssetDeposit ;
849877 type Currency = Balances ;
850- type NewAssetSymbol = NewAssetSymbol ;
851- type NewAssetName = NewAssetName ;
852- type StringLimit = AssetsStringLimit ;
853- type NftCollectionId = <Self as pallet_nfts:: Config >:: CollectionId ;
854- type NftId = <Self as pallet_nfts:: Config >:: ItemId ;
855878 type AssetBalance = <Self as pallet_balances:: Config >:: Balance ;
856879 type AssetId = <Self as pallet_assets:: Config < TrustBackedAssetsInstance > >:: AssetId ;
857880 type Assets = Assets ;
881+ type NftId = <Nfts as AssetDefinition < Instance > >:: Id ;
858882 type Nfts = Nfts ;
883+ type FractionalizedNfts = FractionalizedNfts ;
859884 type PalletId = NftFractionalizationPalletId ;
860885 type WeightInfo = pallet_nft_fractionalization:: weights:: SubstrateWeight < Runtime > ;
861886 type RuntimeHoldReason = RuntimeHoldReason ;
0 commit comments