@@ -72,44 +72,38 @@ contract EIP7702Proxy is Proxy {
7272 bytes32 hash ,
7373 bytes calldata signature
7474 ) external returns (bytes4 ) {
75- if (msg .sig == ERC1271_ISVALIDSIGNATURE_SELECTOR ) {
76- (bytes32 hash , bytes memory signature ) = abi.decode (
77- msg .data [4 :],
78- (bytes32 , bytes )
79- );
80-
81- // First try delegatecall to implementation
82- (bool success , bytes memory result ) = _implementation ()
83- .delegatecall (msg .data );
84-
85- // If delegatecall succeeded and returned magic value, return that
86- if (
87- success &&
88- result.length == 32 &&
89- abi.decode (result, (bytes4 )) == ERC1271_MAGIC_VALUE
90- ) {
75+ // First try delegatecall to implementation
76+ (bool success , bytes memory result ) = _implementation ().delegatecall (
77+ msg .data
78+ );
79+
80+ // If delegatecall succeeded and returned magic value, return that
81+ if (
82+ success &&
83+ result.length == 32 &&
84+ abi.decode (result, (bytes4 )) == ERC1271_MAGIC_VALUE
85+ ) {
86+ assembly {
87+ mstore (0 , ERC1271_MAGIC_VALUE )
88+ return (0 , 32 )
89+ }
90+ }
91+
92+ // Only try ECDSA if signature is the right length (65 bytes)
93+ if (signature.length == 65 ) {
94+ address recovered = ECDSA.recover (hash, signature);
95+ if (recovered == address (this )) {
9196 assembly {
9297 mstore (0 , ERC1271_MAGIC_VALUE )
9398 return (0 , 32 )
9499 }
95100 }
101+ }
96102
97- // Only try ECDSA if signature is the right length (65 bytes)
98- if (signature.length == 65 ) {
99- address recovered = ECDSA.recover (hash, signature);
100- if (recovered == address (this )) {
101- assembly {
102- mstore (0 , ERC1271_MAGIC_VALUE )
103- return (0 , 32 )
104- }
105- }
106- }
107-
108- // If all checks fail, return failure value
109- assembly {
110- mstore (0 , ERC1271_FAIL_VALUE )
111- return (0 , 32 )
112- }
103+ // If all checks fail, return failure value
104+ assembly {
105+ mstore (0 , ERC1271_FAIL_VALUE )
106+ return (0 , 32 )
113107 }
114108 }
115109
0 commit comments