GovernorCountingSimple
Inherits: Governor
Extension of {Governor} for simple, 3 options, vote counting.
State Variables
_proposalVotes
mapping(uint256 proposalId => ProposalVote) private _proposalVotes;
Functions
COUNTING_MODE
module:voting
*A description of the possible support values for {castVote} and the way these votes are counted, meant to
be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of
key-value pairs that each describe one aspect, for example support=bravo&quorum=for,abstain.
There are 2 standard keys: support and quorum.
support=bravorefers to the vote options 0 = Against, 1 = For, 2 = Abstain, as inGovernorBravo.quorum=bravomeans that only For votes are counted towards quorum.quorum=for,abstainmeans that both For and Abstain votes are counted towards quorum. If a counting module makes use of encodedparams, it should include this under aparamskey with a unique name that describes the behavior. For example:params=fractionalmight refer to a scheme where votes are divided fractionally between for/against/abstain.params=erc721might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[URLSearchParams] JavaScript class.*
function COUNTING_MODE() public pure virtual override returns (string memory);
hasVoted
module:voting
Returns whether account has cast a vote on proposalId.
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool);
proposalVotes
Accessor to the internal vote counts.
function proposalVotes(uint256 proposalId)
public
view
virtual
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
_quorumReached
Amount of votes already cast passes the threshold limit.
function _quorumReached(uint256 proposalId) internal view virtual override returns (bool);
_voteSucceeded
See Governor-_voteSucceeded. In this module, the forVotes must be strictly over the againstVotes.
function _voteSucceeded(uint256 proposalId) internal view virtual override returns (bool);
_countVote
See Governor-_countVote. In this module, the support follows the VoteType enum (from Governor Bravo).
function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory)
internal
virtual
override
returns (uint256);
Structs
ProposalVote
struct ProposalVote {
uint256 againstVotes;
uint256 forVotes;
uint256 abstainVotes;
mapping(address voter => bool) hasVoted;
}
Enums
VoteType
Supported vote types. Matches Governor Bravo ordering.
enum VoteType {
Against,
For,
Abstain
}