diff --git a/parachains/common/src/impls.rs b/parachains/common/src/impls.rs index 91112cdae9..880a59c78c 100644 --- a/parachains/common/src/impls.rs +++ b/parachains/common/src/impls.rs @@ -72,7 +72,7 @@ where /// A `HandleCredit` implementation that naively transfers the fees to the block author. /// Will drop and burn the assets in case the transfer fails. pub struct AssetsToBlockAuthor(PhantomData<(R, I)>); -impl HandleCredit, pallet_assets::Pallet> for AssetsToBlockAuthor +impl HandleCredit, pallet_assets::Pallet> for AssetsToBlockAuthor where I: 'static, R: pallet_authorship::Config + pallet_assets::Config, diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 4e1b20bb82..2a2e1fce7c 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -321,7 +321,7 @@ impl Default for ProxyType { Self::Any } } -type TrustBackedAssetsCall = pallet_assets::Call; +type TrustBackedAssetsCall = pallet_assets::Call; impl InstanceFilter for ProxyType { fn filter(&self, c: &RuntimeCall) -> bool { match self { @@ -533,7 +533,7 @@ impl pallet_asset_tx_payment::Config for Runtime { ConvertInto, TrustBackedAssetsInstance, >, - AssetsToBlockAuthor, + AssetsToBlockAuthor, >; } diff --git a/parachains/runtimes/assets/statemint/src/lib.rs b/parachains/runtimes/assets/statemint/src/lib.rs index c2683aaab8..4f039309dd 100644 --- a/parachains/runtimes/assets/statemint/src/lib.rs +++ b/parachains/runtimes/assets/statemint/src/lib.rs @@ -258,7 +258,9 @@ parameter_types! { pub type AssetsForceOrigin = EitherOfDiverse, EnsureXcm>>; -impl pallet_assets::Config for Runtime { +pub type TrustBackedAssetsInstance = pallet_assets::Instance1; +type TrustBackedAssetsCall = pallet_assets::Call; +impl pallet_assets::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Balance = Balance; type AssetId = AssetId; @@ -357,7 +359,7 @@ impl InstanceFilter for ProxyType { ProxyType::NonTransfer => !matches!( c, RuntimeCall::Balances { .. } | - RuntimeCall::Assets { .. } | + RuntimeCall::TrustBackedAssets { .. } | RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( @@ -369,7 +371,7 @@ impl InstanceFilter for ProxyType { ProxyType::Assets => { matches!( c, - RuntimeCall::Assets { .. } | + RuntimeCall::TrustBackedAssets { .. } | RuntimeCall::Utility { .. } | RuntimeCall::Multisig { .. } | RuntimeCall::Uniques { .. } @@ -377,12 +379,13 @@ impl InstanceFilter for ProxyType { }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(pallet_assets::Call::create { .. }) | - RuntimeCall::Assets(pallet_assets::Call::destroy { .. }) | - RuntimeCall::Assets(pallet_assets::Call::transfer_ownership { .. }) | - RuntimeCall::Assets(pallet_assets::Call::set_team { .. }) | - RuntimeCall::Assets(pallet_assets::Call::set_metadata { .. }) | - RuntimeCall::Assets(pallet_assets::Call::clear_metadata { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::create { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::destroy { .. }) | + RuntimeCall::TrustBackedAssets( + TrustBackedAssetsCall::transfer_ownership { .. } + ) | RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::set_team { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::set_metadata { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::clear_metadata { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | @@ -399,12 +402,12 @@ impl InstanceFilter for ProxyType { ), ProxyType::AssetManager => matches!( c, - RuntimeCall::Assets(pallet_assets::Call::mint { .. }) | - RuntimeCall::Assets(pallet_assets::Call::burn { .. }) | - RuntimeCall::Assets(pallet_assets::Call::freeze { .. }) | - RuntimeCall::Assets(pallet_assets::Call::thaw { .. }) | - RuntimeCall::Assets(pallet_assets::Call::freeze_asset { .. }) | - RuntimeCall::Assets(pallet_assets::Call::thaw_asset { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::mint { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::burn { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::freeze { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::thaw { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::freeze_asset { .. }) | + RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::thaw_asset { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | @@ -549,10 +552,15 @@ impl pallet_collator_selection::Config for Runtime { impl pallet_asset_tx_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Fungibles = Assets; + type Fungibles = TrustBackedAssets; type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter< - pallet_assets::BalanceToAssetBalance, - AssetsToBlockAuthor, + pallet_assets::BalanceToAssetBalance< + Balances, + Runtime, + ConvertInto, + TrustBackedAssetsInstance, + >, + AssetsToBlockAuthor, >; } @@ -628,7 +636,7 @@ construct_runtime!( Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 42, // The main stage. - Assets: pallet_assets::{Pallet, Call, Storage, Event} = 50, + TrustBackedAssets: pallet_assets::::{Pallet, Call, Storage, Event} = 50, Uniques: pallet_uniques::{Pallet, Call, Storage, Event} = 51, } ); @@ -664,8 +672,18 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + MigrateAssetsPallet, >; +pub struct MigrateAssetsPallet; +impl frame_support::traits::OnRuntimeUpgrade for MigrateAssetsPallet { + fn on_runtime_upgrade() -> Weight { + use frame_support::storage::migration; + migration::move_pallet(b"Assets", b"TrustBackedAssets"); + ::DbWeight::get().writes(1) + } +} + #[cfg(feature = "runtime-benchmarks")] #[macro_use] extern crate frame_benchmarking; diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index bb9d82680f..5f8d419c44 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -14,9 +14,9 @@ // limitations under the License. use super::{ - AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo, - ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, - XcmpQueue, + AccountId, AllPalletsWithSystem, AssetId, Authorship, Balance, Balances, ParachainInfo, + ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, + TrustBackedAssets, WeightToFee, XcmpQueue, }; use frame_support::{ match_types, parameter_types, @@ -45,8 +45,8 @@ parameter_types! { pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); pub const Local: MultiLocation = MultiLocation::here(); - pub AssetsPalletLocation: MultiLocation = - PalletInstance(::index() as u8).into(); + pub TrustBackedAssetsPalletLocation: MultiLocation = + PalletInstance(::index() as u8).into(); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); } @@ -79,12 +79,12 @@ pub type CurrencyTransactor = CurrencyAdapter< /// Means for transacting assets besides the native currency on this chain. pub type FungiblesTransactor = FungiblesAdapter< // Use this fungibles implementation: - Assets, + TrustBackedAssets, // Use this currency when it is a fungible asset matching the given location or name: ConvertedConcreteId< AssetId, Balance, - AsPrefixedGeneralIndex, + AsPrefixedGeneralIndex, JustTry, >, // Convert an XCM MultiLocation into a local account id: @@ -93,7 +93,7 @@ pub type FungiblesTransactor = FungiblesAdapter< AccountId, // We only want to allow teleports of known assets. We use non-zero issuance as an indication // that this asset is known. - parachains_common::impls::NonZeroIssuance, + parachains_common::impls::NonZeroIssuance, // The account to use for tracking teleports. CheckingAccount, >; diff --git a/parachains/runtimes/assets/westmint/src/lib.rs b/parachains/runtimes/assets/westmint/src/lib.rs index 6aed43eb88..d446d4807d 100644 --- a/parachains/runtimes/assets/westmint/src/lib.rs +++ b/parachains/runtimes/assets/westmint/src/lib.rs @@ -249,19 +249,6 @@ impl pallet_assets::Config for Runtime { type Helper = (); } -// This is frustrating... -// use pallet_assets::BenchmarkHelper; -// pub struct XcmBenchmarkHelper; -// #[cfg(feature = "runtime-benchmarks")] -// impl> BenchmarkHelper for XcmBenchmarkHelper { -// fn create_asset_id(id: u32) -> AssetId { -// match id { -// x => MultiLocationForAssetId { parents: 1, interior: X1(Parachain(x)) }, -// _ => MultiLocationForAssetId { parents: 0, interior: Here }, -// } -// } -// } - /// Assets managed by some foreign location. type ForeignAssetsInstance = pallet_assets::Instance2; impl pallet_assets::Config for Runtime { @@ -281,7 +268,7 @@ impl pallet_assets::Config for Runtime { type WeightInfo = weights::pallet_assets::WeightInfo; type AssetAccountDeposit = AssetAccountDeposit; #[cfg(feature = "runtime-benchmarks")] - type Helper = (); + type Helper = (); //XcmBenchmarkHelper; } parameter_types! { @@ -356,7 +343,7 @@ impl Default for ProxyType { Self::Any } } -type TrustBackedAssetsCall = pallet_assets::Call; +type TrustBackedAssetsCall = pallet_assets::Call; impl InstanceFilter for ProxyType { fn filter(&self, c: &RuntimeCall) -> bool { match self { @@ -563,7 +550,7 @@ impl pallet_asset_tx_payment::Config for Runtime { ConvertInto, TrustBackedAssetsInstance, >, - AssetsToBlockAuthor, + AssetsToBlockAuthor, >; } diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 62a70c6535..fee07a1643 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -57,6 +57,16 @@ parameter_types! { pub CheckingAccount: AccountId = PolkadotXcm::check_account(); } +// This is frustrating... +// use pallet_assets::BenchmarkHelper; +// pub struct XcmBenchmarkHelper; +// #[cfg(feature = "runtime-benchmarks")] +// impl> BenchmarkHelper for XcmBenchmarkHelper { +// fn create_asset_id(id: u32) -> MultiLocation { +// (Parent, Parachain(id)).into() +// } +// } + /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used /// when determining ownership of accounts for asset transacting and when attempting to use XCM /// `Transact` in order to determine the dispatch Origin.