-
Notifications
You must be signed in to change notification settings - Fork 12k
Add Governor module for governance-settable parameters #2904
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
Merged
frangio
merged 26 commits into
OpenZeppelin:master
from
Amxx:feature/governance-settings
Oct 19, 2021
Merged
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
562a9f5
GovernorSettings
Amxx 85f8ca5
add PR ref to changelog
Amxx 80be171
testing
Amxx 7f5f597
fix inheritance order
Amxx 62089aa
Merge branch 'master' into feature/governance-settings
Amxx d85ecc6
merge GovernorProposalThreshold into the core Governor contract
Amxx 7ac8508
Merge branch 'master' into feature/governance-settings
Amxx 4616494
Merge branch 'master' into feature/governance-settings
Amxx b00ec17
add support for previous interfaceId
Amxx 46f743d
fix lint
Amxx 30de83a
rename interfaceId in tests
frangio 5660033
enshure governor built using the wizard can are still supported
Amxx 2d85c55
add wizard produced mocks
Amxx aac4ecf
move proposalThreshold out of IGovernor and into Governor
Amxx 8b8238b
reorder mocks inheritance to pass inheritance ordering tests
Amxx 4b54776
improve coverage
Amxx efafb34
improve coverage
Amxx c5a9fd0
fix lint
Amxx cc122eb
improve coverage
Amxx 07d9724
Apply suggestions from code review
Amxx 9a80138
improve doc
Amxx 734451b
fix test
Amxx 7220c81
remove deprecated contract from top level index
frangio 095086d
simplify events
frangio a3ae78b
add documentation to GovernorSettings
Amxx e10edf1
Merge remote-tracking branch 'Amxx/feature/governance-settings' into …
Amxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,74 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../Governor.sol"; | ||
|
||
/** | ||
* @dev Extension of {Governor} for settings updatable through governance. | ||
* | ||
* _Available since v4.4._ | ||
*/ | ||
abstract contract GovernorSettings is Governor { | ||
uint256 private _votingDelay; | ||
uint256 private _votingPeriod; | ||
uint256 private _proposalThreshold; | ||
|
||
event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay); | ||
event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod); | ||
event ProposalThresholdSet(uint256 oldProposalThreshold, uint256 newProposalThreshold); | ||
|
||
constructor( | ||
uint256 initialVotingDelay, | ||
uint256 initialVotingPeriod, | ||
uint256 initialProposalThreshold | ||
) { | ||
_setVotingDelay(initialVotingDelay); | ||
_setVotingPeriod(initialVotingPeriod); | ||
_setProposalThreshold(initialProposalThreshold); | ||
} | ||
|
||
function votingDelay() public view virtual override returns (uint256) { | ||
return _votingDelay; | ||
} | ||
|
||
function votingPeriod() public view virtual override returns (uint256) { | ||
return _votingPeriod; | ||
} | ||
|
||
function proposalThreshold() public view virtual override returns (uint256) { | ||
return _proposalThreshold; | ||
} | ||
|
||
function setVotingDelay(uint256 newVotingDelay) public onlyGovernance { | ||
_setVotingDelay(newVotingDelay); | ||
} | ||
|
||
function setVotingPeriod(uint256 newVotingPeriod) public onlyGovernance { | ||
_setVotingPeriod(newVotingPeriod); | ||
} | ||
|
||
function setProposalThreshold(uint256 newProposalThreshold) public onlyGovernance { | ||
_setProposalThreshold(newProposalThreshold); | ||
} | ||
|
||
function _setVotingDelay(uint256 newVotingDelay) internal virtual { | ||
uint256 oldVotingDelay = _votingDelay; | ||
_votingDelay = newVotingDelay; | ||
emit VotingDelaySet(oldVotingDelay, newVotingDelay); | ||
Amxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
function _setVotingPeriod(uint256 newVotingPeriod) internal virtual { | ||
// voting period must be at least one block long | ||
require(newVotingPeriod > 0, "GovernorSettings: value too low"); | ||
Amxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uint256 oldVotingPeriod = _votingPeriod; | ||
_votingPeriod = newVotingPeriod; | ||
emit VotingPeriodSet(oldVotingPeriod, newVotingPeriod); | ||
} | ||
|
||
function _setProposalThreshold(uint256 newProposalThreshold) internal virtual { | ||
uint256 oldProposalThreshold = _proposalThreshold; | ||
_proposalThreshold = newProposalThreshold; | ||
emit ProposalThresholdSet(oldProposalThreshold, newProposalThreshold); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.