BatchGovernor
Inherits: IBatchGovernor, ERC712Extended
Author: M^0 Labs
State Variables
_SELECTOR_PLUS_0_ARGS
Length constant for calldata with no argument.
_SELECTOR_PLUS_1_ARGS
Length constant for calldata with one argument.
_SELECTOR_PLUS_2_ARGS
Length constant for calldata with two arguments.
_SELECTOR_PLUS_3_ARGS
Length constant for calldata with three arguments.
BALLOT_TYPEHASH
Returns the EIP712 typehash used in the encoding of the digest for castVoteBySig
function.
BALLOT_WITH_REASON_TYPEHASH
Returns the EIP712 typehash used in the encoding of the digest for castVoteWithReasonBySig
function.
BALLOTS_TYPEHASH
Returns the EIP712 typehash used in the encoding of the digest for castVotesBySig
function.
BALLOTS_WITH_REASON_TYPEHASH
Returns the EIP712 typehash used in the encoding of the digest for castVotesWithReasonBySig
function.
voteToken
Returns the EIP-5805 token contact used for determine voting power and total supplies.
_proposals
The list of proposals per proposal ID.
hasVoted
Returns whether account
has voted on the proposal with identifier proposalId
.
Functions
onlySelf
Reverts if the caller is not the contract itself.
constructor
Construct a new BatchGovernor contract.
Parameters
Name | Type | Description |
---|---|---|
|
| The name of the contract. Used to compute EIP712 domain separator. |
|
| The address of the token used to vote. |
castVote
Allows the caller to cast a vote on a proposal with id proposalId
.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast. |
castVotes
Allows the caller to cast votes on multiple proposals.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast for each proposal (the same for all of them). |
castVoteWithReason
Allows the caller to cast a vote with reason on a proposal with id proposalId
.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast. |
castVotesWithReason
Allows the caller to cast votes with reason on multiple proposals.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast for each proposal (the same for all of them). |
castVoteBySig
Allows a signer to cast a vote on a proposal with id proposalId
via an ECDSA secp256k1 signature.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast. |
castVoteBySig
Allows a signer to cast a vote on a proposal with id proposalId
via an ECDSA secp256k1 signature.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast. |
castVotesBySig
Allows a signer to cast votes on multiple proposals via an ECDSA secp256k1 signature.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast for each proposal (the same for all of them). |
castVotesBySig
Allows a signer to cast votes on multiple proposals via an ECDSA secp256k1 signature.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast for each proposal (the same for all of them). |
castVoteWithReasonBySig
Allows a signer to cast a vote with reason on a proposal with id proposalId
via an ECDSA secp256k1 signature.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast. |
castVoteWithReasonBySig
Allows a signer to cast a vote with reason on a proposal with id proposalId
via an ECDSA secp256k1 signature.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast. |
castVotesWithReasonBySig
Allows a signer to cast votes with reason on multiple proposals via an ECDSA secp256k1 signature.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast for each proposal (the same for all of them). |
castVotesWithReasonBySig
Allows a signer to cast votes with reason on multiple proposals via an ECDSA secp256k1 signature.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| weight The number of votes cast for each proposal (the same for all of them). |
hashProposal
Returns the unique identifier for the proposal if it were created at this exact moment.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The unique identifier for the proposal. |
hashProposal
Returns the unique identifier for the proposal if it were created at this exact moment.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The unique identifier for the proposal. |
name
Returns the name of the contract.
proposalDeadline
Returns the last clock value when voting on the proposal with identifier proposalId
is allowed.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The last clock value when voting on the proposal is allowed. |
proposalProposer
Returns the account that created the proposal with identifier proposalId
.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The address of the account that created the proposal. |
proposalSnapshot
Returns the clock value used to retrieve voting power to vote on proposal with identifier proposalId
.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The clock value used to retrieve voting power. |
proposalVotes
Returns the vote support totals for the proposal with identifier proposalId
.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| noVotes The amount of votes cast against the proposal. |
|
| yesVotes The amount of votes cast for the proposal. |
|
| abstainVotes The amount of votes cast in abstention the proposal. |
token
Returns the EIP-5805 token contact used for determine voting power and total supplies.
CLOCK_MODE
Returns a machine-readable string description of the clock the contract is operating on.
proposalThreshold
Returns the required voting power an account needs to create a proposal.
clock
Returns the current timepoint according to the mode the contract is operating on.
getBallotDigest
Returns the ballot digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
getBallotsDigest
Returns the ballots digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
getBallotWithReasonDigest
Returns the ballot with reason digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
getBallotsWithReasonDigest
Returns the ballots with reason digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
getVotes
Returns the voting power of account
at clock value timepoint
.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The voting power of |
state
Returns the state of a proposal with identifier proposalId
.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The state of the proposal. |
votingDelay
Returns the number of clock values that must elapse before voting begins for a newly created proposal.
votingPeriod
Returns the number of clock values between the vote start and vote end.
_castVotes
Cast votes on several proposals for voter_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the voter. |
|
| The list of unique proposal IDs being voted on. |
|
| The list of support type per proposal IDs to cast. |
|
| The list of reason per proposal IDs to cast. |
Returns
Name | Type | Description |
---|---|---|
|
| The number of votes the voter cast on each proposal. |
_castVote
Cast votes on proposal for voter_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the voter. |
|
| The unique identifier of the proposal. |
|
| The type of support to cast for the proposal. |
|
| The reason for which the caller casts their vote, if any. |
Returns
Name | Type | Description |
---|---|---|
|
| The number of votes cast. |
_castVote
Cast weight_
votes on a proposal with id proposalId_
for voter_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the voter. |
|
| The number of votes the voter is casting. |
|
| The unique identifier of the proposal. |
|
| The type of support to cast for the proposal. |
|
| The reason for which the caller casts their vote, if any. |
_createProposal
Creates a new proposal with the given parameters.
Parameters
Name | Type | Description |
---|---|---|
|
| The unique identifier of the proposal. |
|
| The epoch at which the proposal will start collecting votes. |
_execute
Executes a proposal given its call data and voteStart (which are unique to it).
Parameters
Name | Type | Description |
---|---|---|
|
| The call data to execute. |
|
| The epoch at which the proposal started collecting votes. |
Returns
Name | Type | Description |
---|---|---|
|
| The unique identifier of the proposal that matched the criteria. |
_propose
Internal handler for making proposals.
Parameters
Name | Type | Description |
---|---|---|
|
| An array of addresses that will be called upon the execution. |
|
| An array of ETH amounts that will be sent to each respective target upon execution. |
|
| An array of call data used to call each respective target upon execution. |
|
| The string of the description of the proposal. |
Returns
Name | Type | Description |
---|---|---|
|
| The unique identifier of the proposal. |
|
| The timepoint at which voting on the proposal begins, inclusively. |
_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.
Parameters
Name | Type | Description |
---|---|---|
|
| An array of call data used to call each respective target upon execution. |
|
| The most recent vote start to use in attempting to search for the proposal. |
|
| The least recent vote start to use in attempting to search for the proposal. |
Returns
Name | Type | Description |
---|---|---|
|
| The unique identifier of the most recent proposal that matched the criteria. |
_clock
Returns the current timepoint according to the mode the contract is operating on.
_getTotalSupply
Returns the vote token's total supply at timepoint_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The clock value at which to query the vote token's total supply. |
Returns
Name | Type | Description |
---|---|---|
|
| The vote token's total supply at the |
_voteStart
Returns the timepoint at which voting would start for a proposal created in current timepoint.
_getVoteEnd
Returns the timepoint at which voting would end given a timepoint at which voting would start.
Parameters
Name | Type | Description |
---|---|---|
|
| The clock value at which voting would start, inclusively. |
Returns
Name | Type | Description |
---|---|---|
|
| The clock value at which voting would end, inclusively. |
_getBallotDigest
Returns the ballot digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| The unique proposal ID being voted on. |
|
| The type of support to cast for the proposal. |
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
_getBallotsDigest
Returns the ballots digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| The hash of the list of unique proposal IDs being voted on. |
|
| The hash of the list of support type per proposal IDs to cast. |
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
_getBallotWithReasonDigest
Returns the ballot with reason digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| The unique proposal ID being voted on. |
|
| The type of support to cast for the proposal. |
|
| The reason for which the caller casts their vote, if any. |
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
_getBallotsWithReasonDigest
Returns the ballots digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| The hash of the list of unique proposal IDs being voted on. |
|
| The hash of the list of support type per proposal IDs to cast. |
|
| The hash of the list of reason per proposal IDs to cast. |
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
_getReasonListHash
Returns the hash of the reason list to be used in the ballots digest.
Parameters
Name | Type | Description |
---|---|---|
|
| The list of reasons to hash. |
Returns
Name | Type | Description |
---|---|---|
|
| The hash of the reason list. |
_hashProposal
Returns the unique identifier for the proposal if it were created at this exact moment.
Parameters
Name | Type | Description |
---|---|---|
|
| The single call data used to call this governor upon execution of a proposal. |
Returns
Name | Type | Description |
---|---|---|
|
| The unique identifier for the proposal. |
_hashProposal
Returns the unique identifier for the proposal if it were to have a given vote start timepoint.
Parameters
Name | Type | Description |
---|---|---|
|
| The single call data used to call this governor upon execution of a proposal. |
|
| The clock value at which voting would start, inclusively. |
Returns
Name | Type | Description |
---|---|---|
|
| The unique identifier for the proposal. |
_revertIfNotSelf
Reverts if the caller is not the contract itself.
_votingDelay
Returns the number of clock values that must elapse before voting begins for a newly created proposal.
_votingPeriod
Returns the number of clock values between the vote start and vote end.
_revertIfInvalidCalldata
All proposals target this contract itself, and must call one of the listed functions to be valid.
Parameters
Name | Type | Description |
---|---|---|
|
| The call data to check. |
_revertIfInvalidProposal
Reverts if the proposal arguments are invalid.
Parameters
Name | Type | Description |
---|---|---|
|
| An array of addresses that will be called upon the execution. |
|
| An array of ETH amounts that will be sent to each respective target upon execution. |
|
| An array of call data used to call each respective target upon execution. |
Structs
Proposal
Proposal struct for storing all relevant proposal information.
Properties
Name | Type | Description |
---|---|---|
|
| The epoch at which voting begins, inclusively. |
|
| Whether or not the proposal has been executed. |
|
| The address of the proposer. |
|
| The ratio of yes votes required for a proposal to meet quorum and succeed. |
|
| The total number of votes against the proposal. |
|
| The total number of votes for the proposal. |