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

GovernorCountingOverridableUpgradeable

Inherits: Initializable, GovernorVotesUpgradeable

Extension of {Governor} which enables delegators to override the vote of their delegates. This module requires a token that inherits {VotesExtended}.

State Variables

OVERRIDE_BALLOT_TYPEHASH

bytes32 public constant OVERRIDE_BALLOT_TYPEHASH =
    keccak256("OverrideBallot(uint256 proposalId,uint8 support,address voter,uint256 nonce,string reason)");

GovernorCountingOverridableStorageLocation

bytes32 private constant GovernorCountingOverridableStorageLocation =
    0xbffde6e7ca736efb3d8171f99b09abc076e81f804bf1703dc71fb0b1f7715100;

Functions

_getGovernorCountingOverridableStorage

function _getGovernorCountingOverridableStorage() private pure returns (GovernorCountingOverridableStorage storage $);

__GovernorCountingOverridable_init

function __GovernorCountingOverridable_init() internal onlyInitializing;

__GovernorCountingOverridable_init_unchained

function __GovernorCountingOverridable_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

See IGovernor-hasVoted. NOTE: Calling {castVote} (or similar) casts a vote using the voting power that is delegated to the voter. Conversely, calling {castOverrideVote} (or similar) uses the voting power of the account itself, from its asset balances. Casting an "override vote" does not count as voting and won't be reflected by this getter. Consider using {hasVotedOverride} to check if an account has casted an "override vote" for a given proposal id.

function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool);

hasVotedOverride

Check if an account has overridden their delegate for a proposal.

function hasVotedOverride(uint256 proposalId, address account) public view virtual 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). NOTE: called by {Governor-_castVote} which emits the {IGovernor-VoteCast} (or {IGovernor-VoteCastWithParams}) event.

function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory)
    internal
    virtual
    override
    returns (uint256);

_countOverride

Variant of Governor-_countVote that deals with vote overrides. NOTE: See {hasVoted} for more details about the difference between {castVote} and {castOverrideVote}.

function _countOverride(uint256 proposalId, address account, uint8 support) internal virtual returns (uint256);

_castOverride

Variant of Governor-_castVote that deals with vote overrides. Returns the overridden weight.

function _castOverride(uint256 proposalId, address account, uint8 support, string calldata reason)
    internal
    virtual
    returns (uint256);

castOverrideVote

Public function for casting an override vote. Returns the overridden weight.

function castOverrideVote(uint256 proposalId, uint8 support, string calldata reason) public virtual returns (uint256);

castOverrideVoteBySig

Public function for casting an override vote using a voter's signature. Returns the overridden weight.

function castOverrideVoteBySig(
    uint256 proposalId,
    uint8 support,
    address voter,
    string calldata reason,
    bytes calldata signature
) public virtual returns (uint256);

Events

VoteReduced

The votes casted by delegate were reduced by weight after an override vote was casted by the original token holder

event VoteReduced(address indexed delegate, uint256 proposalId, uint8 support, uint256 weight);

OverrideVoteCast

A delegated vote on proposalId was overridden by weight

event OverrideVoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);

Errors

GovernorAlreadyOverriddenVote

error GovernorAlreadyOverriddenVote(address account);

Structs

VoteReceipt

struct VoteReceipt {
    uint8 casted;
    bool hasOverridden;
    uint208 overriddenWeight;
}

ProposalVote

struct ProposalVote {
    uint256[3] votes;
    mapping(address voter => VoteReceipt) voteReceipt;
}

GovernorCountingOverridableStorage

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

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

Enums

VoteType

Supported vote types. Matches Governor Bravo ordering.

enum VoteType {
    Against,
    For,
    Abstain
}