@erc6900/reference-implementation 0.8.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @erc6900/reference-implementation might be problematic. Click here for more details.
- package/package.json +5 -26
- package/preinstall.js +110 -0
- package/LICENSE +0 -21
- package/README.md +0 -76
- package/src/account/AccountExecutor.sol +0 -20
- package/src/account/AccountFactory.sol +0 -126
- package/src/account/AccountStorage.sol +0 -99
- package/src/account/AccountStorageInitializable.sol +0 -67
- package/src/account/ModularAccountView.sol +0 -66
- package/src/account/ModuleManagerInternals.sol +0 -325
- package/src/account/ReferenceModularAccount.sol +0 -769
- package/src/account/SemiModularAccount.sol +0 -214
- package/src/account/SemiModularAccount7702.sol +0 -38
- package/src/helpers/CollectReturnData.sol +0 -14
- package/src/helpers/Constants.sol +0 -11
- package/src/helpers/EmptyCalldataSlice.sol +0 -12
- package/src/helpers/ValidationResHelpers.sol +0 -50
- package/src/interfaces/IERC6900Account.sol +0 -127
- package/src/interfaces/IERC6900AccountView.sol +0 -52
- package/src/interfaces/IERC6900ExecutionHookModule.sol +0 -26
- package/src/interfaces/IERC6900ExecutionModule.sol +0 -37
- package/src/interfaces/IERC6900Module.sol +0 -24
- package/src/interfaces/IERC6900ValidationHookModule.sol +0 -46
- package/src/interfaces/IERC6900ValidationModule.sol +0 -53
- package/src/libraries/HookConfigLib.sol +0 -135
- package/src/libraries/KnownSelectorsLib.sol +0 -65
- package/src/libraries/ModuleEntityLib.sol +0 -37
- package/src/libraries/ModuleStorageLib.sol +0 -62
- package/src/libraries/SparseCalldataSegmentLib.sol +0 -95
- package/src/libraries/ValidationConfigLib.sol +0 -119
- package/src/modules/BaseModule.sol +0 -54
- package/src/modules/ModuleEIP712.sol +0 -29
- package/src/modules/ReplaySafeWrapper.sol +0 -38
- package/src/modules/TokenReceiverModule.sol +0 -87
- package/src/modules/permissions/AllowlistModule.sol +0 -156
- package/src/modules/permissions/ERC20TokenLimitModule.sol +0 -145
- package/src/modules/permissions/NativeTokenLimitModule.sol +0 -154
- package/src/modules/validation/ISingleSignerValidationModule.sol +0 -22
- package/src/modules/validation/SingleSignerValidationModule.sol +0 -138
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
import {ReferenceModularAccount} from "./ReferenceModularAccount.sol";
|
|
5
|
-
import {IEntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntryPoint.sol";
|
|
6
|
-
import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";
|
|
7
|
-
|
|
8
|
-
import {ModuleEntityLib} from "../libraries/ModuleEntityLib.sol";
|
|
9
|
-
|
|
10
|
-
import {IERC6900Account, ModuleEntity, ValidationConfig} from "../interfaces/IERC6900Account.sol";
|
|
11
|
-
|
|
12
|
-
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
|
|
13
|
-
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
|
|
14
|
-
import {LibClone} from "solady/utils/LibClone.sol";
|
|
15
|
-
|
|
16
|
-
contract SemiModularAccount is ReferenceModularAccount {
|
|
17
|
-
using MessageHashUtils for bytes32;
|
|
18
|
-
using ModuleEntityLib for ModuleEntity;
|
|
19
|
-
|
|
20
|
-
struct SemiModularAccountStorage {
|
|
21
|
-
address fallbackSigner;
|
|
22
|
-
bool fallbackSignerDisabled;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// keccak256("ERC6900.SemiModularAccount.Storage")
|
|
26
|
-
uint256 internal constant _SEMI_MODULAR_ACCOUNT_STORAGE_SLOT =
|
|
27
|
-
0x5b9dc9aa943f8fa2653ceceda5e3798f0686455280432166ba472eca0bc17a32;
|
|
28
|
-
|
|
29
|
-
// keccak256("EIP712Domain(uint256 chainId,address verifyingContract)")
|
|
30
|
-
bytes32 private constant _DOMAIN_SEPARATOR_TYPEHASH =
|
|
31
|
-
0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;
|
|
32
|
-
|
|
33
|
-
// keccak256("ReplaySafeHash(bytes32 hash)")
|
|
34
|
-
bytes32 private constant _REPLAY_SAFE_HASH_TYPEHASH =
|
|
35
|
-
0x294a8735843d4afb4f017c76faf3b7731def145ed0025fc9b1d5ce30adf113ff;
|
|
36
|
-
|
|
37
|
-
ModuleEntity internal constant _FALLBACK_VALIDATION = ModuleEntity.wrap(bytes24(type(uint192).max));
|
|
38
|
-
|
|
39
|
-
uint256 internal constant _SIG_VALIDATION_PASSED = 0;
|
|
40
|
-
uint256 internal constant _SIG_VALIDATION_FAILED = 1;
|
|
41
|
-
|
|
42
|
-
event FallbackSignerSet(address indexed previousFallbackSigner, address indexed newFallbackSigner);
|
|
43
|
-
event FallbackSignerDisabledSet(bool prevDisabled, bool newDisabled);
|
|
44
|
-
|
|
45
|
-
error FallbackSignerMismatch();
|
|
46
|
-
error FallbackSignerDisabled();
|
|
47
|
-
error InitializerDisabled();
|
|
48
|
-
|
|
49
|
-
constructor(IEntryPoint anEntryPoint) ReferenceModularAccount(anEntryPoint) {}
|
|
50
|
-
|
|
51
|
-
/// @notice Updates the fallback signer address in storage.
|
|
52
|
-
/// @dev This function causes the fallback signer getter to ignore the bytecode signer if it is nonzero. It can
|
|
53
|
-
/// also be used to revert back to the bytecode signer by setting to zero.
|
|
54
|
-
/// @param fallbackSigner The new signer to set.
|
|
55
|
-
function updateFallbackSigner(address fallbackSigner) external wrapNativeFunction {
|
|
56
|
-
SemiModularAccountStorage storage _storage = _getSemiModularAccountStorage();
|
|
57
|
-
emit FallbackSignerSet(_storage.fallbackSigner, fallbackSigner);
|
|
58
|
-
|
|
59
|
-
_storage.fallbackSigner = fallbackSigner;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/// @notice Sets whether the fallback signer validation should be enabled or disabled.
|
|
63
|
-
/// @dev Due to being initially zero, we need to store "disabled" rather than "enabled" in storage.
|
|
64
|
-
/// @param isDisabled True to disable fallback signer validation, false to enable it.
|
|
65
|
-
function setFallbackSignerDisabled(bool isDisabled) external wrapNativeFunction {
|
|
66
|
-
SemiModularAccountStorage storage _storage = _getSemiModularAccountStorage();
|
|
67
|
-
emit FallbackSignerDisabledSet(_storage.fallbackSignerDisabled, isDisabled);
|
|
68
|
-
|
|
69
|
-
_storage.fallbackSignerDisabled = isDisabled;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/// @notice Returns whether the fallback signer validation is disabled.
|
|
73
|
-
/// @return True if the fallback signer validation is disabled, false if it is enabled.
|
|
74
|
-
function isFallbackSignerDisabled() external view returns (bool) {
|
|
75
|
-
return _getSemiModularAccountStorage().fallbackSignerDisabled;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/// @notice Returns the fallback signer associated with this account, regardless if the fallback signer
|
|
79
|
-
/// validation is enabled or not.
|
|
80
|
-
/// @return The fallback signer address, either overriden in storage, or read from bytecode.
|
|
81
|
-
function getFallbackSigner() external view returns (address) {
|
|
82
|
-
return _retrieveFallbackSignerUnchecked(_getSemiModularAccountStorage());
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/// Override reverts on initialization, effectively disabling the initializer.
|
|
86
|
-
function initializeWithValidation(ValidationConfig, bytes4[] calldata, bytes calldata, bytes[] calldata)
|
|
87
|
-
external
|
|
88
|
-
pure
|
|
89
|
-
override
|
|
90
|
-
{
|
|
91
|
-
revert InitializerDisabled();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/// @inheritdoc IERC6900Account
|
|
95
|
-
function accountId() external pure virtual override returns (string memory) {
|
|
96
|
-
return "erc6900.reference-semi-modular-account.0.8.0";
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function replaySafeHash(bytes32 hash) public view virtual returns (bytes32) {
|
|
100
|
-
return
|
|
101
|
-
MessageHashUtils.toTypedDataHash({domainSeparator: _domainSeparator(), structHash: _hashStruct(hash)});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function _execUserOpValidation(
|
|
105
|
-
ModuleEntity userOpValidationFunction,
|
|
106
|
-
PackedUserOperation memory userOp,
|
|
107
|
-
bytes32 userOpHash
|
|
108
|
-
) internal override returns (uint256) {
|
|
109
|
-
if (userOpValidationFunction.eq(_FALLBACK_VALIDATION)) {
|
|
110
|
-
address fallbackSigner = _getFallbackSigner();
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
SignatureChecker.isValidSignatureNow(
|
|
114
|
-
fallbackSigner, userOpHash.toEthSignedMessageHash(), userOp.signature
|
|
115
|
-
)
|
|
116
|
-
) {
|
|
117
|
-
return _SIG_VALIDATION_PASSED;
|
|
118
|
-
}
|
|
119
|
-
return _SIG_VALIDATION_FAILED;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return super._execUserOpValidation(userOpValidationFunction, userOp, userOpHash);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function _execRuntimeValidation(
|
|
126
|
-
ModuleEntity runtimeValidationFunction,
|
|
127
|
-
bytes calldata callData,
|
|
128
|
-
bytes calldata authorization
|
|
129
|
-
) internal override {
|
|
130
|
-
if (runtimeValidationFunction.eq(_FALLBACK_VALIDATION)) {
|
|
131
|
-
address fallbackSigner = _getFallbackSigner();
|
|
132
|
-
|
|
133
|
-
if (msg.sender != fallbackSigner) {
|
|
134
|
-
revert FallbackSignerMismatch();
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
super._execRuntimeValidation(runtimeValidationFunction, callData, authorization);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function _exec1271Validation(ModuleEntity sigValidation, bytes32 hash, bytes calldata signature)
|
|
142
|
-
internal
|
|
143
|
-
view
|
|
144
|
-
override
|
|
145
|
-
returns (bytes4)
|
|
146
|
-
{
|
|
147
|
-
if (sigValidation.eq(_FALLBACK_VALIDATION)) {
|
|
148
|
-
address fallbackSigner = _getFallbackSigner();
|
|
149
|
-
|
|
150
|
-
if (SignatureChecker.isValidSignatureNow(fallbackSigner, replaySafeHash(hash), signature)) {
|
|
151
|
-
return _1271_MAGIC_VALUE;
|
|
152
|
-
}
|
|
153
|
-
return _1271_INVALID;
|
|
154
|
-
}
|
|
155
|
-
return super._exec1271Validation(sigValidation, hash, signature);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function _globalValidationAllowed(bytes4 selector) internal view override returns (bool) {
|
|
159
|
-
return selector == this.setFallbackSignerDisabled.selector
|
|
160
|
-
|| selector == this.updateFallbackSigner.selector || super._globalValidationAllowed(selector);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function _isValidationGlobal(ModuleEntity validationFunction) internal view override returns (bool) {
|
|
164
|
-
return validationFunction.eq(_FALLBACK_VALIDATION) || super._isValidationGlobal(validationFunction);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function _getFallbackSigner() internal view returns (address) {
|
|
168
|
-
SemiModularAccountStorage storage _storage = _getSemiModularAccountStorage();
|
|
169
|
-
|
|
170
|
-
if (_storage.fallbackSignerDisabled) {
|
|
171
|
-
revert FallbackSignerDisabled();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return _retrieveFallbackSignerUnchecked(_storage);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function _retrieveFallbackSignerUnchecked(SemiModularAccountStorage storage _storage)
|
|
178
|
-
internal
|
|
179
|
-
view
|
|
180
|
-
virtual
|
|
181
|
-
returns (address)
|
|
182
|
-
{
|
|
183
|
-
address storageFallbackSigner = _storage.fallbackSigner;
|
|
184
|
-
if (storageFallbackSigner != address(0)) {
|
|
185
|
-
return storageFallbackSigner;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
bytes memory appendedData = LibClone.argsOnERC1967(address(this), 0, 20);
|
|
189
|
-
|
|
190
|
-
return address(uint160(bytes20(appendedData)));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function _domainSeparator() internal view returns (bytes32) {
|
|
194
|
-
return keccak256(abi.encode(_DOMAIN_SEPARATOR_TYPEHASH, block.chainid, address(this)));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function _getSemiModularAccountStorage() internal pure returns (SemiModularAccountStorage storage) {
|
|
198
|
-
SemiModularAccountStorage storage _storage;
|
|
199
|
-
assembly ("memory-safe") {
|
|
200
|
-
_storage.slot := _SEMI_MODULAR_ACCOUNT_STORAGE_SLOT
|
|
201
|
-
}
|
|
202
|
-
return _storage;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function _hashStruct(bytes32 hash) internal pure virtual returns (bytes32) {
|
|
206
|
-
bytes32 res;
|
|
207
|
-
assembly ("memory-safe") {
|
|
208
|
-
mstore(0x00, _REPLAY_SAFE_HASH_TYPEHASH)
|
|
209
|
-
mstore(0x20, hash)
|
|
210
|
-
res := keccak256(0, 0x40)
|
|
211
|
-
}
|
|
212
|
-
return res;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
import {IERC6900Account} from "../interfaces/IERC6900Account.sol";
|
|
5
|
-
import {SemiModularAccount} from "./SemiModularAccount.sol";
|
|
6
|
-
import {IEntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntryPoint.sol";
|
|
7
|
-
|
|
8
|
-
contract SemiModularAccount7702 is SemiModularAccount {
|
|
9
|
-
error UpgradeNotAllowed();
|
|
10
|
-
|
|
11
|
-
constructor(IEntryPoint anEntryPoint) SemiModularAccount(anEntryPoint) {}
|
|
12
|
-
|
|
13
|
-
/// @inheritdoc IERC6900Account
|
|
14
|
-
function accountId() external pure virtual override returns (string memory) {
|
|
15
|
-
return "erc6900.reference-semi-modular-account-7702.0.8.0";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/// @dev To prevent accidental self-calls, upgrades are disabled in 7702 accounts.
|
|
19
|
-
function upgradeToAndCall(address, bytes memory) public payable override {
|
|
20
|
-
revert UpgradeNotAllowed();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/// @dev If the fallback signer is set in storage, ignore the 7702 signer.
|
|
24
|
-
function _retrieveFallbackSignerUnchecked(SemiModularAccountStorage storage _storage)
|
|
25
|
-
internal
|
|
26
|
-
view
|
|
27
|
-
override
|
|
28
|
-
returns (address)
|
|
29
|
-
{
|
|
30
|
-
address storageFallbackSigner = _storage.fallbackSigner;
|
|
31
|
-
if (storageFallbackSigner != address(0)) {
|
|
32
|
-
return storageFallbackSigner;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// To support 7702, we default to address(this) as the fallback signer.
|
|
36
|
-
return address(this);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
function collectReturnData() pure returns (bytes memory returnData) {
|
|
5
|
-
assembly ("memory-safe") {
|
|
6
|
-
// Allocate a buffer of that size, advancing the memory pointer to the nearest word
|
|
7
|
-
returnData := mload(0x40)
|
|
8
|
-
mstore(returnData, returndatasize())
|
|
9
|
-
mstore(0x40, and(add(add(returnData, returndatasize()), 0x3f), not(0x1f)))
|
|
10
|
-
|
|
11
|
-
// Copy over the return data
|
|
12
|
-
returndatacopy(add(returnData, 0x20), 0, returndatasize())
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
// Index marking the start of the data for the validation function.
|
|
5
|
-
uint8 constant RESERVED_VALIDATION_DATA_INDEX = type(uint8).max;
|
|
6
|
-
|
|
7
|
-
// Maximum number of validation-associated hooks that can be registered.
|
|
8
|
-
uint8 constant MAX_VALIDATION_ASSOC_HOOKS = type(uint8).max;
|
|
9
|
-
|
|
10
|
-
// Magic value for the Entity ID of direct call validation.
|
|
11
|
-
uint32 constant DIRECT_CALL_VALIDATION_ENTITY_ID = type(uint32).max;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
// solhint-disable-next-line private-vars-leading-underscore
|
|
5
|
-
function _coalescePreValidation(uint256 validationRes1, uint256 validationRes2)
|
|
6
|
-
pure
|
|
7
|
-
returns (uint256 resValidationData)
|
|
8
|
-
{
|
|
9
|
-
uint48 validUntil1 = uint48(validationRes1 >> 160);
|
|
10
|
-
if (validUntil1 == 0) {
|
|
11
|
-
validUntil1 = type(uint48).max;
|
|
12
|
-
}
|
|
13
|
-
uint48 validUntil2 = uint48(validationRes2 >> 160);
|
|
14
|
-
if (validUntil2 == 0) {
|
|
15
|
-
validUntil2 = type(uint48).max;
|
|
16
|
-
}
|
|
17
|
-
resValidationData = ((validUntil1 > validUntil2) ? uint256(validUntil2) << 160 : uint256(validUntil1) << 160);
|
|
18
|
-
|
|
19
|
-
uint48 validAfter1 = uint48(validationRes1 >> 208);
|
|
20
|
-
uint48 validAfter2 = uint48(validationRes2 >> 208);
|
|
21
|
-
|
|
22
|
-
resValidationData |= ((validAfter1 < validAfter2) ? uint256(validAfter2) << 208 : uint256(validAfter1) << 208);
|
|
23
|
-
|
|
24
|
-
// Once we know that the authorizer field is 0 or 1, we can safely bubble up SIG_FAIL with bitwise OR
|
|
25
|
-
resValidationData |= uint160(validationRes1) | uint160(validationRes2);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// solhint-disable-next-line private-vars-leading-underscore
|
|
29
|
-
function _coalesceValidation(uint256 preValidationData, uint256 validationRes)
|
|
30
|
-
pure
|
|
31
|
-
returns (uint256 resValidationData)
|
|
32
|
-
{
|
|
33
|
-
uint48 validUntil1 = uint48(preValidationData >> 160);
|
|
34
|
-
if (validUntil1 == 0) {
|
|
35
|
-
validUntil1 = type(uint48).max;
|
|
36
|
-
}
|
|
37
|
-
uint48 validUntil2 = uint48(validationRes >> 160);
|
|
38
|
-
if (validUntil2 == 0) {
|
|
39
|
-
validUntil2 = type(uint48).max;
|
|
40
|
-
}
|
|
41
|
-
resValidationData = ((validUntil1 > validUntil2) ? uint256(validUntil2) << 160 : uint256(validUntil1) << 160);
|
|
42
|
-
|
|
43
|
-
uint48 validAfter1 = uint48(preValidationData >> 208);
|
|
44
|
-
uint48 validAfter2 = uint48(validationRes >> 208);
|
|
45
|
-
|
|
46
|
-
resValidationData |= ((validAfter1 < validAfter2) ? uint256(validAfter2) << 208 : uint256(validAfter1) << 208);
|
|
47
|
-
|
|
48
|
-
// If prevalidation failed, bubble up failure
|
|
49
|
-
resValidationData |= uint160(preValidationData) == 1 ? 1 : uint160(validationRes);
|
|
50
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
import {ExecutionManifest} from "./IERC6900ExecutionModule.sol";
|
|
5
|
-
|
|
6
|
-
type ModuleEntity is bytes24;
|
|
7
|
-
// ModuleEntity is a packed representation of a module function
|
|
8
|
-
// Layout:
|
|
9
|
-
// 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA________________________ // Address
|
|
10
|
-
// 0x________________________________________BBBBBBBB________________ // Entity ID
|
|
11
|
-
// 0x________________________________________________0000000000000000 // unused
|
|
12
|
-
|
|
13
|
-
type ValidationConfig is bytes25;
|
|
14
|
-
// ValidationConfig is a packed representation of a validation function and flags for its configuration.
|
|
15
|
-
// Layout:
|
|
16
|
-
// 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA________________________ // Address
|
|
17
|
-
// 0x________________________________________BBBBBBBB________________ // Entity ID
|
|
18
|
-
// 0x________________________________________________CC______________ // ValidationFlags
|
|
19
|
-
// 0x__________________________________________________00000000000000 // unused
|
|
20
|
-
|
|
21
|
-
type ValidationFlags is uint8;
|
|
22
|
-
// ValidationFlags layout:
|
|
23
|
-
// 0b00000___ // unused
|
|
24
|
-
// 0b_____A__ // isGlobal
|
|
25
|
-
// 0b______B_ // isSignatureValidation
|
|
26
|
-
// 0b_______C // isUserOpValidation
|
|
27
|
-
|
|
28
|
-
type HookConfig is bytes25;
|
|
29
|
-
// HookConfig is a packed representation of a hook function and flags for its configuration.
|
|
30
|
-
// Layout:
|
|
31
|
-
// 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA________________________ // Address
|
|
32
|
-
// 0x________________________________________BBBBBBBB________________ // Entity ID
|
|
33
|
-
// 0x________________________________________________CC______________ // Hook Flags
|
|
34
|
-
//
|
|
35
|
-
// Hook flags layout:
|
|
36
|
-
// 0b00000___ // unused
|
|
37
|
-
// 0b_____A__ // hasPre (exec only)
|
|
38
|
-
// 0b______B_ // hasPost (exec only)
|
|
39
|
-
// 0b_______C // hook type (0 for exec, 1 for validation)
|
|
40
|
-
|
|
41
|
-
struct Call {
|
|
42
|
-
// The target address for the account to call.
|
|
43
|
-
address target;
|
|
44
|
-
// The value to send with the call.
|
|
45
|
-
uint256 value;
|
|
46
|
-
// The calldata for the call.
|
|
47
|
-
bytes data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface IERC6900Account {
|
|
51
|
-
event ExecutionInstalled(address indexed module, ExecutionManifest manifest);
|
|
52
|
-
event ExecutionUninstalled(address indexed module, bool onUninstallSucceeded, ExecutionManifest manifest);
|
|
53
|
-
event ValidationInstalled(address indexed module, uint32 indexed entityId);
|
|
54
|
-
event ValidationUninstalled(address indexed module, uint32 indexed entityId, bool onUninstallSucceeded);
|
|
55
|
-
|
|
56
|
-
/// @notice Standard execute method.
|
|
57
|
-
/// @param target The target address for the account to call.
|
|
58
|
-
/// @param value The value to send with the call.
|
|
59
|
-
/// @param data The calldata for the call.
|
|
60
|
-
/// @return The return data from the call.
|
|
61
|
-
function execute(address target, uint256 value, bytes calldata data) external payable returns (bytes memory);
|
|
62
|
-
|
|
63
|
-
/// @notice Standard executeBatch method.
|
|
64
|
-
/// @dev If the target is a module, the call SHOULD revert. If any of the calls revert, the entire batch MUST
|
|
65
|
-
/// revert.
|
|
66
|
-
/// @param calls The array of calls.
|
|
67
|
-
/// @return An array containing the return data from the calls.
|
|
68
|
-
function executeBatch(Call[] calldata calls) external payable returns (bytes[] memory);
|
|
69
|
-
|
|
70
|
-
/// @notice Execute a call using the specified runtime validation.
|
|
71
|
-
/// @param data The calldata to send to the account.
|
|
72
|
-
/// @param authorization The authorization data to use for the call. The first 24 bytes is a ModuleEntity which
|
|
73
|
-
/// specifies which runtime validation to use, and the rest is sent as a parameter to runtime validation.
|
|
74
|
-
function executeWithRuntimeValidation(bytes calldata data, bytes calldata authorization)
|
|
75
|
-
external
|
|
76
|
-
payable
|
|
77
|
-
returns (bytes memory);
|
|
78
|
-
|
|
79
|
-
/// @notice Install a module to the modular account.
|
|
80
|
-
/// @param module The module to install.
|
|
81
|
-
/// @param manifest the manifest describing functions to install.
|
|
82
|
-
/// @param installData Optional data to be used by the account to handle the initial execution setup. Data
|
|
83
|
-
/// encoding is implementation-specific.
|
|
84
|
-
function installExecution(address module, ExecutionManifest calldata manifest, bytes calldata installData)
|
|
85
|
-
external;
|
|
86
|
-
|
|
87
|
-
/// @notice Uninstall a module from the modular account.
|
|
88
|
-
/// @param module The module to uninstall.
|
|
89
|
-
/// @param manifest The manifest describing functions to uninstall.
|
|
90
|
-
/// @param uninstallData Optional data to be used by the account to handle the execution uninstallation. Data
|
|
91
|
-
/// encoding is implementation-specific.
|
|
92
|
-
function uninstallExecution(address module, ExecutionManifest calldata manifest, bytes calldata uninstallData)
|
|
93
|
-
external;
|
|
94
|
-
|
|
95
|
-
/// @notice Installs a validation function across a set of execution selectors, and optionally mark it as a
|
|
96
|
-
/// global validation function.
|
|
97
|
-
/// @param validationConfig The validation function to install, along with configuration flags.
|
|
98
|
-
/// @param selectors The selectors to install the validation function for.
|
|
99
|
-
/// @param installData Optional data to be used by the account to handle the initial validation setup. Data
|
|
100
|
-
/// encoding is implementation-specific.
|
|
101
|
-
/// @param hooks Optional hooks to install and associate with the validation function. Data encoding is
|
|
102
|
-
/// implementation-specific.
|
|
103
|
-
function installValidation(
|
|
104
|
-
ValidationConfig validationConfig,
|
|
105
|
-
bytes4[] calldata selectors,
|
|
106
|
-
bytes calldata installData,
|
|
107
|
-
bytes[] calldata hooks
|
|
108
|
-
) external;
|
|
109
|
-
|
|
110
|
-
/// @notice Uninstall a validation function from a set of execution selectors.
|
|
111
|
-
/// @param validationFunction The validation function to uninstall.
|
|
112
|
-
/// @param uninstallData Optional data to be used by the account to handle the validation uninstallation. Data
|
|
113
|
-
/// encoding is implementation-specific.
|
|
114
|
-
/// @param hookUninstallData Optional data to be used by the account to handle hook uninstallation. Data
|
|
115
|
-
/// encoding is implementation-specific.
|
|
116
|
-
function uninstallValidation(
|
|
117
|
-
ModuleEntity validationFunction,
|
|
118
|
-
bytes calldata uninstallData,
|
|
119
|
-
bytes[] calldata hookUninstallData
|
|
120
|
-
) external;
|
|
121
|
-
|
|
122
|
-
/// @notice Return a unique identifier for the account implementation.
|
|
123
|
-
/// @dev This function MUST return a string in the format "vendor.account.semver". The vendor and account
|
|
124
|
-
/// names MUST NOT contain a period character.
|
|
125
|
-
/// @return The account ID.
|
|
126
|
-
function accountId() external view returns (string memory);
|
|
127
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
import {HookConfig, ModuleEntity, ValidationFlags} from "../interfaces/IERC6900Account.sol";
|
|
5
|
-
|
|
6
|
-
/// @dev Represents data associated with a specific function selector.
|
|
7
|
-
struct ExecutionDataView {
|
|
8
|
-
// The module that implements this execution function.
|
|
9
|
-
// If this is a native function, the address must be the address of the account.
|
|
10
|
-
address module;
|
|
11
|
-
// Whether or not the function needs runtime validation, or can be called by anyone. The function can still be
|
|
12
|
-
// state changing if this flag is set to true.
|
|
13
|
-
// Note that even if this is set to true, user op validation will still be required, otherwise anyone could
|
|
14
|
-
// drain the account of native tokens by wasting gas.
|
|
15
|
-
bool skipRuntimeValidation;
|
|
16
|
-
// Whether or not a global validation function may be used to validate this function.
|
|
17
|
-
bool allowGlobalValidation;
|
|
18
|
-
// The execution hooks for this function selector.
|
|
19
|
-
HookConfig[] executionHooks;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
struct ValidationDataView {
|
|
23
|
-
// ValidationFlags layout:
|
|
24
|
-
// 0b00000___ // unused
|
|
25
|
-
// 0b_____A__ // isGlobal
|
|
26
|
-
// 0b______B_ // isSignatureValidation
|
|
27
|
-
// 0b_______C // isUserOpValidation
|
|
28
|
-
ValidationFlags validationFlags;
|
|
29
|
-
// The validation hooks for this validation function.
|
|
30
|
-
HookConfig[] validationHooks;
|
|
31
|
-
// Execution hooks to run with this validation function.
|
|
32
|
-
HookConfig[] executionHooks;
|
|
33
|
-
// The set of selectors that may be validated by this validation function.
|
|
34
|
-
bytes4[] selectors;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface IERC6900AccountView {
|
|
38
|
-
/// @notice Get the execution data for a selector.
|
|
39
|
-
/// @dev If the selector is a native function, the module address will be the address of the account.
|
|
40
|
-
/// @param selector The selector to get the data for.
|
|
41
|
-
/// @return The execution data for this selector.
|
|
42
|
-
function getExecutionData(bytes4 selector) external view returns (ExecutionDataView memory);
|
|
43
|
-
|
|
44
|
-
/// @notice Get the validation data for a validation function.
|
|
45
|
-
/// @dev If the selector is a native function, the module address will be the address of the account.
|
|
46
|
-
/// @param validationFunction The validation function to get the data for.
|
|
47
|
-
/// @return The validation data for this validation function.
|
|
48
|
-
function getValidationData(ModuleEntity validationFunction)
|
|
49
|
-
external
|
|
50
|
-
view
|
|
51
|
-
returns (ValidationDataView memory);
|
|
52
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
import {IERC6900Module} from "./IERC6900Module.sol";
|
|
5
|
-
|
|
6
|
-
interface IERC6900ExecutionHookModule is IERC6900Module {
|
|
7
|
-
/// @notice Run the pre execution hook specified by the `entityId`.
|
|
8
|
-
/// @dev To indicate the entire call should revert, the function MUST revert.
|
|
9
|
-
/// @param entityId An identifier that routes the call to different internal implementations, should there
|
|
10
|
-
/// be more than one.
|
|
11
|
-
/// @param sender The caller address.
|
|
12
|
-
/// @param value The call value.
|
|
13
|
-
/// @param data The calldata sent. For `executeUserOp` calls of validation-associated hooks, hook modules
|
|
14
|
-
/// should receive the full calldata.
|
|
15
|
-
/// @return Context to pass to a post execution hook, if present. An empty bytes array MAY be returned.
|
|
16
|
-
function preExecutionHook(uint32 entityId, address sender, uint256 value, bytes calldata data)
|
|
17
|
-
external
|
|
18
|
-
returns (bytes memory);
|
|
19
|
-
|
|
20
|
-
/// @notice Run the post execution hook specified by the `entityId`.
|
|
21
|
-
/// @dev To indicate the entire call should revert, the function MUST revert.
|
|
22
|
-
/// @param entityId An identifier that routes the call to different internal implementations, should there
|
|
23
|
-
/// be more than one.
|
|
24
|
-
/// @param preExecHookData The context returned by its associated pre execution hook.
|
|
25
|
-
function postExecutionHook(uint32 entityId, bytes calldata preExecHookData) external;
|
|
26
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
import {IERC6900Module} from "./IERC6900Module.sol";
|
|
5
|
-
|
|
6
|
-
struct ManifestExecutionFunction {
|
|
7
|
-
// The selector to install.
|
|
8
|
-
bytes4 executionSelector;
|
|
9
|
-
// If true, the function won't need runtime validation, and can be called by anyone.
|
|
10
|
-
bool skipRuntimeValidation;
|
|
11
|
-
// If true, the function can be validated by a global validation function.
|
|
12
|
-
bool allowGlobalValidation;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
struct ManifestExecutionHook {
|
|
16
|
-
bytes4 executionSelector;
|
|
17
|
-
uint32 entityId;
|
|
18
|
-
bool isPreHook;
|
|
19
|
-
bool isPostHook;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/// @dev A struct describing how the module should be installed on a modular account.
|
|
23
|
-
struct ExecutionManifest {
|
|
24
|
-
// Execution functions defined in this module to be installed on the MSCA.
|
|
25
|
-
ManifestExecutionFunction[] executionFunctions;
|
|
26
|
-
ManifestExecutionHook[] executionHooks;
|
|
27
|
-
// List of ERC-165 interface IDs to add to account to support introspection checks. This MUST NOT include
|
|
28
|
-
// IERC6900Module's interface ID.
|
|
29
|
-
bytes4[] interfaceIds;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface IERC6900ExecutionModule is IERC6900Module {
|
|
33
|
-
/// @notice Describe the contents and intended configuration of the module.
|
|
34
|
-
/// @dev This manifest MUST stay constant over time.
|
|
35
|
-
/// @return A manifest describing the contents and intended configuration of the module.
|
|
36
|
-
function executionManifest() external pure returns (ExecutionManifest memory);
|
|
37
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";
|
|
5
|
-
|
|
6
|
-
interface IERC6900Module is IERC165 {
|
|
7
|
-
/// @notice Initialize module data for the modular account.
|
|
8
|
-
/// @dev Called by the modular account during `installExecution`.
|
|
9
|
-
/// @param data Optional bytes array to be decoded and used by the module to setup initial module data for the
|
|
10
|
-
/// modular account.
|
|
11
|
-
function onInstall(bytes calldata data) external;
|
|
12
|
-
|
|
13
|
-
/// @notice Clear module data for the modular account.
|
|
14
|
-
/// @dev Called by the modular account during `uninstallExecution`.
|
|
15
|
-
/// @param data Optional bytes array to be decoded and used by the module to clear module data for the modular
|
|
16
|
-
/// account.
|
|
17
|
-
function onUninstall(bytes calldata data) external;
|
|
18
|
-
|
|
19
|
-
/// @notice Return a unique identifier for the module.
|
|
20
|
-
/// @dev This function MUST return a string in the format "vendor.module.semver". The vendor and module
|
|
21
|
-
/// names MUST NOT contain a period character.
|
|
22
|
-
/// @return The module ID.
|
|
23
|
-
function moduleId() external view returns (string memory);
|
|
24
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.20;
|
|
3
|
-
|
|
4
|
-
import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";
|
|
5
|
-
|
|
6
|
-
import {IERC6900Module} from "./IERC6900Module.sol";
|
|
7
|
-
|
|
8
|
-
interface IERC6900ValidationHookModule is IERC6900Module {
|
|
9
|
-
/// @notice Run the pre user operation validation hook specified by the `entityId`.
|
|
10
|
-
/// @dev Pre user operation validation hooks MUST NOT return an authorizer value other than 0 or 1.
|
|
11
|
-
/// @param entityId An identifier that routes the call to different internal implementations, should there
|
|
12
|
-
/// be more than one.
|
|
13
|
-
/// @param userOp The user operation.
|
|
14
|
-
/// @param userOpHash The user operation hash.
|
|
15
|
-
/// @return Packed validation data for validAfter (6 bytes), validUntil (6 bytes), and authorizer (20 bytes).
|
|
16
|
-
function preUserOpValidationHook(uint32 entityId, PackedUserOperation calldata userOp, bytes32 userOpHash)
|
|
17
|
-
external
|
|
18
|
-
returns (uint256);
|
|
19
|
-
|
|
20
|
-
/// @notice Run the pre runtime validation hook specified by the `entityId`.
|
|
21
|
-
/// @dev To indicate the entire call should revert, the function MUST revert.
|
|
22
|
-
/// @param entityId An identifier that routes the call to different internal implementations, should there
|
|
23
|
-
/// be more than one.
|
|
24
|
-
/// @param sender The caller address.
|
|
25
|
-
/// @param value The call value.
|
|
26
|
-
/// @param data The calldata sent.
|
|
27
|
-
/// @param authorization Additional data for the hook to use.
|
|
28
|
-
function preRuntimeValidationHook(
|
|
29
|
-
uint32 entityId,
|
|
30
|
-
address sender,
|
|
31
|
-
uint256 value,
|
|
32
|
-
bytes calldata data,
|
|
33
|
-
bytes calldata authorization
|
|
34
|
-
) external;
|
|
35
|
-
|
|
36
|
-
/// @notice Run the pre signature validation hook specified by the `entityId`.
|
|
37
|
-
/// @dev To indicate the call should revert, the function MUST revert.
|
|
38
|
-
/// @param entityId An identifier that routes the call to different internal implementations, should there
|
|
39
|
-
/// be more than one.
|
|
40
|
-
/// @param sender The caller address.
|
|
41
|
-
/// @param hash The hash of the message being signed.
|
|
42
|
-
/// @param signature The signature of the message.
|
|
43
|
-
function preSignatureValidationHook(uint32 entityId, address sender, bytes32 hash, bytes calldata signature)
|
|
44
|
-
external
|
|
45
|
-
view;
|
|
46
|
-
}
|