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_
string
The name of the contract. Used to compute EIP712 domain separator.
voteToken_
address
The address of the token used to vote.
castVote
Allows the caller to cast a vote on a proposal with id proposalId
.
Parameters
proposalId_
uint256
support_
uint8
Returns
weight_
uint256
weight The number of votes cast.
castVotes
Allows the caller to cast votes on multiple proposals.
Parameters
proposalIds_
uint256[]
supportList_
uint8[]
Returns
weight_
uint256
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
proposalId_
uint256
support_
uint8
reason_
string
Returns
weight_
uint256
weight The number of votes cast.
castVotesWithReason
Allows the caller to cast votes with reason on multiple proposals.
Parameters
proposalIds_
uint256[]
supportList_
uint8[]
reasonList_
string[]
Returns
weight_
uint256
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
proposalId_
uint256
support_
uint8
v_
uint8
r_
bytes32
s_
bytes32
Returns
weight_
uint256
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
voter_
address
proposalId_
uint256
support_
uint8
signature_
bytes
Returns
weight_
uint256
weight The number of votes cast.
castVotesBySig
Allows a signer to cast votes on multiple proposals via an ECDSA secp256k1 signature.
Parameters
proposalIds_
uint256[]
supportList_
uint8[]
v_
uint8
r_
bytes32
s_
bytes32
Returns
weight_
uint256
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
voter_
address
proposalIds_
uint256[]
supportList_
uint8[]
signature_
bytes
Returns
weight_
uint256
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
proposalId_
uint256
support_
uint8
reason_
string
v_
uint8
r_
bytes32
s_
bytes32
Returns
weight_
uint256
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
voter_
address
proposalId_
uint256
support_
uint8
reason_
string
signature_
bytes
Returns
weight_
uint256
weight The number of votes cast.
castVotesWithReasonBySig
Allows a signer to cast votes with reason on multiple proposals via an ECDSA secp256k1 signature.
Parameters
proposalIds_
uint256[]
supportList_
uint8[]
reasonList_
string[]
v_
uint8
r_
bytes32
s_
bytes32
Returns
weight_
uint256
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
voter_
address
proposalIds_
uint256[]
supportList_
uint8[]
reasonList_
string[]
signature_
bytes
Returns
weight_
uint256
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
<none>
address[]
<none>
uint256[]
callDatas_
bytes[]
<none>
bytes32
Returns
<none>
uint256
The unique identifier for the proposal.
hashProposal
Returns the unique identifier for the proposal if it were created at this exact moment.
Parameters
callData_
bytes
Returns
<none>
uint256
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
proposalId_
uint256
Returns
<none>
uint256
The last clock value when voting on the proposal is allowed.
proposalProposer
Returns the account that created the proposal with identifier proposalId
.
Parameters
proposalId_
uint256
Returns
<none>
address
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
proposalId_
uint256
Returns
<none>
uint256
The clock value used to retrieve voting power.
proposalVotes
Returns the vote support totals for the proposal with identifier proposalId
.
Parameters
proposalId_
uint256
Returns
<none>
uint256
noVotes The amount of votes cast against the proposal.
<none>
uint256
yesVotes The amount of votes cast for the proposal.
<none>
uint256
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
proposalId_
uint256
support_
uint8
Returns
<none>
bytes32
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
proposalIds_
uint256[]
supportList_
uint8[]
Returns
<none>
bytes32
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
proposalId_
uint256
support_
uint8
reason_
string
Returns
<none>
bytes32
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
proposalIds_
uint256[]
supportList_
uint8[]
reasonList_
string[]
Returns
<none>
bytes32
The digest to be signed.
getVotes
Returns the voting power of account
at clock value timepoint
.
Parameters
account_
address
timepoint_
uint256
Returns
<none>
uint256
The voting power of account
at timepoint
.
state
Returns the state of a proposal with identifier proposalId
.
Parameters
proposalId_
uint256
Returns
<none>
ProposalState
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
voter_
address
The address of the voter.
proposalIds_
uint256[]
The list of unique proposal IDs being voted on.
supportList_
uint8[]
The list of support type per proposal IDs to cast.
reasonList_
string[]
The list of reason per proposal IDs to cast.
Returns
weight_
uint256
The number of votes the voter cast on each proposal.
_castVote
Cast votes on proposal for voter_
.
Parameters
voter_
address
The address of the voter.
proposalId_
uint256
The unique identifier of the proposal.
support_
uint8
The type of support to cast for the proposal.
reason_
string
The reason for which the caller casts their vote, if any.
Returns
weight_
uint256
The number of votes cast.
_castVote
Cast weight_
votes on a proposal with id proposalId_
for voter_
.
Parameters
voter_
address
The address of the voter.
weight_
uint256
The number of votes the voter is casting.
proposalId_
uint256
The unique identifier of the proposal.
support_
uint8
The type of support to cast for the proposal.
reason_
string
The reason for which the caller casts their vote, if any.
_createProposal
Creates a new proposal with the given parameters.
Parameters
proposalId_
uint256
The unique identifier of the proposal.
voteStart_
uint16
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
callData_
bytes
The call data to execute.
voteStart_
uint16
The epoch at which the proposal started collecting votes.
Returns
proposalId_
uint256
The unique identifier of the proposal that matched the criteria.
_propose
Internal handler for making proposals.
Parameters
targets_
address[]
An array of addresses that will be called upon the execution.
values_
uint256[]
An array of ETH amounts that will be sent to each respective target upon execution.
callDatas_
bytes[]
An array of call data used to call each respective target upon execution.
description_
string
The string of the description of the proposal.
Returns
proposalId_
uint256
The unique identifier of the proposal.
voteStart_
uint16
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
callData_
bytes
An array of call data used to call each respective target upon execution.
latestVoteStart_
uint16
The most recent vote start to use in attempting to search for the proposal.
earliestVoteStart_
uint16
The least recent vote start to use in attempting to search for the proposal.
Returns
proposalId_
uint256
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
timepoint_
uint16
The clock value at which to query the vote token's total supply.
Returns
<none>
uint256
The vote token's total supply at the timepoint
clock value.
_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
voteStart_
uint16
The clock value at which voting would start, inclusively.
Returns
<none>
uint16
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
proposalId_
uint256
The unique proposal ID being voted on.
support_
uint8
The type of support to cast for the proposal.
Returns
<none>
bytes32
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
proposalIdsHash_
bytes32
The hash of the list of unique proposal IDs being voted on.
supportListHash_
bytes32
The hash of the list of support type per proposal IDs to cast.
Returns
<none>
bytes32
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
proposalId_
uint256
The unique proposal ID being voted on.
support_
uint8
The type of support to cast for the proposal.
reason_
string
The reason for which the caller casts their vote, if any.
Returns
<none>
bytes32
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
proposalIdsHash_
bytes32
The hash of the list of unique proposal IDs being voted on.
supportListHash_
bytes32
The hash of the list of support type per proposal IDs to cast.
reasonListHash_
bytes32
The hash of the list of reason per proposal IDs to cast.
Returns
<none>
bytes32
The digest to be signed.
_getReasonListHash
Returns the hash of the reason list to be used in the ballots digest.
Parameters
reasonList_
string[]
The list of reasons to hash.
Returns
<none>
bytes32
The hash of the reason list.
_hashProposal
Returns the unique identifier for the proposal if it were created at this exact moment.
Parameters
callData_
bytes
The single call data used to call this governor upon execution of a proposal.
Returns
<none>
uint256
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
callData_
bytes
The single call data used to call this governor upon execution of a proposal.
voteStart_
uint16
The clock value at which voting would start, inclusively.
Returns
<none>
uint256
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
callData_
bytes
The call data to check.
_revertIfInvalidProposal
Reverts if the proposal arguments are invalid.
Parameters
targets_
address[]
An array of addresses that will be called upon the execution.
values_
uint256[]
An array of ETH amounts that will be sent to each respective target upon execution.
callDatas_
bytes[]
An array of call data used to call each respective target upon execution.
Structs
Proposal
Proposal struct for storing all relevant proposal information.
Properties
voteStart
uint16
The epoch at which voting begins, inclusively.
executed
bool
Whether or not the proposal has been executed.
proposer
address
The address of the proposer.
thresholdRatio
uint16
The ratio of yes votes required for a proposal to meet quorum and succeed.
noWeight
uint256
The total number of votes against the proposal.
yesWeight
uint256
The total number of votes for the proposal.