From 0fc3896fc7724659d90e1a7b89d119608520a7b6 Mon Sep 17 00:00:00 2001 From: Giorgi Lagidze Date: Thu, 14 Nov 2024 15:14:36 +0400 Subject: [PATCH] add execute not supported --- packages/contracts/src/Admin.sol | 16 ++++++++++++++++ .../contracts/test/10_unit-testing/11_plugin.ts | 13 ++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/contracts/src/Admin.sol b/packages/contracts/src/Admin.sol index 4ffd1c6f..e6a8e4ec 100644 --- a/packages/contracts/src/Admin.sol +++ b/packages/contracts/src/Admin.sol @@ -28,6 +28,9 @@ contract Admin is IMembership, PluginCloneable, ProposalUpgradeable { bytes32 public constant EXECUTE_PROPOSAL_PERMISSION_ID = keccak256("EXECUTE_PROPOSAL_PERMISSION"); + /// @dev Thrown if the `execute` function is called. + error FunctionNotSupported(); + /// @notice Initializes the contract. /// @param _dao The associated DAO. /// @param _targetConfig Configuration for the execution target, specifying the target address and operation type @@ -93,6 +96,19 @@ contract Admin is IMembership, PluginCloneable, ProposalUpgradeable { return true; } + /// @inheritdoc IProposal + function canExecute(uint256) public view virtual override returns (bool) { + return true; + } + + /// @inheritdoc IProposal + /// @dev Note that this function will always revert since this contract doesn't store + /// proposals and only executes the actions at run-time. This function is still + /// necessary to allow compiling the contract as `Admin` inherits from `IProposal`. + function execute(uint256) public view virtual override { + revert FunctionNotSupported(); + } + /// @notice Creates and executes a new proposal. /// @param _metadata The metadata of the proposal. /// @param _actions The actions to be executed. diff --git a/packages/contracts/test/10_unit-testing/11_plugin.ts b/packages/contracts/test/10_unit-testing/11_plugin.ts index 51336ae5..8b2e9faf 100644 --- a/packages/contracts/test/10_unit-testing/11_plugin.ts +++ b/packages/contracts/test/10_unit-testing/11_plugin.ts @@ -153,7 +153,18 @@ describe(PLUGIN_CONTRACT_NAME, function () { }); }); - describe('execute proposal: ', async () => { + describe('execute', async () => { + it('always reverts', async () => { + const {initializedPlugin: plugin} = await loadFixture(fixture); + + await expect(plugin.execute(1)).to.be.revertedWithCustomError( + plugin, + 'FunctionNotSupported' + ); + }); + }); + + describe('executeProposal: ', async () => { it('reverts when calling `execute()` if `EXECUTE_PROPOSAL_PERMISSION_ID` is not granted to the admin address', async () => { const { alice,