Struct cw_multi_test::WasmKeeper
source · pub struct WasmKeeper<ExecC, QueryC> { /* private fields */ }
Expand description
A structure representing a default wasm keeper.
Implementations§
source§impl<ExecC, QueryC> WasmKeeper<ExecC, QueryC>
impl<ExecC, QueryC> WasmKeeper<ExecC, QueryC>
sourcepub fn contract_code(
&self,
code_id: u64,
) -> AnyResult<&dyn Contract<ExecC, QueryC>>
pub fn contract_code( &self, code_id: u64, ) -> AnyResult<&dyn Contract<ExecC, QueryC>>
Returns a handler to code of the contract with specified code id.
source§impl<ExecC, QueryC> WasmKeeper<ExecC, QueryC>where
ExecC: CustomMsg + DeserializeOwned + 'static,
QueryC: CustomQuery + DeserializeOwned + 'static,
impl<ExecC, QueryC> WasmKeeper<ExecC, QueryC>where
ExecC: CustomMsg + DeserializeOwned + 'static,
QueryC: CustomQuery + DeserializeOwned + 'static,
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a wasm keeper with default settings.
§Example
use cw_multi_test::{no_init, AppBuilder, WasmKeeper};
// create wasm keeper
let wasm_keeper = WasmKeeper::new();
// create and use the application with newly created wasm keeper
let mut app = AppBuilder::default().with_wasm(wasm_keeper).build(no_init);
sourcepub fn with_address_generator(
self,
address_generator: impl AddressGenerator + 'static,
) -> Self
pub fn with_address_generator( self, address_generator: impl AddressGenerator + 'static, ) -> Self
Populates an existing WasmKeeper with custom contract address generator.
§Example
use cosmwasm_std::{Addr, Api, Storage};
use cw_multi_test::{no_init, AddressGenerator, AppBuilder, WasmKeeper};
use cw_multi_test::error::AnyResult;
struct CustomAddressGenerator;
impl AddressGenerator for CustomAddressGenerator {
fn contract_address(
&self,
api: &dyn Api,
storage: &mut dyn Storage,
code_id: u64,
instance_id: u64,
) -> AnyResult<Addr> {
// here implement your address generation logic
}
}
// populate wasm with your custom address generator
let wasm_keeper = WasmKeeper::new().with_address_generator(CustomAddressGenerator);
// create and use the application with customized wasm keeper
let mut app = AppBuilder::default().with_wasm(wasm_keeper).build(no_init);
sourcepub fn with_checksum_generator(
self,
checksum_generator: impl ChecksumGenerator + 'static,
) -> Self
pub fn with_checksum_generator( self, checksum_generator: impl ChecksumGenerator + 'static, ) -> Self
Populates an existing WasmKeeper with custom checksum generator for the contract code.
§Example
use cosmwasm_std::{Addr, Checksum};
use cw_multi_test::{no_init, AppBuilder, ChecksumGenerator, WasmKeeper};
struct MyChecksumGenerator;
impl ChecksumGenerator for MyChecksumGenerator {
fn checksum(&self, creator: &Addr, code_id: u64) -> Checksum {
// here implement your custom checksum generator
}
}
// populate wasm keeper with your custom checksum generator
let wasm_keeper = WasmKeeper::new().with_checksum_generator(MyChecksumGenerator);
// create and use the application with customized wasm keeper
let mut app = AppBuilder::default().with_wasm(wasm_keeper).build(no_init);
sourcepub fn query_smart(
&self,
address: Addr,
api: &dyn Api,
storage: &dyn Storage,
querier: &dyn Querier,
block: &BlockInfo,
msg: Vec<u8>,
) -> AnyResult<Binary>
pub fn query_smart( &self, address: Addr, api: &dyn Api, storage: &dyn Storage, querier: &dyn Querier, block: &BlockInfo, msg: Vec<u8>, ) -> AnyResult<Binary>
Executes contract’s query
entry-point.
sourcepub fn query_raw(
&self,
address: Addr,
storage: &dyn Storage,
key: &[u8],
) -> Binary
pub fn query_raw( &self, address: Addr, storage: &dyn Storage, key: &[u8], ) -> Binary
Returns the value stored under specified key in contracts storage.
sourcepub fn register_contract(
&self,
api: &dyn Api,
storage: &mut dyn Storage,
code_id: u64,
creator: Addr,
admin: impl Into<Option<Addr>>,
label: String,
created: u64,
salt: impl Into<Option<Binary>>,
) -> AnyResult<Addr>
pub fn register_contract( &self, api: &dyn Api, storage: &mut dyn Storage, code_id: u64, creator: Addr, admin: impl Into<Option<Addr>>, label: String, created: u64, salt: impl Into<Option<Binary>>, ) -> AnyResult<Addr>
Creates a contract address and empty storage instance. Returns the new contract address.
You have to call init after this to set up the contract properly. These two steps are separated to have cleaner return values.
sourcepub fn call_execute(
&self,
api: &dyn Api,
storage: &mut dyn Storage,
address: Addr,
router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
block: &BlockInfo,
info: MessageInfo,
msg: Vec<u8>,
) -> AnyResult<Response<ExecC>>
pub fn call_execute( &self, api: &dyn Api, storage: &mut dyn Storage, address: Addr, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, info: MessageInfo, msg: Vec<u8>, ) -> AnyResult<Response<ExecC>>
Executes contract’s execute
entry-point.
sourcepub fn call_instantiate(
&self,
address: Addr,
api: &dyn Api,
storage: &mut dyn Storage,
router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
block: &BlockInfo,
info: MessageInfo,
msg: Vec<u8>,
) -> AnyResult<Response<ExecC>>
pub fn call_instantiate( &self, address: Addr, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, info: MessageInfo, msg: Vec<u8>, ) -> AnyResult<Response<ExecC>>
Executes contract’s instantiate
entry-point.
sourcepub fn call_reply(
&self,
address: Addr,
api: &dyn Api,
storage: &mut dyn Storage,
router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
block: &BlockInfo,
reply: Reply,
) -> AnyResult<Response<ExecC>>
pub fn call_reply( &self, address: Addr, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, reply: Reply, ) -> AnyResult<Response<ExecC>>
Executes contract’s reply
entry-point.
sourcepub fn call_sudo(
&self,
address: Addr,
api: &dyn Api,
storage: &mut dyn Storage,
router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
block: &BlockInfo,
msg: Vec<u8>,
) -> AnyResult<Response<ExecC>>
pub fn call_sudo( &self, address: Addr, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, msg: Vec<u8>, ) -> AnyResult<Response<ExecC>>
Executes contract’s sudo
entry-point.
sourcepub fn call_migrate(
&self,
address: Addr,
api: &dyn Api,
storage: &mut dyn Storage,
router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
block: &BlockInfo,
msg: Vec<u8>,
) -> AnyResult<Response<ExecC>>
pub fn call_migrate( &self, address: Addr, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, msg: Vec<u8>, ) -> AnyResult<Response<ExecC>>
Executes contract’s migrate
entry-point.
sourcepub fn save_contract(
&self,
storage: &mut dyn Storage,
address: &Addr,
contract: &ContractData,
) -> AnyResult<()>
pub fn save_contract( &self, storage: &mut dyn Storage, address: &Addr, contract: &ContractData, ) -> AnyResult<()>
Saves contract data in a storage under specified address.
Trait Implementations§
source§impl<ExecC, QueryC> Default for WasmKeeper<ExecC, QueryC>
impl<ExecC, QueryC> Default for WasmKeeper<ExecC, QueryC>
source§fn default() -> Self
fn default() -> Self
Returns the default value for WasmKeeper.
source§impl<ExecC, QueryC> Wasm<ExecC, QueryC> for WasmKeeper<ExecC, QueryC>where
ExecC: CustomMsg + DeserializeOwned + 'static,
QueryC: CustomQuery + DeserializeOwned + 'static,
impl<ExecC, QueryC> Wasm<ExecC, QueryC> for WasmKeeper<ExecC, QueryC>where
ExecC: CustomMsg + DeserializeOwned + 'static,
QueryC: CustomQuery + DeserializeOwned + 'static,
source§fn store_code(
&mut self,
creator: Addr,
code: Box<dyn Contract<ExecC, QueryC>>,
) -> u64
fn store_code( &mut self, creator: Addr, code: Box<dyn Contract<ExecC, QueryC>>, ) -> u64
Stores the contract’s code in the in-memory lookup table. Returns an identifier of the stored contract code.
source§fn store_code_with_id(
&mut self,
creator: Addr,
code_id: u64,
code: Box<dyn Contract<ExecC, QueryC>>,
) -> AnyResult<u64>
fn store_code_with_id( &mut self, creator: Addr, code_id: u64, code: Box<dyn Contract<ExecC, QueryC>>, ) -> AnyResult<u64>
Stores the contract’s code in the in-memory lookup table. Returns an identifier of the stored contract code.
source§fn duplicate_code(&mut self, code_id: u64) -> AnyResult<u64>
fn duplicate_code(&mut self, code_id: u64) -> AnyResult<u64>
Duplicates the contract’s code with specified identifier. Returns an identifier of the copy of the contract’s code.
source§fn contract_data(
&self,
storage: &dyn Storage,
address: &Addr,
) -> AnyResult<ContractData>
fn contract_data( &self, storage: &dyn Storage, address: &Addr, ) -> AnyResult<ContractData>
Returns ContractData
for the contract with specified address.
source§fn dump_wasm_raw(&self, storage: &dyn Storage, address: &Addr) -> Vec<Record>
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.
source§fn execute(
&self,
api: &dyn Api,
storage: &mut dyn Storage,
router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
block: &BlockInfo,
sender: Addr,
msg: WasmMsg,
) -> AnyResult<AppResponse>
fn execute( &self, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, sender: Addr, msg: WasmMsg, ) -> AnyResult<AppResponse>
WasmMsg
messages.source§fn query(
&self,
api: &dyn Api,
storage: &dyn Storage,
querier: &dyn Querier,
block: &BlockInfo,
request: WasmQuery,
) -> AnyResult<Binary>
fn query( &self, api: &dyn Api, storage: &dyn Storage, querier: &dyn Querier, block: &BlockInfo, request: WasmQuery, ) -> AnyResult<Binary>
WasmQuery
requests.source§fn sudo(
&self,
api: &dyn Api,
storage: &mut dyn Storage,
router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
block: &BlockInfo,
msg: WasmSudo,
) -> AnyResult<AppResponse>
fn sudo( &self, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, msg: WasmSudo, ) -> AnyResult<AppResponse>
CosmosMsg
.source§fn contract_namespace(&self, contract: &Addr) -> Vec<u8>
fn contract_namespace(&self, contract: &Addr) -> Vec<u8>
Auto Trait Implementations§
impl<ExecC, QueryC> Freeze for WasmKeeper<ExecC, QueryC>
impl<ExecC, QueryC> !RefUnwindSafe for WasmKeeper<ExecC, QueryC>
impl<ExecC, QueryC> !Send for WasmKeeper<ExecC, QueryC>
impl<ExecC, QueryC> !Sync for WasmKeeper<ExecC, QueryC>
impl<ExecC, QueryC> Unpin for WasmKeeper<ExecC, QueryC>where
QueryC: Unpin,
impl<ExecC, QueryC> !UnwindSafe for WasmKeeper<ExecC, QueryC>
Blanket Implementations§
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> 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 more