You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.5 KiB
112 lines
3.5 KiB
// SPDX-License-Identifier: MIT
|
|
// OpenZeppelin Contracts (last updated v5.0.0) (governance/extensions/GovernorSettings.sol)
|
|
|
|
pragma solidity ^0.8.20;
|
|
|
|
import {Governor} from "../Governor.sol";
|
|
|
|
/**
|
|
* @dev Extension of {Governor} for settings updatable through governance.
|
|
*/
|
|
abstract contract GovernorSettings is Governor {
|
|
// amount of token
|
|
uint256 private _proposalThreshold;
|
|
// timepoint: limited to uint48 in core (same as clock() type)
|
|
uint48 private _votingDelay;
|
|
// duration: limited to uint32 in core
|
|
uint32 private _votingPeriod;
|
|
|
|
event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay);
|
|
event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod);
|
|
event ProposalThresholdSet(uint256 oldProposalThreshold, uint256 newProposalThreshold);
|
|
|
|
/**
|
|
* @dev Initialize the governance parameters.
|
|
*/
|
|
constructor(uint48 initialVotingDelay, uint32 initialVotingPeriod, uint256 initialProposalThreshold) {
|
|
_setVotingDelay(initialVotingDelay);
|
|
_setVotingPeriod(initialVotingPeriod);
|
|
_setProposalThreshold(initialProposalThreshold);
|
|
}
|
|
|
|
/**
|
|
* @dev See {IGovernor-votingDelay}.
|
|
*/
|
|
function votingDelay() public view virtual override returns (uint256) {
|
|
return _votingDelay;
|
|
}
|
|
|
|
/**
|
|
* @dev See {IGovernor-votingPeriod}.
|
|
*/
|
|
function votingPeriod() public view virtual override returns (uint256) {
|
|
return _votingPeriod;
|
|
}
|
|
|
|
/**
|
|
* @dev See {Governor-proposalThreshold}.
|
|
*/
|
|
function proposalThreshold() public view virtual override returns (uint256) {
|
|
return _proposalThreshold;
|
|
}
|
|
|
|
/**
|
|
* @dev Update the voting delay. This operation can only be performed through a governance proposal.
|
|
*
|
|
* Emits a {VotingDelaySet} event.
|
|
*/
|
|
function setVotingDelay(uint48 newVotingDelay) public virtual onlyGovernance {
|
|
_setVotingDelay(newVotingDelay);
|
|
}
|
|
|
|
/**
|
|
* @dev Update the voting period. This operation can only be performed through a governance proposal.
|
|
*
|
|
* Emits a {VotingPeriodSet} event.
|
|
*/
|
|
function setVotingPeriod(uint32 newVotingPeriod) public virtual onlyGovernance {
|
|
_setVotingPeriod(newVotingPeriod);
|
|
}
|
|
|
|
/**
|
|
* @dev Update the proposal threshold. This operation can only be performed through a governance proposal.
|
|
*
|
|
* Emits a {ProposalThresholdSet} event.
|
|
*/
|
|
function setProposalThreshold(uint256 newProposalThreshold) public virtual onlyGovernance {
|
|
_setProposalThreshold(newProposalThreshold);
|
|
}
|
|
|
|
/**
|
|
* @dev Internal setter for the voting delay.
|
|
*
|
|
* Emits a {VotingDelaySet} event.
|
|
*/
|
|
function _setVotingDelay(uint48 newVotingDelay) internal virtual {
|
|
emit VotingDelaySet(_votingDelay, newVotingDelay);
|
|
_votingDelay = newVotingDelay;
|
|
}
|
|
|
|
/**
|
|
* @dev Internal setter for the voting period.
|
|
*
|
|
* Emits a {VotingPeriodSet} event.
|
|
*/
|
|
function _setVotingPeriod(uint32 newVotingPeriod) internal virtual {
|
|
if (newVotingPeriod == 0) {
|
|
revert GovernorInvalidVotingPeriod(0);
|
|
}
|
|
emit VotingPeriodSet(_votingPeriod, newVotingPeriod);
|
|
_votingPeriod = newVotingPeriod;
|
|
}
|
|
|
|
/**
|
|
* @dev Internal setter for the proposal threshold.
|
|
*
|
|
* Emits a {ProposalThresholdSet} event.
|
|
*/
|
|
function _setProposalThreshold(uint256 newProposalThreshold) internal virtual {
|
|
emit ProposalThresholdSet(_proposalThreshold, newProposalThreshold);
|
|
_proposalThreshold = newProposalThreshold;
|
|
}
|
|
}
|
|
|