multiversx_sc_modules::governance

Trait GovernanceModule

Source
pub trait GovernanceModule:
    ContractBase
    + Sized
    + GovernanceConfigurablePropertiesModule
    + GovernanceEventsModule {
Show 28 methods // Required methods fn proposals(&self) -> VecMapper<Self::Api, GovernanceProposal<Self::Api>>; fn proposal_start_block( &self, proposal_id: usize, ) -> SingleValueMapper<Self::Api, u64>; fn proposal_queue_block( &self, proposal_id: usize, ) -> SingleValueMapper<Self::Api, u64>; fn user_voted_proposals( &self, user: &ManagedAddress<Self::Api>, ) -> UnorderedSetMapper<Self::Api, ProposalId>; fn proposal_votes( &self, proposal_id: ProposalId, ) -> SingleValueMapper<Self::Api, ProposalVotes<Self::Api>>; fn total_votes( &self, proposal_id: usize, ) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>; fn total_downvotes( &self, proposal_id: usize, ) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>; // Provided methods fn deposit_tokens_for_proposal(&self, proposal_id: ProposalId) { ... } fn claim_deposited_tokens(&self, proposal_id: usize) { ... } fn propose( &self, description: ManagedBuffer<Self::Api>, actions: MultiValueEncoded<Self::Api, GovernanceActionAsMultiArg<Self::Api>>, ) -> usize { ... } fn vote(&self, proposal_id: usize, vote: VoteType) { ... } fn queue(&self, proposal_id: usize) { ... } fn execute(&self, proposal_id: usize) { ... } fn cancel(&self, proposal_id: usize) { ... } fn get_proposal_status( &self, proposal_id: usize, ) -> GovernanceProposalStatus { ... } fn quorum_and_vote_reached(&self, proposal_id: ProposalId) -> bool { ... } fn get_proposer( &self, proposal_id: usize, ) -> OptionalValue<ManagedAddress<Self::Api>> { ... } fn get_proposal_description( &self, proposal_id: usize, ) -> OptionalValue<ManagedBuffer<Self::Api>> { ... } fn get_proposal_actions( &self, proposal_id: usize, ) -> MultiValueEncoded<Self::Api, GovernanceActionAsMultiArg<Self::Api>> { ... } fn refund_payments(&self, proposal_id: ProposalId) { ... } fn require_payment_token_governance_token( &self, ) -> EsdtTokenPayment<Self::Api> { ... } fn require_valid_proposal_id(&self, proposal_id: usize) { ... } fn require_caller_not_self(&self) { ... } fn is_valid_proposal_id(&self, proposal_id: usize) -> bool { ... } fn proposal_reached_min_fees(&self, proposal_id: ProposalId) -> bool { ... } fn proposal_exists(&self, proposal_id: usize) -> bool { ... } fn total_gas_needed( &self, actions: &ArrayVec<GovernanceAction<Self::Api>, MAX_GOVERNANCE_PROPOSAL_ACTIONS>, ) -> u64 { ... } fn clear_proposal(&self, proposal_id: usize) { ... }
}

Required Methods§

Source

fn proposals(&self) -> VecMapper<Self::Api, GovernanceProposal<Self::Api>>

Source

fn proposal_start_block( &self, proposal_id: usize, ) -> SingleValueMapper<Self::Api, u64>

Not stored under “proposals”, as that would require deserializing the whole struct

Source

fn proposal_queue_block( &self, proposal_id: usize, ) -> SingleValueMapper<Self::Api, u64>

Source

fn user_voted_proposals( &self, user: &ManagedAddress<Self::Api>, ) -> UnorderedSetMapper<Self::Api, ProposalId>

Source

fn proposal_votes( &self, proposal_id: ProposalId, ) -> SingleValueMapper<Self::Api, ProposalVotes<Self::Api>>

Source

fn total_votes( &self, proposal_id: usize, ) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>

Source

fn total_downvotes( &self, proposal_id: usize, ) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>

Provided Methods§

Source

fn deposit_tokens_for_proposal(&self, proposal_id: ProposalId)

Used to deposit tokens for “payable” actions. Funds will be returned if the proposal is defeated. To keep the logic simple, all tokens have to be deposited at once

Source

fn claim_deposited_tokens(&self, proposal_id: usize)

Source

fn propose( &self, description: ManagedBuffer<Self::Api>, actions: MultiValueEncoded<Self::Api, GovernanceActionAsMultiArg<Self::Api>>, ) -> usize

Propose a list of actions. A maximum of MAX_GOVERNANCE_PROPOSAL_ACTIONS can be proposed at a time.

An action has the following format: - gas limit for action execution - destination address - a vector of ESDT transfers, in the form of ManagedVec - endpoint to be called on the destination - a vector of arguments for the endpoint, in the form of ManagedVec

Returns the ID of the newly created proposal.

Source

fn vote(&self, proposal_id: usize, vote: VoteType)

Vote on a proposal by depositing any amount of governance tokens These tokens will be locked until the proposal is executed or cancelled.

Source

fn queue(&self, proposal_id: usize)

Queue a proposal for execution. This can be done only if the proposal has reached the quorum. A proposal is considered successful and ready for queing if total_votes - total_downvotes >= quorum

Source

fn execute(&self, proposal_id: usize)

Execute a previously queued proposal. This will clear the proposal and unlock the governance tokens. Said tokens can then be withdrawn and used to vote/downvote other proposals.

Source

fn cancel(&self, proposal_id: usize)

Cancel a proposed action. This can be done:

  • by the proposer, at any time
  • by anyone, if the proposal was defeated
Source

fn get_proposal_status(&self, proposal_id: usize) -> GovernanceProposalStatus

Source

fn quorum_and_vote_reached(&self, proposal_id: ProposalId) -> bool

Source

fn get_proposer( &self, proposal_id: usize, ) -> OptionalValue<ManagedAddress<Self::Api>>

Source

fn get_proposal_description( &self, proposal_id: usize, ) -> OptionalValue<ManagedBuffer<Self::Api>>

Source

fn get_proposal_actions( &self, proposal_id: usize, ) -> MultiValueEncoded<Self::Api, GovernanceActionAsMultiArg<Self::Api>>

Source

fn refund_payments(&self, proposal_id: ProposalId)

Source

fn require_payment_token_governance_token(&self) -> EsdtTokenPayment<Self::Api>

Source

fn require_valid_proposal_id(&self, proposal_id: usize)

Source

fn require_caller_not_self(&self)

Source

fn is_valid_proposal_id(&self, proposal_id: usize) -> bool

Source

fn proposal_reached_min_fees(&self, proposal_id: ProposalId) -> bool

Source

fn proposal_exists(&self, proposal_id: usize) -> bool

Source

fn total_gas_needed( &self, actions: &ArrayVec<GovernanceAction<Self::Api>, MAX_GOVERNANCE_PROPOSAL_ACTIONS>, ) -> u64

Source

fn clear_proposal(&self, proposal_id: usize)

specific votes/downvotes are not cleared, as they’re used for reclaim tokens logic and cleared one by one

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§