diff --git a/package.json b/package.json index 7e90eff..8cad7ee 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "package.json": "sort-package-json" }, "dependencies": { - "@defi-wonderland/prophet-core": "0.0.0-0e46031c", + "@defi-wonderland/prophet-core": "0.0.0-c80cc1e9", "@openzeppelin/contracts": "4.9.5", "solmate": "https://github.com/transmissions11/solmate.git#bfc9c25865a274a7827fea5abf6e4fb64fc64e6c" }, diff --git a/solidity/contracts/modules/access/ModuleAccessController.sol b/solidity/contracts/modules/access/ModuleAccessController.sol deleted file mode 100644 index 58d0985..0000000 --- a/solidity/contracts/modules/access/ModuleAccessController.sol +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -import {CommonAccessController} from '@defi-wonderland/prophet-core/solidity/contracts/CommonAccessController.sol'; - -import {IModuleAccessController} from '../../../interfaces/modules/access/IModuleAccessController.sol'; -import {Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; -import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; - -abstract contract ModuleAccessController is IModuleAccessController, CommonAccessController, Module { - constructor(IOracle _oracle) Module(_oracle) {} - - /** - * @notice Returns an access control object using the contract address as user and the given data - * @dev should only be used by modules as the self-access-control object - * @param _data Arbitrary data - * @return _accessControl The self access control for this contract. - */ - function _defaultAccessControl(bytes memory _data) internal view returns (AccessControl memory _accessControl) { - _accessControl = AccessControl({user: address(this), data: _data}); - } - - /** - * @notice Returns an access control object using the contract address as user, and empty data - * - * @dev should only be used by modules as the self-access-control object - * @return _accessControl The self access control for this contract. - */ - function _defaultAccessControl() internal view returns (AccessControl memory _accessControl) { - _accessControl = _defaultAccessControl(bytes('')); - } - - modifier hasAccess( - address _accessModule, - bytes32 _typehash, - bytes memory _params, - AccessControl memory _accessControl - ) { - if (_accessControl.user != msg.sender) { - if (_accessModule == address(0)) { - revert AccessController_NoAccess(); - } else { - if (!ORACLE.isAccessModuleApproved(_accessControl.user, _accessModule)) { - revert ModuleAccessController_AccessModuleNotApproved(); - } - _hasAccess(_accessModule, _typehash, _params, _accessControl); - } - } - _; - } -} diff --git a/solidity/contracts/modules/dispute/BondEscalationModule.sol b/solidity/contracts/modules/dispute/BondEscalationModule.sol index 72ec468..f8be387 100644 --- a/solidity/contracts/modules/dispute/BondEscalationModule.sol +++ b/solidity/contracts/modules/dispute/BondEscalationModule.sol @@ -7,7 +7,8 @@ import {FixedPointMathLib} from 'solmate/src/utils/FixedPointMathLib.sol'; import {IBondEscalationModule} from '../../../interfaces/modules/dispute/IBondEscalationModule.sol'; -import {ModuleAccessController} from '../access/ModuleAccessController.sol'; +import {ModuleAccessController} from + '@defi-wonderland/prophet-core/solidity/contracts/access/ModuleAccessController.sol'; import {ModuleTypehash} from '../../utils/ModuleTypehash.sol'; diff --git a/solidity/contracts/modules/dispute/CircuitResolverModule.sol b/solidity/contracts/modules/dispute/CircuitResolverModule.sol index c7d06d7..7f208eb 100644 --- a/solidity/contracts/modules/dispute/CircuitResolverModule.sol +++ b/solidity/contracts/modules/dispute/CircuitResolverModule.sol @@ -7,7 +7,8 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IProphetVerifier} from '../../../interfaces/IProphetVerifier.sol'; import {ICircuitResolverModule} from '../../../interfaces/modules/dispute/ICircuitResolverModule.sol'; -import {ModuleAccessController} from '../access/ModuleAccessController.sol'; +import {ModuleAccessController} from + '@defi-wonderland/prophet-core/solidity/contracts/access/ModuleAccessController.sol'; contract CircuitResolverModule is ModuleAccessController, ICircuitResolverModule { /// @notice Keeps track of the correct responses to requests diff --git a/solidity/contracts/modules/dispute/RootVerificationModule.sol b/solidity/contracts/modules/dispute/RootVerificationModule.sol index 24e164a..e8bbf36 100644 --- a/solidity/contracts/modules/dispute/RootVerificationModule.sol +++ b/solidity/contracts/modules/dispute/RootVerificationModule.sol @@ -6,7 +6,8 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IRootVerificationModule} from '../../../interfaces/modules/dispute/IRootVerificationModule.sol'; import {MerkleLib} from '../../libraries/MerkleLib.sol'; -import {ModuleAccessController} from '../access/ModuleAccessController.sol'; +import {ModuleAccessController} from + '@defi-wonderland/prophet-core/solidity/contracts/access/ModuleAccessController.sol'; contract RootVerificationModule is ModuleAccessController, IRootVerificationModule { using MerkleLib for MerkleLib.Tree; diff --git a/solidity/contracts/modules/resolution/ArbitratorModule.sol b/solidity/contracts/modules/resolution/ArbitratorModule.sol index 497dfa1..414d519 100644 --- a/solidity/contracts/modules/resolution/ArbitratorModule.sol +++ b/solidity/contracts/modules/resolution/ArbitratorModule.sol @@ -2,11 +2,13 @@ pragma solidity ^0.8.19; import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; + +import {ModuleAccessController} from + '@defi-wonderland/prophet-core/solidity/contracts/access/ModuleAccessController.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; import {IArbitrator} from '../../../interfaces/IArbitrator.sol'; import {IArbitratorModule} from '../../../interfaces/modules/resolution/IArbitratorModule.sol'; -import {ModuleAccessController} from '../access/ModuleAccessController.sol'; contract ArbitratorModule is ModuleAccessController, IArbitratorModule { /** diff --git a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol index 63002a9..9870aa2 100644 --- a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol +++ b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol @@ -16,7 +16,8 @@ import {IResolutionModule} from import {IBondEscalationResolutionModule} from '../../../interfaces/modules/resolution/IBondEscalationResolutionModule.sol'; -import {ModuleAccessController} from '../access/ModuleAccessController.sol'; +import {ModuleAccessController} from + '@defi-wonderland/prophet-core/solidity/contracts/access/ModuleAccessController.sol'; import {ModuleTypehash} from '../../utils/ModuleTypehash.sol'; diff --git a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol index 9e187af..375ca5c 100644 --- a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol @@ -12,7 +12,8 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IERC20ResolutionModule} from '../../../interfaces/modules/resolution/IERC20ResolutionModule.sol'; import {ModuleTypehash} from '../../utils/ModuleTypehash.sol'; -import {ModuleAccessController} from '../access/ModuleAccessController.sol'; +import {ModuleAccessController} from + '@defi-wonderland/prophet-core/solidity/contracts/access/ModuleAccessController.sol'; contract ERC20ResolutionModule is ModuleAccessController, IERC20ResolutionModule { using SafeERC20 for IERC20; diff --git a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol index 172fb46..99d57c3 100644 --- a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol @@ -11,7 +11,8 @@ import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; import {IPrivateERC20ResolutionModule} from '../../../interfaces/modules/resolution/IPrivateERC20ResolutionModule.sol'; -import {ModuleAccessController} from '../access/ModuleAccessController.sol'; +import {ModuleAccessController} from + '@defi-wonderland/prophet-core/solidity/contracts/access/ModuleAccessController.sol'; contract PrivateERC20ResolutionModule is ModuleAccessController, IPrivateERC20ResolutionModule { using SafeERC20 for IERC20; diff --git a/solidity/interfaces/IArbitrator.sol b/solidity/interfaces/IArbitrator.sol index f323ddc..3070398 100644 --- a/solidity/interfaces/IArbitrator.sol +++ b/solidity/interfaces/IArbitrator.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol'; interface IArbitrator { /** diff --git a/solidity/interfaces/modules/access/IModuleAccessController.sol b/solidity/interfaces/modules/access/IModuleAccessController.sol deleted file mode 100644 index 1713b7d..0000000 --- a/solidity/interfaces/modules/access/IModuleAccessController.sol +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; - -/** - * @title Module Access Controller Interface - * @notice Interface for the module access controller - */ -interface IModuleAccessController is IAccessController { - /*/////////////////////////////////////////////////////////////// - EVENTS - //////////////////////////////////////////////////////////////*/ - - /*/////////////////////////////////////////////////////////////// - STRUCTS - //////////////////////////////////////////////////////////////*/ - - /*/////////////////////////////////////////////////////////////// - ERRORS - //////////////////////////////////////////////////////////////*/ - - /** - * @notice Thrown when user has not approved the access module - */ - error ModuleAccessController_AccessModuleNotApproved(); - - /*/////////////////////////////////////////////////////////////// - VARIABLES - //////////////////////////////////////////////////////////////*/ - - /*/////////////////////////////////////////////////////////////// - LOGIC - //////////////////////////////////////////////////////////////*/ -} diff --git a/solidity/interfaces/modules/dispute/IBondEscalationModule.sol b/solidity/interfaces/modules/dispute/IBondEscalationModule.sol index dcc41d5..43e9f41 100644 --- a/solidity/interfaces/modules/dispute/IBondEscalationModule.sol +++ b/solidity/interfaces/modules/dispute/IBondEscalationModule.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol'; import {IDisputeModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/dispute/IDisputeModule.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; diff --git a/solidity/interfaces/modules/resolution/IBondEscalationResolutionModule.sol b/solidity/interfaces/modules/resolution/IBondEscalationResolutionModule.sol index b976c8a..ac59ee9 100644 --- a/solidity/interfaces/modules/resolution/IBondEscalationResolutionModule.sol +++ b/solidity/interfaces/modules/resolution/IBondEscalationResolutionModule.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol'; import {IResolutionModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/resolution/IResolutionModule.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; diff --git a/solidity/interfaces/modules/resolution/IERC20ResolutionModule.sol b/solidity/interfaces/modules/resolution/IERC20ResolutionModule.sol index 365b7e0..7fdbca1 100644 --- a/solidity/interfaces/modules/resolution/IERC20ResolutionModule.sol +++ b/solidity/interfaces/modules/resolution/IERC20ResolutionModule.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol'; import {IResolutionModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/resolution/IResolutionModule.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; diff --git a/solidity/interfaces/modules/resolution/IPrivateERC20ResolutionModule.sol b/solidity/interfaces/modules/resolution/IPrivateERC20ResolutionModule.sol index 692b787..08ad096 100644 --- a/solidity/interfaces/modules/resolution/IPrivateERC20ResolutionModule.sol +++ b/solidity/interfaces/modules/resolution/IPrivateERC20ResolutionModule.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.19; import {IAccountingExtension} from '../../extensions/IAccountingExtension.sol'; -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol'; import {IResolutionModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/resolution/IResolutionModule.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; diff --git a/solidity/test/integration/IntegrationBase.sol b/solidity/test/integration/IntegrationBase.sol index 21e0edb..55f1423 100644 --- a/solidity/test/integration/IntegrationBase.sol +++ b/solidity/test/integration/IntegrationBase.sol @@ -5,11 +5,11 @@ pragma solidity ^0.8.19; // solhint-disable-next-line no-console import {console} from 'forge-std/console.sol'; +import {IOracle, Oracle} from '@defi-wonderland/prophet-core/solidity/contracts/Oracle.sol'; import { CommonAccessController, IAccessController -} from '@defi-wonderland/prophet-core/solidity/contracts/CommonAccessController.sol'; -import {IOracle, Oracle} from '@defi-wonderland/prophet-core/solidity/contracts/Oracle.sol'; +} from '@defi-wonderland/prophet-core/solidity/contracts/access/CommonAccessController.sol'; import {IDisputeModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/dispute/IDisputeModule.sol'; import {IFinalityModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/finality/IFinalityModule.sol'; import {IRequestModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/request/IRequestModule.sol'; diff --git a/solidity/test/mocks/MockArbitrator.sol b/solidity/test/mocks/MockArbitrator.sol index 0ed3624..a50c824 100644 --- a/solidity/test/mocks/MockArbitrator.sol +++ b/solidity/test/mocks/MockArbitrator.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol'; import {IArbitrator, IOracle} from '../../interfaces/IArbitrator.sol'; diff --git a/solidity/test/mocks/MockAtomicArbitrator.sol b/solidity/test/mocks/MockAtomicArbitrator.sol index 710da1b..fb790ab 100644 --- a/solidity/test/mocks/MockAtomicArbitrator.sol +++ b/solidity/test/mocks/MockAtomicArbitrator.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.19; import {IArbitrator} from '../../interfaces/IArbitrator.sol'; -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; + import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol'; contract MockAtomicArbitrator is IArbitrator { IOracle.DisputeStatus public answer; diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index bdd9957..79f99c4 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -5,8 +5,8 @@ import 'forge-std/Test.sol'; import {Helpers} from '../../../utils/Helpers.sol'; -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; import {IModule} from '@defi-wonderland/prophet-core/solidity/interfaces/IModule.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol'; import {IOracle, IOracleAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; import {IAccessModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/access/IAccessModule.sol'; @@ -21,7 +21,8 @@ import { import {ModuleTypehash} from '../../../../contracts/utils/ModuleTypehash.sol'; import {IAccountingExtension} from '../../../../interfaces/extensions/IAccountingExtension.sol'; import {IBondEscalationAccounting} from '../../../../interfaces/extensions/IBondEscalationAccounting.sol'; -import {IModuleAccessController} from '../../../../interfaces/modules/access/IModuleAccessController.sol'; +import {IModuleAccessController} from + '@defi-wonderland/prophet-core/solidity/interfaces/access/IModuleAccessController.sol'; /** * @dev Harness to set an entry in the requestData mapping, without triggering setup request hooks diff --git a/solidity/test/utils/Helpers.sol b/solidity/test/utils/Helpers.sol index cd3d2ad..d226663 100644 --- a/solidity/test/utils/Helpers.sol +++ b/solidity/test/utils/Helpers.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.19; import {TestConstants} from './TestConstants.sol'; -import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; + import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol'; import {DSTestPlus} from '@defi-wonderland/solidity-utils/solidity/test/DSTestPlus.sol'; contract Helpers is DSTestPlus, TestConstants { diff --git a/yarn.lock b/yarn.lock index 931b081..8d39d38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -193,10 +193,10 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@defi-wonderland/prophet-core@0.0.0-0e46031c": - version "0.0.0-0e46031c" - resolved "https://registry.yarnpkg.com/@defi-wonderland/prophet-core/-/prophet-core-0.0.0-0e46031c.tgz#0c31c1a8b45dce4789a1605764672aa9470e89ef" - integrity sha512-0y2Bczrhz3G3lto6UhT8JCfsakKnyi4ERgVIDvjjT8ryBjKBSJqw0jbZ79zU1OMUEE3QiUMKmm7p9V1LsLXiXw== +"@defi-wonderland/prophet-core@0.0.0-c80cc1e9": + version "0.0.0-c80cc1e9" + resolved "https://registry.yarnpkg.com/@defi-wonderland/prophet-core/-/prophet-core-0.0.0-c80cc1e9.tgz#3586b8bcde26bd670384155f187888745af1e000" + integrity sha512-CU/IRGdOPoHDBiNv3XdimdJqx8Tl/4o3JrkYBKVfx+VW58k9e5i9XquAk+NqDiGZx18TMFZwskkt6fA5cMAQHQ== "@defi-wonderland/solidity-utils@0.0.0-3e9c8e8b": version "0.0.0-3e9c8e8b"