Struct Context

Source
pub struct Context<'a, C, Q = Empty>{ /* private fields */ }
Expand description

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

Implementations§

Source§

impl<'a, C, Q> Context<'a, C, Q>

Source

pub fn new_ref(deps: Deps<'a, Q>, 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, Q>, 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: Binary)

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>, HostError>

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>, HostError>

Returns the storage of the context.

Source

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

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 obtain_checksum(&self) -> Result<Binary, HostError>

Returns the checksum of the current contract.

Source

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

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>

Source§

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

Source§

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

Called upon successful client creation and update
Source§

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

Called upon successful client creation and update
Source§

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

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<(), HostError>

Called upon successful client update. Read more
Source§

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

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, HostError>

Source§

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

Source§

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

Source§

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

Source§

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

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

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

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), HostError>

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, HostError>

Returns the current timestamp of the local chain.
Source§

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

Returns the current height of the local chain.
Source§

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

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>, HostError>

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

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

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

impl<'a, C, Q> StorageMut for Context<'a, C, Q>

Source§

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

Source§

impl<'a, C, Q> StorageRef for Context<'a, C, Q>

Source§

fn storage_ref(&self) -> &dyn Storage

Auto Trait Implementations§

§

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

§

impl<'a, C, Q = Empty> !RefUnwindSafe for Context<'a, C, Q>

§

impl<'a, C, Q = Empty> !Send for Context<'a, C, Q>

§

impl<'a, C, Q = Empty> !Sync for Context<'a, C, Q>

§

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

§

impl<'a, C, Q = Empty> !UnwindSafe for Context<'a, C, Q>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, C> Convertible<C> for T
where T: TryFrom<C> + Into<C>,

Source§

impl<T> ExtClientExecutionContext for T