From 082dc181b343335bc474300a2cfad817c0587c81 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 30 Apr 2024 14:13:23 -0500 Subject: [PATCH] Implement From --- ibc-clients/ics07-tendermint/cw-contract/Cargo.toml | 13 +++++++------ ibc-clients/ics07-tendermint/src/consensus_state.rs | 9 +++------ ibc-core/ics02-client/types/src/error.rs | 8 ++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ibc-clients/ics07-tendermint/cw-contract/Cargo.toml b/ibc-clients/ics07-tendermint/cw-contract/Cargo.toml index 8c5c35733..dca014186 100644 --- a/ibc-clients/ics07-tendermint/cw-contract/Cargo.toml +++ b/ibc-clients/ics07-tendermint/cw-contract/Cargo.toml @@ -18,9 +18,10 @@ 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 } @@ -28,7 +29,7 @@ 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", ] diff --git a/ibc-clients/ics07-tendermint/src/consensus_state.rs b/ibc-clients/ics07-tendermint/src/consensus_state.rs index 6518e29b2..e87778f37 100644 --- a/ibc-clients/ics07-tendermint/src/consensus_state.rs +++ b/ibc-clients/ics07-tendermint/src/consensus_state.rs @@ -43,12 +43,9 @@ impl ConsensusState { } } -/// Can't use [`Infallible`](core::convert::Infallible) because TryFrom is required by -/// [`ConsensusStateDecoder`](ibc_core_client::context::consensus_state::ConsensusStateDecoder). -impl TryFrom for ConsensusStateType { - type Error = ClientError; - fn try_from(value: ConsensusState) -> Result { - Ok(value.0) +impl From for ConsensusStateType { + fn from(value: ConsensusState) -> Self { + value.0 } } diff --git a/ibc-core/ics02-client/types/src/error.rs b/ibc-core/ics02-client/types/src/error.rs index 0783c906b..9eb5c51da 100644 --- a/ibc-core/ics02-client/types/src/error.rs +++ b/ibc-core/ics02-client/types/src/error.rs @@ -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; @@ -113,6 +115,12 @@ impl From<&'static str> for ClientError { } } +impl From 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)> {