@@ -4,54 +4,53 @@ pragma solidity ^0.8.23;
44import {CoinbaseImplementationTest} from "./coinbaseImplementation.t.sol " ;
55import {MockERC721} from "../mocks/MockERC721.sol " ;
66import {MockERC1155} from "../mocks/MockERC1155.sol " ;
7+ import {MockERC20} from "../mocks/MockERC20.sol " ;
78import {EIP7702Proxy} from "../../src/EIP7702Proxy.sol " ;
89
910contract TokenReceiveTest is CoinbaseImplementationTest {
1011 MockERC721 public nft;
1112 MockERC1155 public multiToken;
13+ MockERC20 public token;
1214 uint256 constant TOKEN_ID = 1 ;
1315 uint256 constant AMOUNT = 1 ;
16+ uint256 constant TOKEN_AMOUNT = 1 ether ;
1417
1518 function setUp () public override {
1619 super .setUp ();
1720 nft = new MockERC721 ();
1821 multiToken = new MockERC1155 ();
22+ token = new MockERC20 ();
1923 }
2024
21- function test_canReceive_ERC721_afterInitialization () public {
22- // Mint and transfer NFT
25+ function test_succeeds_ERC721Transfer_afterInitialization () public {
2326 nft.mint (address (this ), TOKEN_ID);
2427 nft.safeTransferFrom (address (this ), _eoa, TOKEN_ID);
25-
26- // Verify transfer succeeded
2728 assertEq (nft.ownerOf (TOKEN_ID), _eoa);
2829 }
2930
30- function test_canReceive_ERC1155_afterInitialization () public {
31- // Mint tokens directly to a regular address first
31+ function test_succeeds_ERC1155Transfer_afterInitialization () public {
3232 address regularAddress = makeAddr ("regularHolder " );
3333 multiToken.mint (regularAddress, TOKEN_ID, AMOUNT, "" );
3434
35- // Then transfer to our smart wallet
3635 vm.prank (regularAddress);
3736 multiToken.safeTransferFrom (regularAddress, _eoa, TOKEN_ID, AMOUNT, "" );
38-
39- // Verify transfer succeeded
4037 assertEq (multiToken.balanceOf (_eoa, TOKEN_ID), AMOUNT);
4138 }
4239
40+ function test_succeeds_ERC20Transfer_afterInitialization () public {
41+ token.mint (address (this ), TOKEN_AMOUNT);
42+
43+ token.transfer (_eoa, TOKEN_AMOUNT);
44+ assertEq (token.balanceOf (_eoa), TOKEN_AMOUNT);
45+ }
46+
4347 function test_succeeds_ERC721Transfer_beforeInitialization () public {
4448 // Deploy proxy without initializing
4549 address payable uninitProxy = payable (makeAddr ("uninitProxy " ));
4650 _deployProxy (uninitProxy);
4751
48- // Mint NFT
4952 nft.mint (address (this ), TOKEN_ID);
50-
51- // Transfer should succeed
5253 nft.safeTransferFrom (address (this ), uninitProxy, TOKEN_ID);
53-
54- // Verify transfer succeeded
5554 assertEq (nft.ownerOf (TOKEN_ID), uninitProxy);
5655 }
5756
@@ -60,11 +59,9 @@ contract TokenReceiveTest is CoinbaseImplementationTest {
6059 address payable uninitProxy = payable (makeAddr ("uninitProxy " ));
6160 _deployProxy (uninitProxy);
6261
63- // Mint tokens to a regular address first
6462 address regularAddress = makeAddr ("regularHolder " );
6563 multiToken.mint (regularAddress, TOKEN_ID, AMOUNT, "" );
6664
67- // Transfer should succeed
6865 vm.prank (regularAddress);
6966 multiToken.safeTransferFrom (
7067 regularAddress,
@@ -73,8 +70,16 @@ contract TokenReceiveTest is CoinbaseImplementationTest {
7370 AMOUNT,
7471 ""
7572 );
76-
77- // Verify transfer succeeded
7873 assertEq (multiToken.balanceOf (uninitProxy, TOKEN_ID), AMOUNT);
7974 }
75+
76+ function test_succeeds_ERC20Transfer_beforeInitialization () public {
77+ // Deploy proxy without initializing
78+ address payable uninitProxy = payable (makeAddr ("uninitProxy " ));
79+ _deployProxy (uninitProxy);
80+
81+ token.mint (address (this ), TOKEN_AMOUNT);
82+ token.transfer (uninitProxy, TOKEN_AMOUNT);
83+ assertEq (token.balanceOf (uninitProxy), TOKEN_AMOUNT);
84+ }
8085}
0 commit comments