diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..34e09decd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog + +## v0.2.0 (pre-release) + +- Remove unused constraints in `HasTimestampType::Timestamp`. [(#428)](https://github.com/informalsystems/hermes-sdk/pull/428) +- Update the `header` field in `CosmosUpdateClientMessage` to use `prost_types::Any` instead of `ibc_proto::Any`. [(#428)](https://github.com/informalsystems/hermes-sdk/pull/428) +- Generalize the `CreateClientMessageBuilder` instance `BuildCosmosCreateClientMessage` to `BuildAnyCreateClientMessage`, and allows generic `CreateClientPayload` that has `client_state: Counterparty::ClientState` and `consensus_state: Counterparty::ConsensusState` fields. [(#428)](https://github.com/informalsystems/hermes-sdk/pull/428) +- Rename the `ProvideCreateClientMessageOptionsType` instance in Cosmos from `ProvideCosmosCreateClientSettings` to `ProvideNoCreateClientMessageOptionsType`, with `CreateClientMessageOptions = ()`. [(#428)](https://github.com/informalsystems/hermes-sdk/pull/428) + +## v0.1.0 (2024-09-03) + +- Initial release of Hermes SDK crates on crates.io. \ No newline at end of file diff --git a/crates/cosmos/cosmos-chain-components/src/components/cosmos_to_cosmos.rs b/crates/cosmos/cosmos-chain-components/src/components/cosmos_to_cosmos.rs index 789e07880..f3274af57 100644 --- a/crates/cosmos/cosmos-chain-components/src/components/cosmos_to_cosmos.rs +++ b/crates/cosmos/cosmos-chain-components/src/components/cosmos_to_cosmos.rs @@ -23,12 +23,12 @@ use hermes_relayer_components::chain::traits::types::create_client::CreateClient use hermes_relayer_components::chain::traits::types::ibc::CounterpartyMessageHeightGetterComponent; use crate::impls::channel::channel_handshake_message::BuildCosmosChannelHandshakeMessage; -use crate::impls::client::create_client_message::BuildCosmosCreateClientMessage; +use crate::impls::client::create_client_message::BuildAnyCreateClientMessage; use crate::impls::client::update_client_message::BuildCosmosUpdateClientMessage; use crate::impls::connection::connection_handshake_message::BuildCosmosConnectionHandshakeMessage; use crate::impls::message_height::GetCosmosCounterpartyMessageHeight; use crate::impls::queries::consensus_state_height::QueryConsensusStateHeightsFromGrpc; -use crate::impls::types::create_client_options::ProvideCosmosCreateClientSettings; +use crate::impls::types::create_client_options::ProvideNoCreateClientMessageOptionsType; define_components! { CosmosToCosmosComponents { @@ -44,9 +44,9 @@ define_components! { ]: QueryAndConvertRawConsensusState, CreateClientMessageOptionsTypeComponent: - ProvideCosmosCreateClientSettings, + ProvideNoCreateClientMessageOptionsType, CreateClientMessageBuilderComponent: - BuildCosmosCreateClientMessage, + BuildAnyCreateClientMessage, UpdateClientMessageBuilderComponent: BuildCosmosUpdateClientMessage, [ diff --git a/crates/cosmos/cosmos-chain-components/src/impls/client/create_client_message.rs b/crates/cosmos/cosmos-chain-components/src/impls/client/create_client_message.rs index cd3fad70d..c605182b2 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/client/create_client_message.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/client/create_client_message.rs @@ -1,9 +1,12 @@ -use cgp::core::error::CanRaiseError; -use cgp::core::Async; +use core::marker::PhantomData; + +use cgp::prelude::*; use hermes_encoding_components::traits::convert::CanConvert; use hermes_encoding_components::traits::has_encoding::HasDefaultEncoding; use hermes_encoding_components::types::AsBytes; use hermes_relayer_components::chain::traits::message_builders::create_client::CreateClientMessageBuilder; +use hermes_relayer_components::chain::traits::types::client_state::HasClientStateType; +use hermes_relayer_components::chain::traits::types::consensus_state::HasConsensusStateType; use hermes_relayer_components::chain::traits::types::create_client::{ HasCreateClientMessageOptionsType, HasCreateClientPayloadType, }; @@ -12,35 +15,39 @@ use prost_types::Any; use crate::traits::message::{CosmosMessage, ToCosmosMessage}; use crate::types::messages::client::create::CosmosCreateClientMessage; -use crate::types::payloads::client::CosmosCreateClientPayload; -use crate::types::tendermint::{TendermintClientState, TendermintConsensusState}; -pub struct BuildCosmosCreateClientMessage; +pub struct BuildAnyCreateClientMessage; -impl CreateClientMessageBuilder - for BuildCosmosCreateClientMessage +impl CreateClientMessageBuilder + for BuildAnyCreateClientMessage where Chain: HasMessageType + HasCreateClientMessageOptionsType + CanRaiseError, - Counterparty: HasCreateClientPayloadType + Counterparty: HasCreateClientPayloadType + + HasClientStateType + + HasConsensusStateType + HasDefaultEncoding, - Encoding: - Async + CanConvert + CanConvert, + Payload: Async + + HasField + + HasField, + Encoding: Async + + CanConvert + + CanConvert, { async fn build_create_client_message( _chain: &Chain, _options: &Chain::CreateClientMessageOptions, - payload: CosmosCreateClientPayload, + payload: Payload, ) -> Result { let encoding = Counterparty::default_encoding(); let client_state = encoding - .convert(&payload.client_state) + .convert(payload.get_field(PhantomData::)) .map_err(Chain::raise_error)?; let consensus_state = encoding - .convert(&payload.consensus_state) + .convert(payload.get_field(PhantomData::)) .map_err(Chain::raise_error)?; let message = CosmosCreateClientMessage { diff --git a/crates/cosmos/cosmos-chain-components/src/impls/client/update_client_message.rs b/crates/cosmos/cosmos-chain-components/src/impls/client/update_client_message.rs index 4ccbe9dac..3d946da19 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/client/update_client_message.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/client/update_client_message.rs @@ -2,7 +2,9 @@ use cgp::core::error::HasErrorType; use hermes_relayer_components::chain::traits::message_builders::update_client::UpdateClientMessageBuilder; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; use hermes_relayer_components::chain::traits::types::update_client::HasUpdateClientPayloadType; +use ibc_proto::google::protobuf::Any as IbcProtoAny; use ibc_relayer_types::core::ics24_host::identifier::ClientId; +use prost_types::Any; use crate::traits::message::{CosmosMessage, ToCosmosMessage}; use crate::types::messages::client::update::CosmosUpdateClientMessage; @@ -27,9 +29,14 @@ where .headers .into_iter() .map(|header| { + let header_any: IbcProtoAny = header.into(); + let message = CosmosUpdateClientMessage { client_id: client_id.clone(), - header: header.into(), + header: Any { + type_url: header_any.type_url, + value: header_any.value, + }, }; message.to_cosmos_message() diff --git a/crates/cosmos/cosmos-chain-components/src/impls/types/create_client_options.rs b/crates/cosmos/cosmos-chain-components/src/impls/types/create_client_options.rs index 64a2339ec..46a67b04d 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/types/create_client_options.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/types/create_client_options.rs @@ -15,11 +15,12 @@ where type CreateClientPayloadOptions = Settings; } +pub struct ProvideNoCreateClientMessageOptionsType; + impl ProvideCreateClientMessageOptionsType - for ProvideCosmosCreateClientSettings + for ProvideNoCreateClientMessageOptionsType where Chain: Async, - Counterparty: Async, { type CreateClientMessageOptions = (); } diff --git a/crates/cosmos/cosmos-chain-components/src/types/messages/client/update.rs b/crates/cosmos/cosmos-chain-components/src/types/messages/client/update.rs index 031ff42de..0d20ed9b1 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/messages/client/update.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/messages/client/update.rs @@ -1,7 +1,8 @@ -use ibc_proto::google::protobuf::Any; +use ibc_proto::google::protobuf::Any as IbcProtoAny; use ibc_relayer_types::core::ics24_host::identifier::ClientId; use ibc_relayer_types::signer::Signer; use prost::Message; +use prost_types::Any; use crate::methods::encode::encode_to_any; use crate::traits::message::DynCosmosMessage; @@ -28,7 +29,7 @@ pub struct ProtoMsgUpdateClient { } impl DynCosmosMessage for CosmosUpdateClientMessage { - fn encode_protobuf(&self, signer: &Signer) -> Any { + fn encode_protobuf(&self, signer: &Signer) -> IbcProtoAny { let proto_message = ProtoMsgUpdateClient { client_id: self.client_id.to_string(), client_message: Some(self.header.clone()), diff --git a/crates/cosmos/cosmos-chain-components/src/types/payloads/client.rs b/crates/cosmos/cosmos-chain-components/src/types/payloads/client.rs index 71fb314f3..e823f7829 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/payloads/client.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/payloads/client.rs @@ -1,3 +1,5 @@ +use cgp::prelude::*; + use crate::types::tendermint::{TendermintClientState, TendermintConsensusState, TendermintHeader}; #[derive(Debug)] @@ -5,7 +7,7 @@ pub struct CosmosUpdateClientPayload { pub headers: Vec, } -#[derive(Debug)] +#[derive(Debug, HasField)] pub struct CosmosCreateClientPayload { pub client_state: TendermintClientState, pub consensus_state: TendermintConsensusState, diff --git a/crates/cosmos/cosmos-wasm-relayer/src/impls/update_client_message.rs b/crates/cosmos/cosmos-wasm-relayer/src/impls/update_client_message.rs index bc8a66fd1..413f68424 100644 --- a/crates/cosmos/cosmos-wasm-relayer/src/impls/update_client_message.rs +++ b/crates/cosmos/cosmos-wasm-relayer/src/impls/update_client_message.rs @@ -6,11 +6,12 @@ use hermes_relayer_components::chain::traits::message_builders::update_client::U use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; use hermes_relayer_components::chain::traits::types::update_client::HasUpdateClientPayloadType; use ibc::clients::wasm_types::client_message::{ClientMessage, WASM_CLIENT_MESSAGE_TYPE_URL}; -use ibc_proto::google::protobuf::Any; +use ibc_proto::google::protobuf::Any as IbcProtoAny; use ibc_proto::ibc::lightclients::wasm::v1::ClientMessage as RawClientMessage; use ibc_proto::Protobuf; use ibc_relayer_types::core::ics24_host::identifier::ClientId; use prost::Message; +use prost_types::Any; pub struct BuildUpdateWasmTendermintClientMessage; @@ -31,7 +32,7 @@ where .headers .into_iter() .map(|header| { - let any_header = Any::from(header); + let any_header = IbcProtoAny::from(header); let wasm_message = ClientMessage { data: any_header.encode_to_vec(), diff --git a/crates/relayer/relayer-components/src/chain/traits/types/timestamp.rs b/crates/relayer/relayer-components/src/chain/traits/types/timestamp.rs index 623403f16..8e34cdb3b 100644 --- a/crates/relayer/relayer-components/src/chain/traits/types/timestamp.rs +++ b/crates/relayer/relayer-components/src/chain/traits/types/timestamp.rs @@ -2,8 +2,6 @@ Trait definition for [`HasTimestampType`]. */ -use alloc::borrow::ToOwned; -use core::fmt::Display; use core::time::Duration; use cgp::prelude::*; @@ -32,7 +30,7 @@ pub trait HasTimestampType: Async { concrete context implementers to decide which exact time type they would like to use. */ - type Timestamp: Ord + Display + ToOwned + Async; + type Timestamp: Ord + Async; /** Returns the amount of time elapsed from an `earlier` instant to a `later` one, diff --git a/crates/solomachine/solomachine-chain-components/src/impls/cosmos/update_client_message.rs b/crates/solomachine/solomachine-chain-components/src/impls/cosmos/update_client_message.rs index 0c5a30bcb..c226ba33e 100644 --- a/crates/solomachine/solomachine-chain-components/src/impls/cosmos/update_client_message.rs +++ b/crates/solomachine/solomachine-chain-components/src/impls/cosmos/update_client_message.rs @@ -1,6 +1,7 @@ use cgp::core::error::HasErrorType; use hermes_cosmos_chain_components::traits::message::{CosmosMessage, ToCosmosMessage}; use hermes_cosmos_chain_components::types::messages::client::update::CosmosUpdateClientMessage; +use hermes_protobuf_encoding_components::types::Any; use hermes_relayer_components::chain::traits::message_builders::update_client::UpdateClientMessageBuilder; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; use hermes_relayer_components::chain::traits::types::update_client::HasUpdateClientPayloadType; @@ -28,7 +29,10 @@ where let message = CosmosUpdateClientMessage { client_id: client_id.clone(), - header, + header: Any { + type_url: header.type_url, + value: header.value, + }, }; Ok(vec![message.to_cosmos_message()])