Skip to content

Commit

Permalink
Add support for handling aggregated operations in KintoAppRegistry an…
Browse files Browse the repository at this point in the history
…d corresponding unit tests.
  • Loading branch information
ylv-io committed Oct 30, 2024
1 parent b130b14 commit c81fe5c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/apps/KintoAppRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ contract KintoAppRegistry is

bytes4 public constant SELECTOR_EP_WITHDRAW_STAKE = 0xc23a5cea;
bytes4 public constant SELECTOR_EP_WITHDRAW_TO = 0x205c2878;
bytes4 public constant SELECTOR_EP_HANDLEO_AGGREGATED_OPS = 0x4b1d7cf5;
bytes4 public constant SELECTOR_EP_HANDLE_AGGREGATED_OPS_V7 = 0xdbed18e0;
bytes4 public constant SELECTOR_EP_HANDLEOPS = 0x1fad948c;
bytes4 public constant SELECTOR_EP_HANDLE_OPS_V7 = 0x765e827f;
bytes4 public constant SELECTOR_EP_DEPOSIT = 0xb760faf9;
Expand Down Expand Up @@ -344,7 +346,11 @@ contract KintoAppRegistry is
}

function isHandleOps(address addr, bytes4 selector) public pure returns (bool) {
return isEntryPoint(addr) && (selector == SELECTOR_EP_HANDLEOPS || selector == SELECTOR_EP_HANDLE_OPS_V7);
return isEntryPoint(addr)
&& (
selector == SELECTOR_EP_HANDLEOPS || selector == SELECTOR_EP_HANDLE_OPS_V7
|| selector == SELECTOR_EP_HANDLEO_AGGREGATED_OPS || selector == SELECTOR_EP_HANDLE_AGGREGATED_OPS_V7
);
}

function forbiddenEPFunctions(bytes4 selector) public pure returns (bool) {
Expand Down
32 changes: 32 additions & 0 deletions test/unit/ContractCall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,38 @@ contract ContractCallTest is SharedSetup {
),
false
);

bytes memory handleAggregatedOpsCallData = abi.encodeWithSelector(bytes4(0x4b1d7cf5), new bytes(0), beneficiary);
bytes memory handleAggregatedOpsV7CallData =
abi.encodeWithSelector(bytes4(0xdbed18e0), new bytes(0), beneficiary);

// Test handleAggregatedOps
assertEq(
_kintoAppRegistry.isContractCallAllowedFromEOA(
beneficiary, _kintoAppRegistry.ENTRYPOINT_V6(), handleAggregatedOpsCallData, 0
),
true
);
assertEq(
_kintoAppRegistry.isContractCallAllowedFromEOA(
_user, _kintoAppRegistry.ENTRYPOINT_V6(), handleAggregatedOpsCallData, 0
),
false
);

// Test handleAggregatedOps V7
assertEq(
_kintoAppRegistry.isContractCallAllowedFromEOA(
beneficiary, _kintoAppRegistry.ENTRYPOINT_V7(), handleAggregatedOpsV7CallData, 0
),
true
);
assertEq(
_kintoAppRegistry.isContractCallAllowedFromEOA(
_user, _kintoAppRegistry.ENTRYPOINT_V7(), handleAggregatedOpsV7CallData, 0
),
false
);
}

function testIsContractCallAllowedFromEOA_WhenForbiddenEntryPointFunctions() public view {
Expand Down

0 comments on commit c81fe5c

Please sign in to comment.