Skip to content

Commit 21f4701

Browse files
committed
add documentation
1 parent 1380ec5 commit 21f4701

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/EIP7702Proxy.sol

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ import {ERC1967Utils} from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC19
66
import {ECDSA} from "openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol";
77
import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol";
88

9-
/// @notice Proxy contract designed for EIP-7702 smart accounts.
10-
///
11-
/// @dev Implements ERC-1967, but with an initial implementation.
12-
/// @dev Guards the initializer function, requiring a signed payload by the wallet to call it.
9+
/// @title EIP7702Proxy
10+
/// @notice Proxy contract designed for EIP-7702 smart accounts
11+
/// @dev Implements ERC-1967 with an initial implementation and guarded initialization
1312
contract EIP7702Proxy is Proxy {
1413
// ERC1271 interface constants
1514
bytes4 internal constant ERC1271_MAGIC_VALUE = 0x1626ba7e;
1615
bytes4 internal constant ERC1271_ISVALIDSIGNATURE_SELECTOR = 0x1626ba7e;
1716
bytes4 internal constant ERC1271_FAIL_VALUE = 0xffffffff;
1817

18+
/// @notice Address of this proxy contract (stored as immutable)
1919
address immutable proxy;
20+
/// @notice Initial implementation address set during construction
2021
address immutable initialImplementation;
22+
/// @notice Function selector on the implementation that is guarded from direct calls
2123
bytes4 immutable guardedInitializer;
2224

2325
event Upgraded(address indexed implementation);
@@ -32,6 +34,10 @@ contract EIP7702Proxy is Proxy {
3234
guardedInitializer = initializer;
3335
}
3436

37+
/// @notice Initializes the proxy and implementation with a signed payload
38+
/// @param args The initialization arguments for the implementation
39+
/// @param signature The signature authorizing initialization
40+
/// @dev Signature must be from this contract's address
3541
function initialize(
3642
bytes calldata args,
3743
bytes calldata signature
@@ -55,6 +61,7 @@ contract EIP7702Proxy is Proxy {
5561
);
5662
}
5763

64+
/// @inheritdoc Proxy
5865
function _implementation() internal view override returns (address) {
5966
address implementation = ERC1967Utils.getImplementation();
6067
return
@@ -63,6 +70,9 @@ contract EIP7702Proxy is Proxy {
6370
: initialImplementation;
6471
}
6572

73+
/// @inheritdoc Proxy
74+
/// @dev Handles ERC-1271 signature validation by enforcing an ecrecover check if signatures fail `isValidSignature` check
75+
/// @dev Guards a specified initializer function from being called directly
6676
function _fallback() internal override {
6777
// block guarded initializer from being called
6878
if (msg.sig == guardedInitializer) revert InvalidInitializer();

0 commit comments

Comments
 (0)