From e8b7feda3b8e9d6d3963803e022232227cfb0e1d Mon Sep 17 00:00:00 2001 From: Deepanshu Hooda Date: Wed, 11 Oct 2023 16:16:31 +0530 Subject: [PATCH] filter token transfer from pallet-xcm and tests --- runtime/astar/src/lib.rs | 7 ++++++ runtime/shibuya/src/lib.rs | 7 ++++++ runtime/shiden/src/lib.rs | 7 ++++++ .../src/tests/fungible_assets.rs | 22 ++++++++++--------- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index e73d590c05..851d65e46b 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -210,6 +210,13 @@ impl Contains for BaseFilter { _ => true, }, + // We don't allow xcm assets transfer functions from `pallet-xcm` + // use orml_xtokens for token transfers using xcm + RuntimeCall::PolkadotXcm(method) => match method { + pallet_xcm::Call::limited_reserve_transfer_assets { .. } + | pallet_xcm::Call::reserve_transfer_assets { .. } => false, + _ => true, + }, // These modules are not allowed to be called by transactions: // To leave collator just shutdown it, next session funds will be released // Other modules should works: diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index f89fa911ba..054f73b001 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -242,6 +242,13 @@ impl Contains for BaseFilter { // registering the asset location should be good enough for users, any change can be handled via issue ticket or help request _ => false, }, + // We don't allow xcm assets transfer functions from `pallet-xcm` + // use orml_xtokens for token transfers using xcm + RuntimeCall::PolkadotXcm(method) => match method { + pallet_xcm::Call::limited_reserve_transfer_assets { .. } + | pallet_xcm::Call::reserve_transfer_assets { .. } => false, + _ => true, + }, // These modules are not allowed to be called by transactions: // Other modules should works: _ => true, diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 36e827d609..e576d8ab19 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -213,6 +213,13 @@ impl Contains for BaseFilter { _ => true, }, + // We don't allow xcm assets transfer functions from `pallet-xcm` + // use orml_xtokens for token transfers using xcm + RuntimeCall::PolkadotXcm(method) => match method { + pallet_xcm::Call::limited_reserve_transfer_assets { .. } + | pallet_xcm::Call::reserve_transfer_assets { .. } => false, + _ => true, + }, // These modules are not allowed to be called by transactions: // To leave collator just shutdown it, next session funds will be released // Other modules should works: diff --git a/tests/xcm-simulator/src/tests/fungible_assets.rs b/tests/xcm-simulator/src/tests/fungible_assets.rs index 26e9cbae15..8cf234c17b 100644 --- a/tests/xcm-simulator/src/tests/fungible_assets.rs +++ b/tests/xcm-simulator/src/tests/fungible_assets.rs @@ -46,19 +46,21 @@ fn para_to_para_reserve_transfer_and_back_via_pallet_xcm() { // Next step is to send some of parachain A native asset to parachain B. let withdraw_amount = 567; ParaA::execute_with(|| { - assert_ok!(ParachainPalletXcm::reserve_transfer_assets( - parachain::RuntimeOrigin::signed(ALICE), - Box::new(MultiLocation::new(1, X1(Parachain(2))).into()), - Box::new( - X1(AccountId32 { + let destination = MultiLocation { + parents: 1, + interior: X2( + Parachain(2), + AccountId32 { network: None, - id: ALICE.into() - }) - .into_location() - .into_versioned() + id: ALICE.into(), + }, ), + }; + assert_ok!(ParachainXtokens::transfer_multiasset( + parachain::RuntimeOrigin::signed(ALICE), Box::new((Here, withdraw_amount).into()), - 0, + Box::new(destination.into()), + WeightLimit::Unlimited )); // Parachain 2 sovereign account should have it's balance increased, while Alice balance should be decreased.