Struct boot_core::Contract

source ·
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>

Expose chain and state function to call them on the contract

source

pub fn new(id: impl ToString, chain: Chain) -> Self

source

pub fn get_chain(&self) -> &Chain

get_chain instead of chain to disambiguate from the std prelude .chain() method.

source

pub fn with_wasm_path(self, path: impl ToString) -> Self

source

pub fn with_mock( self, mock_contract: Box<dyn TestContract<Empty, Empty>> ) -> Self

source

pub fn set_mock(&mut self, mock_contract: Box<dyn TestContract<Empty, Empty>>)

source

pub fn with_address(self, address: Option<&Addr>) -> Self

Sets the address of the contract in the local state

source

pub fn execute<E: Serialize + Debug>( &self, msg: &E, coins: Option<&[Coin]> ) -> Result<TxResponse<Chain>, BootError>

source

pub fn instantiate<I: Serialize + Debug>( &self, msg: &I, admin: Option<&Addr>, coins: Option<&[Coin]> ) -> Result<TxResponse<Chain>, BootError>

source

pub fn upload(&mut self) -> Result<TxResponse<Chain>, BootError>

source

pub fn query<Q: Serialize + Debug, T: Serialize + DeserializeOwned + Debug>( &self, query_msg: &Q ) -> Result<T, BootError>

source

pub fn migrate<M: Serialize + Debug>( &self, migrate_msg: &M, new_code_id: u64 ) -> Result<TxResponse<Chain>, BootError>

source

pub fn address(&self) -> Result<Addr, BootError>

source

pub fn code_id(&self) -> Result<u64, BootError>

source

pub fn set_address(&self, address: &Addr)

source

pub fn set_code_id(&self, code_id: u64)

source§

impl Contract<Daemon>

source

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

source

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

source

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

source

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§

source§

impl<Chain: Clone + CwEnv> Clone for Contract<Chain>

source§

fn clone(&self) -> Contract<Chain>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<M> AsAny for Mwhere M: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for Twhere T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more