Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

GovernorCountingSimpleUpgradeable

Inherits: Initializable, GovernorUpgradeable

Extension of {Governor} for simple, 3 options, vote counting.

State Variables

GovernorCountingSimpleStorageLocation

bytes32 private constant GovernorCountingSimpleStorageLocation =
    0xa1cefa0f43667ef127a258e673c94202a79b656e62899531c4376d87a7f39800;

Functions

_getGovernorCountingSimpleStorage

function _getGovernorCountingSimpleStorage() private pure returns (GovernorCountingSimpleStorage storage $);

__GovernorCountingSimple_init

function __GovernorCountingSimple_init() internal onlyInitializing;

__GovernorCountingSimple_init_unchained

function __GovernorCountingSimple_init_unchained() internal onlyInitializing;

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=bravo refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in GovernorBravo.
  • quorum=bravo means that only For votes are counted towards quorum.
  • quorum=for,abstain means that both For and Abstain votes are counted towards quorum. If a counting module makes use of encoded params, it should include this under a params key with a unique name that describes the behavior. For example:
  • params=fractional might refer to a scheme where votes are divided fractionally between for/against/abstain.
  • params=erc721 might 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;
}

GovernorCountingSimpleStorage

Note: storage-location: erc7201:openzeppelin.storage.GovernorCountingSimple

struct GovernorCountingSimpleStorage {
    mapping(uint256 proposalId => ProposalVote) _proposalVotes;
}

Enums

VoteType

Supported vote types. Matches Governor Bravo ordering.

enum VoteType {
    Against,
    For,
    Abstain
}