diff --git a/Cargo.lock b/Cargo.lock index b263e588f9..35b9b3e422 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6525,6 +6525,7 @@ dependencies = [ "sp-std", "substrate-wasm-builder", "xcm", + "xcm-builder", "xcm-executor", ] diff --git a/parachains/common/Cargo.toml b/parachains/common/Cargo.toml index a01b925b1e..540c4c21ca 100644 --- a/parachains/common/Cargo.toml +++ b/parachains/common/Cargo.toml @@ -28,6 +28,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d # Polkadot polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } # Cumulus diff --git a/parachains/common/src/impls.rs b/parachains/common/src/impls.rs index c1158263da..284a431835 100644 --- a/parachains/common/src/impls.rs +++ b/parachains/common/src/impls.rs @@ -18,12 +18,13 @@ use frame_support::traits::{ fungibles::{self, Balanced, CreditOf}, - Contains, ContainsPair, Currency, Get, Imbalance, OnUnbalanced, + ContainsPair, Currency, Get, Imbalance, OnUnbalanced, }; use pallet_asset_tx_payment::HandleCredit; use sp_runtime::traits::Zero; use sp_std::marker::PhantomData; use xcm::latest::{AssetId, Fungibility::Fungible, MultiAsset, MultiLocation}; +use xcm_builder::{AssetChecking, MintLocation}; /// Type alias to conveniently refer to the `Currency::NegativeImbalance` associated type. pub type NegativeImbalance = as Currency< @@ -87,13 +88,16 @@ where /// Allow checking in assets that have issuance > 0. pub struct NonZeroIssuance(PhantomData<(AccountId, Assets)>); -impl Contains<>::AssetId> - for NonZeroIssuance +impl AssetChecking for NonZeroIssuance where Assets: fungibles::Inspect, { - fn contains(id: &>::AssetId) -> bool { - !Assets::total_issuance(*id).is_zero() + fn asset_checking(id: &Assets::AssetId) -> Option { + if Assets::total_issuance(*id).is_zero() { + None + } else { + Some(MintLocation::Local) + } } } diff --git a/parachains/runtimes/testing/penpal/src/xcm_config.rs b/parachains/runtimes/testing/penpal/src/xcm_config.rs index e8f70c20e6..99cbaf0478 100644 --- a/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -31,7 +31,7 @@ use frame_support::{ log, match_types, parameter_types, traits::{ fungibles::{self, Balanced, CreditOf}, - ConstU32, Contains, ContainsPair, Everything, Get, Nothing, + ConstU32, ContainsPair, Everything, Get, Nothing, }, }; use pallet_asset_tx_payment::HandleCredit; @@ -43,10 +43,10 @@ use xcm::latest::{prelude::*, Weight as XCMWeight}; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex, - ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, - IsConcrete, NativeAsset, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + AssetChecking, ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, + FungiblesAdapter, IsConcrete, MintLocation, NativeAsset, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; use xcm_executor::{ traits::{JustTry, ShouldExecute}, @@ -244,13 +244,16 @@ impl> ContainsPair for AssetsFr /// Allow checking in assets that have issuance > 0. pub struct NonZeroIssuance(PhantomData<(AccountId, Assets)>); -impl Contains<>::AssetId> - for NonZeroIssuance +impl AssetChecking for NonZeroIssuance where Assets: fungibles::Inspect, { - fn contains(id: &>::AssetId) -> bool { - !Assets::total_issuance(*id).is_zero() + fn asset_checking(id: &Assets::AssetId) -> Option { + if Assets::total_issuance(*id).is_zero() { + None + } else { + Some(MintLocation::Local) + } } }