multiversx_sc_modules::governance::governance_configurable

Trait GovernanceConfigurablePropertiesModule

Source
pub trait GovernanceConfigurablePropertiesModule: ContractBase + Sized {
Show 19 methods // Required methods fn governance_token_id( &self, ) -> SingleValueMapper<Self::Api, TokenIdentifier<Self::Api>>; fn quorum(&self) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>; fn min_fee_for_propose( &self, ) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>; fn min_token_balance_for_proposing( &self, ) -> SingleValueMapper<Self::Api, BigUint<Self::Api>>; fn voting_delay_in_blocks(&self) -> SingleValueMapper<Self::Api, u64>; fn voting_period_in_blocks(&self) -> SingleValueMapper<Self::Api, u64>; fn lock_time_after_voting_ends_in_blocks( &self, ) -> SingleValueMapper<Self::Api, u64>; // Provided methods fn init_governance_module( &self, governance_token_id: TokenIdentifier<Self::Api>, quorum: BigUint<Self::Api>, min_token_balance_for_proposal: BigUint<Self::Api>, voting_delay_in_blocks: u64, voting_period_in_blocks: u64, lock_time_after_voting_ends_in_blocks: u64, ) { ... } fn change_quorum(&self, new_value: BigUint<Self::Api>) { ... } fn change_min_token_balance_for_proposing( &self, new_value: BigUint<Self::Api>, ) { ... } fn change_voting_delay_in_blocks(&self, new_value: u64) { ... } fn change_voting_period_in_blocks(&self, new_value: u64) { ... } fn change_lock_time_after_voting_ends_in_blocks(&self, new_value: u64) { ... } fn require_caller_self(&self) { ... } fn try_change_quorum(&self, new_value: BigUint<Self::Api>) { ... } fn try_change_min_token_balance_for_proposing( &self, new_value: BigUint<Self::Api>, ) { ... } fn try_change_voting_delay_in_blocks(&self, new_value: u64) { ... } fn try_change_voting_period_in_blocks(&self, new_value: u64) { ... } fn try_change_lock_time_after_voting_ends_in_blocks(&self, new_value: u64) { ... }
}
Expand description

§MultiversX smart contract module - Governance

This is a standard smart contract module, that when added to a smart contract offers governance features:

  • proposing actions
  • voting/downvoting a certain proposal
  • after a voting period, either putting the action in a queue (if it reached quorum), or canceling

Voting can only be done by depositing a certain token, decided upon first time setup.

The module provides the following configurable parameters:

  • quorum - the minimum number of (votes minus downvotes) at the end of voting period
  • minTokenBalanceForProposing - Minimum numbers of tokens the proposer has to deposit. These automatically count as votes as well
  • maxActionsPerProposal - Maximum number of actions (transfers and/or smart contract calls) that a proposal may have
  • votingDelayInBlocks - Number of blocks to wait after a block is proposed before being able to vote/downvote that proposal
  • votingPeriodInBlocks - Number of blocks the voting period lasts (voting delay does not count towards this)
  • lockTimeAfterVotingEndsInBlocks - Number of blocks to wait before a successful proposal can be executed

The module also provides events for most actions that happen:

  • proposalCreated - triggers when a proposal is created. Also provoides all the relevant information, like proposer, actions etc.
  • voteCast - user voted on a proposal
  • downvoteCast - user downvoted a proposal
  • proposalCanceled, proposalQueued and proposalExecuted - provides the ID of the specific proposal
  • userDeposit - a user deposited some tokens needed for a future payable action

Please note that although the main contract can modify the module’s storage directly, it is not recommended to do so, as that defeats the whole purpose of having governance. These parameters should only be modified through actions.

Required Methods§

Provided Methods§

Source

fn init_governance_module( &self, governance_token_id: TokenIdentifier<Self::Api>, quorum: BigUint<Self::Api>, min_token_balance_for_proposal: BigUint<Self::Api>, voting_delay_in_blocks: u64, voting_period_in_blocks: u64, lock_time_after_voting_ends_in_blocks: u64, )

The module can’t protect its storage from the main SC, so it’s the developers responsibility to not modify parameters manually

Source

fn change_quorum(&self, new_value: BigUint<Self::Api>)

Source

fn change_min_token_balance_for_proposing(&self, new_value: BigUint<Self::Api>)

Source

fn change_voting_delay_in_blocks(&self, new_value: u64)

Source

fn change_voting_period_in_blocks(&self, new_value: u64)

Source

fn change_lock_time_after_voting_ends_in_blocks(&self, new_value: u64)

Source

fn require_caller_self(&self)

Source

fn try_change_quorum(&self, new_value: BigUint<Self::Api>)

Source

fn try_change_min_token_balance_for_proposing( &self, new_value: BigUint<Self::Api>, )

Source

fn try_change_voting_delay_in_blocks(&self, new_value: u64)

Source

fn try_change_voting_period_in_blocks(&self, new_value: u64)

Source

fn try_change_lock_time_after_voting_ends_in_blocks(&self, new_value: u64)

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§