Skip to content

Commit

Permalink
refactor: reorganize folders (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamegyed authored Sep 24, 2024
1 parent a5938c5 commit 3e687bc
Show file tree
Hide file tree
Showing 28 changed files with 51 additions and 58 deletions.
2 changes: 1 addition & 1 deletion gas/modular-account/ModularAccount.gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interface
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {Vm} from "forge-std/src/Vm.sol";

import {AccountFactory} from "../../src/account/AccountFactory.sol";
import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {AccountFactory} from "../../src/factory/AccountFactory.sol";

import {ModularAccountBenchmarkBase} from "./ModularAccountBenchmarkBase.sol";

Expand Down
4 changes: 2 additions & 2 deletions gas/modular-account/ModularAccountBenchmarkBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ pragma solidity ^0.8.26;

import {IEntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntryPoint.sol";

import {AccountFactory} from "../../src/account/AccountFactory.sol";
import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {SemiModularAccount} from "../../src/account/SemiModularAccount.sol";
import {AccountFactory} from "../../src/factory/AccountFactory.sol";

import {FALLBACK_VALIDATION} from "../../src/helpers/Constants.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol";

import {ModuleSignatureUtils} from "../../test/utils/ModuleSignatureUtils.sol";
Expand Down
2 changes: 1 addition & 1 deletion gas/modular-account/SemiModularAccount.gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interface
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {Vm} from "forge-std/src/Vm.sol";

import {AccountFactory} from "../../src/account/AccountFactory.sol";
import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {AccountFactory} from "../../src/factory/AccountFactory.sol";

import {ModularAccountBenchmarkBase} from "./ModularAccountBenchmarkBase.sol";

Expand Down
8 changes: 4 additions & 4 deletions src/account/ModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import {IValidationModule} from "@erc6900/reference-implementation/interfaces/IV

import {collectReturnData} from "../helpers/CollectReturnData.sol";
import {DIRECT_CALL_VALIDATION_ENTITYID} from "../helpers/Constants.sol";
import {HookConfig, HookConfigLib} from "../helpers/HookConfigLib.sol";
import {ModuleEntityLib} from "../helpers/ModuleEntityLib.sol";
import {SparseCalldataSegmentLib} from "../helpers/SparseCalldataSegmentLib.sol";
import {ValidationConfigLib} from "../helpers/ValidationConfigLib.sol";
import {_coalescePreValidation, _coalesceValidation} from "../helpers/ValidationResHelpers.sol";
import {HookConfig, HookConfigLib} from "../libraries/HookConfigLib.sol";
import {ModuleEntityLib} from "../libraries/ModuleEntityLib.sol";
import {SparseCalldataSegmentLib} from "../libraries/SparseCalldataSegmentLib.sol";
import {ValidationConfigLib} from "../libraries/ValidationConfigLib.sol";
import {AccountExecutor} from "./AccountExecutor.sol";
import {AccountStorage, getAccountStorage, toHookConfig, toSetValue} from "./AccountStorage.sol";
import {AccountStorageInitializable} from "./AccountStorageInitializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/account/ModularAccountView.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ValidationDataView
} from "@erc6900/reference-implementation/interfaces/IModularAccountView.sol";

import {HookConfigLib} from "../helpers/HookConfigLib.sol";
import {HookConfigLib} from "../libraries/HookConfigLib.sol";
import {ExecutionData, ValidationData, getAccountStorage, toHookConfig} from "./AccountStorage.sol";

abstract contract ModularAccountView is IModularAccountView {
Expand Down
14 changes: 7 additions & 7 deletions src/account/ModuleManagerInternals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import {IValidationModule} from "@erc6900/reference-implementation/interfaces/IV

import {collectReturnData} from "../helpers/CollectReturnData.sol";
import {MAX_PRE_VALIDATION_HOOKS} from "../helpers/Constants.sol";
import {HookConfigLib} from "../helpers/HookConfigLib.sol";
import {KnownSelectors} from "../helpers/KnownSelectors.sol";
import {ModuleEntityLib} from "../helpers/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../helpers/ValidationConfigLib.sol";
import {HookConfigLib} from "../libraries/HookConfigLib.sol";
import {KnownSelectorsLib} from "../libraries/KnownSelectorsLib.sol";
import {ModuleEntityLib} from "../libraries/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../libraries/ValidationConfigLib.sol";
import {
AccountStorage,
ExecutionData,
Expand Down Expand Up @@ -69,12 +69,12 @@ abstract contract ModuleManagerInternals is IModularAccount {

// Make sure incoming execution function does not collide with any native functions (data are stored on the
// account implementation contract)
if (KnownSelectors.isNativeFunction(selector)) {
if (KnownSelectorsLib.isNativeFunction(selector)) {
revert NativeFunctionNotAllowed(selector);
}

// Make sure incoming execution function is not a function in IModule
if (KnownSelectors.isIModuleFunction(selector)) {
if (KnownSelectorsLib.isIModuleFunction(selector)) {
revert IModuleFunctionNotAllowed(selector);
}

Expand All @@ -83,7 +83,7 @@ abstract contract ModuleManagerInternals is IModularAccount {
// sneaking in a function with the same selector as e.g.
// `validatePaymasterUserOp` and turning the account into their own
// personal paymaster.
if (KnownSelectors.isErc4337Function(selector)) {
if (KnownSelectorsLib.isErc4337Function(selector)) {
revert Erc4337FunctionNotAllowed(selector);
}

Expand Down
2 changes: 1 addition & 1 deletion src/account/SemiModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/Signa
import {LibClone} from "solady/utils/LibClone.sol";

import {FALLBACK_VALIDATION} from "../helpers/Constants.sol";
import {ModuleEntityLib} from "../helpers/ModuleEntityLib.sol";
import {ModuleEntityLib} from "../libraries/ModuleEntityLib.sol";
import {ModularAccount} from "./ModularAccount.sol";

contract SemiModularAccount is ModularAccount {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";

import {ModularAccount} from "../account/ModularAccount.sol";
import {SemiModularAccount} from "../account/SemiModularAccount.sol";
import {ValidationConfigLib} from "../helpers/ValidationConfigLib.sol";
import {ValidationConfigLib} from "../libraries/ValidationConfigLib.sol";

import {LibClone} from "solady/utils/LibClone.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/Constants.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;

import {ModuleEntity} from "./ModuleEntityLib.sol";
import {ModuleEntity} from "../libraries/ModuleEntityLib.sol";

// Index marking the start of the data for the validation function.
uint8 constant RESERVED_VALIDATION_DATA_INDEX = type(uint8).max;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {IValidationModule} from "@erc6900/reference-implementation/interfaces/IV

/// @dev Library to help to check if a selector is a know function selector of the modular account or ERC-4337
/// contract.
library KnownSelectors {
library KnownSelectorsLib {
function isNativeFunction(bytes4 selector) internal pure returns (bool) {
return
// check against IAccount methods
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;

import {RESERVED_VALIDATION_DATA_INDEX} from "./Constants.sol";
import {RESERVED_VALIDATION_DATA_INDEX} from "../helpers/Constants.sol";

/// @title Sparse Calldata Segment Library
/// @notice Library for working with sparsely-packed calldata segments, identified with an index.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/account/AccountReturnData.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Call} from "@erc6900/reference-implementation/interfaces/IModularAccount
import {IModularAccount} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol";

import {DIRECT_CALL_VALIDATION_ENTITYID} from "../../src/helpers/Constants.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";
import {ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";

import {
RegularResultContract,
Expand Down
2 changes: 1 addition & 1 deletion test/account/DeferredValidation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {SemiModularAccount} from "../../src/account/SemiModularAccount.sol";

import {IEntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntryPoint.sol";

import {ValidationConfig, ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";
import {ValidationConfig, ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";

import {MockUserOpValidationModule} from "../mocks/modules/ValidationModuleMocks.sol";
import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";
Expand Down
7 changes: 3 additions & 4 deletions test/account/DirectCallsFromModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {Call, IModularAccount} from "@erc6900/reference-implementation/interface

import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {DIRECT_CALL_VALIDATION_ENTITYID} from "../../src/helpers/Constants.sol";
import {HookConfigLib} from "../../src/helpers/HookConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ValidationConfig, ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";

import {HookConfigLib} from "../../src/libraries/HookConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {ValidationConfig, ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";
import {DirectCallModule} from "../mocks/modules/DirectCallModule.sol";
import {AccountTestBase} from "../utils/AccountTestBase.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/account/GlobalValidationTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interface
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";

import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";

import {AccountTestBase} from "../utils/AccountTestBase.sol";

Expand Down
5 changes: 2 additions & 3 deletions test/account/ModularAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ import {ExecutionDataView} from "@erc6900/reference-implementation/interfaces/IM
import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {ModuleManagerInternals} from "../../src/account/ModuleManagerInternals.sol";
import {SemiModularAccount} from "../../src/account/SemiModularAccount.sol";
import {ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";
import {ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";
import {TokenReceiverModule} from "../../src/modules/TokenReceiverModule.sol";
import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol";

import {Counter} from "../mocks/Counter.sol";
import {ComprehensiveModule} from "../mocks/modules/ComprehensiveModule.sol";
import {MockModule} from "../mocks/modules/MockModule.sol";
Expand Down
4 changes: 2 additions & 2 deletions test/account/ModularAccountView.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
ValidationDataView
} from "@erc6900/reference-implementation/interfaces/IModularAccountView.sol";

import {HookConfigLib} from "../../src/helpers/HookConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {HookConfigLib} from "../../src/libraries/HookConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";

import {ComprehensiveModule} from "../mocks/modules/ComprehensiveModule.sol";
import {CustomValidationTestBase} from "../utils/CustomValidationTestBase.sol";
Expand Down
5 changes: 2 additions & 3 deletions test/account/MultiValidation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/Messa
import {IModularAccount, ModuleEntity} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol";

import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";
import {ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";
import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol";

import {AccountTestBase} from "../utils/AccountTestBase.sol";
import {TEST_DEFAULT_VALIDATION_ENTITY_ID} from "../utils/TestConstants.sol";

Expand Down
9 changes: 4 additions & 5 deletions test/account/PerHookData.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interface
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";

import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {HookConfigLib} from "../../src/helpers/HookConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {SparseCalldataSegmentLib} from "../../src/helpers/SparseCalldataSegmentLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";

import {HookConfigLib} from "../../src/libraries/HookConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {SparseCalldataSegmentLib} from "../../src/libraries/SparseCalldataSegmentLib.sol";
import {ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";
import {Counter} from "../mocks/Counter.sol";
import {MockAccessControlHookModule} from "../mocks/modules/MockAccessControlHookModule.sol";
import {CustomValidationTestBase} from "../utils/CustomValidationTestBase.sol";
Expand Down
7 changes: 3 additions & 4 deletions test/account/ReplaceModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import {
import {IValidationHookModule} from "@erc6900/reference-implementation/interfaces/IValidationHookModule.sol";

import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {HookConfigLib} from "../../src/helpers/HookConfigLib.sol";
import {ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";
import {HookConfigLib} from "../../src/libraries/HookConfigLib.sol";
import {ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";
import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol";

import {MockModule} from "../mocks/modules/MockModule.sol";
import {AccountTestBase} from "../utils/AccountTestBase.sol";

Expand Down
5 changes: 2 additions & 3 deletions test/account/SelfCallAuthorization.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interface
import {Call, IModularAccount} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol";

import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";

import {ModuleEntity, ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";
import {ComprehensiveModule} from "../mocks/modules/ComprehensiveModule.sol";
import {AccountTestBase} from "../utils/AccountTestBase.sol";

Expand Down
6 changes: 3 additions & 3 deletions test/account/ValidationIntersection.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ pragma solidity ^0.8.26;
import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";

import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {HookConfigLib} from "../../src/helpers/HookConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";

import {HookConfigLib} from "../../src/libraries/HookConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";
import {
MockBaseUserOpValidationModule,
MockUserOpValidation1HookModule,
Expand Down
7 changes: 3 additions & 4 deletions test/utils/AccountTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/Messa

import {Call, IModularAccount} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol";

import {AccountFactory} from "../../src/account/AccountFactory.sol";
import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {SemiModularAccount} from "../../src/account/SemiModularAccount.sol";

import {AccountFactory} from "../../src/factory/AccountFactory.sol";
import {DIRECT_CALL_VALIDATION_ENTITYID} from "../../src/helpers/Constants.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";
import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol";

import {ModuleSignatureUtils} from "./ModuleSignatureUtils.sol";
Expand Down
4 changes: 2 additions & 2 deletions test/utils/CustomValidationTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pragma solidity ^0.8.26;
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

import {ModularAccount} from "../../src/account/ModularAccount.sol";
import {ModuleEntity} from "../../src/helpers/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";
import {ModuleEntity} from "../../src/libraries/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";

import {AccountTestBase} from "./AccountTestBase.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/utils/ModuleSignatureUtils.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;

import {ModuleEntity} from "../../src/helpers/ModuleEntityLib.sol";
import {ModuleEntity} from "../../src/libraries/ModuleEntityLib.sol";

/// @dev Utilities for encoding signatures for modular account validation. Used for encoding user op, runtime, and
/// 1271 signatures.
Expand Down

0 comments on commit 3e687bc

Please sign in to comment.