Skip to content

Commit

Permalink
approve in exec
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipp Makarov authored and Filipp Makarov committed Dec 4, 2024
1 parent 3c27ca6 commit abfc70a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
9 changes: 5 additions & 4 deletions test/unit/concrete/TestTokenPaymaster.Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ contract TestTokenPaymasterBase is TestBase {
function test_BaseFork_Success_TokenPaymaster_IndependentMode_WithoutPremium() external {
tokenPaymaster.deposit{ value: 10 ether }();
deal(address(usdc), address(ALICE_ACCOUNT), 100e6);
vm.startPrank(address(ALICE_ACCOUNT));
usdc.approve(address(tokenPaymaster), usdc.balanceOf(address(ALICE_ACCOUNT)));
vm.stopPrank();

vm.startPrank(PAYMASTER_OWNER.addr);
tokenPaymaster.setUnaccountedGas(40_000);
Expand All @@ -94,7 +91,11 @@ contract TestTokenPaymasterBase is TestBase {
uint256 initialUserTokenBalance = usdc.balanceOf(address(ALICE_ACCOUNT));
uint256 initialPaymasterTokenBalance = usdc.balanceOf(address(tokenPaymaster));

PackedUserOperation memory userOp = buildUserOpWithCalldata(ALICE, "", address(VALIDATOR_MODULE));
PackedUserOperation memory userOp = buildUserOpWithCalldata(
ALICE,
abi.encodeWithSelector(IExecutionHelper.execute.selector, bytes32(0), abi.encodePacked(address(usdc), uint256(0), abi.encodeWithSelector(IERC20.approve.selector, address(tokenPaymaster), 1_000*1e18))),
address(VALIDATOR_MODULE)
);

// Encode paymasterAndData for independent mode
bytes memory paymasterAndData = abi.encodePacked(
Expand Down
12 changes: 5 additions & 7 deletions test/unit/concrete/TestTokenPaymaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,6 @@ contract TestTokenPaymaster is TestBase {
function test_Success_TokenPaymaster_ExternalMode_WithoutPremium() external {
tokenPaymaster.deposit{ value: 10 ether }();
testToken.mint(address(ALICE_ACCOUNT), 100_000 * (10 ** testToken.decimals()));
vm.startPrank(address(ALICE_ACCOUNT));
testToken.approve(address(tokenPaymaster), testToken.balanceOf(address(ALICE_ACCOUNT)));
vm.stopPrank();

vm.startPrank(PAYMASTER_OWNER.addr);
tokenPaymaster.setUnaccountedGas(22_000);
Expand Down Expand Up @@ -467,9 +464,6 @@ contract TestTokenPaymaster is TestBase {
function test_Success_TokenPaymaster_IndependentMode_WithoutPremium() external {
tokenPaymaster.deposit{ value: 10 ether }();
testToken.mint(address(ALICE_ACCOUNT), 100_000 * (10 ** testToken.decimals()));
vm.startPrank(address(ALICE_ACCOUNT));
testToken.approve(address(tokenPaymaster), testToken.balanceOf(address(ALICE_ACCOUNT)));
vm.stopPrank();

vm.startPrank(PAYMASTER_OWNER.addr);
tokenPaymaster.setUnaccountedGas(40_000);
Expand All @@ -480,7 +474,11 @@ contract TestTokenPaymaster is TestBase {
uint256 initialUserTokenBalance = testToken.balanceOf(address(ALICE_ACCOUNT));
uint256 initialPaymasterTokenBalance = testToken.balanceOf(address(tokenPaymaster));

PackedUserOperation memory userOp = buildUserOpWithCalldata(ALICE, "", address(VALIDATOR_MODULE));
PackedUserOperation memory userOp = buildUserOpWithCalldata(
ALICE,
abi.encodeWithSelector(IExecutionHelper.execute.selector, bytes32(0), abi.encodePacked(address(testToken), uint256(0), abi.encodeWithSelector(IERC20.approve.selector, address(tokenPaymaster), 1_000*1e18))),
address(VALIDATOR_MODULE)
);

// Encode paymasterAndData for independent mode
bytes memory paymasterAndData = abi.encodePacked(
Expand Down

0 comments on commit abfc70a

Please sign in to comment.