Skip to content

Commit 8ffb40c

Browse files
committed
move to dedicated function
1 parent 26bacfc commit 8ffb40c

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

src/EIP7702Proxy.sol

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,17 @@ contract EIP7702Proxy is Proxy {
6161
);
6262
}
6363

64-
/// @inheritdoc Proxy
65-
function _implementation() internal view override returns (address) {
66-
address implementation = ERC1967Utils.getImplementation();
67-
return
68-
implementation != address(0)
69-
? implementation
70-
: initialImplementation;
71-
}
72-
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
76-
function _fallback() internal override {
77-
// block guarded initializer from being called
78-
if (msg.sig == guardedInitializer) revert InvalidInitializer();
79-
80-
// Special handling for isValidSignature
64+
/**
65+
* @notice Handles ERC-1271 signature validation by enforcing a final ecrecover check if signatures fail `isValidSignature` check
66+
* @dev This ensures EOA signatures are considered valid regardless of the implementation's `isValidSignature` implementation
67+
* @param hash The hash of the message being signed
68+
* @param signature The signature of the message
69+
* @return The result of the `isValidSignature` check
70+
*/
71+
function isValidSignature(
72+
bytes32 hash,
73+
bytes calldata signature
74+
) external returns (bytes4) {
8175
if (msg.sig == ERC1271_ISVALIDSIGNATURE_SELECTOR) {
8276
(bytes32 hash, bytes memory signature) = abi.decode(
8377
msg.data[4:],
@@ -117,6 +111,23 @@ contract EIP7702Proxy is Proxy {
117111
return(0, 32)
118112
}
119113
}
114+
}
115+
116+
/// @inheritdoc Proxy
117+
function _implementation() internal view override returns (address) {
118+
address implementation = ERC1967Utils.getImplementation();
119+
return
120+
implementation != address(0)
121+
? implementation
122+
: initialImplementation;
123+
}
124+
125+
/// @inheritdoc Proxy
126+
/// @dev Handles ERC-1271 signature validation by enforcing an ecrecover check if signatures fail `isValidSignature` check
127+
/// @dev Guards a specified initializer function from being called directly
128+
function _fallback() internal override {
129+
// block guarded initializer from being called
130+
if (msg.sig == guardedInitializer) revert InvalidInitializer();
120131

121132
_delegate(_implementation());
122133
}

0 commit comments

Comments
 (0)