From fa07561d04fb8d850625c7574c07c6921e3cf13a Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Thu, 19 Oct 2023 07:13:25 -0700 Subject: [PATCH] chore: remove AnySchema (#930) --- .../unreleased/improvements/929-remove-anyschema.md | 2 ++ crates/ibc/Cargo.toml | 4 ++-- crates/ibc/src/core/ics02_client/msgs/create_client.rs | 2 -- crates/ibc/src/core/ics02_client/msgs/misbehaviour.rs | 1 - crates/ibc/src/core/ics02_client/msgs/update_client.rs | 1 - crates/ibc/src/core/ics02_client/msgs/upgrade_client.rs | 2 -- .../ibc/src/core/ics03_connection/msgs/conn_open_ack.rs | 1 - .../ibc/src/core/ics03_connection/msgs/conn_open_try.rs | 1 - crates/ibc/src/utils/mod.rs | 1 - crates/ibc/src/utils/schema.rs | 9 --------- 10 files changed, 4 insertions(+), 20 deletions(-) create mode 100644 .changelog/unreleased/improvements/929-remove-anyschema.md delete mode 100644 crates/ibc/src/utils/schema.rs diff --git a/.changelog/unreleased/improvements/929-remove-anyschema.md b/.changelog/unreleased/improvements/929-remove-anyschema.md new file mode 100644 index 000000000..5e3e904d2 --- /dev/null +++ b/.changelog/unreleased/improvements/929-remove-anyschema.md @@ -0,0 +1,2 @@ +- Remove `AnySchema` as `JsonSchema` derive on `Any` now accessible through + `ibc-proto-rs` ([#929](https://github.com/cosmos/ibc-rs/issues/929)) diff --git a/crates/ibc/Cargo.toml b/crates/ibc/Cargo.toml index 79723ca7c..aca555c97 100644 --- a/crates/ibc/Cargo.toml +++ b/crates/ibc/Cargo.toml @@ -42,7 +42,7 @@ borsh = ["dep:borsh", "ibc-proto/borsh"] serde = ["dep:serde", "dep:serde_derive", "serde_json", "ibc-proto/serde", "ics23/serde"] # CosmWasm message API generator compatible, should not be inside on chain code -schema = ["dep:schemars", "serde", "std"] +schema = ["dep:schemars", "ibc-proto/json-schema", "serde", "std"] # This feature grants access to development-time mocking libraries, such as `MockContext` or `MockHeader`. # Depends on the `testgen` suite for generating Tendermint light blocks. @@ -50,7 +50,7 @@ mocks = ["tendermint-testgen", "parking_lot", "typed-builder", "std"] [dependencies] # Proto definitions for all IBC-related interfaces, e.g., connections or channels. -ibc-proto = { version = "0.37.1", default-features = false, features = ["serde"] } +ibc-proto = { version = "0.37.1", default-features = false } ics23 = { version = "0.11", default-features = false, features = ["host-functions"] } time = { version = ">=0.3.0, <0.3.30", default-features = false } serde_derive = { version = "1.0.104", default-features = false, optional = true } diff --git a/crates/ibc/src/core/ics02_client/msgs/create_client.rs b/crates/ibc/src/core/ics02_client/msgs/create_client.rs index 37214c326..b292367b8 100644 --- a/crates/ibc/src/core/ics02_client/msgs/create_client.rs +++ b/crates/ibc/src/core/ics02_client/msgs/create_client.rs @@ -19,9 +19,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.client.v1.MsgCreateClient"; #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgCreateClient { - #[cfg_attr(feature = "schema", schemars(with = "crate::utils::schema::AnySchema"))] pub client_state: Any, - #[cfg_attr(feature = "schema", schemars(with = "crate::utils::schema::AnySchema"))] pub consensus_state: Any, pub signer: Signer, } diff --git a/crates/ibc/src/core/ics02_client/msgs/misbehaviour.rs b/crates/ibc/src/core/ics02_client/msgs/misbehaviour.rs index 72f49d0b2..96b3e4e68 100644 --- a/crates/ibc/src/core/ics02_client/msgs/misbehaviour.rs +++ b/crates/ibc/src/core/ics02_client/msgs/misbehaviour.rs @@ -23,7 +23,6 @@ pub struct MsgSubmitMisbehaviour { /// client unique identifier pub client_id: ClientId, /// misbehaviour used for freezing the light client - #[cfg_attr(feature = "schema", schemars(with = "crate::utils::schema::AnySchema"))] pub misbehaviour: ProtoAny, /// signer address pub signer: Signer, diff --git a/crates/ibc/src/core/ics02_client/msgs/update_client.rs b/crates/ibc/src/core/ics02_client/msgs/update_client.rs index 4d4b809c5..3995d15d2 100644 --- a/crates/ibc/src/core/ics02_client/msgs/update_client.rs +++ b/crates/ibc/src/core/ics02_client/msgs/update_client.rs @@ -24,7 +24,6 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.client.v1.MsgUpdateClient"; #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgUpdateClient { pub client_id: ClientId, - #[cfg_attr(feature = "schema", schemars(with = "crate::utils::schema::AnySchema"))] pub client_message: Any, pub signer: Signer, } diff --git a/crates/ibc/src/core/ics02_client/msgs/upgrade_client.rs b/crates/ibc/src/core/ics02_client/msgs/upgrade_client.rs index 6fdbca40e..9a3bfa444 100644 --- a/crates/ibc/src/core/ics02_client/msgs/upgrade_client.rs +++ b/crates/ibc/src/core/ics02_client/msgs/upgrade_client.rs @@ -27,11 +27,9 @@ pub struct MsgUpgradeClient { // client unique identifier pub client_id: ClientId, // Upgraded client state - #[cfg_attr(feature = "schema", schemars(with = "crate::utils::schema::AnySchema"))] pub upgraded_client_state: Any, // Upgraded consensus state, only contains enough information // to serve as a basis of trust in update logic - #[cfg_attr(feature = "schema", schemars(with = "crate::utils::schema::AnySchema"))] pub upgraded_consensus_state: Any, // proof that old chain committed to new client pub proof_upgrade_client: CommitmentProofBytes, diff --git a/crates/ibc/src/core/ics03_connection/msgs/conn_open_ack.rs b/crates/ibc/src/core/ics03_connection/msgs/conn_open_ack.rs index a470c8c10..0e9500abf 100644 --- a/crates/ibc/src/core/ics03_connection/msgs/conn_open_ack.rs +++ b/crates/ibc/src/core/ics03_connection/msgs/conn_open_ack.rs @@ -27,7 +27,6 @@ pub struct MsgConnectionOpenAck { /// ConnectionId that chain B has chosen for it's ConnectionEnd pub conn_id_on_b: ConnectionId, /// ClientState of client tracking chain A on chain B - #[cfg_attr(feature = "schema", schemars(with = "crate::utils::schema::AnySchema"))] pub client_state_of_a_on_b: Any, /// proof of ConnectionEnd stored on Chain B during ConnOpenTry pub proof_conn_end_on_b: CommitmentProofBytes, diff --git a/crates/ibc/src/core/ics03_connection/msgs/conn_open_try.rs b/crates/ibc/src/core/ics03_connection/msgs/conn_open_try.rs index ba24309f1..f69ee6016 100644 --- a/crates/ibc/src/core/ics03_connection/msgs/conn_open_try.rs +++ b/crates/ibc/src/core/ics03_connection/msgs/conn_open_try.rs @@ -25,7 +25,6 @@ pub struct MsgConnectionOpenTry { /// ClientId on B that the connection is being opened for pub client_id_on_b: ClientId, /// ClientState of client tracking chain B on chain A - #[cfg_attr(feature = "schema", schemars(with = "crate::utils::schema::AnySchema"))] pub client_state_of_b_on_a: Any, /// ClientId, ConnectionId and prefix of chain A pub counterparty: Counterparty, diff --git a/crates/ibc/src/utils/mod.rs b/crates/ibc/src/utils/mod.rs index 5cf51aed6..b4f1b623d 100644 --- a/crates/ibc/src/utils/mod.rs +++ b/crates/ibc/src/utils/mod.rs @@ -2,4 +2,3 @@ pub(crate) mod macros; pub(crate) mod pretty; -pub mod schema; diff --git a/crates/ibc/src/utils/schema.rs b/crates/ibc/src/utils/schema.rs deleted file mode 100644 index adc2e5269..000000000 --- a/crates/ibc/src/utils/schema.rs +++ /dev/null @@ -1,9 +0,0 @@ -use crate::prelude::*; - -/// Dummy type that mirrors `ibc_proto::google::protobuf::Any`. -/// Meant to be used with `#[cfg_attr(feature = "schema", schemars(with = "crate::utils::schema::AnySchema"))]` -#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -pub struct AnySchema { - pub type_url: String, - pub value: Vec, -}