multiversx_sc_modules::governance

Struct ContractObj

Source
pub struct ContractObj<A>(/* private fields */)
where
    A: VMApi;

Trait Implementations§

Source§

impl<A> CallableContract for ContractObj<A>
where A: VMApi + Send + Sync,

Source§

fn call(&self, fn_name: &str) -> bool

Source§

impl<A> ContractBase for ContractObj<A>
where A: VMApi,

Source§

type Api = A

Source§

fn call_value(&self) -> CallValueWrapper<Self::Api>

Gateway into the call value retrieval functionality. The payment annotations should normally be the ones to handle this, but the developer is also given direct access to the API.
Source§

fn send(&self) -> SendWrapper<Self::Api>

Gateway to the functionality related to sending transactions from the current contract.
Source§

fn tx(&self) -> Tx<TxScEnv<Self::Api>, (), (), (), (), (), ()>

Starts the declaration of a new transaction.
Source§

fn send_raw(&self) -> SendRawWrapper<Self::Api>

Low-level functionality related to sending transactions from the current contract. Read more
Source§

fn blockchain(&self) -> BlockchainWrapper<Self::Api>

Gateway blockchain info related to the current transaction and to accounts.
Source§

fn crypto(&self) -> CryptoWrapper<Self::Api>

Stateless crypto functions provided by the Arwen VM.
Source§

fn serializer(&self) -> ManagedSerializer<Self::Api>

Component that provides contract developers access to highly optimized manual serialization and deserialization.
Source§

fn error(&self) -> ErrorHelper<Self::Api>

Source§

fn storage_raw(&self) -> StorageRawWrapper<Self::Api>

Source§

impl<A> EndpointWrappers for ContractObj<A>
where A: VMApi,

Source§

impl<A> EndpointWrappers for ContractObj<A>
where A: VMApi,

Source§

fn call(&mut self, fn_name: &str) -> bool

Source§

fn callback_selector( &mut self, ___cb_closure___: &CallbackClosureForDeser<Self::Api>, ) -> CallbackSelectorResult

Source§

fn callback(&mut self)

Source§

impl<A> EndpointWrappers for ContractObj<A>
where A: VMApi,

Source§

impl<A> AutoImpl for ContractObj<A>
where A: VMApi,

Source§

impl<A> AutoImpl for ContractObj<A>
where A: VMApi,

Source§

impl<A> AutoImpl for ContractObj<A>
where A: VMApi,

Auto Trait Implementations§

§

impl<A> Freeze for ContractObj<A>

§

impl<A> RefUnwindSafe for ContractObj<A>
where A: RefUnwindSafe,

§

impl<A> Send for ContractObj<A>

§

impl<A> Sync for ContractObj<A>

§

impl<A> Unpin for ContractObj<A>
where A: Unpin,

§

impl<A> UnwindSafe for ContractObj<A>
where A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<C> GovernanceConfigurablePropertiesModule for C
where C: AutoImpl,

Source§

fn governance_token_id( &self, ) -> SingleValueMapper<<C as ContractBase>::Api, TokenIdentifier<<C as ContractBase>::Api>>

Source§

fn quorum( &self, ) -> SingleValueMapper<<C as ContractBase>::Api, BigUint<<C as ContractBase>::Api>>

Source§

fn min_fee_for_propose( &self, ) -> SingleValueMapper<<C as ContractBase>::Api, BigUint<<C as ContractBase>::Api>>

Source§

fn min_token_balance_for_proposing( &self, ) -> SingleValueMapper<<C as ContractBase>::Api, BigUint<<C as ContractBase>::Api>>

Source§

fn voting_delay_in_blocks( &self, ) -> SingleValueMapper<<C as ContractBase>::Api, u64>

Source§

fn voting_period_in_blocks( &self, ) -> SingleValueMapper<<C as ContractBase>::Api, u64>

Source§

fn lock_time_after_voting_ends_in_blocks( &self, ) -> SingleValueMapper<<C as ContractBase>::Api, u64>

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)

Source§

impl<C> GovernanceEventsModule for C
where C: AutoImpl,

Source§

fn proposal_created_event( &self, proposal_id: usize, proposer: &ManagedAddress<<C as ContractBase>::Api>, start_block: u64, proposal: &GovernanceProposal<<C as ContractBase>::Api>, )

Source§

fn up_vote_cast_event( &self, up_voter: &ManagedAddress<<C as ContractBase>::Api>, proposal_id: usize, nr_votes: &BigUint<<C as ContractBase>::Api>, )

Source§

fn down_vote_cast_event( &self, down_voter: &ManagedAddress<<C as ContractBase>::Api>, proposal_id: usize, nr_downvotes: &BigUint<<C as ContractBase>::Api>, )

Source§

fn down_veto_vote_cast_event( &self, down_veto_voter: &ManagedAddress<<C as ContractBase>::Api>, proposal_id: usize, nr_downvotes: &BigUint<<C as ContractBase>::Api>, )

Source§

fn abstain_vote_cast_event( &self, abstain_voter: &ManagedAddress<<C as ContractBase>::Api>, proposal_id: usize, nr_downvotes: &BigUint<<C as ContractBase>::Api>, )

Source§

fn proposal_canceled_event(&self, proposal_id: usize)

Source§

fn proposal_queued_event(&self, proposal_id: usize, queued_block: u64)

Source§

fn proposal_executed_event(&self, proposal_id: usize)

Source§

fn user_deposit_event( &self, address: &ManagedAddress<<C as ContractBase>::Api>, proposal_id: usize, payment: &EsdtTokenPayment<<C as ContractBase>::Api>, )

Source§

fn user_claim_event( &self, address: &ManagedAddress<<C as ContractBase>::Api>, proposal_id: usize, payment: &EsdtTokenPayment<<C as ContractBase>::Api>, )

Source§

impl<C> GovernanceModule for C

Source§

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

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

Source§

fn proposals( &self, ) -> VecMapper<<C as ContractBase>::Api, GovernanceProposal<<C as ContractBase>::Api>>

Source§

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

Source§

fn user_voted_proposals( &self, user: &ManagedAddress<<C as ContractBase>::Api>, ) -> UnorderedSetMapper<<C as ContractBase>::Api, usize>

Source§

fn proposal_votes( &self, proposal_id: usize, ) -> SingleValueMapper<<C as ContractBase>::Api, ProposalVotes<<C as ContractBase>::Api>>

Source§

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

Source§

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

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. Read more
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: Read more
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
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.