pub struct Context<'a, C, Q = Empty>where
C: ClientType<'a>,
Q: CustomQuery,
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,{ /* 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>where
C: ClientType<'a>,
Q: CustomQuery,
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
impl<'a, C, Q> Context<'a, C, Q>where
C: ClientType<'a>,
Q: CustomQuery,
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
Sourcepub fn new_ref(deps: Deps<'a, Q>, env: Env) -> Result<Self, ContractError>
pub fn new_ref(deps: Deps<'a, Q>, env: Env) -> Result<Self, ContractError>
Constructs a new Context object with the given deps and env.
Sourcepub fn new_mut(
deps_mut: DepsMut<'a, Q>,
env: Env,
) -> Result<Self, ContractError>
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.
Sourcepub fn set_checksum(&mut self, checksum: Binary)
pub fn set_checksum(&mut self, checksum: Binary)
Sets the checksum of the context.
Sourcepub fn set_subject_prefix(&mut self)
pub fn set_subject_prefix(&mut self)
Enables the migration mode with the subject prefix.
Sourcepub fn set_substitute_prefix(&mut self)
pub fn set_substitute_prefix(&mut self)
Enables the migration mode with the substitute prefix.
Sourcepub fn prefixed_key(&self, key: impl AsRef<[u8]>) -> Vec<u8> ⓘ
pub fn prefixed_key(&self, key: impl AsRef<[u8]>) -> Vec<u8> ⓘ
Prefixes the given key with the migration prefix.
Sourcepub fn retrieve(&self, key: impl AsRef<[u8]>) -> Result<Vec<u8>, HostError>
pub fn retrieve(&self, key: impl AsRef<[u8]>) -> Result<Vec<u8>, HostError>
Retrieves the value of the given key.
Sourcepub fn insert(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>)
pub fn insert(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>)
Inserts the given key-value pair.
Sourcepub fn get_heights(&self) -> Result<Vec<Height>, HostError>
pub fn get_heights(&self) -> Result<Vec<Height>, HostError>
Returns the storage of the context.
Sourcepub fn get_adjacent_height(
&self,
height: &Height,
travel: HeightTravel,
) -> Result<Option<Height>, HostError>
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.
Sourcepub fn client_update_time_key(&self, height: &Height) -> Vec<u8> ⓘ
pub fn client_update_time_key(&self, height: &Height) -> Vec<u8> ⓘ
Returns the key for the client update time.
Sourcepub fn client_update_height_key(&self, height: &Height) -> Vec<u8> ⓘ
pub fn client_update_height_key(&self, height: &Height) -> Vec<u8> ⓘ
Returns the key for the client update height.
Sourcepub fn obtain_checksum(&self) -> Result<Binary, HostError>
pub fn obtain_checksum(&self) -> Result<Binary, HostError>
Returns the checksum of the current contract.
Sourcepub fn encode_client_state(
&self,
client_state: C::ClientState,
) -> Result<Vec<u8>, HostError>
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>where
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
impl<'a, C: ClientType<'a>> Context<'a, C>where
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
Sourcepub fn instantiate(
&mut self,
msg: InstantiateMsg,
) -> Result<Binary, ContractError>
pub fn instantiate( &mut self, msg: InstantiateMsg, ) -> Result<Binary, ContractError>
Instantiates a new client with the given InstantiateMsg
message.
Trait Implementations§
Source§impl<'a, C: ClientType<'a>> ClientExecutionContext for Context<'a, C>where
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
impl<'a, C: ClientType<'a>> ClientExecutionContext for Context<'a, C>where
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
type ClientStateMut = <C as ClientType<'a>>::ClientState
Source§fn store_client_state(
&mut self,
_client_state_path: ClientStatePath,
client_state: Self::ClientStateMut,
) -> Result<(), HostError>
fn store_client_state( &mut self, _client_state_path: ClientStatePath, client_state: Self::ClientStateMut, ) -> Result<(), HostError>
Source§fn store_consensus_state(
&mut self,
consensus_state_path: ClientConsensusStatePath,
consensus_state: Self::ConsensusStateRef,
) -> Result<(), HostError>
fn store_consensus_state( &mut self, consensus_state_path: ClientConsensusStatePath, consensus_state: Self::ConsensusStateRef, ) -> Result<(), HostError>
Source§fn delete_consensus_state(
&mut self,
consensus_state_path: ClientConsensusStatePath,
) -> Result<(), HostError>
fn delete_consensus_state( &mut self, consensus_state_path: ClientConsensusStatePath, ) -> Result<(), HostError>
ClientConsensusStatePath
Source§fn store_update_meta(
&mut self,
_client_id: ClientId,
height: Height,
host_timestamp: Timestamp,
host_height: Height,
) -> Result<(), HostError>
fn store_update_meta( &mut self, _client_id: ClientId, height: Height, host_timestamp: Timestamp, host_height: Height, ) -> Result<(), HostError>
Source§fn delete_update_meta(
&mut self,
_client_id: ClientId,
height: Height,
) -> Result<(), HostError>
fn delete_update_meta( &mut self, _client_id: ClientId, height: Height, ) -> Result<(), HostError>
fn client_state_mut( &self, client_id: &ClientId, ) -> Result<Self::ClientStateMut, HostError>
Source§impl<'a, C: ClientType<'a>> ClientValidationContext for Context<'a, C>where
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
impl<'a, C: ClientType<'a>> ClientValidationContext for Context<'a, C>where
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
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, HostError>
fn client_state( &self, _client_id: &ClientId, ) -> Result<Self::ClientStateRef, HostError>
client_id
. Read moreSource§fn consensus_state(
&self,
client_cons_state_path: &ClientConsensusStatePath,
) -> Result<Self::ConsensusStateRef, HostError>
fn consensus_state( &self, client_cons_state_path: &ClientConsensusStatePath, ) -> Result<Self::ConsensusStateRef, HostError>
Source§impl<'a, C: ClientType<'a>> ExtClientValidationContext for Context<'a, C>where
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
impl<'a, C: ClientType<'a>> ExtClientValidationContext for Context<'a, C>where
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
Source§fn host_timestamp(&self) -> Result<Timestamp, HostError>
fn host_timestamp(&self) -> Result<Timestamp, HostError>
Source§fn host_height(&self) -> Result<Height, HostError>
fn host_height(&self) -> Result<Height, HostError>
Source§fn consensus_state_heights(
&self,
_client_id: &ClientId,
) -> Result<Vec<Height>, HostError>
fn consensus_state_heights( &self, _client_id: &ClientId, ) -> Result<Vec<Height>, HostError>
Source§fn next_consensus_state(
&self,
client_id: &ClientId,
height: &Height,
) -> Result<Option<Self::ConsensusStateRef>, HostError>
fn next_consensus_state( &self, client_id: &ClientId, height: &Height, ) -> Result<Option<Self::ConsensusStateRef>, HostError>
height
.Source§fn prev_consensus_state(
&self,
client_id: &ClientId,
height: &Height,
) -> Result<Option<Self::ConsensusStateRef>, HostError>
fn prev_consensus_state( &self, client_id: &ClientId, height: &Height, ) -> Result<Option<Self::ConsensusStateRef>, HostError>
height
.Source§impl<'a, C, Q> StorageMut for Context<'a, C, Q>where
C: ClientType<'a>,
Q: CustomQuery,
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
impl<'a, C, Q> StorageMut for Context<'a, C, Q>where
C: ClientType<'a>,
Q: CustomQuery,
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
fn storage_mut(&mut self) -> &mut dyn Storage
Source§impl<'a, C, Q> StorageRef for Context<'a, C, Q>where
C: ClientType<'a>,
Q: CustomQuery,
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
impl<'a, C, Q> StorageRef for Context<'a, C, Q>where
C: ClientType<'a>,
Q: CustomQuery,
<C::ClientState as TryFrom<Any>>::Error: Display,
<C::ConsensusState as TryFrom<Any>>::Error: Display,
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>
impl<'a, C, Q = Empty> !UnwindSafe for Context<'a, C, Q>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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