Skip to content

Commit

Permalink
use Convertible<Any>
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbguy committed Apr 28, 2024
1 parent 1a0d8eb commit a8cbf89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
11 changes: 3 additions & 8 deletions ibc-core/ics02-client/context/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ use ibc_core_host_types::path::Path;
use ibc_primitives::prelude::*;
use ibc_primitives::proto::Any;

/// Convenient trait to decode a client state from an [`Any`] type and obtain a
/// handle to the local instance of [`ClientState`].
pub trait ClientStateDecoder: Into<Any> + TryFrom<Any> {}

impl<T> ClientStateDecoder for T where T: Into<Any> + TryFrom<Any> {}
use crate::context::{ClientExecutionContext, ClientValidationContext};
use crate::Convertible;

/// `ClientState` methods needed in both validation and execution.
///
/// They do not require access to a client `ValidationContext` nor
/// `ExecutionContext`.
pub trait ClientStateCommon: ClientStateDecoder {
pub trait ClientStateCommon: Convertible<Any> {
/// Performs basic validation on the `consensus_state`.
///
/// Notably, an implementation should verify that it can properly
Expand Down Expand Up @@ -206,8 +203,6 @@ where
) -> Result<(), ClientError>;
}

use crate::context::{ClientExecutionContext, ClientValidationContext};

/// Primary client trait. Defines all the methods that clients must implement.
///
/// `ClientState` is broken up in 3 separate traits to avoid needing to use
Expand Down
8 changes: 2 additions & 6 deletions ibc-core/ics02-client/context/src/consensus_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ use ibc_primitives::prelude::*;
use ibc_primitives::proto::Any;
use ibc_primitives::Timestamp;

/// Convenient trait to decode a consensus state from an [`Any`] type and obtain
/// a handle to the local instance of [`ConsensusState`].
pub trait ConsensusStateDecoder: Into<Any> + TryFrom<Any> {}

impl<T> ConsensusStateDecoder for T where T: Into<Any> + TryFrom<Any> {}
use crate::Convertible;

/// Defines methods that all `ConsensusState`s should provide.
///
/// One can think of a "consensus state" as a pruned header, to be stored on chain. In other words,
/// a consensus state only contains the header's information needed by IBC message handlers.
pub trait ConsensusState: Send + Sync + ConsensusStateDecoder {
pub trait ConsensusState: Send + Sync + Convertible<Any> {
/// Commitment root of the consensus state, which is used for key-value pair verification.
fn root(&self) -> &CommitmentRoot;

Expand Down

0 comments on commit a8cbf89

Please sign in to comment.