forked from erc6900/reference-implementation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComprehensiveModule.sol
More file actions
180 lines (155 loc) · 5.77 KB
/
ComprehensiveModule.sol
File metadata and controls
180 lines (155 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";
import {
ExecutionManifest,
IERC6900ExecutionModule,
ManifestExecutionFunction,
ManifestExecutionHook
} from "../../../src/interfaces/IERC6900ExecutionModule.sol";
import {IERC6900ExecutionHookModule} from "../../../src/interfaces/IERC6900ExecutionHookModule.sol";
import {IERC6900ExecutionModule} from "../../../src/interfaces/IERC6900ExecutionModule.sol";
import {IERC6900ValidationHookModule} from "../../../src/interfaces/IERC6900ValidationHookModule.sol";
import {IERC6900ValidationModule} from "../../../src/interfaces/IERC6900ValidationModule.sol";
import {BaseModule} from "../../../src/modules/BaseModule.sol";
contract ComprehensiveModule is
IERC6900ExecutionModule,
IERC6900ValidationModule,
IERC6900ValidationHookModule,
IERC6900ExecutionHookModule,
BaseModule
{
enum EntityId {
PRE_VALIDATION_HOOK_1,
PRE_VALIDATION_HOOK_2,
VALIDATION,
BOTH_EXECUTION_HOOKS,
PRE_EXECUTION_HOOK,
POST_EXECUTION_HOOK,
SIG_VALIDATION
}
string internal constant _NAME = "Comprehensive Module";
string internal constant _VERSION = "1.0.0";
string internal constant _AUTHOR = "ERC-6900 Authors";
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ Execution functions ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
function foo() external {}
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ Module interface functions ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
function onInstall(bytes calldata) external override {}
function onUninstall(bytes calldata) external override {}
function preUserOpValidationHook(uint32 entityId, PackedUserOperation calldata, bytes32)
external
pure
override
returns (uint256)
{
if (entityId == uint32(EntityId.PRE_VALIDATION_HOOK_1)) {
return 0;
} else if (entityId == uint32(EntityId.PRE_VALIDATION_HOOK_2)) {
return 0;
}
revert NotImplemented();
}
function validateUserOp(uint32 entityId, PackedUserOperation calldata, bytes32)
external
pure
override
returns (uint256)
{
if (entityId == uint32(EntityId.VALIDATION)) {
return 0;
}
revert NotImplemented();
}
function preRuntimeValidationHook(uint32 entityId, address, uint256, bytes calldata, bytes calldata)
external
pure
override
{
if (entityId == uint32(EntityId.PRE_VALIDATION_HOOK_1)) {
return;
} else if (entityId == uint32(EntityId.PRE_VALIDATION_HOOK_2)) {
return;
}
revert NotImplemented();
}
function validateRuntime(address, uint32 entityId, address, uint256, bytes calldata, bytes calldata)
external
pure
override
{
if (entityId == uint32(EntityId.VALIDATION)) {
return;
}
revert NotImplemented();
}
function preSignatureValidationHook(uint32, address, bytes32, bytes calldata) external pure override {
return;
}
function validateSignature(address, uint32 entityId, address, bytes32, bytes calldata)
external
pure
returns (bytes4)
{
if (entityId == uint32(EntityId.SIG_VALIDATION)) {
return 0xffffffff;
}
revert NotImplemented();
}
function preExecutionHook(uint32 entityId, address, uint256, bytes calldata)
external
pure
override
returns (bytes memory)
{
if (entityId == uint32(EntityId.PRE_EXECUTION_HOOK)) {
return "";
} else if (entityId == uint32(EntityId.BOTH_EXECUTION_HOOKS)) {
return "";
}
revert NotImplemented();
}
function postExecutionHook(uint32 entityId, bytes calldata) external pure override {
if (entityId == uint32(EntityId.POST_EXECUTION_HOOK)) {
return;
} else if (entityId == uint32(EntityId.BOTH_EXECUTION_HOOKS)) {
return;
}
revert NotImplemented();
}
function executionManifest() external pure override returns (ExecutionManifest memory) {
ExecutionManifest memory manifest;
manifest.executionFunctions = new ManifestExecutionFunction[](1);
manifest.executionFunctions[0] = ManifestExecutionFunction({
executionSelector: this.foo.selector,
skipRuntimeValidation: false,
allowGlobalValidation: false
});
manifest.executionHooks = new ManifestExecutionHook[](3);
manifest.executionHooks[0] = ManifestExecutionHook({
executionSelector: this.foo.selector,
entityId: uint32(EntityId.BOTH_EXECUTION_HOOKS),
isPreHook: true,
isPostHook: true
});
manifest.executionHooks[1] = ManifestExecutionHook({
executionSelector: this.foo.selector,
entityId: uint32(EntityId.PRE_EXECUTION_HOOK),
isPreHook: true,
isPostHook: false
});
manifest.executionHooks[2] = ManifestExecutionHook({
executionSelector: this.foo.selector,
entityId: uint32(EntityId.POST_EXECUTION_HOOK),
isPreHook: false,
isPostHook: true
});
return manifest;
}
function moduleId() external pure returns (string memory) {
return "erc6900.comprehensive-module.1.0.0";
}
}