Struct ibc_client_cw::context::Context

source ·
pub struct Context<'a, C: ClientType<'a>> { /* private fields */ }
Expand description

Context is a wrapper around the deps and env that gives access to the methods under the ibc-rs Validation and Execution traits.

Implementations§

source§

impl<'a, C: ClientType<'a>> Context<'a, C>

source

pub fn new_ref(deps: Deps<'a>, env: Env) -> Result<Self, ContractError>

Constructs a new Context object with the given deps and env.

source

pub fn new_mut(deps_mut: DepsMut<'a>, env: Env) -> Result<Self, ContractError>

Constructs a new Context object with the given deps_mut and env.

source

pub fn env(&self) -> &Env

Returns the env of the context.

source

pub fn log(&self, msg: &str) -> Option<()>

Logs the given message.

source

pub fn client_id(&self) -> ClientId

Returns the client id of the context.

source

pub fn set_checksum(&mut self, checksum: Vec<u8>)

Sets the checksum of the context.

source

pub fn set_subject_prefix(&mut self)

Enables the migration mode with the subject prefix.

source

pub fn set_substitute_prefix(&mut self)

Enables the migration mode with the substitute prefix.

source

pub fn prefixed_key(&self, key: impl AsRef<[u8]>) -> Vec<u8>

Prefixes the given key with the migration prefix.

source

pub fn retrieve(&self, key: impl AsRef<[u8]>) -> Result<Vec<u8>, ClientError>

Retrieves the value of the given key.

source

pub fn insert(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>)

Inserts the given key-value pair.

source

pub fn remove(&mut self, key: impl AsRef<[u8]>)

Removes the value of the given key.

source

pub fn get_heights(&self) -> Result<Vec<Height>, ClientError>

Returns the storage of the context.

source

pub fn get_adjacent_height( &self, height: &Height, travel: HeightTravel ) -> Result<Option<Height>, ClientError>

Searches for either the earliest next or latest previous height based on the given height and travel direction.

source

pub fn client_update_time_key(&self, height: &Height) -> Vec<u8>

Returns the key for the client update time.

source

pub fn client_update_height_key(&self, height: &Height) -> Vec<u8>

Returns the key for the client update height.

source

pub fn get_metadata( &self ) -> Result<Option<Vec<GenesisMetadata>>, ContractError>

Returns the genesis metadata by iterating over the stored consensus state metadata.

source

pub fn obtain_checksum(&self) -> Result<Vec<u8>, ClientError>

Returns the checksum of the current contract.

source

pub fn encode_client_state( &self, client_state: C::ClientState ) -> Result<Vec<u8>, ClientError>

Encodes the given client state into a byte vector.

source§

impl<'a, C: ClientType<'a>> Context<'a, C>

source

pub fn instantiate( &mut self, msg: InstantiateMsg ) -> Result<Binary, ContractError>

Instantiates a new client with the given InstantiateMsg message.

source

pub fn sudo(&mut self, msg: SudoMsg) -> Result<Binary, ContractError>

Executes the given SudoMsg.

source

pub fn query(&self, msg: QueryMsg) -> Result<Binary, ContractError>

Queries the client with the given QueryMsg message.

Trait Implementations§

source§

impl<'a, C: ClientType<'a>> ClientExecutionContext for Context<'a, C>

§

type ClientStateMut = <C as ClientType<'a>>::ClientState

source§

fn store_client_state( &mut self, _client_state_path: ClientStatePath, client_state: Self::ClientStateMut ) -> Result<(), ContextError>

Called upon successful client creation and update
source§

fn store_consensus_state( &mut self, consensus_state_path: ClientConsensusStatePath, consensus_state: Self::ConsensusStateRef ) -> Result<(), ContextError>

Called upon successful client creation and update
source§

fn delete_consensus_state( &mut self, consensus_state_path: ClientConsensusStatePath ) -> Result<(), ContextError>

Delete the consensus state from the store located at the given ClientConsensusStatePath
source§

fn store_update_meta( &mut self, _client_id: ClientId, height: Height, host_timestamp: Timestamp, host_height: Height ) -> Result<(), ContextError>

Called upon successful client update. Read more
source§

fn delete_update_meta( &mut self, _client_id: ClientId, height: Height ) -> Result<(), ContextError>

Delete the update time and height associated with the client at the specified height. Read more
source§

fn client_state_mut( &self, client_id: &ClientId ) -> Result<Self::ClientStateMut, ContextError>

source§

impl<'a, C: ClientType<'a>> ClientValidationContext for Context<'a, C>

§

type ClientStateRef = <C as ClientType<'a>>::ClientState

§

type ConsensusStateRef = <C as ClientType<'a>>::ConsensusState

source§

fn client_state( &self, _client_id: &ClientId ) -> Result<Self::ClientStateRef, ContextError>

Returns the ClientState for the given identifier client_id. Read more
source§

fn consensus_state( &self, client_cons_state_path: &ClientConsensusStatePath ) -> Result<Self::ConsensusStateRef, ContextError>

Retrieve the consensus state for the given client ID at the specified height. Read more
source§

fn client_update_meta( &self, _client_id: &ClientId, height: &Height ) -> Result<(Timestamp, Height), ContextError>

Returns the timestamp and height of the host when it processed a client update request at the specified height.
source§

impl<'a, C: ClientType<'a>> ExtClientValidationContext for Context<'a, C>

source§

fn host_timestamp(&self) -> Result<Timestamp, ContextError>

Returns the current timestamp of the local chain.
source§

fn host_height(&self) -> Result<Height, ContextError>

Returns the current height of the local chain.
source§

fn consensus_state_heights( &self, _client_id: &ClientId ) -> Result<Vec<Height>, ContextError>

Returns all the heights at which a consensus state is stored.
source§

fn next_consensus_state( &self, client_id: &ClientId, height: &Height ) -> Result<Option<Self::ConsensusStateRef>, ContextError>

Search for the lowest consensus state higher than height.
source§

fn prev_consensus_state( &self, client_id: &ClientId, height: &Height ) -> Result<Option<Self::ConsensusStateRef>, ContextError>

Search for the highest consensus state lower than height.
source§

impl<'a, C: ClientType<'a>> StorageMut for Context<'a, C>

source§

fn storage_mut(&mut self) -> &mut dyn Storage

source§

impl<'a, C: ClientType<'a>> StorageRef for Context<'a, C>

source§

fn storage_ref(&self) -> &dyn Storage

Auto Trait Implementations§

§

impl<'a, C> Freeze for Context<'a, C>

§

impl<'a, C> !RefUnwindSafe for Context<'a, C>

§

impl<'a, C> !Send for Context<'a, C>

§

impl<'a, C> !Sync for Context<'a, C>

§

impl<'a, C> Unpin for Context<'a, C>
where C: Unpin,

§

impl<'a, C> !UnwindSafe for Context<'a, C>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<U> As for U

source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, C, E> Convertible<C, E> for T
where T: TryInto<C, Error = E> + From<C>,

source§

impl<T> ExtClientExecutionContext for T