@@ -6,64 +6,74 @@ import {PackedUserOperation} from "lib/account-abstraction/contracts/interfaces/
66import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol " ;
77import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol " ;
88import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol " ;
9- import {SIG_VALIDATION_FAILED,SIG_VALIDATION_SUCCESS} from "lib/account-abstraction/contracts/core/Helpers.sol " ;
9+ import {SIG_VALIDATION_FAILED, SIG_VALIDATION_SUCCESS} from "lib/account-abstraction/contracts/core/Helpers.sol " ;
1010import {IEntryPoint} from "lib/account-abstraction/contracts/interfaces/IEntryPoint.sol " ;
1111
12- contract MinimalAccount is IAccount , Ownable {
12+ contract MinimalAccount is IAccount , Ownable {
1313 error MinimalAccount__NotFromEntryPoint ();
1414 error MinimalAccount__NotFromEntryPointOrOwner ();
1515 error MinimalAccount__CallFailed (bytes );
1616
1717 IEntryPoint private immutable i_entrypoint;
1818
1919 modifier requireFromEntryPoint () {
20- if (msg .sender != address (i_entrypoint)){
20+ if (msg .sender != address (i_entrypoint)) {
2121 revert MinimalAccount__NotFromEntryPoint ();
2222 }
2323 _;
2424 }
2525
2626 modifier requireFromEntryPointOrOwner () {
27- if (msg .sender != address (i_entrypoint) && msg .sender != owner ()){
27+ if (msg .sender != address (i_entrypoint) && msg .sender != owner ()) {
2828 revert MinimalAccount__NotFromEntryPointOrOwner ();
2929 }
3030 _;
3131 }
3232
33- constructor (address entrypoint ) Ownable (msg .sender ){
33+ constructor (address entrypoint ) Ownable (msg .sender ) {
3434 i_entrypoint = IEntryPoint (entrypoint);
3535 }
3636
3737 receive () external payable {}
3838
39- function execute (address to ,uint256 value ,bytes calldata functiondata ) external requireFromEntryPointOrOwner{
40- (bool success , bytes memory result )= to.call {value:value}(functiondata);
41- if (! success){
39+ function execute (address to , uint256 value , bytes calldata functiondata ) external requireFromEntryPointOrOwner {
40+ (bool success , bytes memory result ) = to.call {value: value}(functiondata);
41+ if (! success) {
4242 revert MinimalAccount__CallFailed (result);
4343 }
4444 }
4545
46- function validateUserOp (PackedUserOperation calldata userOp ,bytes32 userOpHash ,uint256 missingAccountFunds ) external requireFromEntryPoint returns (uint256 validationData ){
47- validationData= _validateSignature (userOp,userOpHash);
46+ function validateUserOp (PackedUserOperation calldata userOp , bytes32 userOpHash , uint256 missingAccountFunds )
47+ external
48+ requireFromEntryPoint
49+ returns (uint256 validationData )
50+ {
51+ validationData = _validateSignature (userOp, userOpHash);
4852 _payPrefund (missingAccountFunds);
4953 }
50- function _validateSignature (PackedUserOperation calldata userOp ,bytes32 userOpHash ) internal view returns (uint256 validationData ){
51- bytes32 ethSignedMessageHash= MessageHashUtils.toEthSignedMessageHash (userOpHash);
52- address signer= ECDSA.recover (ethSignedMessageHash,userOp.signature);
53- if (signer!= owner ()){
54+
55+ function _validateSignature (PackedUserOperation calldata userOp , bytes32 userOpHash )
56+ internal
57+ view
58+ returns (uint256 validationData )
59+ {
60+ bytes32 ethSignedMessageHash = MessageHashUtils.toEthSignedMessageHash (userOpHash);
61+ address signer = ECDSA.recover (ethSignedMessageHash, userOp.signature);
62+ if (signer != owner ()) {
5463 return SIG_VALIDATION_FAILED;
5564 } else {
5665 return SIG_VALIDATION_SUCCESS;
5766 }
58-
5967 }
60- function _payPrefund (uint256 missingAccountFunds ) internal {
61- if (missingAccountFunds!= 0 ){
62- (bool success ,)= payable (msg .sender ).call {value:missingAccountFunds,gas:type (uint256 ).max}("" );
68+
69+ function _payPrefund (uint256 missingAccountFunds ) internal {
70+ if (missingAccountFunds != 0 ) {
71+ (bool success ,) = payable (msg .sender ).call {value: missingAccountFunds, gas: type (uint256 ).max}("" );
6372 (success);
6473 }
6574 }
66- function getEntryPoint () external view returns (address ){
75+
76+ function getEntryPoint () external view returns (address ) {
6777 return address (i_entrypoint);
6878 }
69- }
79+ }
0 commit comments