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

Commit

Permalink
imp: place AnyCodec under sov-celestia-cw + reomve now unused PrettyS…
Browse files Browse the repository at this point in the history
…lice + clean-ups
  • Loading branch information
Farhad-Shabani committed Apr 13, 2024
1 parent e3d9e5a commit 9df342a
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 77 deletions.
2 changes: 1 addition & 1 deletion clients/sov-celestia-cw/src/context/client_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use ibc_core::host::types::identifiers::ClientId;
use ibc_core::host::types::path::{iteration_key, ClientConsensusStatePath, ClientStatePath};
use ibc_core::primitives::proto::{Any, Protobuf};
use ibc_core::primitives::Timestamp;
use sov_celestia_client::types::sovereign::AnyCodec;

use super::Context;
use crate::types::ClientType;
use crate::utils::AnyCodec;

impl<'a, C: ClientType<'a>> ClientValidationContext for Context<'a, C> {
type ClientStateRef = C::ClientState;
Expand Down
6 changes: 2 additions & 4 deletions clients/sov-celestia-cw/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ use ibc_core::host::types::path::{
};
use ibc_core::primitives::proto::{Any, Protobuf};
use prost::Message;
use sov_celestia_client::types::sovereign::AnyCodec;

use crate::types::{
parse_height, ClientType, ContractError, GenesisMetadata, HeightTravel, MigrationPrefix,
};
use crate::types::{ClientType, ContractError, GenesisMetadata, HeightTravel, MigrationPrefix};
use crate::utils::{parse_height, AnyCodec};

type Checksum = Vec<u8>;

Expand Down
1 change: 1 addition & 0 deletions clients/sov-celestia-cw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod context;
pub mod entrypoints;
pub mod handlers;
pub mod types;
pub mod utils;

#[cfg(test)]
pub mod tests;
3 changes: 2 additions & 1 deletion clients/sov-celestia-cw/src/tests/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ use sov_celestia_client::types::client_state::test_util::{
};
use sov_celestia_client::types::client_state::SovTmClientState;
use sov_celestia_client::types::consensus_state::SovTmConsensusState;
use sov_celestia_client::types::sovereign::{AnyCodec, Root, SovereignParamsConfig};
use sov_celestia_client::types::sovereign::{Root, SovereignParamsConfig};
use tendermint_testgen::{Generator, Validator};

use crate::entrypoints::SovTmContext;
use crate::types::{
CheckForMisbehaviourMsgRaw, ExportMetadataMsg, GenesisMetadata, InstantiateMsg, QueryMsg,
QueryResponse, StatusMsg, VerifyClientMessageRaw,
};
use crate::utils::AnyCodec;

/// Test fixture
#[derive(Clone, Debug)]
Expand Down
30 changes: 30 additions & 0 deletions clients/sov-celestia-cw/src/types/helper.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use ibc_client_wasm_types::{SUBJECT_PREFIX, SUBSTITUTE_PREFIX};

/// The MigrationPrefix enumerates the prefix type used during migration mode.
/// The migration mode is activated when there is an incoming
/// `MigrateClientStore` message. It specifies the prefix key for either the
/// subject or substitute store, or none if the migration is not active.
#[derive(Clone, Debug)]
pub enum MigrationPrefix {
Subject,
Substitute,
None,
}

impl MigrationPrefix {
pub fn key(&self) -> &[u8] {
match self {
MigrationPrefix::Subject => SUBJECT_PREFIX,
MigrationPrefix::Substitute => SUBSTITUTE_PREFIX,
MigrationPrefix::None => b"",
}
}
}

/// Travel is an enum to represent the direction of travel in the context of
/// height.
#[derive(Clone, Debug)]
pub enum HeightTravel {
Next,
Prev,
}
4 changes: 2 additions & 2 deletions clients/sov-celestia-cw/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mod client_type;
mod error;
mod helper;
mod msgs;
mod response;
mod utils;

pub use client_type::*;
pub use error::*;
pub use helper::*;
pub use msgs::*;
pub use response::*;
pub use utils::*;
1 change: 0 additions & 1 deletion clients/sov-celestia-cw/src/types/msgs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Contains the definition of the messages that can be sent to the CosmWasm contract.
use std::str::FromStr;

use cosmwasm_schema::cw_serde;
Expand Down
43 changes: 0 additions & 43 deletions clients/sov-celestia-cw/src/types/utils.rs

This file was deleted.

17 changes: 17 additions & 0 deletions clients/sov-celestia-cw/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
mod codec;

pub use codec::*;
use ibc_core::client::types::error::ClientError;
use ibc_core::client::types::Height;

/// Decodes a `Height` from a UTF-8 encoded byte array.
pub fn parse_height(encoded_height: Vec<u8>) -> Result<Height, ClientError> {
let height_str =
alloc::str::from_utf8(encoded_height.as_slice()).map_err(|e| ClientError::Other {
description: e.to_string(),
})?;

Height::try_from(height_str).map_err(|e| ClientError::Other {
description: e.to_string(),
})
}
5 changes: 0 additions & 5 deletions clients/sov-types/src/helpers/mod.rs

This file was deleted.

18 changes: 0 additions & 18 deletions clients/sov-types/src/helpers/pretty.rs

This file was deleted.

2 changes: 0 additions & 2 deletions clients/sov-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ mod aggregated_proof;
mod client_params;
mod consensus_params;
mod error;
mod helpers;

#[cfg(feature = "test-util")]
pub use aggregated_proof::test_util::*;
Expand All @@ -15,7 +14,6 @@ pub use client_params::test_util::*;
pub use client_params::{SovereignClientParams, UpgradePath};
pub use consensus_params::SovereignConsensusParams;
pub use error::*;
pub use helpers::*;

/// Re-exports Sovereign SDK light clients proto types from `sov-ibc-proto`
/// crate.
Expand Down

0 comments on commit 9df342a

Please sign in to comment.