@@ -13,8 +13,9 @@ import {SignatureCheckerLib} from "../utils/SignatureCheckerLib.sol";
13
13
///
14
14
/// Recommended usage:
15
15
/// 1. Deploy the ERC4337 as an implementation contract, and verify it on Etherscan.
16
- /// 2. Create a simple factory that uses `LibClone.deployERC1967` or
16
+ /// 2. Create a factory that uses `LibClone.deployERC1967` or
17
17
/// `LibClone.deployDeterministicERC1967` to clone the implementation.
18
+ /// See: `ERC4337Factory.sol`.
18
19
contract ERC4337 is Ownable , UUPSUpgradeable , Receiver {
19
20
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
20
21
/* STRUCTS */
@@ -89,8 +90,8 @@ contract ERC4337 is Ownable, UUPSUpgradeable, Receiver {
89
90
_validateNonce (userOp.nonce);
90
91
}
91
92
92
- /// @dev Validates the signature with ERC1271 return.
93
- /// So this account can also be used as a signer.
93
+ /// @dev Validates the signature with ERC1271 return,
94
+ /// so that this account can also be used as a signer.
94
95
function isValidSignature (bytes32 hash , bytes calldata signature )
95
96
public
96
97
view
@@ -220,14 +221,15 @@ contract ERC4337 is Ownable, UUPSUpgradeable, Receiver {
220
221
}
221
222
mstore (r, m) // Append `m` into `results`.
222
223
mstore (m, returndatasize ()) // Store the length,
223
- returndatacopy (add (m, 0x20 ), 0x00 , returndatasize ()) // and copy the returndata.
224
- m := add (add (m, 0x20 ), returndatasize ()) // Advance `m`.
224
+ let p := add (m, 0x20 )
225
+ returndatacopy (p, 0x00 , returndatasize ()) // and copy the returndata.
226
+ m := add (p, returndatasize ()) // Advance `m`.
225
227
}
226
228
mstore (0x40 , m) // Allocate the memory.
227
229
}
228
230
}
229
231
230
- /// @dev Executes a delegatecall with `delegate` on this account.
232
+ /// @dev Execute a delegatecall with `delegate` on this account.
231
233
function delegateExecute (address delegate , bytes calldata data )
232
234
public
233
235
payable
@@ -238,9 +240,9 @@ contract ERC4337 is Ownable, UUPSUpgradeable, Receiver {
238
240
{
239
241
/// @solidity memory-safe-assembly
240
242
assembly {
241
- // Forwards the `data` to `delegate` via delegatecall.
242
243
result := mload (0x40 )
243
244
calldatacopy (result, data.offset, data.length )
245
+ // Forwards the `data` to `delegate` via delegatecall.
244
246
if iszero (delegatecall (gas (), delegate, result, data.length , codesize (), 0x00 )) {
245
247
// Bubble up the revert if the call reverts.
246
248
returndatacopy (result, 0x00 , returndatasize ())
@@ -253,8 +255,7 @@ contract ERC4337 is Ownable, UUPSUpgradeable, Receiver {
253
255
}
254
256
}
255
257
256
- /// @dev Guard to ensure that the owner slot's and implementation slot's values
257
- /// aren't changed by the function.
258
+ /// @dev Ensures that the owner and implementation slots' values aren't changed.
258
259
/// You can override this modifier to ensure the sanctity of other storage slots too.
259
260
modifier storageGuard () virtual {
260
261
bytes32 ownerSlotValue = _ownerSlotValue ();
@@ -305,14 +306,14 @@ contract ERC4337 is Ownable, UUPSUpgradeable, Receiver {
305
306
address ep = entryPoint ();
306
307
/// @solidity memory-safe-assembly
307
308
assembly {
308
- mstore (0x14 , address ()) // Store the `account` argument.
309
- mstore (0x00 , 0x70a08231000000000000000000000000 ) // `balanceOf(address)`.
309
+ mstore (0x20 , address ()) // Store the `account` argument.
310
+ mstore (0x00 , 0x70a08231 ) // `balanceOf(address)`.
310
311
result :=
311
312
mul ( // Returns 0 if the EntryPoint does not exist.
312
313
mload (0x20 ),
313
314
and ( // The arguments of `and` are evaluated from right to left.
314
315
gt (returndatasize (), 0x1f ), // At least 32 bytes returned.
315
- staticcall (gas (), ep, 0x10 , 0x24 , 0x20 , 0x20 )
316
+ staticcall (gas (), ep, 0x1c , 0x24 , 0x20 , 0x20 )
316
317
)
317
318
)
318
319
}
0 commit comments