Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/executor/ERC721Actions.sol

This file was deleted.

19 changes: 19 additions & 0 deletions src/executor/TokenActions.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pragma solidity ^0.8.0;

import "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol";
import "openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol";

contract TokenActions {
function transfer20Action(address _token, uint256 _amount, address _to) external {
IERC20(_token).transfer(_to, _amount);
}

function transferERC721Action(address _token, uint256 _id, address _to) external {
IERC721(_token).transferFrom(address(this), _to, _id);
}

function transferERC1155Action(address _token, uint256 _id, address _to, uint256 amount, bytes calldata data) external {
IERC1155(_token).safeTransferFrom(address(this), _to, _id, amount, data);
}
}
12 changes: 6 additions & 6 deletions test/foundry/KernelExecution.test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "forge-std/Test.sol";
import {ERC4337Utils} from "./ERC4337Utils.sol";
// test actions/validators
import "src/validator/ERC165SessionKeyValidator.sol";
import "src/executor/ERC721Actions.sol";
import "src/executor/TokenActions.sol";

using ERC4337Utils for EntryPoint;

Expand Down Expand Up @@ -148,29 +148,29 @@ contract KernelExecutionTest is Test {

function test_mode_2_erc165() external {
ERC165SessionKeyValidator sessionKeyValidator = new ERC165SessionKeyValidator();
ERC721Actions action = new ERC721Actions();
TokenActions action = new TokenActions();
TestERC721 erc721 = new TestERC721();
erc721.mint(address(kernel), 0);
erc721.mint(address(kernel), 1);
UserOperation memory op = entryPoint.fillUserOp(
address(kernel),
abi.encodeWithSelector(ERC721Actions.transferERC721Action.selector, address(erc721), 0, address(0xdead))
abi.encodeWithSelector(TokenActions.transferERC721Action.selector, address(erc721), 0, address(0xdead))
);
address sessionKeyAddr;
uint256 sessionKeyPriv;
(sessionKeyAddr, sessionKeyPriv) = makeAddrAndKey("sessionKey");
bytes memory enableData = abi.encodePacked(
sessionKeyAddr,
type(IERC721).interfaceId,
ERC721Actions.transferERC721Action.selector,
TokenActions.transferERC721Action.selector,
uint48(0),
uint48(0),
uint32(16)
);
{
bytes32 digest = getTypedDataHash(
address(kernel),
ERC721Actions.transferERC721Action.selector,
TokenActions.transferERC721Action.selector,
0,
0,
address(sessionKeyValidator),
Expand Down Expand Up @@ -203,7 +203,7 @@ contract KernelExecutionTest is Test {

op = entryPoint.fillUserOp(
address(kernel),
abi.encodeWithSelector(ERC721Actions.transferERC721Action.selector, address(erc721), 1, address(0xdead))
abi.encodeWithSelector(TokenActions.transferERC721Action.selector, address(erc721), 1, address(0xdead))
);
op.signature = abi.encodePacked(bytes4(0x00000001), entryPoint.signUserOpHash(vm, sessionKeyPriv, op));
ops[0] = op;
Expand Down