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
minusdownvotes
) at the end of voting periodminTokenBalanceForProposing
- Minimum numbers of tokens the proposer has to deposit. These automatically count asvotes
as wellmaxActionsPerProposal
- Maximum number of actions (transfers and/or smart contract calls) that a proposal may havevotingDelayInBlocks
- Number of blocks to wait after a block is proposed before being able to vote/downvote that proposalvotingPeriodInBlocks
- 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 proposaldownvoteCast
- user downvoted a proposalproposalCanceled
,proposalQueued
andproposalExecuted
- provides the ID of the specific proposaluserDeposit
- 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§
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§
Sourcefn 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 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
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)
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.