App

Struct App 

Source
pub struct App<Bank = BankKeeper, Api = MockApi, Storage = MockStorage, Custom = FailingModule<Empty, Empty, Empty>, Wasm = WasmKeeper<Empty, Empty>, Staking = StakeKeeper, Distr = DistributionKeeper, Ibc = FailingModule<IbcMsg, IbcQuery, Empty>, Gov = FailingModule<GovMsg, Empty, Empty>, Stargate = StargateKeeper<Empty, Empty>> {
    pub router: RefCell<Router<Bank, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>>,
    /* private fields */
}
Expand description

Router is a persisted state. You can query this. Execution generally happens on the RouterCache, which then can be atomically committed or rolled back. We offer .execute() as a wrapper around cache, execute, commit/rollback process.

Fields§

§router: RefCell<Router<Bank, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>>

Implementations§

Source§

impl App

Source

pub fn new<F>(init_fn: F) -> Self

Creates new default App implementation working with Empty custom messages.

Source§

impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT> App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>
where WasmT: Wasm<CustomT::ExecT, CustomT::QueryT>, BankT: Bank, ApiT: Api, StorageT: Storage, CustomT: Module, StakingT: Staking, DistrT: Distribution, IbcT: Ibc, GovT: Gov,

Source

pub fn init_modules<F, T>(&self, init_fn: F) -> T
where F: FnOnce(&mut Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>, &dyn Api, &mut dyn Storage) -> T,

Source

pub fn read_module<F, T>(&self, query_fn: F) -> T
where F: FnOnce(&Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>, &dyn Api, &dyn Storage) -> T,

Source§

impl<BankT, ApiT, StorageT, CustomT, StakingT, DistrT, IbcT, GovT, StargateT> App<BankT, ApiT, StorageT, CustomT, WasmKeeper<CustomT::ExecT, CustomT::QueryT>, StakingT, DistrT, IbcT, GovT, StargateT>
where BankT: Bank, ApiT: Api, StorageT: Storage, CustomT: Module, StakingT: Staking, DistrT: Distribution, IbcT: Ibc, GovT: Gov, CustomT::ExecT: Clone + Debug + PartialEq + JsonSchema + DeserializeOwned + 'static, CustomT::QueryT: CustomQuery + DeserializeOwned + 'static, StargateT: Stargate<CustomT::ExecT, CustomT::QueryT>,

Source

pub fn store_code( &self, code: Box<dyn Contract<CustomT::ExecT, CustomT::QueryT>>, ) -> u64

This registers contract code (like uploading wasm bytecode on a chain), so it can later be used to instantiate a contract.

Source

pub fn contract_data(&self, address: &Addr) -> AnyResult<ContractData>

This allows to get ContractData for specific contract

Source

pub fn dump_wasm_raw(&self, address: &Addr) -> Vec<Record>

This gets a raw state dump of all key-values held by a given contract

Source§

impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT> App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>
where CustomT::ExecT: Debug + PartialEq + Clone + JsonSchema + DeserializeOwned + 'static, CustomT::QueryT: CustomQuery + DeserializeOwned + 'static, WasmT: Wasm<CustomT::ExecT, CustomT::QueryT>, BankT: Bank, ApiT: Api, StorageT: Storage, CustomT: Module, StakingT: Staking, DistrT: Distribution, IbcT: Ibc, GovT: Gov, StargateT: Stargate<CustomT::ExecT, CustomT::QueryT>,

Source

pub fn set_block(&self, block: BlockInfo)

Source

pub fn update_block<F: Fn(&mut BlockInfo)>(&self, action: F)

Source

pub fn block_info(&self) -> BlockInfo

Returns a copy of the current block_info

Source

pub fn wrap(&self) -> QuerierWrapper<'_, CustomT::QueryT>

Simple helper so we get access to all the QuerierWrapper helpers, eg. wrap().query_wasm_smart, query_all_balances, …

Source

pub fn execute_multi( &self, sender: Addr, msgs: Vec<CosmosMsg<CustomT::ExecT>>, ) -> AnyResult<Vec<AppResponse>>

Runs multiple CosmosMsg in one atomic operation. This will create a cache before the execution, so no state changes are persisted if any of them return an error. But all writes are persisted on success.

Source

pub fn wasm_sudo<T: Serialize, U: Into<Addr>>( &self, contract_addr: U, msg: &T, ) -> AnyResult<AppResponse>

Call a smart contract in “sudo” mode. This will create a cache before the execution, so no state changes are persisted if this returns an error, but all are persisted on success.

Source

pub fn sudo(&self, msg: SudoMsg) -> AnyResult<AppResponse>

Runs arbitrary SudoMsg. This will create a cache before the execution, so no state changes are persisted if this returns an error, but all are persisted on success.

Trait Implementations§

Source§

impl Default for App

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT> Executor<<CustomT as Module>::ExecT> for App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>
where CustomT::ExecT: Clone + Debug + PartialEq + JsonSchema + DeserializeOwned + 'static, CustomT::QueryT: CustomQuery + DeserializeOwned + 'static, WasmT: Wasm<CustomT::ExecT, CustomT::QueryT>, BankT: Bank, ApiT: Api, StorageT: Storage, CustomT: Module, StakingT: Staking, DistrT: Distribution, IbcT: Ibc, GovT: Gov, StargateT: Stargate<CustomT::ExecT, CustomT::QueryT>,

Source§

fn execute( &self, sender: Addr, msg: CosmosMsg<CustomT::ExecT>, ) -> AnyResult<AppResponse>

Runs arbitrary CosmosMsg. This will create a cache before the execution, so no state changes are persisted if this returns an error, but all are persisted on success.
Source§

fn instantiate_contract<T: Serialize, U: Into<String>>( &self, code_id: u64, sender: Addr, init_msg: &T, send_funds: &[Coin], label: U, admin: Option<String>, ) -> AnyResult<Addr>

Create a contract and get the new address. This is just a helper around execute()
Source§

fn execute_contract<T: Serialize + Debug>( &self, sender: Addr, contract_addr: Addr, msg: &T, send_funds: &[Coin], ) -> AnyResult<AppResponse>

Execute a contract and process all returned messages. This is just a helper around execute(), but we parse out the data field to that what is returned by the contract (not the protobuf wrapper)
Source§

fn migrate_contract<T: Serialize>( &mut self, sender: Addr, contract_addr: Addr, msg: &T, new_code_id: u64, ) -> AnyResult<AppResponse>

Migrate a contract. Sender must be registered admin. This is just a helper around execute()
Source§

fn send_tokens( &mut self, sender: Addr, recipient: Addr, amount: &[Coin], ) -> AnyResult<AppResponse>

Source§

impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT> Querier for App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>
where CustomT::ExecT: Clone + Debug + PartialEq + JsonSchema + DeserializeOwned + 'static, CustomT::QueryT: CustomQuery + DeserializeOwned + 'static, WasmT: Wasm<CustomT::ExecT, CustomT::QueryT>, BankT: Bank, ApiT: Api, StorageT: Storage, CustomT: Module, StakingT: Staking, DistrT: Distribution, IbcT: Ibc, GovT: Gov, StargateT: Stargate<CustomT::ExecT, CustomT::QueryT>,

Source§

fn raw_query(&self, bin_request: &[u8]) -> QuerierResult

raw_query is all that must be implemented for the Querier. This allows us to pass through binary queries from one level to another without knowing the custom format, or we can decode it, with the knowledge of the allowed types. People using the querier probably want one of the simpler auto-generated helper methods

Auto Trait Implementations§

§

impl<Bank = BankKeeper, Api = MockApi, Storage = MemoryStorage, Custom = FailingModule<Empty, Empty, Empty>, Wasm = WasmKeeper<Empty, Empty>, Staking = StakeKeeper, Distr = DistributionKeeper, Ibc = FailingModule<IbcMsg, IbcQuery, Empty>, Gov = FailingModule<GovMsg, Empty, Empty>, Stargate = StargateKeeper<Empty, Empty>> !Freeze for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>

§

impl<Bank = BankKeeper, Api = MockApi, Storage = MemoryStorage, Custom = FailingModule<Empty, Empty, Empty>, Wasm = WasmKeeper<Empty, Empty>, Staking = StakeKeeper, Distr = DistributionKeeper, Ibc = FailingModule<IbcMsg, IbcQuery, Empty>, Gov = FailingModule<GovMsg, Empty, Empty>, Stargate = StargateKeeper<Empty, Empty>> !RefUnwindSafe for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>

§

impl<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate> Send for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>
where Api: Send, Storage: Send, Wasm: Send, Bank: Send, Custom: Send, Staking: Send, Distr: Send, Ibc: Send, Gov: Send, Stargate: Send,

§

impl<Bank = BankKeeper, Api = MockApi, Storage = MemoryStorage, Custom = FailingModule<Empty, Empty, Empty>, Wasm = WasmKeeper<Empty, Empty>, Staking = StakeKeeper, Distr = DistributionKeeper, Ibc = FailingModule<IbcMsg, IbcQuery, Empty>, Gov = FailingModule<GovMsg, Empty, Empty>, Stargate = StargateKeeper<Empty, Empty>> !Sync for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>

§

impl<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate> Unpin for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>
where Api: Unpin, Storage: Unpin, Wasm: Unpin, Bank: Unpin, Custom: Unpin, Staking: Unpin, Distr: Unpin, Ibc: Unpin, Gov: Unpin, Stargate: Unpin,

§

impl<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate> UnwindSafe for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>
where Api: UnwindSafe, Storage: UnwindSafe, Wasm: UnwindSafe, Bank: UnwindSafe, Custom: UnwindSafe, Staking: UnwindSafe, Distr: UnwindSafe, Ibc: UnwindSafe, Gov: UnwindSafe, Stargate: 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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. 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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.