diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index d56876d60ca..aba8ffa29dd 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -5,8 +5,9 @@ use frame_support::{ traits::{fungibles::Inspect, tokens::BalanceConversion}, weights::{Weight, WeightToFee, WeightToFeePolynomial}, }; +use sp_runtime::traits::Get; use xcm::latest::prelude::*; -use xcm_executor::traits::ShouldExecute; +use xcm_executor::traits::{FilterAssetLocation, ShouldExecute}; //TODO: move DenyThenTry to polkadot's xcm module. /// Deny executing the XCM if it matches any of the Deny filter regardless of anything else. @@ -107,3 +108,14 @@ where Ok(asset_amount) } } + +/// Accepts an asset if it is a native asset from a particular `MultiLocation`. +pub struct ConcreteNativeAssetFrom(PhantomData); +impl> FilterAssetLocation for ConcreteNativeAssetFrom { + fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { + log::trace!(target: "xcm::filter_asset_location", + "ConcreteNativeAsset asset: {:?}, origin: {:?}, location: {:?}", + asset, origin, Location::get()); + matches!(asset.id, Concrete(ref id) if id == origin && origin == &Location::get()) + } +} diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 78f5b224f8d..09869b67e72 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -25,15 +25,15 @@ use frame_support::{ use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry}, + xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, }; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentAsSuperuser, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + FixedWeightBounds, IsConcrete, LocationInverter, ParentAsSuperuser, ParentIsPreset, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; @@ -140,7 +140,8 @@ impl xcm_executor::Config for XcmConfig { // Collectives does not recognize a reserve location for any asset. Users must teleport DOT // where allowed (e.g. with the Relay Chain). type IsReserve = (); - type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of DOT + /// Only allow teleportation of DOT. + type IsTeleporter = ConcreteNativeAssetFrom; type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds;