Trait Module

Source
pub trait Module {
    type ExecT;
    type QueryT;
    type SudoT;

    // Required methods
    fn execute<ExecC, QueryC>(
        &self,
        api: &dyn Api,
        storage: &mut dyn Storage,
        router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
        block: &BlockInfo,
        sender: Addr,
        msg: Self::ExecT,
    ) -> AnyResult<AppResponse>
       where ExecC: CustomMsg + DeserializeOwned + 'static,
             QueryC: CustomQuery + DeserializeOwned + 'static;
    fn query(
        &self,
        api: &dyn Api,
        storage: &dyn Storage,
        querier: &dyn Querier,
        block: &BlockInfo,
        request: Self::QueryT,
    ) -> AnyResult<Binary>;
    fn sudo<ExecC, QueryC>(
        &self,
        api: &dyn Api,
        storage: &mut dyn Storage,
        router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
        block: &BlockInfo,
        msg: Self::SudoT,
    ) -> AnyResult<AppResponse>
       where ExecC: CustomMsg + DeserializeOwned + 'static,
             QueryC: CustomQuery + DeserializeOwned + 'static;
}
Expand description

§General module

Provides a generic interface for modules within the test environment. It is essential for creating modular and extensible testing setups, allowing developers to integrate custom functionalities or test specific scenarios.

Required Associated Types§

Source

type ExecT

Type of messages processed by the module instance.

Source

type QueryT

Type of queries processed by the module instance.

Source

type SudoT

Type of privileged messages used by the module instance.

Required Methods§

Source

fn execute<ExecC, QueryC>( &self, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, sender: Addr, msg: Self::ExecT, ) -> AnyResult<AppResponse>
where ExecC: CustomMsg + DeserializeOwned + 'static, QueryC: CustomQuery + DeserializeOwned + 'static,

Runs any ExecT message, which can be called by any external actor or smart contract.

Source

fn query( &self, api: &dyn Api, storage: &dyn Storage, querier: &dyn Querier, block: &BlockInfo, request: Self::QueryT, ) -> AnyResult<Binary>

Runs any QueryT message, which can be called by any external actor or smart contract.

Source

fn sudo<ExecC, QueryC>( &self, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, msg: Self::SudoT, ) -> AnyResult<AppResponse>
where ExecC: CustomMsg + DeserializeOwned + 'static, QueryC: CustomQuery + DeserializeOwned + 'static,

Runs privileged actions, like minting tokens, or governance proposals. This allows modules to have full access to these privileged actions, that cannot be triggered by smart contracts.

There is no sender, as this must be previously authorized before calling.

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§

Source§

impl Module for BankKeeper

Source§

impl Module for DistributionKeeper

Source§

impl Module for StakeKeeper

Source§

impl<Exec, Query> Module for CachingCustomHandler<Exec, Query>
where Exec: Default + Clone, Query: Default + Clone,

Source§

type ExecT = Exec

Source§

type QueryT = Query

Source§

type SudoT = Empty

Source§

impl<ExecT, QueryT, SudoT> Module for AcceptingModule<ExecT, QueryT, SudoT>
where ExecT: Debug, QueryT: Debug, SudoT: Debug,

Source§

type ExecT = ExecT

Source§

type QueryT = QueryT

Source§

type SudoT = SudoT

Source§

impl<ExecT, QueryT, SudoT> Module for FailingModule<ExecT, QueryT, SudoT>
where ExecT: Debug, QueryT: Debug, SudoT: Debug,

Source§

type ExecT = ExecT

Source§

type QueryT = QueryT

Source§

type SudoT = SudoT