Skip to content

Commit

Permalink
Implement From<ConsensusState>
Browse files Browse the repository at this point in the history
  • Loading branch information
seanchen1991 committed Apr 30, 2024
1 parent a680f03 commit 082dc18
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
13 changes: 7 additions & 6 deletions ibc-clients/ics07-tendermint/cw-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ crate-type = [ "cdylib", "rlib" ]

[dependencies]
# ibc dependencies
ibc-core = { workspace = true }
ibc-client-cw = { workspace = true }
ibc-client-tendermint = { workspace = true }
ibc-core = { workspace = true }
ibc-client-cw = { workspace = true }
ibc-client-tendermint = { workspace = true }
ibc-client-tendermint-types = { workspace = true }

# cosmwasm dependencies
cosmwasm-std = { workspace = true }

[features]
default = [ "std" ]
std = [
"ibc-core/std",
"ibc-client-cw/std",
"ibc-client-tendermint/std",
"ibc-core/std",
"ibc-client-cw/std",
"ibc-client-tendermint/std",
]
9 changes: 3 additions & 6 deletions ibc-clients/ics07-tendermint/src/consensus_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ impl ConsensusState {
}
}

/// Can't use [`Infallible`](core::convert::Infallible) because TryFrom<Error = ClientError> is required by
/// [`ConsensusStateDecoder`](ibc_core_client::context::consensus_state::ConsensusStateDecoder).
impl TryFrom<ConsensusState> for ConsensusStateType {
type Error = ClientError;
fn try_from(value: ConsensusState) -> Result<Self, Self::Error> {
Ok(value.0)
impl From<ConsensusState> for ConsensusStateType {
fn from(value: ConsensusState) -> Self {
value.0
}
}

Expand Down
8 changes: 8 additions & 0 deletions ibc-core/ics02-client/types/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Defines the client error type
use core::convert::Infallible;

use displaydoc::Display;
use ibc_core_commitment_types::error::CommitmentError;
use ibc_core_host_types::error::IdentifierError;
Expand Down Expand Up @@ -113,6 +115,12 @@ impl From<&'static str> for ClientError {
}
}

impl From<Infallible> for ClientError {
fn from(value: Infallible) -> Self {
match value {}
}
}

#[cfg(feature = "std")]
impl std::error::Error for ClientError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Expand Down

0 comments on commit 082dc18

Please sign in to comment.