Skip to content

Commit 13a50f0

Browse files
committed
fix: rename validationData/executionData to validationStorage/executionStorage (#199)
1 parent 482d429 commit 13a50f0

File tree

4 files changed

+73
-72
lines changed

4 files changed

+73
-72
lines changed

src/account/AccountStorage.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {HookConfig, ModuleEntity} from "../interfaces/IModularAccount.sol";
99
bytes32 constant _ACCOUNT_STORAGE_SLOT = 0xc531f081ecdb5a90f38c197521797881a6e5c752a7d451780f325a95f8b91f45;
1010

1111
// Represents data associated with a specifc function selector.
12-
struct ExecutionData {
12+
struct ExecutionStorage {
1313
// The module that implements this execution function.
1414
// If this is a native function, the address must remain address(0).
1515
address module;
@@ -24,7 +24,7 @@ struct ExecutionData {
2424
EnumerableSet.Bytes32Set executionHooks;
2525
}
2626

27-
struct ValidationData {
27+
struct ValidationStorage {
2828
// Whether or not this validation can be used as a global validation function.
2929
bool isGlobal;
3030
// Whether or not this validation is allowed to validate ERC-1271 signatures.
@@ -44,8 +44,8 @@ struct AccountStorage {
4444
uint8 initialized;
4545
bool initializing;
4646
// Execution functions and their associated functions
47-
mapping(bytes4 selector => ExecutionData) executionData;
48-
mapping(ModuleEntity validationFunction => ValidationData) validationData;
47+
mapping(bytes4 selector => ExecutionStorage) executionStorage;
48+
mapping(ModuleEntity validationFunction => ValidationStorage) validationStorage;
4949
// For ERC165 introspection
5050
mapping(bytes4 => uint256) supportedIfaces;
5151
}

src/account/ModularAccountView.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet
88
import {HookConfig, IModularAccount, ModuleEntity} from "../interfaces/IModularAccount.sol";
99
import {ExecutionDataView, IModularAccountView, ValidationDataView} from "../interfaces/IModularAccountView.sol";
1010
import {HookConfigLib} from "../libraries/HookConfigLib.sol";
11-
import {ExecutionData, ValidationData, getAccountStorage, toHookConfig} from "./AccountStorage.sol";
11+
import {ExecutionStorage, ValidationStorage, getAccountStorage, toHookConfig} from "./AccountStorage.sol";
1212

1313
abstract contract ModularAccountView is IModularAccountView {
1414
using EnumerableSet for EnumerableSet.Bytes32Set;
@@ -26,15 +26,15 @@ abstract contract ModularAccountView is IModularAccountView {
2626
data.module = address(this);
2727
data.allowGlobalValidation = true;
2828
} else {
29-
ExecutionData storage executionData = getAccountStorage().executionData[selector];
30-
data.module = executionData.module;
31-
data.skipRuntimeValidation = executionData.skipRuntimeValidation;
32-
data.allowGlobalValidation = executionData.allowGlobalValidation;
29+
ExecutionStorage storage executionStorage = getAccountStorage().executionStorage[selector];
30+
data.module = executionStorage.module;
31+
data.skipRuntimeValidation = executionStorage.skipRuntimeValidation;
32+
data.allowGlobalValidation = executionStorage.allowGlobalValidation;
3333

34-
uint256 executionHooksLen = executionData.executionHooks.length();
34+
uint256 executionHooksLen = executionStorage.executionHooks.length();
3535
data.executionHooks = new HookConfig[](executionHooksLen);
3636
for (uint256 i = 0; i < executionHooksLen; ++i) {
37-
data.executionHooks[i] = toHookConfig(executionData.executionHooks.at(i));
37+
data.executionHooks[i] = toHookConfig(executionStorage.executionHooks.at(i));
3838
}
3939
}
4040
}
@@ -46,19 +46,19 @@ abstract contract ModularAccountView is IModularAccountView {
4646
override
4747
returns (ValidationDataView memory data)
4848
{
49-
ValidationData storage validationData = getAccountStorage().validationData[validationFunction];
50-
data.isGlobal = validationData.isGlobal;
51-
data.isSignatureValidation = validationData.isSignatureValidation;
52-
data.isUserOpValidation = validationData.isUserOpValidation;
53-
data.validationHooks = validationData.validationHooks;
49+
ValidationStorage storage validationStorage = getAccountStorage().validationStorage[validationFunction];
50+
data.isGlobal = validationStorage.isGlobal;
51+
data.isSignatureValidation = validationStorage.isSignatureValidation;
52+
data.isUserOpValidation = validationStorage.isUserOpValidation;
53+
data.validationHooks = validationStorage.validationHooks;
5454

55-
uint256 execHooksLen = validationData.executionHooks.length();
55+
uint256 execHooksLen = validationStorage.executionHooks.length();
5656
data.executionHooks = new HookConfig[](execHooksLen);
5757
for (uint256 i = 0; i < execHooksLen; ++i) {
58-
data.executionHooks[i] = toHookConfig(validationData.executionHooks.at(i));
58+
data.executionHooks[i] = toHookConfig(validationStorage.executionHooks.at(i));
5959
}
6060

61-
bytes32[] memory selectors = validationData.selectors.values();
61+
bytes32[] memory selectors = validationStorage.selectors.values();
6262
uint256 selectorsLen = selectors.length;
6363
data.selectors = new bytes4[](selectorsLen);
6464
for (uint256 j = 0; j < selectorsLen; ++j) {

src/account/ModuleManagerInternals.sol

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {ValidationConfigLib} from "../libraries/ValidationConfigLib.sol";
1919

2020
import {
2121
AccountStorage,
22-
ExecutionData,
23-
ValidationData,
22+
ExecutionStorage,
23+
ValidationStorage,
2424
getAccountStorage,
2525
toModuleEntity,
2626
toSetValue
@@ -53,9 +53,9 @@ abstract contract ModuleManagerInternals is IModularAccount {
5353
bool allowGlobalValidation,
5454
address module
5555
) internal {
56-
ExecutionData storage _executionData = getAccountStorage().executionData[selector];
56+
ExecutionStorage storage _executionStorage = getAccountStorage().executionStorage[selector];
5757

58-
if (_executionData.module != address(0)) {
58+
if (_executionStorage.module != address(0)) {
5959
revert ExecutionFunctionAlreadySet(selector);
6060
}
6161

@@ -79,25 +79,25 @@ abstract contract ModuleManagerInternals is IModularAccount {
7979
revert Erc4337FunctionNotAllowed(selector);
8080
}
8181

82-
_executionData.module = module;
83-
_executionData.skipRuntimeValidation = skipRuntimeValidation;
84-
_executionData.allowGlobalValidation = allowGlobalValidation;
82+
_executionStorage.module = module;
83+
_executionStorage.skipRuntimeValidation = skipRuntimeValidation;
84+
_executionStorage.allowGlobalValidation = allowGlobalValidation;
8585
}
8686

8787
function _removeExecutionFunction(bytes4 selector) internal {
88-
ExecutionData storage _executionData = getAccountStorage().executionData[selector];
88+
ExecutionStorage storage _executionStorage = getAccountStorage().executionStorage[selector];
8989

90-
_executionData.module = address(0);
91-
_executionData.skipRuntimeValidation = false;
92-
_executionData.allowGlobalValidation = false;
90+
_executionStorage.module = address(0);
91+
_executionStorage.skipRuntimeValidation = false;
92+
_executionStorage.allowGlobalValidation = false;
9393
}
9494

9595
function _removeValidationFunction(ModuleEntity validationFunction) internal {
96-
ValidationData storage _validationData = getAccountStorage().validationData[validationFunction];
96+
ValidationStorage storage _validationStorage = getAccountStorage().validationStorage[validationFunction];
9797

98-
_validationData.isGlobal = false;
99-
_validationData.isSignatureValidation = false;
100-
_validationData.isUserOpValidation = false;
98+
_validationStorage.isGlobal = false;
99+
_validationStorage.isSignatureValidation = false;
100+
_validationStorage.isUserOpValidation = false;
101101
}
102102

103103
function _addExecHooks(EnumerableSet.Bytes32Set storage hooks, HookConfig hookConfig) internal {
@@ -134,7 +134,7 @@ abstract contract ModuleManagerInternals is IModularAccount {
134134
for (uint256 i = 0; i < length; ++i) {
135135
ManifestExecutionHook memory mh = manifest.executionHooks[i];
136136
EnumerableSet.Bytes32Set storage execHooks =
137-
_storage.executionData[mh.executionSelector].executionHooks;
137+
_storage.executionStorage[mh.executionSelector].executionHooks;
138138
HookConfig hookConfig = HookConfigLib.packExecHook({
139139
_module: module,
140140
_entityId: mh.entityId,
@@ -165,7 +165,7 @@ abstract contract ModuleManagerInternals is IModularAccount {
165165
for (uint256 i = 0; i < length; ++i) {
166166
ManifestExecutionHook memory mh = manifest.executionHooks[i];
167167
EnumerableSet.Bytes32Set storage execHooks =
168-
_storage.executionData[mh.executionSelector].executionHooks;
168+
_storage.executionStorage[mh.executionSelector].executionHooks;
169169
HookConfig hookConfig = HookConfigLib.packExecHook({
170170
_module: module,
171171
_entityId: mh.entityId,
@@ -224,19 +224,19 @@ abstract contract ModuleManagerInternals is IModularAccount {
224224
bytes calldata installData,
225225
bytes[] calldata hooks
226226
) internal {
227-
ValidationData storage _validationData =
228-
getAccountStorage().validationData[validationConfig.moduleEntity()];
227+
ValidationStorage storage _validationStorage =
228+
getAccountStorage().validationStorage[validationConfig.moduleEntity()];
229229
ModuleEntity moduleEntity = validationConfig.moduleEntity();
230230

231231
for (uint256 i = 0; i < hooks.length; ++i) {
232232
HookConfig hookConfig = HookConfig.wrap(bytes25(hooks[i][:25]));
233233
bytes calldata hookData = hooks[i][25:];
234234

235235
if (hookConfig.isValidationHook()) {
236-
_validationData.validationHooks.push(hookConfig);
236+
_validationStorage.validationHooks.push(hookConfig);
237237

238238
// Avoid collision between reserved index and actual indices
239-
if (_validationData.validationHooks.length > MAX_PRE_VALIDATION_HOOKS) {
239+
if (_validationStorage.validationHooks.length > MAX_PRE_VALIDATION_HOOKS) {
240240
revert PreValidationHookLimitExceeded();
241241
}
242242

@@ -245,21 +245,21 @@ abstract contract ModuleManagerInternals is IModularAccount {
245245
continue;
246246
}
247247
// Hook is an execution hook
248-
_addExecHooks(_validationData.executionHooks, hookConfig);
248+
_addExecHooks(_validationStorage.executionHooks, hookConfig);
249249

250250
_onInstall(hookConfig.module(), hookData, type(IExecutionHookModule).interfaceId);
251251
}
252252

253253
for (uint256 i = 0; i < selectors.length; ++i) {
254254
bytes4 selector = selectors[i];
255-
if (!_validationData.selectors.add(toSetValue(selector))) {
255+
if (!_validationStorage.selectors.add(toSetValue(selector))) {
256256
revert ValidationAlreadySet(selector, moduleEntity);
257257
}
258258
}
259259

260-
_validationData.isGlobal = validationConfig.isGlobal();
261-
_validationData.isSignatureValidation = validationConfig.isSignatureValidation();
262-
_validationData.isUserOpValidation = validationConfig.isUserOpValidation();
260+
_validationStorage.isGlobal = validationConfig.isGlobal();
261+
_validationStorage.isSignatureValidation = validationConfig.isSignatureValidation();
262+
_validationStorage.isUserOpValidation = validationConfig.isUserOpValidation();
263263

264264
_onInstall(validationConfig.module(), installData, type(IValidationModule).interfaceId);
265265
emit ValidationInstalled(validationConfig.module(), validationConfig.entityId());
@@ -270,7 +270,7 @@ abstract contract ModuleManagerInternals is IModularAccount {
270270
bytes calldata uninstallData,
271271
bytes[] calldata hookUninstallDatas
272272
) internal {
273-
ValidationData storage _validationData = getAccountStorage().validationData[validationFunction];
273+
ValidationStorage storage _validationStorage = getAccountStorage().validationStorage[validationFunction];
274274
bool onUninstallSuccess = true;
275275

276276
_removeValidationFunction(validationFunction);
@@ -280,44 +280,45 @@ abstract contract ModuleManagerInternals is IModularAccount {
280280
// If any uninstall data is provided, assert it is of the correct length.
281281
if (
282282
hookUninstallDatas.length
283-
!= _validationData.validationHooks.length + _validationData.executionHooks.length()
283+
!= _validationStorage.validationHooks.length + _validationStorage.executionHooks.length()
284284
) {
285285
revert ArrayLengthMismatch();
286286
}
287287

288288
// Hook uninstall data is provided in the order of pre validation hooks, then execution hooks.
289289
uint256 hookIndex = 0;
290-
for (uint256 i = 0; i < _validationData.validationHooks.length; ++i) {
290+
for (uint256 i = 0; i < _validationStorage.validationHooks.length; ++i) {
291291
bytes calldata hookData = hookUninstallDatas[hookIndex];
292-
(address hookModule,) = ModuleEntityLib.unpack(_validationData.validationHooks[i].moduleEntity());
292+
(address hookModule,) =
293+
ModuleEntityLib.unpack(_validationStorage.validationHooks[i].moduleEntity());
293294
onUninstallSuccess = onUninstallSuccess && _onUninstall(hookModule, hookData);
294295
hookIndex++;
295296
}
296297

297-
for (uint256 i = 0; i < _validationData.executionHooks.length(); ++i) {
298+
for (uint256 i = 0; i < _validationStorage.executionHooks.length(); ++i) {
298299
bytes calldata hookData = hookUninstallDatas[hookIndex];
299300
(address hookModule,) =
300-
ModuleEntityLib.unpack(toModuleEntity(_validationData.executionHooks.at(i)));
301+
ModuleEntityLib.unpack(toModuleEntity(_validationStorage.executionHooks.at(i)));
301302
onUninstallSuccess = onUninstallSuccess && _onUninstall(hookModule, hookData);
302303
hookIndex++;
303304
}
304305
}
305306

306307
// Clear all stored hooks
307-
delete _validationData.validationHooks;
308+
delete _validationStorage.validationHooks;
308309

309-
EnumerableSet.Bytes32Set storage executionHooks = _validationData.executionHooks;
310+
EnumerableSet.Bytes32Set storage executionHooks = _validationStorage.executionHooks;
310311
uint256 executionHookLen = executionHooks.length();
311312
for (uint256 i = 0; i < executionHookLen; ++i) {
312313
bytes32 executionHook = executionHooks.at(0);
313314
executionHooks.remove(executionHook);
314315
}
315316

316317
// Clear selectors
317-
uint256 selectorLen = _validationData.selectors.length();
318+
uint256 selectorLen = _validationStorage.selectors.length();
318319
for (uint256 i = 0; i < selectorLen; ++i) {
319-
bytes32 selectorSetValue = _validationData.selectors.at(0);
320-
_validationData.selectors.remove(selectorSetValue);
320+
bytes32 selectorSetValue = _validationStorage.selectors.at(0);
321+
_validationStorage.selectors.remove(selectorSetValue);
321322
}
322323

323324
(address module, uint32 entityId) = ModuleEntityLib.unpack(validationFunction);

0 commit comments

Comments
 (0)