Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add execute not supported #23

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading