-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename
GovernorSecurityCouncil
to GovernorProposalGuardian
- Loading branch information
Showing
4 changed files
with
92 additions
and
93 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
contracts/governance/extensions/GovernorProposalGuardian.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import {Governor} from "../Governor.sol"; | ||
|
||
/** | ||
* @dev Extension of {Governor} which adds a proposal guardian that can cancel proposals at any stage of their lifecycle. | ||
* | ||
* Note: if the proposal guardian is not configured, then proposers take this role for their proposals. | ||
*/ | ||
abstract contract GovernorProposalGuardian is Governor { | ||
address private _proposalGuardian; | ||
|
||
event ProposalGuardianSet(address oldProposalGuardian, address newProposalGuardian); | ||
|
||
/** | ||
* @dev Override {IGovernor-cancel} that implements the extended cancellation logic. | ||
* * proposal guardian can cancel any proposal at any point in the lifecycle. | ||
* * if no proposal guardian is set, proposer can cancel their proposals at any point in the lifecycle. | ||
* * if the proposal guardian is set, proposer keep their ability to cancel during the pending stage (default behavior). | ||
*/ | ||
function cancel( | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
bytes32 descriptionHash | ||
) public virtual override returns (uint256) { | ||
address caller = _msgSender(); | ||
address authority = proposalGuardian(); | ||
|
||
if (authority == address(0)) { | ||
// if there is no proposal guardian | ||
// ... only the proposer can cancel | ||
// ... no restriction on when the proposer can cancel | ||
uint256 proposalId = hashProposal(targets, values, calldatas, descriptionHash); | ||
address proposer = proposalProposer(proposalId); | ||
if (caller != proposer) revert GovernorOnlyProposer(caller); | ||
return _cancel(targets, values, calldatas, descriptionHash); | ||
} else if (authority == caller) { | ||
// if there is a proposal guardian, and the caller is the proposal guardian | ||
// ... just cancel | ||
return _cancel(targets, values, calldatas, descriptionHash); | ||
} else { | ||
// if there is a proposal guardian, and the caller is not the proposal guardian | ||
// ... apply default behavior | ||
return super.cancel(targets, values, calldatas, descriptionHash); | ||
} | ||
} | ||
|
||
/** | ||
* @dev Getter that returns the address of the proposal guardian. | ||
*/ | ||
function proposalGuardian() public view virtual returns (address) { | ||
return _proposalGuardian; | ||
} | ||
|
||
/** | ||
* @dev Update the proposal guardian's address. This operation can only be performed through a governance proposal. | ||
* | ||
* Emits a {ProposalGuardianSet} event. | ||
*/ | ||
function setProposalGuardian(address newProposalGuardian) public virtual onlyGovernance { | ||
_setProposalGuardian(newProposalGuardian); | ||
} | ||
|
||
/** | ||
* @dev Internal setter for the proposal guardian. | ||
* | ||
* Emits a {ProposalGuardianSet} event. | ||
*/ | ||
function _setProposalGuardian(address newProposalGuardian) internal virtual { | ||
emit ProposalGuardianSet(_proposalGuardian, newProposalGuardian); | ||
_proposalGuardian = newProposalGuardian; | ||
} | ||
} |
76 changes: 0 additions & 76 deletions
76
contracts/governance/extensions/GovernorSecurityCouncil.sol
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters