Trait cw_multi_test::Wasm

source ·
pub trait Wasm<ExecC, QueryC> {
    // Required methods
    fn execute(
        &self,
        api: &dyn Api,
        storage: &mut dyn Storage,
        router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
        block: &BlockInfo,
        sender: Addr,
        msg: WasmMsg
    ) -> AnyResult<AppResponse>;
    fn query(
        &self,
        api: &dyn Api,
        storage: &dyn Storage,
        querier: &dyn Querier,
        block: &BlockInfo,
        request: WasmQuery
    ) -> AnyResult<Binary>;
    fn sudo(
        &self,
        api: &dyn Api,
        storage: &mut dyn Storage,
        router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
        block: &BlockInfo,
        msg: WasmSudo
    ) -> AnyResult<AppResponse>;
    fn store_code(
        &mut self,
        creator: Addr,
        code: Box<dyn Contract<ExecC, QueryC>>
    ) -> u64;
    fn store_code_with_id(
        &mut self,
        creator: Addr,
        code_id: u64,
        code: Box<dyn Contract<ExecC, QueryC>>
    ) -> AnyResult<u64>;
    fn duplicate_code(&mut self, code_id: u64) -> AnyResult<u64>;
    fn contract_data(
        &self,
        storage: &dyn Storage,
        address: &Addr
    ) -> AnyResult<ContractData>;
    fn dump_wasm_raw(
        &self,
        storage: &dyn Storage,
        address: &Addr
    ) -> Vec<Record>;

    // Provided methods
    fn contract_namespace(&self, contract: &Addr) -> Vec<u8> { ... }
    fn contract_storage<'a>(
        &self,
        storage: &'a dyn Storage,
        address: &Addr
    ) -> Box<dyn Storage + 'a> { ... }
    fn contract_storage_mut<'a>(
        &self,
        storage: &'a mut dyn Storage,
        address: &Addr
    ) -> Box<dyn Storage + 'a> { ... }
}
Expand description

Acts as the interface for interacting with WebAssembly (Wasm) modules. This trait is crucial for testing smart contracts written in languages that compile to WebAssembly, which is common in the Cosmos and CosmWasm ecosystems.

Required Methods§

source

fn execute( &self, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, sender: Addr, msg: WasmMsg ) -> AnyResult<AppResponse>

Handles all WasmMsg messages.

source

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

Handles all WasmQuery requests.

source

fn sudo( &self, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, msg: WasmSudo ) -> AnyResult<AppResponse>

Handles all sudo messages, this is an admin interface and can not be called via CosmosMsg.

source

fn store_code( &mut self, creator: Addr, code: Box<dyn Contract<ExecC, QueryC>> ) -> u64

Stores the contract’s code and returns an identifier of the stored contract’s code.

source

fn store_code_with_id( &mut self, creator: Addr, code_id: u64, code: Box<dyn Contract<ExecC, QueryC>> ) -> AnyResult<u64>

Stores the contract’s code under specified identifier, returns the same code identifier when successful.

source

fn duplicate_code(&mut self, code_id: u64) -> AnyResult<u64>

Duplicates the contract’s code with specified identifier and returns an identifier of the copy of the contract’s code.

source

fn contract_data( &self, storage: &dyn Storage, address: &Addr ) -> AnyResult<ContractData>

Returns ContractData for the contract with specified address.

source

fn dump_wasm_raw(&self, storage: &dyn Storage, address: &Addr) -> Vec<Record>

Returns a raw state dump of all key-values held by a contract with specified address.

Provided Methods§

source

fn contract_namespace(&self, contract: &Addr) -> Vec<u8>

Returns the namespace of the contract storage.

source

fn contract_storage<'a>( &self, storage: &'a dyn Storage, address: &Addr ) -> Box<dyn Storage + 'a>

Returns read-only (not mutable) contract storage.

source

fn contract_storage_mut<'a>( &self, storage: &'a mut dyn Storage, address: &Addr ) -> Box<dyn Storage + 'a>

Returns read-write (mutable) contract storage.

Implementors§

source§

impl<ExecC, QueryC> Wasm<ExecC, QueryC> for WasmKeeper<ExecC, QueryC>
where ExecC: CustomMsg + DeserializeOwned + 'static, QueryC: CustomQuery + DeserializeOwned + 'static,