@@ -24,12 +24,6 @@ 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, calculated via ERC-7201
28- bytes32 internal constant INITIALIZED_SLOT =
29- keccak256 (
30- abi.encode (uint256 (keccak256 ("EIP7702Proxy.initialized " )) - 1 )
31- ) & ~ bytes32 (uint256 (0xff ));
32-
3327 /// @notice Emitted when the initialization signature is invalid
3428 error InvalidSignature ();
3529
@@ -55,11 +49,6 @@ contract EIP7702Proxy is Proxy {
5549 guardedInitializer = initializer;
5650 }
5751
58- /// @dev Checks if proxy has been initialized by checking the initialized flag
59- function _isInitialized () internal view returns (bool ) {
60- return StorageSlot.getBooleanSlot (INITIALIZED_SLOT).value;
61- }
62-
6352 /// @notice Initializes the proxy and implementation with a signed payload
6453 ///
6554 /// @dev Signature must be from this contract's address
@@ -78,9 +67,6 @@ contract EIP7702Proxy is Proxy {
7867 address recovered = ECDSA.recover (hash, signature);
7968 if (recovered != address (this )) revert InvalidSignature ();
8069
81- // Set initialized flag before upgrading
82- StorageSlot.getBooleanSlot (INITIALIZED_SLOT).value = true ;
83-
8470 // Set the ERC-1967 implementation slot, emit Upgraded event, call the initializer
8571 ERC1967Utils .upgradeToAndCall (
8672 initialImplementation,
@@ -100,9 +86,6 @@ contract EIP7702Proxy is Proxy {
10086 bytes32 hash ,
10187 bytes calldata signature
10288 ) external returns (bytes4 ) {
103- // Check initialization status first
104- if (! _isInitialized ()) revert ProxyNotInitialized ();
105-
10689 // First try delegatecall to implementation
10790 (bool success , bytes memory result ) = _implementation ().delegatecall (
10891 msg .data
@@ -133,15 +116,17 @@ contract EIP7702Proxy is Proxy {
133116 /// @dev Handles ERC-1271 signature validation by enforcing an ecrecover check if signatures fail `isValidSignature` check
134117 /// @dev Guards a specified initializer function from being called directly
135118 function _fallback () internal override {
136- if (! _isInitialized ()) revert ProxyNotInitialized ();
137-
138119 // block guarded initializer from being called
139120 if (msg .sig == guardedInitializer) revert InvalidInitializer ();
140121
141122 _delegate (_implementation ());
142123 }
143124
125+ /// @notice Returns the implementation address, falling back to the initial implementation if the ERC-1967 implementation slot is not set
126+ /// @return The implementation address
144127 function _implementation () internal view override returns (address ) {
128+ if (ERC1967Utils .getImplementation () == address (0 ))
129+ return initialImplementation;
145130 return ERC1967Utils .getImplementation ();
146131 }
147132
0 commit comments