pub struct App<Bank = BankKeeper, Api = MockApi, Storage = MockStorage, Custom = FailingModule<Empty, Empty, Empty>, Wasm = WasmKeeper<Empty, Empty>, Staking = StakeKeeper, Distr = DistributionKeeper, Ibc = IbcFailingModule, Gov = GovFailingModule> { /* 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.
Implementations§
Source§impl App
impl App
Sourcepub fn new<F>(remote: RemoteChannel, init_fn: F) -> AnyResult<Self>where
F: FnOnce(&mut Router<BankKeeper, FailingModule<Empty, Empty, Empty>, WasmKeeper<Empty, Empty>, StakeKeeper, DistributionKeeper, IbcFailingModule, GovFailingModule>, &dyn Api, &mut dyn Storage),
pub fn new<F>(remote: RemoteChannel, init_fn: F) -> AnyResult<Self>where
F: FnOnce(&mut Router<BankKeeper, FailingModule<Empty, Empty, Empty>, WasmKeeper<Empty, Empty>, StakeKeeper, DistributionKeeper, IbcFailingModule, GovFailingModule>, &dyn Api, &mut dyn Storage),
Creates new default App implementation working with Empty custom messages.
Source§impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>
impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>
Sourcepub fn router(
&self,
) -> &Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>
pub fn router( &self, ) -> &Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>
Returns a shared reference to application’s router.
Sourcepub fn storage_mut(&mut self) -> &mut StorageT
pub fn storage_mut(&mut self) -> &mut StorageT
Returns a mutable reference to application’s storage.
pub fn init_modules<F, T>(&mut self, init_fn: F) -> T
pub fn read_module<F, T>(&self, query_fn: F) -> T
Source§impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>where
BankT: Bank,
ApiT: Api,
StorageT: Storage,
CustomT: Module,
WasmT: Wasm<CustomT::ExecT, CustomT::QueryT>,
StakingT: Staking,
DistrT: Distribution,
IbcT: Ibc,
GovT: Gov,
CustomT::ExecT: CustomMsg + DeserializeOwned + 'static,
CustomT::QueryT: CustomQuery + DeserializeOwned + 'static,
impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>where
BankT: Bank,
ApiT: Api,
StorageT: Storage,
CustomT: Module,
WasmT: Wasm<CustomT::ExecT, CustomT::QueryT>,
StakingT: Staking,
DistrT: Distribution,
IbcT: Ibc,
GovT: Gov,
CustomT::ExecT: CustomMsg + DeserializeOwned + 'static,
CustomT::QueryT: CustomQuery + DeserializeOwned + 'static,
Sourcepub fn store_wasm_code(&mut self, code: Vec<u8>) -> u64
pub fn store_wasm_code(&mut self, code: Vec<u8>) -> u64
Registers contract code (like uploading wasm bytecode on a chain), so it can later be used to instantiate a contract. Only for wasm codes
Sourcepub fn store_code(
&mut self,
code: Box<dyn Contract<CustomT::ExecT, CustomT::QueryT>>,
) -> u64
pub fn store_code( &mut self, code: Box<dyn Contract<CustomT::ExecT, CustomT::QueryT>>, ) -> u64
Registers contract code (like uploading wasm bytecode on a chain), so it can later be used to instantiate a contract.
Sourcepub fn store_wasm_code_with_creator(
&mut self,
creator: Addr,
code: Vec<u8>,
) -> u64
pub fn store_wasm_code_with_creator( &mut self, creator: Addr, code: Vec<u8>, ) -> u64
Registers contract code (like store_code), but takes the address of the code creator as an additional argument.
Sourcepub fn store_code_with_creator(
&mut self,
creator: Addr,
code: Box<dyn Contract<CustomT::ExecT, CustomT::QueryT>>,
) -> u64
pub fn store_code_with_creator( &mut self, creator: Addr, code: Box<dyn Contract<CustomT::ExecT, CustomT::QueryT>>, ) -> u64
Registers contract code (like store_code), but takes the address of the code creator as an additional argument.
Sourcepub fn contract_data(&self, address: &Addr) -> AnyResult<ContractData>
pub fn contract_data(&self, address: &Addr) -> AnyResult<ContractData>
Returns ContractData for the contract with specified address.
Source§impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>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,
impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>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,
pub fn set_block(&mut self, block: BlockInfo)
pub fn update_block<F: Fn(&mut BlockInfo)>(&mut self, action: F)
Sourcepub fn block_info(&self) -> BlockInfo
pub fn block_info(&self) -> BlockInfo
Returns a copy of the current block_info
Sourcepub fn next_address(&mut self) -> Addr
pub fn next_address(&mut self) -> Addr
Returns a new account address
Sourcepub fn wrap(&self) -> QuerierWrapper<'_, CustomT::QueryT>
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, …
pub fn get_querier_storage(&self) -> AnyResult<QuerierStorage>
Sourcepub fn execute_multi(
&mut self,
sender: Addr,
msgs: Vec<CosmosMsg<CustomT::ExecT>>,
) -> AnyResult<Vec<AppResponse>>
pub fn execute_multi( &mut 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.
Sourcepub fn wasm_sudo<T: Serialize, U: Into<Addr>>(
&mut self,
contract_addr: U,
msg: &T,
) -> AnyResult<AppResponse>
pub fn wasm_sudo<T: Serialize, U: Into<Addr>>( &mut 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.
Sourcepub fn sudo(&mut self, msg: SudoMsg) -> AnyResult<AppResponse>
pub fn sudo(&mut 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<Bank: Clone, Api: Clone, Storage: Clone, Custom: Clone, Wasm: Clone, Staking: Clone, Distr: Clone, Ibc: Clone, Gov: Clone> Clone for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov>
impl<Bank: Clone, Api: Clone, Storage: Clone, Custom: Clone, Wasm: Clone, Staking: Clone, Distr: Clone, Ibc: Clone, Gov: Clone> Clone for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov>
Source§impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> Executor<<CustomT as Module>::ExecT> for App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>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,
impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> Executor<<CustomT as Module>::ExecT> for App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>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,
Source§fn execute(
&mut self,
sender: Addr,
msg: CosmosMsg<CustomT::ExecT>,
) -> AnyResult<AppResponse>
fn execute( &mut self, sender: Addr, msg: CosmosMsg<CustomT::ExecT>, ) -> AnyResult<AppResponse>
Source§fn instantiate_contract<T: Serialize, U: Into<String>>(
&mut self,
code_id: u64,
sender: Addr,
init_msg: &T,
send_funds: &[Coin],
label: U,
admin: Option<String>,
) -> AnyResult<Addr>
fn instantiate_contract<T: Serialize, U: Into<String>>( &mut self, code_id: u64, sender: Addr, init_msg: &T, send_funds: &[Coin], label: U, admin: Option<String>, ) -> AnyResult<Addr>
Source§fn instantiate2_contract<M, L, A, S>(
&mut self,
code_id: u64,
sender: Addr,
init_msg: &M,
funds: &[Coin],
label: L,
admin: A,
salt: S,
) -> AnyResult<Addr>
fn instantiate2_contract<M, L, A, S>( &mut self, code_id: u64, sender: Addr, init_msg: &M, funds: &[Coin], label: L, admin: A, salt: S, ) -> AnyResult<Addr>
WasmMsg::Instantiate2 message.Source§fn execute_contract<T: Serialize + Debug>(
&mut self,
sender: Addr,
contract_addr: Addr,
msg: &T,
send_funds: &[Coin],
) -> AnyResult<AppResponse>
fn execute_contract<T: Serialize + Debug>( &mut self, sender: Addr, contract_addr: Addr, msg: &T, send_funds: &[Coin], ) -> AnyResult<AppResponse>
Source§fn migrate_contract<T: Serialize>(
&mut self,
sender: Addr,
contract_addr: Addr,
msg: &T,
new_code_id: u64,
) -> AnyResult<AppResponse>
fn migrate_contract<T: Serialize>( &mut self, sender: Addr, contract_addr: Addr, msg: &T, new_code_id: u64, ) -> AnyResult<AppResponse>
fn send_tokens( &mut self, sender: Addr, recipient: Addr, amount: &[Coin], ) -> AnyResult<AppResponse>
Source§impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> Querier for App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>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,
impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT> Querier for App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>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,
Source§fn raw_query(&self, bin_request: &[u8]) -> QuerierResult
fn raw_query(&self, bin_request: &[u8]) -> QuerierResult
Auto Trait Implementations§
impl<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov> Freeze for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov>
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>> !RefUnwindSafe for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov>
impl<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov> Send for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov>
impl<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov> Sync for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov>
impl<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov> Unpin for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov>
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>> !UnwindSafe for App<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request