From d6ca84fc3ebd5637cab6a390def6ffc426766085 Mon Sep 17 00:00:00 2001 From: Jongwon Park Date: Fri, 29 Mar 2024 14:16:56 -0700 Subject: [PATCH] Refactor Access Controller into access folder (#29) * refactor: Access Controller into access folder * refactor: Access controller test folder --- contracts/IPAccountImpl.sol | 2 +- contracts/access/AccessControlled.sol | 2 +- contracts/{ => access}/AccessController.sol | 19 ++++++++-------- .../{ => access}/IAccessController.sol | 2 +- script/foundry/deployment/Main.s.sol | 2 +- .../{ => access}/AccessController.t.sol | 22 +++++++++---------- .../mocks/access/MockAccessController.sol | 2 +- .../foundry/mocks/module/MockMetaTxModule.sol | 2 +- .../PILPolicyFramework.derivation.t.sol | 2 +- .../PILPolicyFramework.multi-parent.sol | 2 +- .../licensing/PILPolicyFramework.t.sol | 2 +- test/foundry/utils/BaseTest.t.sol | 2 +- test/foundry/utils/DeployHelper.t.sol | 4 ++-- test/foundry/utils/LicensingHelper.t.sol | 2 +- 14 files changed, 34 insertions(+), 33 deletions(-) rename contracts/{ => access}/AccessController.sol (95%) rename contracts/interfaces/{ => access}/IAccessController.sol (98%) rename test/foundry/{ => access}/AccessController.t.sol (98%) diff --git a/contracts/IPAccountImpl.sol b/contracts/IPAccountImpl.sol index cab28617..3b3bfbe6 100644 --- a/contracts/IPAccountImpl.sol +++ b/contracts/IPAccountImpl.sol @@ -9,7 +9,7 @@ import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/Sig import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; import { IERC6551Account } from "erc6551/interfaces/IERC6551Account.sol"; -import { IAccessController } from "./interfaces/IAccessController.sol"; +import { IAccessController } from "./interfaces/access/IAccessController.sol"; import { IIPAccount } from "./interfaces/IIPAccount.sol"; import { MetaTx } from "./lib/MetaTx.sol"; import { Errors } from "./lib/Errors.sol"; diff --git a/contracts/access/AccessControlled.sol b/contracts/access/AccessControlled.sol index 1f3c3b95..638ebc78 100644 --- a/contracts/access/AccessControlled.sol +++ b/contracts/access/AccessControlled.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; -import { IAccessController } from "../interfaces/IAccessController.sol"; +import { IAccessController } from "../interfaces/access/IAccessController.sol"; import { IPAccountChecker } from "../lib/registries/IPAccountChecker.sol"; import { IIPAccountRegistry } from "../interfaces/registries/IIPAccountRegistry.sol"; import { Errors } from "../lib/Errors.sol"; diff --git a/contracts/AccessController.sol b/contracts/access/AccessController.sol similarity index 95% rename from contracts/AccessController.sol rename to contracts/access/AccessController.sol index 11df5044..237a418b 100644 --- a/contracts/AccessController.sol +++ b/contracts/access/AccessController.sol @@ -1,17 +1,18 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; -import { IModuleRegistry } from "./interfaces/registries/IModuleRegistry.sol"; -import { IAccessController } from "./interfaces/IAccessController.sol"; -import { IIPAccountRegistry } from "./interfaces/registries/IIPAccountRegistry.sol"; -import { IModuleRegistry } from "./interfaces/registries/IModuleRegistry.sol"; -import { IPAccountChecker } from "./lib/registries/IPAccountChecker.sol"; -import { IIPAccount } from "./interfaces/IIPAccount.sol"; -import { AccessPermission } from "./lib/AccessPermission.sol"; -import { Errors } from "./lib/Errors.sol"; -import { GovernableUpgradeable } from "./governance/GovernableUpgradeable.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import { IAccessController } from "../interfaces/access/IAccessController.sol"; +import { IModuleRegistry } from "../interfaces/registries/IModuleRegistry.sol"; +import { IIPAccountRegistry } from "../interfaces/registries/IIPAccountRegistry.sol"; +import { IModuleRegistry } from "../interfaces/registries/IModuleRegistry.sol"; +import { IPAccountChecker } from "../lib/registries/IPAccountChecker.sol"; +import { IIPAccount } from "../interfaces/IIPAccount.sol"; +import { GovernableUpgradeable } from "../governance/GovernableUpgradeable.sol"; +import { AccessPermission } from "../lib/AccessPermission.sol"; +import { Errors } from "../lib/Errors.sol"; + /// @title AccessController /// @dev This contract is used to control access permissions for different function calls in the protocol. /// It allows setting permissions for specific function calls, checking permissions, and initializing the contract. diff --git a/contracts/interfaces/IAccessController.sol b/contracts/interfaces/access/IAccessController.sol similarity index 98% rename from contracts/interfaces/IAccessController.sol rename to contracts/interfaces/access/IAccessController.sol index 521a9bff..3bed3c7d 100644 --- a/contracts/interfaces/IAccessController.sol +++ b/contracts/interfaces/access/IAccessController.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; -import { AccessPermission } from "../lib/AccessPermission.sol"; +import { AccessPermission } from "../../lib/AccessPermission.sol"; interface IAccessController { /// @notice Emitted when a permission is set. diff --git a/script/foundry/deployment/Main.s.sol b/script/foundry/deployment/Main.s.sol index be2739bd..00b54947 100644 --- a/script/foundry/deployment/Main.s.sol +++ b/script/foundry/deployment/Main.s.sol @@ -12,7 +12,7 @@ import { stdJson } from "forge-std/StdJson.sol"; import { TestProxyHelper } from "test/foundry/utils/TestProxyHelper.sol"; // contracts -import { AccessController } from "contracts/AccessController.sol"; +import { AccessController } from "contracts/access/AccessController.sol"; import { IPAccountImpl } from "contracts/IPAccountImpl.sol"; import { IIPAccount } from "contracts/interfaces/IIPAccount.sol"; import { IRoyaltyPolicyLAP } from "contracts/interfaces/modules/royalty/policies/IRoyaltyPolicyLAP.sol"; diff --git a/test/foundry/AccessController.t.sol b/test/foundry/access/AccessController.t.sol similarity index 98% rename from test/foundry/AccessController.t.sol rename to test/foundry/access/AccessController.t.sol index e85443d5..a39449ab 100644 --- a/test/foundry/AccessController.t.sol +++ b/test/foundry/access/AccessController.t.sol @@ -1,17 +1,17 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; -import { IIPAccount } from "../../contracts/interfaces/IIPAccount.sol"; -import { AccessPermission } from "../../contracts/lib/AccessPermission.sol"; -import { Errors } from "../../contracts/lib/Errors.sol"; -import { TOKEN_WITHDRAWAL_MODULE_KEY } from "../../contracts/lib/modules/Module.sol"; -import { TokenWithdrawalModule } from "../../contracts/modules/external/TokenWithdrawalModule.sol"; - -import { MockModule } from "./mocks/module/MockModule.sol"; -import { MockOrchestratorModule } from "./mocks/module/MockOrchestratorModule.sol"; -import { MockERC1155 } from "./mocks/token/MockERC1155.sol"; -import { MockERC20 } from "./mocks/token/MockERC20.sol"; -import { BaseTest } from "./utils/BaseTest.t.sol"; +import { IIPAccount } from "../../../contracts/interfaces/IIPAccount.sol"; +import { AccessPermission } from "../../../contracts/lib/AccessPermission.sol"; +import { Errors } from "../../../contracts/lib/Errors.sol"; +import { TOKEN_WITHDRAWAL_MODULE_KEY } from "../../../contracts/lib/modules/Module.sol"; +import { TokenWithdrawalModule } from "../../../contracts/modules/external/TokenWithdrawalModule.sol"; + +import { MockModule } from "../mocks/module/MockModule.sol"; +import { MockOrchestratorModule } from "../mocks/module/MockOrchestratorModule.sol"; +import { MockERC1155 } from "../mocks/token/MockERC1155.sol"; +import { MockERC20 } from "../mocks/token/MockERC20.sol"; +import { BaseTest } from "../utils/BaseTest.t.sol"; contract AccessControllerTest is BaseTest { MockModule public mockModule; diff --git a/test/foundry/mocks/access/MockAccessController.sol b/test/foundry/mocks/access/MockAccessController.sol index 05d708e8..06cbd515 100644 --- a/test/foundry/mocks/access/MockAccessController.sol +++ b/test/foundry/mocks/access/MockAccessController.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; -import { IAccessController } from "contracts/interfaces/IAccessController.sol"; +import { IAccessController } from "contracts/interfaces/access/IAccessController.sol"; import { IIPAccount } from "contracts/interfaces/IIPAccount.sol"; import { Errors } from "contracts/lib/Errors.sol"; import { AccessPermission } from "contracts/lib/AccessPermission.sol"; diff --git a/test/foundry/mocks/module/MockMetaTxModule.sol b/test/foundry/mocks/module/MockMetaTxModule.sol index c401d7bb..461ed5c0 100644 --- a/test/foundry/mocks/module/MockMetaTxModule.sol +++ b/test/foundry/mocks/module/MockMetaTxModule.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.23; import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; -import { IAccessController } from "../../../../contracts/interfaces/IAccessController.sol"; +import { IAccessController } from "../../../../contracts/interfaces/access/IAccessController.sol"; import { IIPAccount } from "../../../../contracts/interfaces/IIPAccount.sol"; import { IModule } from "../../../../contracts/interfaces/modules/base/IModule.sol"; import { IIPAccountRegistry } from "../../../../contracts/interfaces/registries/IIPAccountRegistry.sol"; diff --git a/test/foundry/modules/licensing/PILPolicyFramework.derivation.t.sol b/test/foundry/modules/licensing/PILPolicyFramework.derivation.t.sol index e01139cf..a1d181ff 100644 --- a/test/foundry/modules/licensing/PILPolicyFramework.derivation.t.sol +++ b/test/foundry/modules/licensing/PILPolicyFramework.derivation.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; -import { IAccessController } from "contracts/interfaces/IAccessController.sol"; +import { IAccessController } from "contracts/interfaces/access/IAccessController.sol"; import { ILicensingModule } from "contracts/interfaces/modules/licensing/ILicensingModule.sol"; import { IRoyaltyModule } from "contracts/interfaces/modules/royalty/IRoyaltyModule.sol"; import { Errors } from "contracts/lib/Errors.sol"; diff --git a/test/foundry/modules/licensing/PILPolicyFramework.multi-parent.sol b/test/foundry/modules/licensing/PILPolicyFramework.multi-parent.sol index c8cbf754..1bb2be6c 100644 --- a/test/foundry/modules/licensing/PILPolicyFramework.multi-parent.sol +++ b/test/foundry/modules/licensing/PILPolicyFramework.multi-parent.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; -import { IAccessController } from "contracts/interfaces/IAccessController.sol"; +import { IAccessController } from "contracts/interfaces/access/IAccessController.sol"; import { ILicensingModule } from "contracts/interfaces/modules/licensing/ILicensingModule.sol"; import { IRoyaltyModule } from "contracts/interfaces/modules/royalty/IRoyaltyModule.sol"; import { Errors } from "contracts/lib/Errors.sol"; diff --git a/test/foundry/modules/licensing/PILPolicyFramework.t.sol b/test/foundry/modules/licensing/PILPolicyFramework.t.sol index 7a25aa26..ed08fb1b 100644 --- a/test/foundry/modules/licensing/PILPolicyFramework.t.sol +++ b/test/foundry/modules/licensing/PILPolicyFramework.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; -import { IAccessController } from "contracts/interfaces/IAccessController.sol"; +import { IAccessController } from "contracts/interfaces/access/IAccessController.sol"; import { ILicensingModule } from "contracts/interfaces/modules/licensing/ILicensingModule.sol"; import { Errors } from "contracts/lib/Errors.sol"; import { PILFrameworkErrors } from "contracts/lib/PILFrameworkErrors.sol"; diff --git a/test/foundry/utils/BaseTest.t.sol b/test/foundry/utils/BaseTest.t.sol index e54db972..fbd95f1e 100644 --- a/test/foundry/utils/BaseTest.t.sol +++ b/test/foundry/utils/BaseTest.t.sol @@ -7,7 +7,7 @@ import { console2 } from "forge-std/console2.sol"; // console to indicate mock d import { Test } from "forge-std/Test.sol"; // contracts -import { AccessController } from "../../../contracts/AccessController.sol"; +import { AccessController } from "../../../contracts/access/AccessController.sol"; // solhint-disable-next-line max-line-length import { DISPUTE_MODULE_KEY, ROYALTY_MODULE_KEY, LICENSING_MODULE_KEY } from "../../../contracts/lib/modules/Module.sol"; import { AccessPermission } from "../../../contracts/lib/AccessPermission.sol"; diff --git a/test/foundry/utils/DeployHelper.t.sol b/test/foundry/utils/DeployHelper.t.sol index 907b4419..618e074b 100644 --- a/test/foundry/utils/DeployHelper.t.sol +++ b/test/foundry/utils/DeployHelper.t.sol @@ -7,9 +7,9 @@ import { console2 } from "forge-std/console2.sol"; // console to indicate mock d import { ERC6551Registry } from "erc6551/ERC6551Registry.sol"; // contracts -import { AccessController } from "../../../contracts/AccessController.sol"; +import { AccessController } from "../../../contracts/access/AccessController.sol"; import { Governance } from "../../../contracts/governance/Governance.sol"; -import { IAccessController } from "../../../contracts/interfaces/IAccessController.sol"; +import { IAccessController } from "../../../contracts/interfaces/access/IAccessController.sol"; import { IGovernance } from "../../../contracts/interfaces/governance/IGovernance.sol"; import { IDisputeModule } from "../../../contracts/interfaces/modules/dispute/IDisputeModule.sol"; import { ILicensingModule } from "../../../contracts/interfaces/modules/licensing/ILicensingModule.sol"; diff --git a/test/foundry/utils/LicensingHelper.t.sol b/test/foundry/utils/LicensingHelper.t.sol index 6703bf98..66336632 100644 --- a/test/foundry/utils/LicensingHelper.t.sol +++ b/test/foundry/utils/LicensingHelper.t.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.23; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // contract -import { IAccessController } from "../../../contracts/interfaces/IAccessController.sol"; +import { IAccessController } from "../../../contracts/interfaces/access/IAccessController.sol"; import { IIPAccountRegistry } from "../../../contracts/interfaces/registries/IIPAccountRegistry.sol"; import { ILicensingModule } from "../../../contracts/interfaces/modules/licensing/ILicensingModule.sol"; import { IRoyaltyModule } from "../../../contracts/interfaces/modules/royalty/IRoyaltyModule.sol";