Skip to content

Commit

Permalink
filter token transfer from pallet-xcm and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gitofdeepanshu committed Oct 11, 2023
1 parent 7990808 commit e8b7fed
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
7 changes: 7 additions & 0 deletions runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ impl Contains<RuntimeCall> 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:
Expand Down
7 changes: 7 additions & 0 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ impl Contains<RuntimeCall> 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,
Expand Down
7 changes: 7 additions & 0 deletions runtime/shiden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ impl Contains<RuntimeCall> 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:
Expand Down
22 changes: 12 additions & 10 deletions tests/xcm-simulator/src/tests/fungible_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e8b7fed

Please sign in to comment.