Skip to content

Commit

Permalink
refactor: move FunctionReferenceLib under helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypaik committed Jan 11, 2024
1 parent 2cfb616 commit 1c8a5c0
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/account/AccountLoupe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
HookGroup,
toFunctionReferenceArray
} from "./AccountStorage.sol";
import {FunctionReference} from "../helpers/FunctionReferenceLib.sol";
import {IAccountLoupe} from "../interfaces/IAccountLoupe.sol";
import {IPluginManager} from "../interfaces/IPluginManager.sol";
import {IStandardExecutor} from "../interfaces/IStandardExecutor.sol";
import {FunctionReference} from "../libraries/FunctionReferenceLib.sol";

abstract contract AccountLoupe is IAccountLoupe {
using EnumerableMap for EnumerableMap.Bytes32ToUintMap;
Expand Down
5 changes: 3 additions & 2 deletions src/account/AccountStorage.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.19;

import {IPlugin} from "../interfaces/IPlugin.sol";
import {EnumerableMap} from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {FunctionReference} from "../libraries/FunctionReferenceLib.sol";

import {FunctionReference} from "../helpers/FunctionReferenceLib.sol";
import {IPlugin} from "../interfaces/IPlugin.sol";

// bytes = keccak256("ERC6900.UpgradeableModularAccount.Storage")
bytes32 constant _ACCOUNT_STORAGE_SLOT = 0x9f09680beaa4e5c9f38841db2460c401499164f368baef687948c315d9073e40;
Expand Down
2 changes: 1 addition & 1 deletion src/account/PluginManagerInternals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
PermittedExternalCallData,
StoredInjectedHook
} from "./AccountStorage.sol";
import {FunctionReference, FunctionReferenceLib} from "../libraries/FunctionReferenceLib.sol";
import {FunctionReference, FunctionReferenceLib} from "../helpers/FunctionReferenceLib.sol";
import {IPluginManager} from "../interfaces/IPluginManager.sol";
import {
IPlugin,
Expand Down
2 changes: 1 addition & 1 deletion src/account/UpgradeableModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {AccountExecutor} from "./AccountExecutor.sol";
import {AccountLoupe} from "./AccountLoupe.sol";
import {AccountStorage, HookGroup, getAccountStorage, getPermittedCallKey} from "./AccountStorage.sol";
import {AccountStorageInitializable} from "./AccountStorageInitializable.sol";
import {FunctionReference, FunctionReferenceLib} from "../libraries/FunctionReferenceLib.sol";
import {FunctionReference, FunctionReferenceLib} from "../helpers/FunctionReferenceLib.sol";
import {IPlugin, PluginManifest} from "../interfaces/IPlugin.sol";
import {IPluginExecutor} from "../interfaces/IPluginExecutor.sol";
import {IPluginManager} from "../interfaces/IPluginManager.sol";
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/interfaces/IAccountLoupe.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.19;

import {FunctionReference} from "../libraries/FunctionReferenceLib.sol";
import {FunctionReference} from "../helpers/FunctionReferenceLib.sol";

interface IAccountLoupe {
/// @notice Config for an execution function, given a selector
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IPluginManager.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.19;

import {FunctionReference} from "../libraries/FunctionReferenceLib.sol";
import {FunctionReference} from "../helpers/FunctionReferenceLib.sol";

/// @title Plugin Manager Interface
interface IPluginManager {
Expand Down
4 changes: 2 additions & 2 deletions test/account/AccountExecHooks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity ^0.8.19;
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol";

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {FunctionReference, FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol";
import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {
IPlugin,
Expand All @@ -13,9 +15,7 @@ import {
ManifestFunction,
PluginManifest
} from "../../src/interfaces/IPlugin.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {FunctionReference, FunctionReferenceLib} from "../../src/libraries/FunctionReferenceLib.sol";

import {MockPlugin} from "../mocks/MockPlugin.sol";
import {MSCAFactoryFixture} from "../mocks/MSCAFactoryFixture.sol";
Expand Down
6 changes: 3 additions & 3 deletions test/account/AccountLoupe.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeab
import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol";

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {ISingleOwnerPlugin} from "../../src/plugins/owner/ISingleOwnerPlugin.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {FunctionReference, FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol";
import {
ManifestAssociatedFunctionType,
ManifestExecutionHook,
Expand All @@ -16,7 +15,8 @@ import {
import {IAccountLoupe} from "../../src/interfaces/IAccountLoupe.sol";
import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {IStandardExecutor} from "../../src/interfaces/IStandardExecutor.sol";
import {FunctionReference, FunctionReferenceLib} from "../../src/libraries/FunctionReferenceLib.sol";
import {ISingleOwnerPlugin} from "../../src/plugins/owner/ISingleOwnerPlugin.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";

import {MSCAFactoryFixture} from "../mocks/MSCAFactoryFixture.sol";
import {ComprehensivePlugin} from "../mocks/plugins/ComprehensivePlugin.sol";
Expand Down
4 changes: 2 additions & 2 deletions test/account/AccountPermittedCallHooks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity ^0.8.19;
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol";

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {FunctionReference} from "../../src/helpers/FunctionReferenceLib.sol";
import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {
IPlugin,
Expand All @@ -13,9 +15,7 @@ import {
ManifestFunction,
PluginManifest
} from "../../src/interfaces/IPlugin.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {FunctionReference} from "../../src/libraries/FunctionReferenceLib.sol";

import {MockPlugin} from "../mocks/MockPlugin.sol";
import {MSCAFactoryFixture} from "../mocks/MSCAFactoryFixture.sol";
Expand Down
6 changes: 3 additions & 3 deletions test/account/AccountReturnData.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ pragma solidity ^0.8.19;

import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol";

import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {FunctionReference} from "../../src/libraries/FunctionReferenceLib.sol";
import {FunctionReference} from "../../src/helpers/FunctionReferenceLib.sol";
import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {Call} from "../../src/interfaces/IStandardExecutor.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";

import {
RegularResultContract,
Expand Down
4 changes: 2 additions & 2 deletions test/account/ExecuteFromPluginPermissions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {console} from "forge-std/Test.sol";

import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol";

import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {FunctionReference} from "../../src/helpers/FunctionReferenceLib.sol";
import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {FunctionReference} from "../../src/libraries/FunctionReferenceLib.sol";

import {MSCAFactoryFixture} from "../mocks/MSCAFactoryFixture.sol";
import {Counter} from "../mocks/Counter.sol";
Expand Down
6 changes: 3 additions & 3 deletions test/account/ManifestValidity.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ pragma solidity ^0.8.19;

import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol";

import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {FunctionReference} from "../../src/helpers/FunctionReferenceLib.sol";
import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {FunctionReference} from "../../src/libraries/FunctionReferenceLib.sol";

import {MSCAFactoryFixture} from "../mocks/MSCAFactoryFixture.sol";
import {
Expand Down
9 changes: 4 additions & 5 deletions test/account/UpgradeableModularAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import {UserOperation} from "@eth-infinitism/account-abstraction/interfaces/User

import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {TokenReceiverPlugin} from "../../src/plugins/TokenReceiverPlugin.sol";
import {PluginManifest} from "../../src/interfaces/IPlugin.sol";
import {FunctionReference} from "../../src/helpers/FunctionReferenceLib.sol";
import {IPlugin, PluginManifest} from "../../src/interfaces/IPlugin.sol";
import {IAccountLoupe} from "../../src/interfaces/IAccountLoupe.sol";
import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {IPluginExecutor} from "../../src/interfaces/IPluginExecutor.sol";
import {Call} from "../../src/interfaces/IStandardExecutor.sol";
import {FunctionReference} from "../../src/libraries/FunctionReferenceLib.sol";
import {IPlugin, PluginManifest} from "../../src/interfaces/IPlugin.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {TokenReceiverPlugin} from "../../src/plugins/TokenReceiverPlugin.sol";

import {Counter} from "../mocks/Counter.sol";
import {MSCAFactoryFixture} from "../mocks/MSCAFactoryFixture.sol";
Expand Down
4 changes: 2 additions & 2 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.19;
import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol";
import {UserOperation} from "@eth-infinitism/account-abstraction/interfaces/UserOperation.sol";

import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {FunctionReference} from "../../src/helpers/FunctionReferenceLib.sol";
import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {FunctionReference} from "../../src/libraries/FunctionReferenceLib.sol";

import {MSCAFactoryFixture} from "../mocks/MSCAFactoryFixture.sol";
import {
Expand Down
3 changes: 2 additions & 1 deletion test/libraries/FunctionReferenceLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
pragma solidity ^0.8.19;

import {Test} from "forge-std/Test.sol";
import {FunctionReference, FunctionReferenceLib} from "../../src/libraries/FunctionReferenceLib.sol";

import {FunctionReference, FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol";

contract FunctionReferenceLibTest is Test {
function testFuzz_functionReference_packing(address addr, uint8 functionId) public {
Expand Down
4 changes: 2 additions & 2 deletions test/mocks/plugins/ExecFromPluginPermissionsMocks.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {FunctionReference} from "../../../src/helpers/FunctionReferenceLib.sol";
import {
ManifestFunction,
ManifestAssociatedFunctionType,
Expand All @@ -12,9 +13,8 @@ import {
import {IStandardExecutor} from "../../../src/interfaces/IStandardExecutor.sol";
import {IPluginExecutor} from "../../../src/interfaces/IPluginExecutor.sol";
import {IPlugin} from "../../../src/interfaces/IPlugin.sol";
import {BaseTestPlugin} from "./BaseTestPlugin.sol";
import {FunctionReference} from "../../../src/libraries/FunctionReferenceLib.sol";

import {BaseTestPlugin} from "./BaseTestPlugin.sol";
import {ResultCreatorPlugin} from "./ReturnDataPluginMocks.sol";
import {Counter} from "../Counter.sol";

Expand Down
3 changes: 2 additions & 1 deletion test/mocks/plugins/ManifestValidityMocks.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {FunctionReference} from "../../../src/helpers/FunctionReferenceLib.sol";
import {
ManifestFunction,
ManifestAssociatedFunctionType,
Expand All @@ -12,8 +13,8 @@ import {
import {IStandardExecutor} from "../../../src/interfaces/IStandardExecutor.sol";
import {IPluginExecutor} from "../../../src/interfaces/IPluginExecutor.sol";
import {IPlugin} from "../../../src/interfaces/IPlugin.sol";

import {BaseTestPlugin} from "./BaseTestPlugin.sol";
import {FunctionReference} from "../../../src/libraries/FunctionReferenceLib.sol";

contract BadValidationMagicValue_UserOp_Plugin is BaseTestPlugin {
function onInstall(bytes calldata) external override {}
Expand Down
3 changes: 2 additions & 1 deletion test/mocks/plugins/ReturnDataPluginMocks.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {FunctionReference} from "../../../src/helpers/FunctionReferenceLib.sol";
import {
ManifestFunction,
ManifestAssociatedFunctionType,
Expand All @@ -11,8 +12,8 @@ import {
import {IStandardExecutor} from "../../../src/interfaces/IStandardExecutor.sol";
import {IPluginExecutor} from "../../../src/interfaces/IPluginExecutor.sol";
import {IPlugin} from "../../../src/interfaces/IPlugin.sol";

import {BaseTestPlugin} from "./BaseTestPlugin.sol";
import {FunctionReference} from "../../../src/libraries/FunctionReferenceLib.sol";

contract RegularResultContract {
function foo() external pure returns (bytes32) {
Expand Down
4 changes: 2 additions & 2 deletions test/plugin/TokenReceiverPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {ERC721PresetMinterPauserAutoId} from
import {IERC777Recipient} from "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";
import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";

import {TokenReceiverPlugin} from "../../src/plugins/TokenReceiverPlugin.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {FunctionReference} from "../../src/libraries/FunctionReferenceLib.sol";
import {FunctionReference} from "../../src/helpers/FunctionReferenceLib.sol";
import {IPluginManager} from "../../src/interfaces/IPluginManager.sol";
import {TokenReceiverPlugin} from "../../src/plugins/TokenReceiverPlugin.sol";

import {MSCAFactoryFixture} from "../mocks/MSCAFactoryFixture.sol";
import {MockERC777} from "../mocks/MockERC777.sol";
Expand Down

0 comments on commit 1c8a5c0

Please sign in to comment.