Skip to content

Commit

Permalink
add batch_all to whitelist call
Browse files Browse the repository at this point in the history
  • Loading branch information
gitofdeepanshu committed Sep 20, 2023
1 parent e8dd394 commit 74651c1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,8 @@ pub struct DispatchPrecompileFilter;
impl InstanceFilter<RuntimeCall> for DispatchPrecompileFilter {
fn filter(&self, c: &RuntimeCall) -> bool {
match c {
RuntimeCall::Utility(pallet_utility::Call::batch { calls }) => {
RuntimeCall::Utility(pallet_utility::Call::batch { calls })
| RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => {
for call in calls {
if !DispatchPrecompileFilter::default().filter(call) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,8 @@ pub struct DispatchPrecompileFilter;
impl InstanceFilter<RuntimeCall> for DispatchPrecompileFilter {
fn filter(&self, c: &RuntimeCall) -> bool {
match c {
RuntimeCall::Utility(pallet_utility::Call::batch { calls }) => {
RuntimeCall::Utility(pallet_utility::Call::batch { calls })
| RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => {
for call in calls {
if !DispatchPrecompileFilter::default().filter(call) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,8 @@ pub struct DispatchPrecompileFilter;
impl InstanceFilter<RuntimeCall> for DispatchPrecompileFilter {
fn filter(&self, c: &RuntimeCall) -> bool {
match c {
RuntimeCall::Utility(pallet_utility::Call::batch { calls }) => {
RuntimeCall::Utility(pallet_utility::Call::batch { calls })
| RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => {
for call in calls {
if !DispatchPrecompileFilter::default().filter(call) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion runtime/shiden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,8 @@ pub struct DispatchPrecompileFilter;
impl InstanceFilter<RuntimeCall> for DispatchPrecompileFilter {
fn filter(&self, c: &RuntimeCall) -> bool {
match c {
RuntimeCall::Utility(pallet_utility::Call::batch { calls }) => {
RuntimeCall::Utility(pallet_utility::Call::batch { calls })
| RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => {
for call in calls {
if !DispatchPrecompileFilter::default().filter(call) {
return false;
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/src/dispatch_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,20 @@ fn filter_rejects_non_whitelisted_calls() {
assert!(!DispatchPrecompileFilter.filter(&transfer_call));
})
}

#[test]
fn filter_accepts_whitelisted_batch_all_calls() {
ExtBuilder::default().build().execute_with(|| {
let contract = SmartContract::Evm(H160::repeat_byte(0x01));
let inner_call1 = RuntimeCall::DappsStaking(DappStakingCall::Call::claim_staker {
contract_id: contract.clone(),
});
let inner_call2 = RuntimeCall::DappsStaking(DappStakingCall::Call::claim_staker {
contract_id: contract.clone(),
});
let call = RuntimeCall::Utility(UtilityCall::batch_all {
calls: vec![inner_call1, inner_call2],
});
assert!(DispatchPrecompileFilter.filter(&call));
});
}

0 comments on commit 74651c1

Please sign in to comment.