pub struct Contract<Chain: CwEnv> {
pub id: String,
/* private fields */
}
Expand description
An instance of a contract. Contains references to the execution environment (chain) and a local state (state) The state is used to store contract addresses/code-ids
Fields§
§id: String
ID of the contract, used to retrieve addr/code-id
Implementations§
source§impl<Chain: CwEnv + Clone> Contract<Chain>
impl<Chain: CwEnv + Clone> Contract<Chain>
Expose chain and state function to call them on the contract
pub fn new(id: impl ToString, chain: Chain) -> Self
sourcepub fn get_chain(&self) -> &Chain
pub fn get_chain(&self) -> &Chain
get_chain
instead of chain
to disambiguate from the std prelude .chain() method.
pub fn with_wasm_path(self, path: impl ToString) -> Self
pub fn with_mock( self, mock_contract: Box<dyn TestContract<Empty, Empty>> ) -> Self
pub fn set_mock(&mut self, mock_contract: Box<dyn TestContract<Empty, Empty>>)
sourcepub fn with_address(self, address: Option<&Addr>) -> Self
pub fn with_address(self, address: Option<&Addr>) -> Self
Sets the address of the contract in the local state
pub fn execute<E: Serialize + Debug>( &self, msg: &E, coins: Option<&[Coin]> ) -> Result<TxResponse<Chain>, BootError>
pub fn instantiate<I: Serialize + Debug>( &self, msg: &I, admin: Option<&Addr>, coins: Option<&[Coin]> ) -> Result<TxResponse<Chain>, BootError>
pub fn upload(&mut self) -> Result<TxResponse<Chain>, BootError>
pub fn query<Q: Serialize + Debug, T: Serialize + DeserializeOwned + Debug>( &self, query_msg: &Q ) -> Result<T, BootError>
pub fn migrate<M: Serialize + Debug>( &self, migrate_msg: &M, new_code_id: u64 ) -> Result<TxResponse<Chain>, BootError>
pub fn address(&self) -> Result<Addr, BootError>
pub fn code_id(&self) -> Result<u64, BootError>
pub fn set_address(&self, address: &Addr)
pub fn set_code_id(&self, code_id: u64)
source§impl Contract<Daemon>
impl Contract<Daemon>
sourcepub fn upload_if_needed(
&mut self
) -> Result<Option<TxResponse<Daemon>>, BootError>
pub fn upload_if_needed( &mut self ) -> Result<Option<TxResponse<Daemon>>, BootError>
Only upload the contract if it is not uploaded yet (checksum does not match) @TODO proper response
sourcepub fn latest_is_uploaded(&self) -> Result<bool, BootError>
pub fn latest_is_uploaded(&self) -> Result<bool, BootError>
Returns a bool whether the checksum of the wasm file matches the checksum of the previously uploaded code
sourcepub fn migrate_if_needed(
&mut self,
migrate_msg: &impl Serialize + Debug
) -> Result<Option<TxResponse<Daemon>>, BootError>
pub fn migrate_if_needed( &mut self, migrate_msg: &impl Serialize + Debug ) -> Result<Option<TxResponse<Daemon>>, BootError>
Only migrate the contract if it is not on the latest code-id yet
sourcepub fn is_running_latest(&self) -> Result<bool, BootError>
pub fn is_running_latest(&self) -> Result<bool, BootError>
Returns a bool whether the contract is running the latest uploaded code for it
Trait Implementations§
Auto Trait Implementations§
impl<Chain> !RefUnwindSafe for Contract<Chain>
impl<Chain> !Send for Contract<Chain>
impl<Chain> !Sync for Contract<Chain>
impl<Chain> Unpin for Contract<Chain>where Chain: Unpin,
impl<Chain> !UnwindSafe for Contract<Chain>
Blanket Implementations§
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request