pub struct Contract<Chain: TxHandler, E: Serialize + Debug, I: Serialize + Debug, Q: Serialize, M: Serialize>where
TxResponse<Chain>: IndexResponse,{
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: StringID of the contract, used to retrieve addr/code-id
Implementations
sourceimpl<Chain: TxHandler + Clone, E: Serialize + Debug, I: Serialize + Debug, Q: Serialize + Debug, M: Serialize + Debug> Contract<Chain, E, I, Q, M>where
TxResponse<Chain>: IndexResponse,
impl<Chain: TxHandler + Clone, E: Serialize + Debug, I: Serialize + Debug, Q: Serialize + Debug, M: Serialize + Debug> Contract<Chain, E, I, Q, M>where
TxResponse<Chain>: IndexResponse,
Expose chain and state function to call them on the contract
pub fn new(id: impl ToString, chain: &Chain) -> Self
pub fn chain(&self) -> Chain
pub fn with_wasm_path(self, path: impl ToString) -> Self
pub fn with_mock(
self,
mock_contract: Box<dyn TestContract<Empty, Empty>>
) -> Self
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(
&self,
msg: &E,
coins: Option<&[Coin]>
) -> Result<TxResponse<Chain>, BootError>
pub fn instantiate(
&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<T: Serialize + DeserializeOwned>(
&self,
query_msg: &Q
) -> Result<T, BootError>
pub fn migrate(
&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)
Auto Trait Implementations
impl<Chain, E, I, Q, M> !RefUnwindSafe for Contract<Chain, E, I, Q, M>
impl<Chain, E, I, Q, M> !Send for Contract<Chain, E, I, Q, M>
impl<Chain, E, I, Q, M> !Sync for Contract<Chain, E, I, Q, M>
impl<Chain, E, I, Q, M> Unpin for Contract<Chain, E, I, Q, M>where
Chain: Unpin,
E: Unpin,
I: Unpin,
M: Unpin,
Q: Unpin,
impl<Chain, E, I, Q, M> !UnwindSafe for Contract<Chain, E, I, Q, M>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request