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§
sourcefn as_instance(&self) -> &Contract<Chain>
fn as_instance(&self) -> &Contract<Chain>
Return a reference to the underlying contract instance.
sourcefn as_instance_mut(&mut self) -> &mut Contract<Chain>
fn as_instance_mut(&mut self) -> &mut Contract<Chain>
Return a mutable reference to the underlying contract instance.
Provided Methods§
sourcefn address(&self) -> Result<Addr, CwEnvError>
fn address(&self) -> Result<Addr, CwEnvError>
Returns the contract address for this instance.
sourcefn code_id(&self) -> Result<u64, CwEnvError>
fn code_id(&self) -> Result<u64, CwEnvError>
Returns contract code_id.
sourcefn set_address(&self, address: &Addr)
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.
sourcefn set_default_address(&mut self, address: &Addr)
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.
sourcefn set_code_id(&self, code_id: u64)
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.
sourcefn set_default_code_id(&mut self, code_id: u64)
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.