[][src]Trait cosmwasm_std::Api

pub trait Api: Copy + Clone + Send {
    fn canonical_address(&self, human: &HumanAddr) -> StdResult<CanonicalAddr>;
fn human_address(&self, canonical: &CanonicalAddr) -> StdResult<HumanAddr>;
fn debug(&self, message: &str); }

Api are callbacks to system functions implemented outside of the wasm modules. Currently it just supports address conversion but we could add eg. crypto functions here.

This is a trait to allow mocks in the test code. Its members have a read-only reference to the Api instance to allow accessing configuration. Implementations must not have mutable state, such that an instance can freely be copied and shared between threads without affecting the behaviour. Given an Api instance, all members should return the same value when called with the same arguments. In particular this means the result must not depend in the state of the chain. If you need to access chaim state, you probably want to use the Querier. Side effects (such as logging) are allowed.

We can use feature flags to opt-in to non-essential methods for backwards compatibility in systems that don't have them all.

Required methods

fn canonical_address(&self, human: &HumanAddr) -> StdResult<CanonicalAddr>

fn human_address(&self, canonical: &CanonicalAddr) -> StdResult<HumanAddr>

fn debug(&self, message: &str)

Emits a debugging message that is handled depending on the environment (typically printed to console or ignored). Those messages are not persisted to chain.

Loading content...

Implementors

impl Api for MockApi[src]

Loading content...