IGovernor
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor
pub trait IGovernor<TState>
Trait functions
name
Name of the governor instance (used in building the SNIP-12 domain separator).
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::name
fn name(self: @TState) -> felt252
version
Version of the governor instance (used in building SNIP-12 domain separator).
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::version
fn version(self: @TState) -> felt252
COUNTING_MODE
A description of the possible support values for cast_vote 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=bravorefers to the vote options 0 = Against, 1 = For, 2 = Abstain, as inGovernorBravo.quorum=bravomeans that only For votes are counted towards quorum.quorum=for,abstainmeans 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=fractionalmight refer to a scheme where votes are divided fractionally between for/against/abstain.params=erc721might 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/URLSearchParamsURLSearchParams
JavaScript class.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::COUNTING_MODE
fn COUNTING_MODE(self: @TState) -> ByteArray
hash_proposal
Hashing function used to (re)build the proposal id from the proposal details.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::hash_proposal
fn hash_proposal(self: @TState, calls: Span<Call>, description_hash: felt252) -> felt252
state
Returns the state of a proposal, given its id.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::state
fn state(self: @TState, proposal_id: felt252) -> ProposalState
proposal_threshold
The number of votes required in order for a voter to become a proposer.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::proposal_threshold
fn proposal_threshold(self: @TState) -> u256
proposal_snapshot
Timepoint used to retrieve user’s votes and quorum. If using block number, the snapshot is performed at the end of this block. Hence, voting for this proposal starts at the beginning of the following block.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::proposal_snapshot
fn proposal_snapshot(self: @TState, proposal_id: felt252) -> u64
proposal_deadline
Timepoint at which votes close. If using block number, votes close at the end of this block, so it is possible to cast a vote during this block.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::proposal_deadline
fn proposal_deadline(self: @TState, proposal_id: felt252) -> u64
proposal_proposer
The account that created a proposal.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::proposal_proposer
fn proposal_proposer(self: @TState, proposal_id: felt252) -> ContractAddress
proposal_eta
The time when a queued proposal becomes executable (“ETA”). Unlike proposal_snapshot and
proposal_deadline, this doesn’t use the governor clock, and instead relies on the
executor’s clock which may be different. In most cases this will be a timestamp.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::proposal_eta
fn proposal_eta(self: @TState, proposal_id: felt252) -> u64
proposal_needs_queuing
Whether a proposal needs to be queued before execution.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::proposal_needs_queuing
fn proposal_needs_queuing(self: @TState, proposal_id: felt252) -> bool
voting_delay
Delay between the proposal is created and the vote starts. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses.
This can be increased to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
NOTE: While this function returns a u64 value, timepoints must fit into u48 according to the EIP-6372 specification. Consequently this value must fit in a u48 (when added to the current clock).
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::voting_delay
fn voting_delay(self: @TState) -> u64
voting_period
Delay between the vote start and vote end. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses.
NOTE: The voting_delay can delay the start of the vote. This must be considered when
setting the voting duration compared to the voting delay.
NOTE: This value is stored when the proposal is submitted so that possible changes to the value do not affect proposals that have already been submitted.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::voting_period
fn voting_period(self: @TState) -> u64
quorum
Minimum number of cast voted required for a proposal to be successful.
NOTE: The timepoint parameter corresponds to the snapshot used for counting vote. This
allows the quorum to scale depending on values such as the total supply of a token at this
timepoint.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::quorum
fn quorum(self: @TState, timepoint: u64) -> u256
get_votes
Voting power of an account at a specific timepoint.
NOTE: This can be implemented in a number of ways, for example by reading the delegated
balance from one (or multiple) ERC20Votes tokens.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::get_votes
fn get_votes(self: @TState, account: ContractAddress, timepoint: u64) -> u256
get_votes_with_params
Voting power of an account at a specific timepoint given additional encoded parameters.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::get_votes_with_params
fn get_votes_with_params(
self: @TState, account: ContractAddress, timepoint: u64, params: Span<felt252>,
) -> u256
has_voted
Returns whether account has cast a vote on proposal_id.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::has_voted
fn has_voted(self: @TState, proposal_id: felt252, account: ContractAddress) -> bool
propose
Creates a new proposal. Vote start after a delay specified by voting_delay and
lasts for a duration specified by voting_period.
NOTE: The state of the Governor and targets may change between the proposal creation and its execution. This may be the result of third party actions on the targeted contracts, or other governor proposals. For example, the balance of this contract could be updated or its access control permissions may be modified, possibly compromising the proposal’s ability to execute successfully (e.g. the governor doesn’t have enough value to cover a proposal with multiple transfers).
Returns the id of the proposal.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::propose
fn propose(ref self: TState, calls: Span<Call>, description: ByteArray) -> felt252
queue
Queue a proposal. Some governors require this step to be performed before execution can happen. If queuing is not necessary, this function may revert. Queuing a proposal requires the quorum to be reached, the vote to be successful, and the deadline to be reached.
Returns the id of the proposal.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::queue
fn queue(ref self: TState, calls: Span<Call>, description_hash: felt252) -> felt252
execute
Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the deadline to be reached. Depending on the governor it might also be required that the proposal was queued and that some delay passed.
NOTE: Some modules can modify the requirements for execution, for example by adding an
additional timelock (See timelock_controller).
Returns the id of the proposal.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::execute
fn execute(ref self: TState, calls: Span<Call>, description_hash: felt252) -> felt252
cancel
Cancel a proposal. A proposal is cancellable by the proposer, but only while it is Pending state, i.e. before the vote starts.
Returns the id of the proposal.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::cancel
fn cancel(ref self: TState, calls: Span<Call>, description_hash: felt252) -> felt252
cast_vote
Cast a vote.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::cast_vote
fn cast_vote(ref self: TState, proposal_id: felt252, support: u8) -> u256
cast_vote_with_reason
Cast a vote with a reason.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::cast_vote_with_reason
fn cast_vote_with_reason(
ref self: TState, proposal_id: felt252, support: u8, reason: ByteArray,
) -> u256
cast_vote_with_reason_and_params
Cast a vote with a reason and additional serialized params.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::cast_vote_with_reason_and_params
fn cast_vote_with_reason_and_params(
ref self: TState, proposal_id: felt252, support: u8, reason: ByteArray, params: Span<felt252>,
) -> u256
cast_vote_by_sig
Cast a vote using the voter’s signature.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::cast_vote_by_sig
fn cast_vote_by_sig(
ref self: TState,
proposal_id: felt252,
support: u8,
voter: ContractAddress,
signature: Span<felt252>,
) -> u256
cast_vote_with_reason_and_params_by_sig
Cast a vote with a reason and additional serialized params using the voter’s
signature.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::cast_vote_with_reason_and_params_by_sig
fn cast_vote_with_reason_and_params_by_sig(
ref self: TState,
proposal_id: felt252,
support: u8,
voter: ContractAddress,
reason: ByteArray,
params: Span<felt252>,
signature: Span<felt252>,
) -> u256
nonces
Returns the next unused nonce for an address.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::nonces
fn nonces(self: @TState, voter: ContractAddress) -> felt252
relay
Relays a transaction or function call to an arbitrary target.
In cases where the governance executor is some contract other than the governor itself, like when using a timelock, this function can be invoked in a governance proposal to recover tokens that were sent to the governor contract by mistake.
NOTE: If the executor is simply the governor itself, use of relay is redundant.
Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernor::relay
fn relay(ref self: TState, call: Call)