@@ -60,9 +60,16 @@ use frame_support::{
6060 genesis_builder_helper:: { build_state, get_preset} ,
6161 ord_parameter_types, parameter_types,
6262 traits:: {
63- fungible, fungibles, tokens:: imbalance:: ResolveAssetTo , AsEnsureOriginWithArg , ConstBool ,
64- ConstU128 , ConstU32 , ConstU64 , ConstU8 , EitherOfDiverse , Equals , InstanceFilter ,
65- TransformOrigin ,
63+ fungible, fungibles,
64+ tokens:: {
65+ asset_ops:: {
66+ common_asset_kinds:: Instance , common_strategies:: Bytes , AssetDefinition ,
67+ InspectMetadata ,
68+ } ,
69+ imbalance:: ResolveAssetTo ,
70+ } ,
71+ AsEnsureOriginWithArg , ConstBool , ConstU128 , ConstU32 , ConstU64 , ConstU8 , EitherOfDiverse ,
72+ Equals , InstanceFilter , TransformOrigin ,
6673 } ,
6774 weights:: { ConstantMultiplier , Weight , WeightToFee as _} ,
6875 BoundedVec , PalletId ,
@@ -72,14 +79,16 @@ use frame_system::{
7279 EnsureRoot , EnsureSigned , EnsureSignedBy ,
7380} ;
7481use pallet_asset_conversion_tx_payment:: SwapAssetAdapter ;
82+ use pallet_nft_fractionalization:: { FractionalizedName , FractionalizedSymbol } ;
7583use pallet_nfts:: PalletFeatures ;
7684use parachains_common:: {
7785 impls:: DealWithFees ,
7886 message_queue:: { NarrowOriginToSibling , ParaIdToSibling } ,
7987 AccountId , AssetIdForTrustBackedAssets , AuraId , Balance , BlockNumber , CollectionId , Hash ,
8088 Header , ItemId , Nonce , Signature , AVERAGE_ON_INITIALIZE_RATIO , NORMAL_DISPATCH_RATIO ,
8189} ;
82- use sp_runtime:: { Perbill , RuntimeDebug } ;
90+ use scale_info:: prelude:: { format, string:: String } ;
91+ use sp_runtime:: { DispatchError , Perbill , RuntimeDebug } ;
8392use testnet_parachains_constants:: rococo:: { consensus:: * , currency:: * , fee:: WeightToFee , time:: * } ;
8493use xcm_config:: {
8594 ForeignAssetsConvertedConcreteId , ForeignCreatorsSovereignAccountOf , GovernanceLocation ,
@@ -844,23 +853,39 @@ impl pallet_uniques::Config for Runtime {
844853
845854parameter_types ! {
846855 pub const NftFractionalizationPalletId : PalletId = PalletId ( * b"fraction" ) ;
847- pub NewAssetSymbol : BoundedVec <u8 , AssetsStringLimit > = ( * b"FRAC" ) . to_vec( ) . try_into( ) . unwrap( ) ;
848- pub NewAssetName : BoundedVec <u8 , AssetsStringLimit > = ( * b"Frac" ) . to_vec( ) . try_into( ) . unwrap( ) ;
856+ }
857+
858+ pub struct FractionalizedNfts ;
859+ impl AssetDefinition < Instance > for FractionalizedNfts {
860+ type Id = <Nfts as AssetDefinition < Instance > >:: Id ;
861+ }
862+ impl InspectMetadata < Instance , Bytes < FractionalizedName > > for FractionalizedNfts {
863+ fn inspect_metadata (
864+ ( collection_id, item_id) : & Self :: Id ,
865+ _frac_name : Bytes < FractionalizedName > ,
866+ ) -> Result < Vec < u8 > , DispatchError > {
867+ Ok ( format ! ( "Frac {collection_id}-{item_id}" ) . into_bytes ( ) )
868+ }
869+ }
870+ impl InspectMetadata < Instance , Bytes < FractionalizedSymbol > > for FractionalizedNfts {
871+ fn inspect_metadata (
872+ _instance_id : & Self :: Id ,
873+ _frac_name : Bytes < FractionalizedSymbol > ,
874+ ) -> Result < Vec < u8 > , DispatchError > {
875+ Ok ( String :: from ( "FRAC" ) . into_bytes ( ) )
876+ }
849877}
850878
851879impl pallet_nft_fractionalization:: Config for Runtime {
852880 type RuntimeEvent = RuntimeEvent ;
853881 type Deposit = AssetDeposit ;
854882 type Currency = Balances ;
855- type NewAssetSymbol = NewAssetSymbol ;
856- type NewAssetName = NewAssetName ;
857- type StringLimit = AssetsStringLimit ;
858- type NftCollectionId = <Self as pallet_nfts:: Config >:: CollectionId ;
859- type NftId = <Self as pallet_nfts:: Config >:: ItemId ;
860883 type AssetBalance = <Self as pallet_balances:: Config >:: Balance ;
861884 type AssetId = <Self as pallet_assets:: Config < TrustBackedAssetsInstance > >:: AssetId ;
862885 type Assets = Assets ;
886+ type NftId = <Nfts as AssetDefinition < Instance > >:: Id ;
863887 type Nfts = Nfts ;
888+ type FractionalizedNfts = FractionalizedNfts ;
864889 type PalletId = NftFractionalizationPalletId ;
865890 type WeightInfo = pallet_nft_fractionalization:: weights:: SubstrateWeight < Runtime > ;
866891 type RuntimeHoldReason = RuntimeHoldReason ;
0 commit comments