Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

IGovernorSafeDispatcherTrait

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait

Part of the group: dispatchers

pub trait IGovernorSafeDispatcherTrait<T>

Trait functions

name

Name of the governor instance (used in building the SNIP-12 domain separator).

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::name

fn name(self: T) -> Result<felt252, Array<felt252>>

version

Version of the governor instance (used in building SNIP-12 domain separator).

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::version

fn version(self: T) -> Result<felt252, Array<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=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/URLSearchParamsURLSearchParams JavaScript class.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::COUNTING_MODE

fn COUNTING_MODE(self: T) -> Result<ByteArray, Array<felt252>>

hash_proposal

Hashing function used to (re)build the proposal id from the proposal details.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::hash_proposal

fn hash_proposal(
    self: T, calls: Span<Call>, description_hash: felt252,
) -> Result<felt252, Array<felt252>>

state

Returns the state of a proposal, given its id.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::state

fn state(self: T, proposal_id: felt252) -> Result<ProposalState, Array<felt252>>

proposal_threshold

The number of votes required in order for a voter to become a proposer.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::proposal_threshold

fn proposal_threshold(self: T) -> Result<u256, Array<felt252>>

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::IGovernorSafeDispatcherTrait::proposal_snapshot

fn proposal_snapshot(self: T, proposal_id: felt252) -> Result<u64, Array<felt252>>

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::IGovernorSafeDispatcherTrait::proposal_deadline

fn proposal_deadline(self: T, proposal_id: felt252) -> Result<u64, Array<felt252>>

proposal_proposer

The account that created a proposal.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::proposal_proposer

fn proposal_proposer(self: T, proposal_id: felt252) -> Result<ContractAddress, Array<felt252>>

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::IGovernorSafeDispatcherTrait::proposal_eta

fn proposal_eta(self: T, proposal_id: felt252) -> Result<u64, Array<felt252>>

proposal_needs_queuing

Whether a proposal needs to be queued before execution.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::proposal_needs_queuing

fn proposal_needs_queuing(self: T, proposal_id: felt252) -> Result<bool, Array<felt252>>

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::IGovernorSafeDispatcherTrait::voting_delay

fn voting_delay(self: T) -> Result<u64, Array<felt252>>

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::IGovernorSafeDispatcherTrait::voting_period

fn voting_period(self: T) -> Result<u64, Array<felt252>>

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::IGovernorSafeDispatcherTrait::quorum

fn quorum(self: T, timepoint: u64) -> Result<u256, Array<felt252>>

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::IGovernorSafeDispatcherTrait::get_votes

fn get_votes(self: T, account: ContractAddress, timepoint: u64) -> Result<u256, Array<felt252>>

get_votes_with_params

Voting power of an account at a specific timepoint given additional encoded parameters.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::get_votes_with_params

fn get_votes_with_params(
    self: T, account: ContractAddress, timepoint: u64, params: Span<felt252>,
) -> Result<u256, Array<felt252>>

has_voted

Returns whether account has cast a vote on proposal_id.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::has_voted

fn has_voted(
    self: T, proposal_id: felt252, account: ContractAddress,
) -> Result<bool, Array<felt252>>

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::IGovernorSafeDispatcherTrait::propose

fn propose(self: T, calls: Span<Call>, description: ByteArray) -> Result<felt252, Array<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::IGovernorSafeDispatcherTrait::queue

fn queue(self: T, calls: Span<Call>, description_hash: felt252) -> Result<felt252, Array<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::IGovernorSafeDispatcherTrait::execute

fn execute(self: T, calls: Span<Call>, description_hash: felt252) -> Result<felt252, Array<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::IGovernorSafeDispatcherTrait::cancel

fn cancel(self: T, calls: Span<Call>, description_hash: felt252) -> Result<felt252, Array<felt252>>

cast_vote

Cast a vote.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::cast_vote

fn cast_vote(self: T, proposal_id: felt252, support: u8) -> Result<u256, Array<felt252>>

cast_vote_with_reason

Cast a vote with a reason.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::cast_vote_with_reason

fn cast_vote_with_reason(
    self: T, proposal_id: felt252, support: u8, reason: ByteArray,
) -> Result<u256, Array<felt252>>

cast_vote_with_reason_and_params

Cast a vote with a reason and additional serialized params.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::cast_vote_with_reason_and_params

fn cast_vote_with_reason_and_params(
    self: T, proposal_id: felt252, support: u8, reason: ByteArray, params: Span<felt252>,
) -> Result<u256, Array<felt252>>

cast_vote_by_sig

Cast a vote using the voter’s signature.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::cast_vote_by_sig

fn cast_vote_by_sig(
    self: T, proposal_id: felt252, support: u8, voter: ContractAddress, signature: Span<felt252>,
) -> Result<u256, Array<felt252>>

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::IGovernorSafeDispatcherTrait::cast_vote_with_reason_and_params_by_sig

fn cast_vote_with_reason_and_params_by_sig(
    self: T,
    proposal_id: felt252,
    support: u8,
    voter: ContractAddress,
    reason: ByteArray,
    params: Span<felt252>,
    signature: Span<felt252>,
) -> Result<u256, Array<felt252>>

nonces

Returns the next unused nonce for an address.

Fully qualified path: openzeppelin_interfaces::governance::governor::IGovernorSafeDispatcherTrait::nonces

fn nonces(self: T, voter: ContractAddress) -> Result<felt252, Array<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::IGovernorSafeDispatcherTrait::relay

fn relay(self: T, call: Call) -> Result<(), Array<felt252>>