Skip to content

Commit

Permalink
Merge pull request #23 from aragon/feat/add-execute
Browse files Browse the repository at this point in the history
add execute not supported
  • Loading branch information
novaknole authored Nov 18, 2024
2 parents 20999b1 + 0fc3896 commit 2db5b60
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/contracts/src/Admin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 12 additions & 1 deletion packages/contracts/test/10_unit-testing/11_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2db5b60

Please sign in to comment.