Struct AppBuilder

Source
pub struct AppBuilder<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate> { /* private fields */ }
Expand description

The chain builder.

Utility structure for building a chain in stages. When particular properties are not explicitly set, then default values are used.

Implementations§

Source§

impl AppBuilder<BankKeeper, MockApi, MockStorage, FailingModule<Empty, Empty, Empty>, WasmKeeper<Empty, Empty>, StakeKeeper, DistributionKeeper, IbcFailingModule, GovFailingModule, StargateFailing>

Source

pub fn new() -> Self

Creates a builder with default components working with empty exec and query messages.

§Examples
use cw_multi_test::{no_init, AppBuilder};

let app = AppBuilder::new().build(no_init);

let sender_addr = app.api().addr_make("sender");
assert!(sender_addr.as_str().starts_with("cosmwasm1"));
Source§

impl<ExecC, QueryC> AppBuilder<BankKeeper, MockApi, MockStorage, FailingModule<ExecC, QueryC, Empty>, WasmKeeper<ExecC, QueryC>, StakeKeeper, DistributionKeeper, IbcFailingModule, GovFailingModule, StargateFailing>
where ExecC: CustomMsg + DeserializeOwned + 'static, QueryC: Debug + CustomQuery + DeserializeOwned + 'static,

Source

pub fn new_custom() -> Self

Creates builder with default components designed to work with custom exec and query messages.

Source§

impl<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT> AppBuilder<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>
where CustomT: Module, WasmT: Wasm<CustomT::ExecT, CustomT::QueryT>,

Source

pub fn with_wasm<NewWasm: Wasm<CustomT::ExecT, CustomT::QueryT>>( self, wasm: NewWasm, ) -> AppBuilder<BankT, ApiT, StorageT, CustomT, NewWasm, StakingT, DistrT, IbcT, GovT, StargateT>

Overwrites the default wasm executor.

At this point it is needed that new wasm implements some Wasm trait, but it doesn’t need to be bound to Bank or Custom yet - as those may change. The cross-components validation is done on final building.

Source

pub fn with_bank<NewBank: Bank>( self, bank: NewBank, ) -> AppBuilder<NewBank, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>

Overwrites the default bank interface.

Source

pub fn with_api<NewApi: Api>( self, api: NewApi, ) -> AppBuilder<BankT, NewApi, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>

Overwrites the default api interface.

Source

pub fn with_storage<NewStorage: Storage>( self, storage: NewStorage, ) -> AppBuilder<BankT, ApiT, NewStorage, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>

Overwrites the default storage interface.

Source

pub fn with_custom<NewCustom: Module>( self, custom: NewCustom, ) -> AppBuilder<BankT, ApiT, StorageT, NewCustom, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>

Overwrites the default handler for custom messages.

At this point it is needed that new custom implements some Module trait, but it doesn’t need to be bound to ExecC or QueryC yet - as those may change. The cross-components validation is done on final building.

Source

pub fn with_staking<NewStaking: Staking>( self, staking: NewStaking, ) -> AppBuilder<BankT, ApiT, StorageT, CustomT, WasmT, NewStaking, DistrT, IbcT, GovT, StargateT>

Overwrites the default staking interface.

Source

pub fn with_distribution<NewDistribution: Distribution>( self, distribution: NewDistribution, ) -> AppBuilder<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, NewDistribution, IbcT, GovT, StargateT>

Overwrites the default distribution interface.

Source

pub fn with_ibc<NewIbc: Ibc>( self, ibc: NewIbc, ) -> AppBuilder<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, NewIbc, GovT, StargateT>

Overwrites the default ibc interface.

If you wish to simply ignore/drop all returned IBC Messages, you can use the IbcAcceptingModule type:

builder.with_ibc(IbcAcceptingModule::new())
Source

pub fn with_gov<NewGov: Gov>( self, gov: NewGov, ) -> AppBuilder<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, NewGov, StargateT>

Overwrites the default governance module.

§Examples
use cw_multi_test::{no_init, AppBuilder, GovAcceptingModule};

let app = AppBuilder::default()
    .with_gov(GovAcceptingModule::new())
    .build(no_init);

// use the app with accepting governance module in your test
Source

pub fn with_stargate<NewStargate: Stargate>( self, stargate: NewStargate, ) -> AppBuilder<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, NewStargate>

Overwrites the default stargate interface.

Source

pub fn with_block(self, block: BlockInfo) -> Self

Overwrites the initial block.

Source

pub fn build<F>( self, init_fn: F, ) -> App<BankT, ApiT, StorageT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>
where BankT: Bank, ApiT: Api, StorageT: Storage, CustomT: Module, WasmT: Wasm<CustomT::ExecT, CustomT::QueryT>, StakingT: Staking, DistrT: Distribution, IbcT: Ibc, GovT: Gov, StargateT: Stargate, F: FnOnce(&mut Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>, &ApiT, &mut dyn Storage),

Builds the final App with initialization.

At this point all component types have to be properly related to each other.

Trait Implementations§

Source§

impl Default for AppBuilder<BankKeeper, MockApi, MockStorage, FailingModule<Empty, Empty, Empty>, WasmKeeper<Empty, Empty>, StakeKeeper, DistributionKeeper, IbcFailingModule, GovFailingModule, StargateFailing>

Source§

fn default() -> Self

Creates a chain with default settings.

§Examples
use cw_multi_test::{no_init, AppBuilder};

let app = AppBuilder::default().build(no_init);

let sender_addr = app.api().addr_make("sender");
assert!(sender_addr.as_str().starts_with("cosmwasm1"));

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate> Unpin for AppBuilder<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>
where Api: Unpin, Storage: Unpin, Bank: Unpin, Wasm: 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 AppBuilder<Bank, Api, Storage, Custom, Wasm, Staking, Distr, Ibc, Gov, Stargate>
where Api: UnwindSafe, Storage: UnwindSafe, Bank: UnwindSafe, Wasm: 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V