Skip to content

Commit

Permalink
Merge pull request #114 from aragon/feature/execute-in-iproposal
Browse files Browse the repository at this point in the history
feature: add execute and canExecute in iproposal
  • Loading branch information
Rekard0 authored Nov 8, 2024
2 parents c0f0007 + 96b2151 commit 7f8f255
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ contract ProposalMock is Proposal {
bytes memory
) external returns (uint256 proposalId) {}

function execute(uint256 proposalId) external view {}

function canExecute(uint256 _proposalId) external view returns (bool) {}

function hasSucceeded(uint256 proposalId) external view returns (bool) {}

function customProposalParamsABI() external view returns (string memory) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ contract ProposalUpgradeableMock is ProposalUpgradeable {
bytes memory
) external returns (uint256 proposalId) {}

function execute(uint256 proposalId) external view {}

function canExecute(uint256 _proposalId) external view returns (bool) {}

function hasSucceeded(uint256 proposalId) external view returns (bool) {}

function customProposalParamsABI() external view returns (string memory) {}
Expand Down
9 changes: 9 additions & 0 deletions contracts/src/plugin/extensions/proposal/IProposal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ interface IProposal {
/// @return bool Returns if proposal has been succeeded or not without including time window checks.
function hasSucceeded(uint256 proposalId) external view returns (bool);

/// @notice Executes a proposal.
/// @param proposalId The ID of the proposal to be executed.
function execute(uint256 proposalId) external;

/// @notice Checks if a proposal can be executed.
/// @param _proposalId The ID of the proposal to be checked.
/// @return True if the proposal can be executed, false otherwise.
function canExecute(uint256 _proposalId) external view returns (bool);

/// @notice The human-readable abi format for extra params included in `data` of `createProposal`.
/// @dev Used for UI to easily detect what extra params the contract expects.
/// @return abi ABI of params in `data` of `createProposal`.
Expand Down
4 changes: 3 additions & 1 deletion contracts/src/plugin/extensions/proposal/Proposal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ abstract contract Proposal is IProposal, ERC165 {
function supportsInterface(bytes4 _interfaceId) public view virtual override returns (bool) {
// In addition to the current interfaceId, also support previous version of the interfaceId
// that did not include the following functions:
// `createProposal`, `hasSucceeded`, `customProposalParamsABI`.
// `createProposal`, `hasSucceeded`, `execute`, `canExecute`, `customProposalParamsABI`.
return
_interfaceId ==
type(IProposal).interfaceId ^
IProposal.createProposal.selector ^
IProposal.hasSucceeded.selector ^
IProposal.execute.selector ^
IProposal.canExecute.selector ^
IProposal.customProposalParamsABI.selector ||
_interfaceId == type(IProposal).interfaceId ||
super.supportsInterface(_interfaceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ abstract contract ProposalUpgradeable is IProposal, ERC165Upgradeable {
function supportsInterface(bytes4 _interfaceId) public view virtual override returns (bool) {
// In addition to the current interfaceId, also support previous version of the interfaceId
// that did not include the following functions:
// `createProposal`, `hasSucceeded`, `customProposalParamsABI`.
// `createProposal`, `hasSucceeded`, `execute`, `canExecute`, `customProposalParamsABI`.
return
_interfaceId ==
type(IProposal).interfaceId ^
IProposal.createProposal.selector ^
IProposal.hasSucceeded.selector ^
IProposal.execute.selector ^
IProposal.canExecute.selector ^
IProposal.customProposalParamsABI.selector ||
_interfaceId == type(IProposal).interfaceId ||
super.supportsInterface(_interfaceId);
Expand Down

0 comments on commit 7f8f255

Please sign in to comment.