From 494eddb01c8891a830d69c87d42b7b421f79e6e1 Mon Sep 17 00:00:00 2001 From: PierreOssun <35110271+PierreOssun@users.noreply.github.com> Date: Thu, 8 Feb 2024 10:27:05 +0100 Subject: [PATCH] Add TransferKeepAlive to filter (#1167) * Added transferKeepAlive to Filter * Allow transfer_all * Allow transfer_allow_death --- precompiles/dispatch-lockdrop/src/mock.rs | 2 +- precompiles/dispatch-lockdrop/src/tests.rs | 8 ++++---- runtime/local/src/precompiles.rs | 4 +++- runtime/shibuya/src/precompiles.rs | 4 +++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/precompiles/dispatch-lockdrop/src/mock.rs b/precompiles/dispatch-lockdrop/src/mock.rs index e830752153..a319beb8c3 100644 --- a/precompiles/dispatch-lockdrop/src/mock.rs +++ b/precompiles/dispatch-lockdrop/src/mock.rs @@ -87,7 +87,7 @@ pub struct WhitelistedCalls; impl Contains for WhitelistedCalls { fn contains(call: &RuntimeCall) -> bool { match call { - RuntimeCall::Balances(pallet_balances::Call::transfer { .. }) => true, + RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { .. }) => true, RuntimeCall::System(frame_system::Call::remark { .. }) => true, RuntimeCall::Utility(_) => true, _ => false, diff --git a/precompiles/dispatch-lockdrop/src/tests.rs b/precompiles/dispatch-lockdrop/src/tests.rs index 5a9cd53624..9fd565624d 100644 --- a/precompiles/dispatch-lockdrop/src/tests.rs +++ b/precompiles/dispatch-lockdrop/src/tests.rs @@ -38,7 +38,7 @@ fn precompiles() -> TestPrecompileSet { fn dispatch_calls_on_behalf_of_lockdrop_works() { ExtBuilder::default().build().execute_with(|| { // Transfer balance to Alice - let call = RuntimeCall::Balances(pallet_balances::Call::transfer { + let call = RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { dest: ALICE, value: 15 * ONE, }); @@ -74,7 +74,7 @@ fn dispatch_calls_on_behalf_of_lockdrop_works() { #[test] fn proper_gas_is_charged() { ExtBuilder::default().build().execute_with(|| { - let call = RuntimeCall::Balances(pallet_balances::Call::transfer { + let call = RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { dest: ALICE, value: 15 * ONE, }); @@ -111,7 +111,7 @@ fn proper_gas_is_charged() { fn pubkey_does_not_match_caller_address() { ExtBuilder::default().build().execute_with(|| { // Transfer balance to Alice - let call = RuntimeCall::Balances(pallet_balances::Call::transfer { + let call = RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { dest: ALICE, value: 15 * ONE, }); @@ -148,7 +148,7 @@ fn pubkey_does_not_match_caller_address() { fn pubkey_derive_to_proper_ss58() { ExtBuilder::default().build().execute_with(|| { // Transfer balance to Alice - let call = RuntimeCall::Balances(pallet_balances::Call::transfer { + let call = RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { dest: ALICE, value: 15 * ONE, }); diff --git a/runtime/local/src/precompiles.rs b/runtime/local/src/precompiles.rs index d2a299127d..f037d3fa9b 100644 --- a/runtime/local/src/precompiles.rs +++ b/runtime/local/src/precompiles.rs @@ -83,7 +83,9 @@ impl Contains for WhitelistedLockdropCalls { RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::withdraw_unbonded { .. }) => true, - RuntimeCall::Balances(pallet_balances::Call::transfer { .. }) => true, + RuntimeCall::Balances(pallet_balances::Call::transfer_all { .. }) => true, + RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { .. }) => true, + RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) => true, RuntimeCall::Assets(pallet_assets::Call::transfer { .. }) => true, _ => false, } diff --git a/runtime/shibuya/src/precompiles.rs b/runtime/shibuya/src/precompiles.rs index 8153f03146..c499c4d121 100644 --- a/runtime/shibuya/src/precompiles.rs +++ b/runtime/shibuya/src/precompiles.rs @@ -84,7 +84,9 @@ impl Contains for WhitelistedLockdropCalls { RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::withdraw_unbonded { .. }) => true, - RuntimeCall::Balances(pallet_balances::Call::transfer { .. }) => true, + RuntimeCall::Balances(pallet_balances::Call::transfer_all { .. }) => true, + RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { .. }) => true, + RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) => true, RuntimeCall::Assets(pallet_assets::Call::transfer { .. }) => true, _ => false, }