|
| 1 | +# ARecoverableAccount |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +#### License: MIT |
| 6 | + |
| 7 | +```solidity |
| 8 | +abstract contract ARecoverableAccount is IAccount, Initializable, AAccountRecovery, ERC7821 |
| 9 | +``` |
| 10 | + |
| 11 | +EIP-7702/ERC-4337 Recoverable Account module |
| 12 | + |
| 13 | +A basic EIP-7702/ERC-4337 account implementation with ERC-7821 batching execution, |
| 14 | +ERC-4337 sponsored transactions, and ERC-7947 recoverable trusted executor. |
| 15 | +## Structs info |
| 16 | + |
| 17 | +### RecoverableAccountStorage |
| 18 | + |
| 19 | +```solidity |
| 20 | +struct RecoverableAccountStorage { |
| 21 | + address entryPoint; |
| 22 | + address trustedExecutor; |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | + |
| 27 | +## Events info |
| 28 | + |
| 29 | +### TrustedExecutorUpdated |
| 30 | + |
| 31 | +```solidity |
| 32 | +event TrustedExecutorUpdated(address indexed oldTrustedExecutor, address indexed newTrustedExecutor) |
| 33 | +``` |
| 34 | + |
| 35 | + |
| 36 | +## Errors info |
| 37 | + |
| 38 | +### NotSelfCalled |
| 39 | + |
| 40 | +```solidity |
| 41 | +error NotSelfCalled() |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | +### InvalidExecutor |
| 46 | + |
| 47 | +```solidity |
| 48 | +error InvalidExecutor(address executor) |
| 49 | +``` |
| 50 | + |
| 51 | + |
| 52 | +## Constants info |
| 53 | + |
| 54 | +### SIG_VALIDATION_FAILED (0x8f41ec5a) |
| 55 | + |
| 56 | +```solidity |
| 57 | +uint256 constant SIG_VALIDATION_FAILED = 1 |
| 58 | +``` |
| 59 | + |
| 60 | + |
| 61 | +### SIG_VALIDATION_SUCCESS (0x861af77c) |
| 62 | + |
| 63 | +```solidity |
| 64 | +uint256 constant SIG_VALIDATION_SUCCESS = 0 |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | +## Modifiers info |
| 69 | + |
| 70 | +### onlySelfCalled |
| 71 | + |
| 72 | +```solidity |
| 73 | +modifier onlySelfCalled() |
| 74 | +``` |
| 75 | + |
| 76 | + |
| 77 | +## Functions info |
| 78 | + |
| 79 | +### addRecoveryProvider (0x180e8d5c) |
| 80 | + |
| 81 | +```solidity |
| 82 | +function addRecoveryProvider( |
| 83 | + address provider_, |
| 84 | + bytes memory recoveryData_ |
| 85 | +) external payable virtual override onlySelfCalled |
| 86 | +``` |
| 87 | + |
| 88 | +A function to add a new recovery provider. |
| 89 | +SHOULD be access controlled. |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +Parameters: |
| 94 | + |
| 95 | +| Name | Type | Description | |
| 96 | +| :------------ | :------ | :--------------------------------------------------------- | |
| 97 | +| provider_ | address | the address of a recovery provider (ZKP verifier) to add. | |
| 98 | +| recoveryData_ | bytes | custom data (commitment) for the recovery provider. | |
| 99 | + |
| 100 | +### removeRecoveryProvider (0xefe4256c) |
| 101 | + |
| 102 | +```solidity |
| 103 | +function removeRecoveryProvider( |
| 104 | + address provider_ |
| 105 | +) external payable virtual override onlySelfCalled |
| 106 | +``` |
| 107 | + |
| 108 | +A function to remove an existing recovery provider. |
| 109 | +SHOULD be access controlled. |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | +Parameters: |
| 114 | + |
| 115 | +| Name | Type | Description | |
| 116 | +| :-------- | :------ | :------------------------------------------------------------- | |
| 117 | +| provider_ | address | the address of a previously added recovery provider to remove. | |
| 118 | + |
| 119 | +### recoverAccess (0x15494a7d) |
| 120 | + |
| 121 | +```solidity |
| 122 | +function recoverAccess( |
| 123 | + bytes memory subject_, |
| 124 | + address provider_, |
| 125 | + bytes memory proof_ |
| 126 | +) external virtual override returns (bool) |
| 127 | +``` |
| 128 | + |
| 129 | +A non-view function to recover access of a smart account. |
| 130 | + |
| 131 | + |
| 132 | +Parameters: |
| 133 | + |
| 134 | +| Name | Type | Description | |
| 135 | +| :-------- | :------ | :----------------------------------------------------------------------- | |
| 136 | +| subject_ | bytes | the recovery subject (encoded owner address, access control role, etc). | |
| 137 | +| provider_ | address | the address of a recovery provider. | |
| 138 | +| proof_ | bytes | an encoded proof of recovery (ZKP/ZKAI, signature, etc). | |
| 139 | + |
| 140 | + |
| 141 | +Return values: |
| 142 | + |
| 143 | +| Name | Type | Description | |
| 144 | +| :--- | :--- | :--------------------------------------------------------------- | |
| 145 | +| [0] | bool | `true` if recovery is successful, `false` (or revert) otherwise. | |
| 146 | + |
| 147 | +### validateUserOp (0x19822f7c) |
| 148 | + |
| 149 | +```solidity |
| 150 | +function validateUserOp( |
| 151 | + IAccount.PackedUserOperation calldata userOp_, |
| 152 | + bytes32 userOpHash_, |
| 153 | + uint256 missingAccountFunds_ |
| 154 | +) external virtual returns (uint256 validationData_) |
| 155 | +``` |
| 156 | + |
| 157 | +A function to validate a `PackedUserOperation` for the account. |
| 158 | + |
| 159 | +This function is called from the `EntryPoint` while executing the user operation. |
| 160 | +Must be implemented by accounts to verify signatures and pay required funds. |
| 161 | + |
| 162 | + |
| 163 | +Parameters: |
| 164 | + |
| 165 | +| Name | Type | Description | |
| 166 | +| :------------------- | :---------------------------------- | :------------------------------------------------------ | |
| 167 | +| userOp_ | struct IAccount.PackedUserOperation | The user operation being validated. | |
| 168 | +| userOpHash_ | bytes32 | The user operation hash used for signature validation. | |
| 169 | +| missingAccountFunds_ | uint256 | Amount that the account must fund to the `EntryPoint`. | |
| 170 | + |
| 171 | + |
| 172 | +Return values: |
| 173 | + |
| 174 | +| Name | Type | Description | |
| 175 | +| :-------------- | :------ | :-------------------------------------- | |
| 176 | +| validationData_ | uint256 | The result of the signature validation. | |
| 177 | + |
| 178 | +### trustedExecutor (0x39584b19) |
| 179 | + |
| 180 | +```solidity |
| 181 | +function trustedExecutor() public view virtual returns (address) |
| 182 | +``` |
| 183 | + |
| 184 | +A function to retrieve the current trusted executor. |
| 185 | + |
| 186 | + |
| 187 | +Return values: |
| 188 | + |
| 189 | +| Name | Type | Description | |
| 190 | +| :--- | :------ | :------------------------------------------- | |
| 191 | +| [0] | address | The address of the current trusted executor. | |
| 192 | + |
| 193 | +### entryPoint (0xb0d691fe) |
| 194 | + |
| 195 | +```solidity |
| 196 | +function entryPoint() public view virtual returns (address) |
| 197 | +``` |
| 198 | + |
| 199 | +A function to retrieve the address of the `EntryPoint` this account is bound to. |
| 200 | + |
| 201 | + |
| 202 | +Return values: |
| 203 | + |
| 204 | +| Name | Type | Description | |
| 205 | +| :--- | :------ | :--------------------------------- | |
| 206 | +| [0] | address | The `EntryPoint` contract address. | |
0 commit comments