pub trait ContractInstance<Chain: ChainState> {
    // Required methods
    fn as_instance(&self) -> &Contract<Chain>;
    fn as_instance_mut(&mut self) -> &mut Contract<Chain>;

    // Provided methods
    fn id(&self) -> String { ... }
    fn address(&self) -> Result<Addr, CwEnvError> { ... }
    fn addr_str(&self) -> Result<String, CwEnvError> { ... }
    fn code_id(&self) -> Result<u64, CwEnvError> { ... }
    fn set_address(&self, address: &Addr) { ... }
    fn set_default_address(&mut self, address: &Addr) { ... }
    fn set_code_id(&self, code_id: u64) { ... }
    fn set_default_code_id(&mut self, code_id: u64) { ... }
    fn get_chain(&self) -> &Chain { ... }
}
Expand description

Interface to the underlying Contract struct. Implemented automatically when using our macros.

Required Methods§

source

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

Return a reference to the underlying contract instance.

source

fn as_instance_mut(&mut self) -> &mut Contract<Chain>

Return a mutable reference to the underlying contract instance.

Provided Methods§

source

fn id(&self) -> String

Returns the contract id.

source

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

Returns the contract address for this instance.

source

fn addr_str(&self) -> Result<String, CwEnvError>

Returns the contract address as a String.

source

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

Returns contract code_id.

source

fn set_address(&self, address: &Addr)

Sets the address for the contract. Useful when the contract is already initialized and not registered in the configured state file.

source

fn set_default_address(&mut self, address: &Addr)

Sets a default address for the contract. If the contract already has an address registered in the state, this won’t be used. This is mostly used to ship address with a cw-orch package.

source

fn set_code_id(&self, code_id: u64)

Sets the code_id for the contract. Useful when the contract is already initialized and not registered in the configured state file.

source

fn set_default_code_id(&mut self, code_id: u64)

Sets a default address for the contract. If the contract already has an address registered in the state, this won’t be used. This is mostly used to ship address with a cw-orch package.

source

fn get_chain(&self) -> &Chain

Returns the chain that this contract is deployed on.

Implementors§