diff --git a/modules/ismp/pallets/asset-gateway/src/xcm_utilities.rs b/modules/ismp/pallets/asset-gateway/src/xcm_utilities.rs index e3d71a38..3a12b07f 100644 --- a/modules/ismp/pallets/asset-gateway/src/xcm_utilities.rs +++ b/modules/ismp/pallets/asset-gateway/src/xcm_utilities.rs @@ -1,20 +1,23 @@ use crate::{AssetIds, Config, Pallet}; +use alloc::vec::Vec; use codec::Encode; use core::marker::PhantomData; -use frame_support::traits::fungibles::{self, Mutate}; +use frame_support::traits::{ + fungibles::{self, Mutate}, + Contains, +}; use ismp::host::StateMachine; use sp_core::{Get, H160}; use sp_runtime::traits::MaybeEquivalence; use staging_xcm::v4::{ - Asset, Error as XcmError, Junction, Junctions, Location, NetworkId, Result as XcmResult, - XcmContext, + Asset, Error as XcmError, Fungibility::Fungible, Junction, Junctions, Location, NetworkId, + Result as XcmResult, XcmContext, }; use staging_xcm_builder::{AssetChecking, FungiblesMutateAdapter}; use staging_xcm_executor::{ traits::{ConvertLocation, Error as MatchError, MatchesFungibles, TransactAsset}, AssetsInHolding, }; - pub struct WrappedNetworkId(pub NetworkId); impl TryFrom for StateMachine { @@ -101,6 +104,22 @@ where AssetIds::::get(converted) } } + +pub struct ReserveTransferFilter; + +impl Contains<(Location, Vec)> for ReserveTransferFilter { + fn contains(t: &(Location, Vec)) -> bool { + let native = Location::parent(); + t.1.iter().all(|asset| { + if let Asset { id: asset_id, fun: Fungible(_) } = asset { + asset_id.0 == native + } else { + false + } + }) + } +} + pub struct HyperbridgeAssetTransactor( PhantomData<(T, Matcher, AccountIdConverter, CheckAsset, CheckingAccount)>, ); diff --git a/modules/ismp/pallets/testsuite/src/xcm.rs b/modules/ismp/pallets/testsuite/src/xcm.rs index 6d87c067..ee3372ad 100644 --- a/modules/ismp/pallets/testsuite/src/xcm.rs +++ b/modules/ismp/pallets/testsuite/src/xcm.rs @@ -26,7 +26,7 @@ use frame_system::EnsureRoot; use pallet_assets::BenchmarkHelper; use pallet_xcm::XcmPassthrough; use pallet_xcm_gateway::{ - xcm_utilities::{ConvertAssetId, HyperbridgeAssetTransactor}, + xcm_utilities::{ConvertAssetId, HyperbridgeAssetTransactor, ReserveTransferFilter}, AssetGatewayParams, }; use polkadot_parachain_primitives::primitives::{DmpMessageHandler, Sibling}; @@ -332,7 +332,7 @@ impl pallet_xcm::Config for Test { type XcmExecuteFilter = Everything; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; - type XcmReserveTransferFilter = Everything; + type XcmReserveTransferFilter = ReserveTransferFilter; type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; diff --git a/parachain/runtimes/gargantua/src/lib.rs b/parachain/runtimes/gargantua/src/lib.rs index 970376ac..7ffdaf3c 100644 --- a/parachain/runtimes/gargantua/src/lib.rs +++ b/parachain/runtimes/gargantua/src/lib.rs @@ -233,7 +233,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("gargantua"), impl_name: create_runtime_str!("gargantua"), authoring_version: 1, - spec_version: 1160, + spec_version: 1170, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/parachain/runtimes/gargantua/src/xcm.rs b/parachain/runtimes/gargantua/src/xcm.rs index 314cd3e4..0556b12b 100644 --- a/parachain/runtimes/gargantua/src/xcm.rs +++ b/parachain/runtimes/gargantua/src/xcm.rs @@ -41,7 +41,9 @@ use staging_xcm_builder::{ }; use staging_xcm_executor::XcmExecutor; -use pallet_xcm_gateway::xcm_utilities::{ConvertAssetId, HyperbridgeAssetTransactor}; +use pallet_xcm_gateway::xcm_utilities::{ + ConvertAssetId, HyperbridgeAssetTransactor, ReserveTransferFilter, +}; parameter_types! { pub const RelayLocation: Location = Location::parent(); @@ -182,12 +184,12 @@ impl pallet_xcm::Config for Runtime { type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin; - type XcmExecuteFilter = Nothing; + type XcmExecuteFilter = Everything; // ^ Disable dispatchable execute on the XCM pallet. // Needs to be `Everything` for local testing. type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Nothing; + type XcmReserveTransferFilter = ReserveTransferFilter; type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; diff --git a/parachain/runtimes/nexus/src/lib.rs b/parachain/runtimes/nexus/src/lib.rs index d3a622e0..11587725 100644 --- a/parachain/runtimes/nexus/src/lib.rs +++ b/parachain/runtimes/nexus/src/lib.rs @@ -217,7 +217,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("nexus"), impl_name: create_runtime_str!("nexus"), authoring_version: 1, - spec_version: 1000, + spec_version: 1100, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/parachain/runtimes/nexus/src/xcm.rs b/parachain/runtimes/nexus/src/xcm.rs index 00e14452..19e19a43 100644 --- a/parachain/runtimes/nexus/src/xcm.rs +++ b/parachain/runtimes/nexus/src/xcm.rs @@ -41,7 +41,9 @@ use staging_xcm_builder::{ }; use staging_xcm_executor::XcmExecutor; -use pallet_xcm_gateway::xcm_utilities::{ConvertAssetId, HyperbridgeAssetTransactor}; +use pallet_xcm_gateway::xcm_utilities::{ + ConvertAssetId, HyperbridgeAssetTransactor, ReserveTransferFilter, +}; parameter_types! { pub const RelayLocation: Location = Location::parent(); @@ -182,12 +184,12 @@ impl pallet_xcm::Config for Runtime { type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin; - type XcmExecuteFilter = Nothing; + type XcmExecuteFilter = Everything; // ^ Disable dispatchable execute on the XCM pallet. // Needs to be `Everything` for local testing. type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Nothing; + type XcmReserveTransferFilter = ReserveTransferFilter; type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin;