Skip to content

Commit c399a82

Browse files
committed
final pre-audit nits
1 parent dd72de1 commit c399a82

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/EIP7702Proxy.sol

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import {StorageSlot} from "openzeppelin-contracts/contracts/utils/StorageSlot.so
88

99
/// @title EIP7702Proxy
1010
/// @notice Proxy contract designed for EIP-7702 smart accounts
11-
/// @dev Implements ERC-1967 with an initial implementation and guarded initialization
11+
/// @dev Implements ERC-1967 with an initial implementation address and guarded initializer function
1212
/// @author Coinbase (https://github.com/base-org/eip-7702-proxy)
1313
contract EIP7702Proxy is Proxy {
1414
/// @notice ERC1271 interface constants
1515
bytes4 internal constant ERC1271_MAGIC_VALUE = 0x1626ba7e;
1616
bytes4 internal constant ERC1271_FAIL_VALUE = 0xffffffff;
1717

18-
/// @notice Address of this proxy contract (stored as immutable)
18+
/// @notice Address of this proxy contract delegate
1919
address immutable proxy;
2020

2121
/// @notice Initial implementation address set during construction
@@ -24,15 +24,12 @@ contract EIP7702Proxy is Proxy {
2424
/// @notice Function selector on the implementation that is guarded from direct calls
2525
bytes4 immutable guardedInitializer;
2626

27-
/// @dev Storage slot with the initialized flag, conforms to ERC-7201
27+
/// @dev Storage slot with the initialized flag, calculated via ERC-7201
2828
bytes32 internal constant INITIALIZED_SLOT =
2929
keccak256(
3030
abi.encode(uint256(keccak256("EIP7702Proxy.initialized")) - 1)
3131
) & ~bytes32(uint256(0xff));
3232

33-
/// @notice Emitted when the implementation is upgraded
34-
event Upgraded(address indexed implementation);
35-
3633
/// @notice Emitted when the initialization signature is invalid
3734
error InvalidSignature();
3835

@@ -76,9 +73,7 @@ contract EIP7702Proxy is Proxy {
7673
// Construct hash without Ethereum signed message prefix to prevent phishing via standard wallet signing.
7774
// Since this proxy is designed for EIP-7702 (where the proxy address is an EOA),
7875
// using a raw hash ensures that initialization signatures cannot be obtained through normal
79-
// wallet "Sign Message" prompts. This prevents malicious dapps from tricking users into
80-
// initializing their account via standard wallet signing flows.
81-
// Wallets must implement custom signing logic at a lower level to support initialization.
76+
// wallet "Sign Message" prompts.
8277
bytes32 hash = keccak256(abi.encode(proxy, args));
8378
address recovered = ECDSA.recover(hash, signature);
8479
if (recovered != address(this)) revert InvalidSignature();
@@ -93,7 +88,7 @@ contract EIP7702Proxy is Proxy {
9388
);
9489
}
9590

96-
/// @notice Handles ERC-1271 signature validation by enforcing a final ecrecover check if signatures fail `isValidSignature` check
91+
/// @notice Handles ERC-1271 signature validation by enforcing a final `ecrecover` check if signatures fail `isValidSignature` check
9792
///
9893
/// @dev This ensures EOA signatures are considered valid regardless of the implementation's `isValidSignature` implementation
9994
///

test/EIP7702Proxy/initialize.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {EIP7702Proxy} from "../../src/EIP7702Proxy.sol";
66
import {MockImplementation, RevertingInitializerMockImplementation} from "../mocks/MockImplementation.sol";
77
import {ECDSA} from "openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol";
88
import {ERC1967Utils} from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol";
9+
import {IERC1967} from "openzeppelin-contracts/contracts/interfaces/IERC1967.sol";
910

1011
contract InitializeTest is EIP7702ProxyBase {
1112
function test_succeeds_withValidSignatureAndArgs(address newOwner) public {
@@ -44,9 +45,8 @@ contract InitializeTest is EIP7702ProxyBase {
4445
function test_emitsUpgradedEvent() public {
4546
bytes memory initArgs = _createInitArgs(_newOwner);
4647
bytes memory signature = _signInitData(_EOA_PRIVATE_KEY, initArgs);
47-
4848
vm.expectEmit(true, false, false, false, address(_eoa));
49-
emit EIP7702Proxy.Upgraded(address(_implementation));
49+
emit IERC1967.Upgraded(address(_implementation));
5050
EIP7702Proxy(_eoa).initialize(initArgs, signature);
5151
}
5252

test/EIP7702Proxy/upgradeToAndCall.t.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pragma solidity ^0.8.23;
44
import {EIP7702ProxyBase} from "../base/EIP7702ProxyBase.sol";
55
import {EIP7702Proxy} from "../../src/EIP7702Proxy.sol";
66
import {MockImplementation} from "../mocks/MockImplementation.sol";
7+
import {IERC1967} from "openzeppelin-contracts/contracts/interfaces/IERC1967.sol";
78

89
/**
910
* @title UpgradeToAndCallTest
@@ -31,7 +32,7 @@ contract UpgradeToAndCallTest is EIP7702ProxyBase {
3132

3233
// Expect the Upgraded event
3334
vm.expectEmit(true, false, false, false, address(_eoa));
34-
emit EIP7702Proxy.Upgraded(address(newImplementation));
35+
emit IERC1967.Upgraded(address(newImplementation));
3536

3637
MockImplementation(payable(_eoa)).upgradeToAndCall(
3738
address(newImplementation),
@@ -52,7 +53,7 @@ contract UpgradeToAndCallTest is EIP7702ProxyBase {
5253
vm.prank(_newOwner);
5354

5455
vm.expectEmit(true, false, false, false, address(_eoa));
55-
emit EIP7702Proxy.Upgraded(address(newImplementation));
56+
emit IERC1967.Upgraded(address(newImplementation));
5657

5758
MockImplementation(payable(_eoa)).upgradeToAndCall(
5859
address(newImplementation),

0 commit comments

Comments
 (0)