pub trait GovernanceModule: ContractBase + Sized + GovernanceConfigurablePropertiesModule + GovernanceEventsModule {
Show 28 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>>; 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§

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

Provided Methods§

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

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.

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

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

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.

Cancel a proposed action. This can be done:

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

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

Implementors§