Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

InternalTrait

Fully qualified path: openzeppelin_governance::governor::governor::GovernorComponent::InternalTrait

pub trait InternalTrait<
    TContractState,
    +HasComponent<TContractState>,
    impl SRC5: HasComponent<TContractState>,
    +Drop<TContractState>,
>

Trait functions

initializer

Initializes the contract by registering the supported interface id.

Fully qualified path: openzeppelin_governance::governor::governor::GovernorComponent::InternalTrait::initializer

fn initializer(ref self: ComponentState<TContractState>)

get_proposal

Returns the proposal object given its id.

Fully qualified path: openzeppelin_governance::governor::governor::GovernorComponent::InternalTrait::get_proposal

fn get_proposal(self: @ComponentState<TContractState>, proposal_id: felt252) -> ProposalCore

is_valid_description_for_proposer

Checks if the proposer is authorized to submit a proposal with the given description.

If the proposal description ends with #proposer=0x???, where 0x??? is an address written as a hex string (case insensitive), then the submission of this proposal will only be authorized to said address.

This is used for frontrunning protection. By adding this pattern at the end of their proposal, one can ensure that no other address can submit the same proposal. An attacker would have to either remove or change that part, which would result in a different proposal id.

NOTE: In Starknet, the Sequencer ensures the order of transactions, but frontrunning can still be achieved by nodes, and potentially other actors in the future with sequencer decentralization.

If the description does not match this pattern, it is unrestricted and anyone can submit it. This includes:

  • If the 0x??? part is not a valid hex string.
  • If the 0x??? part is a valid hex string, but does not contain exactly 64 hex digits.
  • If it ends with the expected suffix followed by newlines or other whitespace.
  • If it ends with some other similar suffix, e.g. #other=abc.
  • If it does not end with any such suffix.

Fully qualified path: openzeppelin_governance::governor::governor::GovernorComponent::InternalTrait::is_valid_description_for_proposer

fn is_valid_description_for_proposer(
    self: @ComponentState<TContractState>, proposer: ContractAddress, description: @ByteArray,
) -> bool

_hash_proposal

Returns a hash of the proposal using the Pedersen hashing algorithm.

Fully qualified path: openzeppelin_governance::governor::governor::GovernorComponent::InternalTrait::_hash_proposal

fn _hash_proposal(
    self: @ComponentState<TContractState>, calls: Span<Call>, description_hash: felt252,
) -> 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_governance::governor::governor::GovernorComponent::InternalTrait::_proposal_snapshot

fn _proposal_snapshot(self: @ComponentState<TContractState>, 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_governance::governor::governor::GovernorComponent::InternalTrait::_proposal_deadline

fn _proposal_deadline(self: @ComponentState<TContractState>, proposal_id: felt252) -> u64

_proposal_proposer

The account that created a proposal.

Fully qualified path: openzeppelin_governance::governor::governor::GovernorComponent::InternalTrait::_proposal_proposer

fn _proposal_proposer(
    self: @ComponentState<TContractState>, 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_governance::governor::governor::GovernorComponent::InternalTrait::_proposal_eta

fn _proposal_eta(self: @ComponentState<TContractState>, proposal_id: felt252) -> u64