From 362a9078df6a5d6b7b2eff50544b990c25072c1f Mon Sep 17 00:00:00 2001 From: joepetrowski Date: Fri, 18 Nov 2022 20:35:00 +0100 Subject: [PATCH] fix deps to make compile --- Cargo.lock | 2 +- parachains/common/src/xcm_config.rs | 13 ++++++------- parachains/runtimes/assets/westmint/src/lib.rs | 17 ++++++++--------- .../runtimes/assets/westmint/src/xcm_config.rs | 16 +++++----------- 4 files changed, 20 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c908727eac..23b7c2f887 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5310,7 +5310,7 @@ dependencies = [ [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e1e17cccd499dfe49e8c1bed01957953aa4c839" +source = "git+https://github.com/paritytech/substrate?branch=master#087ec5a5b2c9a960fe0f8dc658ab5b21fe8199b3" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index 49bd563387..b0c774dc6d 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -82,25 +82,24 @@ pub struct AssetFeeAsExistentialDepositMultiplier cumulus_primitives_utility::ChargeWeightInFungibles< AccountIdOf, - // todo: I don't understand why `frame_support` is the instance here??? but it compiles... - pallet_assets::Pallet, + pallet_assets::Pallet, > for AssetFeeAsExistentialDepositMultiplier where - Runtime: pallet_assets::Config, + Runtime: pallet_assets::Config, WeightToFee: WeightToFeePolynomial, BalanceConverter: BalanceConversion< CurrencyBalance, - >::AssetId, - >::Balance, + >::AssetId, + >::Balance, >, AccountIdOf: From + Into, { fn charge_weight_in_fungibles( - asset_id: as Inspect>>::AssetId, + asset_id: as Inspect>>::AssetId, weight: Weight, ) -> Result< - as Inspect< + as Inspect< AccountIdOf, >>::Balance, XcmError, diff --git a/parachains/runtimes/assets/westmint/src/lib.rs b/parachains/runtimes/assets/westmint/src/lib.rs index 00c03e56e8..5c42cd12ff 100644 --- a/parachains/runtimes/assets/westmint/src/lib.rs +++ b/parachains/runtimes/assets/westmint/src/lib.rs @@ -234,6 +234,7 @@ impl pallet_assets::Config for Runtime { type Balance = Balance; type AssetId = AssetId; type Currency = Balances; + type CreateOrigin = AsEnsureOriginWithArg>; type ForceOrigin = AssetsForceOrigin; type AssetDeposit = AssetDeposit; type MetadataDepositBase = MetadataDepositBase; @@ -251,8 +252,7 @@ type ForeignAssetsInstance = pallet_assets::Instance2; impl pallet_assets::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Balance = Balance; - // TODO: impl Copy for MultiLocation or relax AssetId to Clone? - // https://github.com/paritytech/substrate/pull/12731 + // TODO: need HasCompact for MultiLocation type AssetId = AssetId; // MultiLocationForAssetId; type Currency = Balances; type CreateOrigin = AsEnsureOriginWithArg>; // ForeignCreators; @@ -266,7 +266,6 @@ impl pallet_assets::Config for Runtime { type Extra = (); type WeightInfo = weights::pallet_assets::WeightInfo; type AssetAccountDeposit = AssetAccountDeposit; - type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; } parameter_types! { @@ -369,12 +368,12 @@ impl InstanceFilter for ProxyType { }, ProxyType::AssetOwner => matches!( c, - RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::destroy { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | - RuntimeCall::Assets(TrustBackedAssetsCall::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 { .. }) | diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 74f661815c..3c396c95e0 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -14,7 +14,7 @@ // limitations under the License. use super::{ - AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo, + AccountId, AllPalletsWithSystem, AssetId, Authorship, Balance, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, TrustBackedAssets, TrustBackedAssetsInstance, WeightToFee, XcmpQueue, }; @@ -52,7 +52,7 @@ parameter_types! { pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); pub const Local: MultiLocation = Here.into_location(); // todo: accept all instances, perhaps need a type for each instance? - pub AssetsPalletLocation: MultiLocation = + pub TrustBackedAssetsPalletLocation: MultiLocation = PalletInstance(::index() as u8).into(); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); } @@ -91,7 +91,7 @@ pub type FungiblesTransactor = FungiblesAdapter< ConvertedConcreteId< AssetId, Balance, - AsPrefixedGeneralIndex, // todo: accept all instances + AsPrefixedGeneralIndex, // todo: accept all instances JustTry, >, // Convert an XCM MultiLocation into a local account id: @@ -193,7 +193,7 @@ impl xcm_executor::Config for XcmConfig { ConvertedConcreteId< AssetId, Balance, - AsPrefixedGeneralIndex, // todo: accept all instances + AsPrefixedGeneralIndex, // todo: accept all instances JustTry, >, TrustBackedAssets, // todo: accept all instances @@ -280,13 +280,7 @@ impl EnsureOriginWithArg for ForeignCreators { a: &MultiLocation, ) -> sp_std::result::Result { let origin_location = EnsureXcm::::try_origin(o.clone())?; - - // dirty hack, should port vvv into master and use `starts_with` - // https://github.com/paritytech/polkadot/commit/e640d826513c45a0452138c8908a699e19ac0143 - if a.parents != origin_location.parents || - a.interior.len() < origin_location.interior.len() || - !origin_location.interior.iter().zip(a.interior.iter()).all(|(l, r)| l == r) - { + if !a.starts_with(&origin_location) { return Err(o) } SovereignAccountOf::convert(origin_location).map_err(|_| o)