From 70dfcdbff9202b2e78e2ae853fd840c1fc115410 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Jan 2024 10:51:39 +0100 Subject: [PATCH] Asset Hub - Stout NFT transfers --- runtime/stout/src/lib.rs | 7 +++++-- runtime/stout/src/xcm_config.rs | 36 ++++++++++++++++++++++++++++----- zombienet/stout_rococo.toml | 10 ++++----- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/runtime/stout/src/lib.rs b/runtime/stout/src/lib.rs index 451a0f05..ab5e4d99 100644 --- a/runtime/stout/src/lib.rs +++ b/runtime/stout/src/lib.rs @@ -467,10 +467,13 @@ parameter_types! { pub const ValueLimit: u32 = 64; } +type StoutCollectionId = u32; +type StoutItemId = u32; + impl pallet_uniques::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CollectionId = u32; - type ItemId = u32; + type CollectionId = StoutCollectionId; + type ItemId = StoutItemId; type Currency = Balances; type ForceOrigin = frame_system::EnsureRoot; type CreateOrigin = AsEnsureOriginWithArg>; diff --git a/runtime/stout/src/xcm_config.rs b/runtime/stout/src/xcm_config.rs index c642c91c..24418433 100644 --- a/runtime/stout/src/xcm_config.rs +++ b/runtime/stout/src/xcm_config.rs @@ -20,7 +20,8 @@ use cumulus_primitives_core::ParaId; use super::{ AccountId, AssetRegistry, Assets, Balance, Balances, ParachainInfo, ParachainSystem, - PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, + PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StoutCollectionId, StoutItemId, + Uniques, WeightToFee, XcmpQueue, }; use frame_support::{ match_types, parameter_types, @@ -46,9 +47,10 @@ use xcm_builder::{ AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, IsConcrete, - MintLocation, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, - SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + MintLocation, NativeAsset, NoChecking, NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + UsingComponents, }; use xcm_executor::XcmExecutor; @@ -148,8 +150,30 @@ pub type ReservedFungiblesTransactor = FungiblesAdapter< PlaceholderAccount, >; +pub type NonFungiblesTransactor = NonFungiblesAdapter< + // Use this nonfungibles implementation: + Uniques, + // Type that attempts to convert the `MultiAsset` into a registered uniques item. + // Assets not found in AssetRegistry will not be used. + ConvertedConcreteId< + StoutCollectionId, + StoutItemId, + AsPrefixedGeneralIndex, + JustTry, + >, + // Convert an XCM MultiLocation into a local account id: + LocationToAccountId, + // This chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We don't track any teleports of `Assets`. + NoChecking, + // No teleports. + (), +>; + /// Means for transacting assets on this chain. -pub type AssetTransactors = (CurrencyTransactor, ReservedFungiblesTransactor, FungiblesTransactor); +pub type AssetTransactors = + (CurrencyTransactor, ReservedFungiblesTransactor, FungiblesTransactor, NonFungiblesTransactor); /// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, /// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can @@ -236,6 +260,8 @@ parameter_types! { // Statemine's Assets pallet index pub StatemineAssetsPalletLocation: MultiLocation = MultiLocation::new(1, X2(Parachain(1000), PalletInstance(50))); + pub StatemineUniquesPalletLocation: MultiLocation = + MultiLocation::new(1, X2(Parachain(1000), PalletInstance(51))); } pub struct ReserveAssetsFrom(PhantomData); diff --git a/zombienet/stout_rococo.toml b/zombienet/stout_rococo.toml index 52dbd765..f5a755c1 100644 --- a/zombienet/stout_rococo.toml +++ b/zombienet/stout_rococo.toml @@ -30,19 +30,19 @@ default_command = "./bin/polkadot" id = 1000 add_to_genesis = true cumulus_based = true -chain = "statemine-local" +chain = "asset-hub-rococo-local" [[parachains.collators]] name = "statemine-collator01" command = "./bin/polkadot-parachain" ws_port = 9910 - args = ["--log=xcm=trace,pallet-assets=trace"] + args = ["--log=xcm=trace,pallet-assets=trace,pallet-uniques=trace"] [[parachains.collators]] name = "statemine-collator02" command = "./bin/polkadot-parachain" ws_port = 9911 - args = ["--log=xcm=trace,pallet-assets=trace"] + args = ["--log=xcm=trace,pallet-assets=trace,pallet-uniques=trace"] [[parachains]] id = 3000 @@ -54,13 +54,13 @@ chain = "stout-local" name = "stout-collator01" command = "./target/release/trappist-node" ws_port = 9930 - args = ["--log=xcm=trace,pallet-assets=trace"] + args = ["--log=xcm=trace,pallet-assets=trace,pallet-uniques=trace"] [[parachains.collators]] name = "stout-collator02" command = "./target/release/trappist-node" ws_port = 9931 - args = ["--log=xcm=trace,pallet-assets=trace"] + args = ["--log=xcm=trace,pallet-assets=trace,pallet-uniques=trace"] [types.Header] number = "u64"