Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
chore: reflect ibc-rs ADR010 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad-Shabani committed Mar 8, 2024
1 parent 622a3fa commit babc662
Show file tree
Hide file tree
Showing 20 changed files with 977 additions and 3,322 deletions.
2,645 changes: 208 additions & 2,437 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
"clients/sov-celestia-cw",
"modules/sov-ibc-transfer",
"modules/sov-ibc",
"mocks",
# "mocks",
]

exclude = [
Expand Down Expand Up @@ -40,15 +40,15 @@ tempfile = "3.5"
thiserror = "1.0.38"

# ibc depedenencies
ibc-core = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false, features = ["borsh","schema","serde"] }
ibc-core-client = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-core-host-cosmos = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-client-tendermint = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-client-wasm-types = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-app-transfer = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-primitives = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-query = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-testkit = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-core = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false, features = ["borsh","schema","serde"] }
ibc-core-client = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-core-host-cosmos = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-client-tendermint = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-client-wasm-types = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-app-transfer = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-primitives = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-query = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-testkit = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", rev = "1b1d7a9", default-features = false }

# cosmos dependencies
Expand Down
45 changes: 39 additions & 6 deletions clients/sov-celestia-cw/src/context/client_ctx.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,56 @@
use ibc_client_wasm_types::client_state::ClientState as WasmClientState;
use ibc_client_wasm_types::consensus_state::ConsensusState as WasmConsensusState;
use ibc_core::client::context::{ClientExecutionContext, ClientValidationContext};
use ibc_core::client::types::error::ClientError;
use ibc_core::client::types::Height;
use ibc_core::handler::types::error::ContextError;
use ibc_core::host::types::identifiers::ClientId;
use ibc_core::host::types::path::{iteration_key, ClientConsensusStatePath, ClientStatePath};
use ibc_core::host::ValidationContext;
use ibc_core::primitives::proto::Any;
use ibc_core::primitives::proto::{Any, Protobuf};
use ibc_core::primitives::Timestamp;
use prost::Message;
use sov_celestia_client::client_state::ClientState;
use sov_celestia_client::types::client_state::SovTmClientState;
use sov_celestia_client::types::consensus_state::SovTmConsensusState;

use super::Context;
use crate::types::AnyConsensusState;

impl ClientValidationContext for Context<'_> {
fn update_meta(
type ClientStateRef = ClientState;
type ConsensusStateRef = AnyConsensusState;

fn client_state(&self, _client_id: &ClientId) -> Result<Self::ClientStateRef, ContextError> {
let client_state_value = self.retrieve(ClientStatePath::leaf())?;

let any_wasm: WasmClientState = Protobuf::<Any>::decode(client_state_value.as_slice())
.map_err(|e| ClientError::Other {
description: e.to_string(),
})?;

let sov_client_state = SovTmClientState::decode_thru_any(any_wasm.data)?;

Ok(sov_client_state.into())
}

fn consensus_state(
&self,
client_cons_state_path: &ClientConsensusStatePath,
) -> Result<Self::ConsensusStateRef, ContextError> {
let consensus_state_value = self.retrieve(client_cons_state_path.leaf())?;
let any_wasm: WasmConsensusState =
Protobuf::<Any>::decode(consensus_state_value.as_slice()).map_err(|e| {
ClientError::Other {
description: e.to_string(),
}
})?;

let consensus_state = SovTmConsensusState::decode_thru_any(any_wasm.data)?;

Ok(AnyConsensusState::Sovereign(consensus_state.into()))
}

fn client_update_meta(
&self,
_client_id: &ClientId,
height: &Height,
Expand Down Expand Up @@ -43,9 +78,7 @@ impl ClientValidationContext for Context<'_> {
}

impl ClientExecutionContext for Context<'_> {
type V = <Self as ValidationContext>::V;
type AnyClientState = <Self as ValidationContext>::AnyClientState;
type AnyConsensusState = <Self as ValidationContext>::AnyConsensusState;
type ClientStateMut = ClientState;

fn store_client_state(
&mut self,
Expand Down
Loading

0 comments on commit babc662

Please sign in to comment.