BatchGovernor

Git Source

Inherits: IBatchGovernor, ERC712Extended

Author: M^0 Labs

State Variables

_SELECTOR_PLUS_0_ARGS

Length constant for calldata with no argument.

uint256 internal constant _SELECTOR_PLUS_0_ARGS = 4;

_SELECTOR_PLUS_1_ARGS

Length constant for calldata with one argument.

uint256 internal constant _SELECTOR_PLUS_1_ARGS = 36;

_SELECTOR_PLUS_2_ARGS

Length constant for calldata with two arguments.

uint256 internal constant _SELECTOR_PLUS_2_ARGS = 68;

_SELECTOR_PLUS_3_ARGS

Length constant for calldata with three arguments.

uint256 internal constant _SELECTOR_PLUS_3_ARGS = 100;

BALLOT_TYPEHASH

Returns the EIP712 typehash used in the encoding of the digest for castVoteBySig function.

bytes32 public constant BALLOT_TYPEHASH = 0x150214d74d59b7d1e90c73fc22ef3d991dd0a76b046543d4d80ab92d2a50328f;

BALLOT_WITH_REASON_TYPEHASH

Returns the EIP712 typehash used in the encoding of the digest for castVoteWithReasonBySig function.

bytes32 public constant BALLOT_WITH_REASON_TYPEHASH = 0x7949bd92105c02f48ca245aa185f4a7a4d7185641d59b186ac64abeb44964f0c;

BALLOTS_TYPEHASH

Returns the EIP712 typehash used in the encoding of the digest for castVotesBySig function.

bytes32 public constant BALLOTS_TYPEHASH = 0x9a121fc10d6025acfc09275f9709796b68831733b5bbac0d510d13f85b1b730f;

BALLOTS_WITH_REASON_TYPEHASH

Returns the EIP712 typehash used in the encoding of the digest for castVotesWithReasonBySig function.

bytes32 public constant BALLOTS_WITH_REASON_TYPEHASH =
    0xa891f76027ef63a24501b9dd3b0c779b49ad26d2328e9d423640209d1ad4fcc4;

voteToken

Returns the EIP-5805 token contact used for determine voting power and total supplies.

address public immutable voteToken;

_proposals

The list of proposals per proposal ID.

mapping(uint256 proposalId => Proposal proposal) internal _proposals;

hasVoted

Returns whether account has voted on the proposal with identifier proposalId.

mapping(uint256 proposalId => mapping(address voter => bool hasVoted)) public hasVoted;

Functions

onlySelf

Reverts if the caller is not the contract itself.

modifier onlySelf();

constructor

Construct a new BatchGovernor contract.

constructor(string memory name_, address voteToken_) ERC712Extended(name_);

Parameters

castVote

Allows the caller to cast a vote on a proposal with id proposalId.

function castVote(uint256 proposalId_, uint8 support_) external returns (uint256 weight_);

Parameters

Returns

castVotes

Allows the caller to cast votes on multiple proposals.

function castVotes(uint256[] calldata proposalIds_, uint8[] calldata supportList_) external returns (uint256 weight_);

Parameters

Returns

castVoteWithReason

Allows the caller to cast a vote with reason on a proposal with id proposalId.

function castVoteWithReason(uint256 proposalId_, uint8 support_, string calldata reason_)
    external
    returns (uint256 weight_);

Parameters

Returns

castVotesWithReason

Allows the caller to cast votes with reason on multiple proposals.

function castVotesWithReason(
    uint256[] calldata proposalIds_,
    uint8[] calldata supportList_,
    string[] calldata reasonList_
) external returns (uint256 weight_);

Parameters

Returns

castVoteBySig

Allows a signer to cast a vote on a proposal with id proposalId via an ECDSA secp256k1 signature.

function castVoteBySig(uint256 proposalId_, uint8 support_, uint8 v_, bytes32 r_, bytes32 s_)
    external
    returns (uint256 weight_);

Parameters

Returns

castVoteBySig

Allows a signer to cast a vote on a proposal with id proposalId via an ECDSA secp256k1 signature.

function castVoteBySig(address voter_, uint256 proposalId_, uint8 support_, bytes memory signature_)
    external
    returns (uint256 weight_);

Parameters

Returns

castVotesBySig

Allows a signer to cast votes on multiple proposals via an ECDSA secp256k1 signature.

function castVotesBySig(
    uint256[] calldata proposalIds_,
    uint8[] calldata supportList_,
    uint8 v_,
    bytes32 r_,
    bytes32 s_
) external returns (uint256 weight_);

Parameters

Returns

castVotesBySig

Allows a signer to cast votes on multiple proposals via an ECDSA secp256k1 signature.

function castVotesBySig(
    address voter_,
    uint256[] calldata proposalIds_,
    uint8[] calldata supportList_,
    bytes memory signature_
) external returns (uint256 weight_);

Parameters

Returns

castVoteWithReasonBySig

Allows a signer to cast a vote with reason on a proposal with id proposalId via an ECDSA secp256k1 signature.

function castVoteWithReasonBySig(
    uint256 proposalId_,
    uint8 support_,
    string calldata reason_,
    uint8 v_,
    bytes32 r_,
    bytes32 s_
) external returns (uint256 weight_);

Parameters

Returns

castVoteWithReasonBySig

Allows a signer to cast a vote with reason on a proposal with id proposalId via an ECDSA secp256k1 signature.

function castVoteWithReasonBySig(
    address voter_,
    uint256 proposalId_,
    uint8 support_,
    string calldata reason_,
    bytes memory signature_
) external returns (uint256 weight_);

Parameters

Returns

castVotesWithReasonBySig

Allows a signer to cast votes with reason on multiple proposals via an ECDSA secp256k1 signature.

function castVotesWithReasonBySig(
    uint256[] calldata proposalIds_,
    uint8[] calldata supportList_,
    string[] calldata reasonList_,
    uint8 v_,
    bytes32 r_,
    bytes32 s_
) external returns (uint256 weight_);

Parameters

Returns

castVotesWithReasonBySig

Allows a signer to cast votes with reason on multiple proposals via an ECDSA secp256k1 signature.

function castVotesWithReasonBySig(
    address voter_,
    uint256[] calldata proposalIds_,
    uint8[] calldata supportList_,
    string[] calldata reasonList_,
    bytes memory signature_
) external returns (uint256 weight_);

Parameters

Returns

hashProposal

Returns the unique identifier for the proposal if it were created at this exact moment.

function hashProposal(address[] memory, uint256[] memory, bytes[] memory callDatas_, bytes32)
    external
    view
    returns (uint256);

Parameters

Returns

hashProposal

Returns the unique identifier for the proposal if it were created at this exact moment.

function hashProposal(bytes memory callData_) external view returns (uint256);

Parameters

Returns

name

Returns the name of the contract.

function name() external view returns (string memory);

proposalDeadline

Returns the last clock value when voting on the proposal with identifier proposalId is allowed.

function proposalDeadline(uint256 proposalId_) external view returns (uint256);

Parameters

Returns

proposalProposer

Returns the account that created the proposal with identifier proposalId.

function proposalProposer(uint256 proposalId_) external view returns (address);

Parameters

Returns

proposalSnapshot

Returns the clock value used to retrieve voting power to vote on proposal with identifier proposalId.

function proposalSnapshot(uint256 proposalId_) external view returns (uint256);

Parameters

Returns

proposalVotes

Returns the vote support totals for the proposal with identifier proposalId.

function proposalVotes(uint256 proposalId_) external view returns (uint256, uint256, uint256);

Parameters

Returns

token

Returns the EIP-5805 token contact used for determine voting power and total supplies.

function token() external view returns (address);

CLOCK_MODE

Returns a machine-readable string description of the clock the contract is operating on.

function CLOCK_MODE() external pure returns (string memory);

proposalThreshold

Returns the required voting power an account needs to create a proposal.

function proposalThreshold() external pure returns (uint256);

clock

Returns the current timepoint according to the mode the contract is operating on.

function clock() public view returns (uint48);

getBallotDigest

Returns the ballot digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).

function getBallotDigest(uint256 proposalId_, uint8 support_) external view returns (bytes32);

Parameters

Returns

getBallotsDigest

Returns the ballots digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).

function getBallotsDigest(uint256[] calldata proposalIds_, uint8[] calldata supportList_)
    external
    view
    returns (bytes32);

Parameters

Returns

getBallotWithReasonDigest

Returns the ballot with reason digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).

function getBallotWithReasonDigest(uint256 proposalId_, uint8 support_, string calldata reason_)
    external
    view
    returns (bytes32);

Parameters

Returns

getBallotsWithReasonDigest

Returns the ballots with reason digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).

function getBallotsWithReasonDigest(
    uint256[] calldata proposalIds_,
    uint8[] calldata supportList_,
    string[] calldata reasonList_
) external view returns (bytes32);

Parameters

Returns

getVotes

Returns the voting power of account at clock value timepoint.

function getVotes(address account_, uint256 timepoint_) public view returns (uint256);

Parameters

Returns

state

Returns the state of a proposal with identifier proposalId.

function state(uint256 proposalId_) public view virtual returns (ProposalState);

Parameters

Returns

votingDelay

Returns the number of clock values that must elapse before voting begins for a newly created proposal.

function votingDelay() public view returns (uint256);

votingPeriod

Returns the number of clock values between the vote start and vote end.

function votingPeriod() public view returns (uint256);

_castVotes

Cast votes on several proposals for voter_.

function _castVotes(
    address voter_,
    uint256[] calldata proposalIds_,
    uint8[] calldata supportList_,
    string[] memory reasonList_
) internal virtual returns (uint256 weight_);

Parameters

Returns

_castVote

Cast votes on proposal for voter_.

function _castVote(address voter_, uint256 proposalId_, uint8 support_, string memory reason_)
    internal
    returns (uint256 weight_);

Parameters

Returns

_castVote

Cast weight_ votes on a proposal with id proposalId_ for voter_.

function _castVote(address voter_, uint256 weight_, uint256 proposalId_, uint8 support_, string memory reason_)
    internal
    virtual;

Parameters

_createProposal

Creates a new proposal with the given parameters.

function _createProposal(uint256 proposalId_, uint16 voteStart_) internal virtual;

Parameters

_execute

Executes a proposal given its call data and voteStart (which are unique to it).

function _execute(bytes memory callData_, uint16 voteStart_) internal virtual returns (uint256 proposalId_);

Parameters

Returns

_propose

Internal handler for making proposals.

function _propose(
    address[] memory targets_,
    uint256[] memory values_,
    bytes[] memory callDatas_,
    string memory description_
) internal returns (uint256 proposalId_, uint16 voteStart_);

Parameters

Returns

_tryExecute

This function tries to execute a proposal based on the call data and a range of possible vote starts. This is needed due to the fact that proposalId's are generated based on the call data and vote start time, and so an executed function will need this in order to attempt to find and execute a proposal given a known range of possible vote start times which depends on how the inheriting implementation determines the vote start time and expiry of proposals based on the time of the proposal creation.

function _tryExecute(bytes memory callData_, uint16 latestVoteStart_, uint16 earliestVoteStart_)
    internal
    returns (uint256 proposalId_);

Parameters

Returns

_clock

Returns the current timepoint according to the mode the contract is operating on.

function _clock() internal view returns (uint16);

_getTotalSupply

Returns the vote token's total supply at timepoint_.

function _getTotalSupply(uint16 timepoint_) internal view returns (uint256);

Parameters

Returns

_voteStart

Returns the timepoint at which voting would start for a proposal created in current timepoint.

function _voteStart() internal view returns (uint16);

_getVoteEnd

Returns the timepoint at which voting would end given a timepoint at which voting would start.

function _getVoteEnd(uint16 voteStart_) internal view returns (uint16);

Parameters

Returns

_getBallotDigest

Returns the ballot digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).

function _getBallotDigest(uint256 proposalId_, uint8 support_) internal view returns (bytes32);

Parameters

Returns

_getBallotsDigest

Returns the ballots digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).

function _getBallotsDigest(bytes32 proposalIdsHash_, bytes32 supportListHash_) internal view returns (bytes32);

Parameters

Returns

_getBallotWithReasonDigest

Returns the ballot with reason digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).

function _getBallotWithReasonDigest(uint256 proposalId_, uint8 support_, string calldata reason_)
    internal
    view
    returns (bytes32);

Parameters

Returns

_getBallotsWithReasonDigest

Returns the ballots digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).

function _getBallotsWithReasonDigest(bytes32 proposalIdsHash_, bytes32 supportListHash_, bytes32 reasonListHash_)
    internal
    view
    returns (bytes32);

Parameters

Returns

_getReasonListHash

Returns the hash of the reason list to be used in the ballots digest.

function _getReasonListHash(string[] calldata reasonList_) internal pure returns (bytes32);

Parameters

Returns

_hashProposal

Returns the unique identifier for the proposal if it were created at this exact moment.

function _hashProposal(bytes memory callData_) internal view returns (uint256);

Parameters

Returns

_hashProposal

Returns the unique identifier for the proposal if it were to have a given vote start timepoint.

function _hashProposal(bytes memory callData_, uint16 voteStart_) internal view returns (uint256);

Parameters

Returns

_revertIfNotSelf

Reverts if the caller is not the contract itself.

function _revertIfNotSelf() internal view;

_votingDelay

Returns the number of clock values that must elapse before voting begins for a newly created proposal.

function _votingDelay() internal view virtual returns (uint16);

_votingPeriod

Returns the number of clock values between the vote start and vote end.

function _votingPeriod() internal view virtual returns (uint16);

_revertIfInvalidCalldata

All proposals target this contract itself, and must call one of the listed functions to be valid.

function _revertIfInvalidCalldata(bytes memory callData_) internal pure virtual;

Parameters

_revertIfInvalidProposal

Reverts if the proposal arguments are invalid.

function _revertIfInvalidProposal(address[] memory targets_, uint256[] memory values_, bytes[] memory callDatas_)
    internal
    view;

Parameters

Structs

Proposal

Proposal struct for storing all relevant proposal information.

struct Proposal {
    uint16 voteStart;
    bool executed;
    address proposer;
    uint16 thresholdRatio;
    uint256 noWeight;
    uint256 yesWeight;
}

Properties

Copyright 2024 M^0 Foundation