Trait 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,
    ) -> StdResult<AppResponse>;
    fn query(
        &self,
        api: &dyn Api,
        storage: &dyn Storage,
        querier: &dyn Querier,
        block: &BlockInfo,
        request: WasmQuery,
    ) -> StdResult<Binary>;
    fn sudo(
        &self,
        api: &dyn Api,
        storage: &mut dyn Storage,
        router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
        block: &BlockInfo,
        msg: WasmSudo,
    ) -> StdResult<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>>,
    ) -> StdResult<u64>;
    fn duplicate_code(&mut self, code_id: u64) -> StdResult<u64>;
    fn contract_data(
        &self,
        storage: &dyn Storage,
        address: &Addr,
    ) -> StdResult<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

This trait implements the interface of the Wasm module.

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, ) -> StdResult<AppResponse>

Handles all WasmMsg messages.

Source

fn query( &self, api: &dyn Api, storage: &dyn Storage, querier: &dyn Querier, block: &BlockInfo, request: WasmQuery, ) -> StdResult<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, ) -> StdResult<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>>, ) -> StdResult<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) -> StdResult<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, ) -> StdResult<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,