From fbd3a55b6908e8c31d4fdda7bafa74f67a9eab54 Mon Sep 17 00:00:00 2001 From: Philippe Laferriere Date: Tue, 5 Sep 2023 10:59:18 -0400 Subject: [PATCH 1/3] derive JsonSchema --- crates/ibc/src/core/ics02_client/msgs.rs | 3 ++- crates/ibc/src/core/ics02_client/msgs/create_client.rs | 3 +++ crates/ibc/src/core/ics02_client/msgs/misbehaviour.rs | 2 ++ crates/ibc/src/core/ics02_client/msgs/update_client.rs | 2 ++ .../ibc/src/core/ics02_client/msgs/upgrade_client.rs | 3 +++ crates/ibc/src/core/ics03_connection/connection.rs | 1 + crates/ibc/src/core/ics03_connection/msgs.rs | 2 ++ .../src/core/ics03_connection/msgs/conn_open_ack.rs | 2 ++ .../core/ics03_connection/msgs/conn_open_confirm.rs | 1 + .../src/core/ics03_connection/msgs/conn_open_init.rs | 1 + .../src/core/ics03_connection/msgs/conn_open_try.rs | 2 ++ crates/ibc/src/core/ics03_connection/version.rs | 1 + crates/ibc/src/core/ics04_channel/acknowledgement.rs | 1 + crates/ibc/src/core/ics04_channel/channel.rs | 1 + crates/ibc/src/core/ics04_channel/msgs.rs | 4 ++++ .../ibc/src/core/ics04_channel/msgs/acknowledgement.rs | 1 + .../src/core/ics04_channel/msgs/chan_close_confirm.rs | 1 + .../ibc/src/core/ics04_channel/msgs/chan_close_init.rs | 1 + .../ibc/src/core/ics04_channel/msgs/chan_open_ack.rs | 1 + .../src/core/ics04_channel/msgs/chan_open_confirm.rs | 1 + .../ibc/src/core/ics04_channel/msgs/chan_open_init.rs | 1 + .../ibc/src/core/ics04_channel/msgs/chan_open_try.rs | 1 + crates/ibc/src/core/ics04_channel/msgs/recv_packet.rs | 1 + crates/ibc/src/core/ics04_channel/msgs/timeout.rs | 1 + .../src/core/ics04_channel/msgs/timeout_on_close.rs | 1 + crates/ibc/src/core/ics04_channel/packet.rs | 2 ++ crates/ibc/src/core/ics04_channel/version.rs | 1 + crates/ibc/src/core/ics23_commitment/commitment.rs | 2 ++ crates/ibc/src/core/ics24_host/identifier.rs | 1 + crates/ibc/src/core/msgs.rs | 1 + crates/ibc/src/core/timestamp.rs | 3 +++ crates/ibc/src/utils/mod.rs | 1 + crates/ibc/src/utils/schema.rs | 10 ++++++++++ 33 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 crates/ibc/src/utils/schema.rs diff --git a/crates/ibc/src/core/ics02_client/msgs.rs b/crates/ibc/src/core/ics02_client/msgs.rs index b1b29ac82..2b1617609 100644 --- a/crates/ibc/src/core/ics02_client/msgs.rs +++ b/crates/ibc/src/core/ics02_client/msgs.rs @@ -1,5 +1,5 @@ //! Defines the client message types that are sent to the chain by the relayer. - +use crate::prelude::*; use ibc_proto::google::protobuf::Any; use crate::core::ics02_client::msgs::create_client::MsgCreateClient; @@ -20,6 +20,7 @@ pub mod upgrade_client; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub enum ClientMsg { CreateClient(MsgCreateClient), 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 c55e8668c..3b428f90d 100644 --- a/crates/ibc/src/core/ics02_client/msgs/create_client.rs +++ b/crates/ibc/src/core/ics02_client/msgs/create_client.rs @@ -17,9 +17,12 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.client.v1.MsgCreateClient"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[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 6ab10266b..ae3fc2e69 100644 --- a/crates/ibc/src/core/ics02_client/msgs/misbehaviour.rs +++ b/crates/ibc/src/core/ics02_client/msgs/misbehaviour.rs @@ -18,11 +18,13 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.client.v1.MsgSubmitMisbehaviour"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] 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 74e365a44..d8e60ee3d 100644 --- a/crates/ibc/src/core/ics02_client/msgs/update_client.rs +++ b/crates/ibc/src/core/ics02_client/msgs/update_client.rs @@ -21,9 +21,11 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.client.v1.MsgUpdateClient"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[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 f18160f89..0b8908158 100644 --- a/crates/ibc/src/core/ics02_client/msgs/upgrade_client.rs +++ b/crates/ibc/src/core/ics02_client/msgs/upgrade_client.rs @@ -22,14 +22,17 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.client.v1.MsgUpgradeClient"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] 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/connection.rs b/crates/ibc/src/core/ics03_connection/connection.rs index 6ab1513ec..27d5339d6 100644 --- a/crates/ibc/src/core/ics03_connection/connection.rs +++ b/crates/ibc/src/core/ics03_connection/connection.rs @@ -380,6 +380,7 @@ impl ConnectionEnd { derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct Counterparty { client_id: ClientId, diff --git a/crates/ibc/src/core/ics03_connection/msgs.rs b/crates/ibc/src/core/ics03_connection/msgs.rs index 486ce3956..af6a87add 100644 --- a/crates/ibc/src/core/ics03_connection/msgs.rs +++ b/crates/ibc/src/core/ics03_connection/msgs.rs @@ -16,6 +16,7 @@ use crate::core::ics03_connection::msgs::conn_open_ack::MsgConnectionOpenAck; use crate::core::ics03_connection::msgs::conn_open_confirm::MsgConnectionOpenConfirm; use crate::core::ics03_connection::msgs::conn_open_init::MsgConnectionOpenInit; use crate::core::ics03_connection::msgs::conn_open_try::MsgConnectionOpenTry; +use crate::prelude::*; pub mod conn_open_ack; pub mod conn_open_confirm; @@ -27,6 +28,7 @@ pub mod conn_open_try; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub enum ConnectionMsg { OpenInit(MsgConnectionOpenInit), 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 5b57756f7..ade055279 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 @@ -20,6 +20,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.connection.v1.MsgConnectionOpenAck" feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgConnectionOpenAck { /// ConnectionId that chain A has chosen for it's ConnectionEnd @@ -27,6 +28,7 @@ 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_confirm.rs b/crates/ibc/src/core/ics03_connection/msgs/conn_open_confirm.rs index 4f0337a69..8a8aa809b 100644 --- a/crates/ibc/src/core/ics03_connection/msgs/conn_open_confirm.rs +++ b/crates/ibc/src/core/ics03_connection/msgs/conn_open_confirm.rs @@ -18,6 +18,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.connection.v1.MsgConnectionOpenConf feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgConnectionOpenConfirm { /// ConnectionId that chain B has chosen for it's ConnectionEnd diff --git a/crates/ibc/src/core/ics03_connection/msgs/conn_open_init.rs b/crates/ibc/src/core/ics03_connection/msgs/conn_open_init.rs index d6732f258..1b27ce8bf 100644 --- a/crates/ibc/src/core/ics03_connection/msgs/conn_open_init.rs +++ b/crates/ibc/src/core/ics03_connection/msgs/conn_open_init.rs @@ -17,6 +17,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.connection.v1.MsgConnectionOpenInit /// Per our convention, this message is sent to chain A. /// The handler will check proofs of chain B. #[derive(Clone, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct MsgConnectionOpenInit { /// ClientId on chain A that the connection is being opened for pub client_id_on_a: ClientId, 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 11f7fb884..06d87b31c 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 @@ -22,11 +22,13 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.connection.v1.MsgConnectionOpenTry" /// Per our convention, this message is sent to chain B. /// The handler will check proofs of chain A. +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] 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/core/ics03_connection/version.rs b/crates/ibc/src/core/ics03_connection/version.rs index ba6fdb9a6..9b0bc448d 100644 --- a/crates/ibc/src/core/ics03_connection/version.rs +++ b/crates/ibc/src/core/ics03_connection/version.rs @@ -25,6 +25,7 @@ use crate::core::ics04_channel::channel::Order; derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct Version { /// unique version identifier diff --git a/crates/ibc/src/core/ics04_channel/acknowledgement.rs b/crates/ibc/src/core/ics04_channel/acknowledgement.rs index 3b3ebb844..5f4e0408c 100644 --- a/crates/ibc/src/core/ics04_channel/acknowledgement.rs +++ b/crates/ibc/src/core/ics04_channel/acknowledgement.rs @@ -22,6 +22,7 @@ use crate::prelude::*; derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq, Into)] pub struct Acknowledgement(Vec); diff --git a/crates/ibc/src/core/ics04_channel/channel.rs b/crates/ibc/src/core/ics04_channel/channel.rs index 0c77c99be..3694cb0eb 100644 --- a/crates/ibc/src/core/ics04_channel/channel.rs +++ b/crates/ibc/src/core/ics04_channel/channel.rs @@ -435,6 +435,7 @@ impl From for RawCounterparty { derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Order { None = 0isize, diff --git a/crates/ibc/src/core/ics04_channel/msgs.rs b/crates/ibc/src/core/ics04_channel/msgs.rs index 728c8926c..687646a00 100644 --- a/crates/ibc/src/core/ics04_channel/msgs.rs +++ b/crates/ibc/src/core/ics04_channel/msgs.rs @@ -1,6 +1,8 @@ //! Message definitions for all ICS4 domain types: channel open & close handshake datagrams, as well //! as packets. +use crate::prelude::*; + pub(crate) mod acknowledgement; pub(crate) mod chan_close_confirm; pub(crate) mod chan_close_init; @@ -35,6 +37,7 @@ use crate::core::ics24_host::identifier::PortId; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub enum ChannelMsg { OpenInit(MsgChannelOpenInit), @@ -50,6 +53,7 @@ pub enum ChannelMsg { feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub enum PacketMsg { Recv(MsgRecvPacket), diff --git a/crates/ibc/src/core/ics04_channel/msgs/acknowledgement.rs b/crates/ibc/src/core/ics04_channel/msgs/acknowledgement.rs index 6f448d6fc..658c1c2a4 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/acknowledgement.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/acknowledgement.rs @@ -20,6 +20,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgAcknowledgement"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgAcknowledgement { pub packet: Packet, diff --git a/crates/ibc/src/core/ics04_channel/msgs/chan_close_confirm.rs b/crates/ibc/src/core/ics04_channel/msgs/chan_close_confirm.rs index c40c88c5a..5c3911cec 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/chan_close_confirm.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/chan_close_confirm.rs @@ -21,6 +21,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelCloseConfirm"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelCloseConfirm { pub port_id_on_b: PortId, diff --git a/crates/ibc/src/core/ics04_channel/msgs/chan_close_init.rs b/crates/ibc/src/core/ics04_channel/msgs/chan_close_init.rs index d3a569217..4956fb058 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/chan_close_init.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/chan_close_init.rs @@ -19,6 +19,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelCloseInit"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelCloseInit { pub port_id_on_a: PortId, diff --git a/crates/ibc/src/core/ics04_channel/msgs/chan_open_ack.rs b/crates/ibc/src/core/ics04_channel/msgs/chan_open_ack.rs index 9fca241ff..1280b909a 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/chan_open_ack.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/chan_open_ack.rs @@ -18,6 +18,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenAck"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelOpenAck { pub port_id_on_a: PortId, diff --git a/crates/ibc/src/core/ics04_channel/msgs/chan_open_confirm.rs b/crates/ibc/src/core/ics04_channel/msgs/chan_open_confirm.rs index 4bd43bd39..a5284d83d 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/chan_open_confirm.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/chan_open_confirm.rs @@ -19,6 +19,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenConfirm"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelOpenConfirm { pub port_id_on_b: PortId, diff --git a/crates/ibc/src/core/ics04_channel/msgs/chan_open_init.rs b/crates/ibc/src/core/ics04_channel/msgs/chan_open_init.rs index 08f034eb2..f726a106b 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/chan_open_init.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/chan_open_init.rs @@ -22,6 +22,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenInit"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelOpenInit { pub port_id_on_a: PortId, diff --git a/crates/ibc/src/core/ics04_channel/msgs/chan_open_try.rs b/crates/ibc/src/core/ics04_channel/msgs/chan_open_try.rs index ad0e93ca4..83637713e 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/chan_open_try.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/chan_open_try.rs @@ -23,6 +23,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenTry"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgChannelOpenTry { pub port_id_on_b: PortId, diff --git a/crates/ibc/src/core/ics04_channel/msgs/recv_packet.rs b/crates/ibc/src/core/ics04_channel/msgs/recv_packet.rs index 241c67976..beb32ac77 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/recv_packet.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/recv_packet.rs @@ -20,6 +20,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgRecvPacket"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgRecvPacket { /// The packet to be received diff --git a/crates/ibc/src/core/ics04_channel/msgs/timeout.rs b/crates/ibc/src/core/ics04_channel/msgs/timeout.rs index b3104bca3..6722df5f5 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/timeout.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/timeout.rs @@ -21,6 +21,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgTimeout"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgTimeout { pub packet: Packet, diff --git a/crates/ibc/src/core/ics04_channel/msgs/timeout_on_close.rs b/crates/ibc/src/core/ics04_channel/msgs/timeout_on_close.rs index e299d9a18..ed35a5285 100644 --- a/crates/ibc/src/core/ics04_channel/msgs/timeout_on_close.rs +++ b/crates/ibc/src/core/ics04_channel/msgs/timeout_on_close.rs @@ -19,6 +19,7 @@ pub(crate) const TYPE_URL: &str = "/ibc.core.channel.v1.MsgTimeoutOnClose"; feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgTimeoutOnClose { pub packet: Packet, diff --git a/crates/ibc/src/core/ics04_channel/packet.rs b/crates/ibc/src/core/ics04_channel/packet.rs index 91ca8fd88..c036a8e46 100644 --- a/crates/ibc/src/core/ics04_channel/packet.rs +++ b/crates/ibc/src/core/ics04_channel/packet.rs @@ -66,6 +66,7 @@ impl core::fmt::Display for PacketMsgType { derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] /// The sequence number of a packet enforces ordering among packets from the same source. #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Sequence(u64); @@ -127,6 +128,7 @@ impl core::fmt::Display for Sequence { derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Default, Hash, PartialEq, Eq)] pub struct Packet { pub seq_on_a: Sequence, diff --git a/crates/ibc/src/core/ics04_channel/version.rs b/crates/ibc/src/core/ics04_channel/version.rs index dd3e39bf7..109e7dcfb 100644 --- a/crates/ibc/src/core/ics04_channel/version.rs +++ b/crates/ibc/src/core/ics04_channel/version.rs @@ -28,6 +28,7 @@ use super::error::ChannelError; derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct Version(String); diff --git a/crates/ibc/src/core/ics23_commitment/commitment.rs b/crates/ibc/src/core/ics23_commitment/commitment.rs index b5b876b71..51bfe1d19 100644 --- a/crates/ibc/src/core/ics23_commitment/commitment.rs +++ b/crates/ibc/src/core/ics23_commitment/commitment.rs @@ -67,6 +67,7 @@ impl From> for CommitmentRoot { )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(transparent))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, PartialEq, Eq)] pub struct CommitmentProofBytes { #[cfg_attr( @@ -149,6 +150,7 @@ impl TryFrom for RawMerkleProof { derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, PartialEq, Eq, Hash, Default)] pub struct CommitmentPrefix { bytes: Vec, diff --git a/crates/ibc/src/core/ics24_host/identifier.rs b/crates/ibc/src/core/ics24_host/identifier.rs index 6ce2f4b18..9bfa1d89e 100644 --- a/crates/ibc/src/core/ics24_host/identifier.rs +++ b/crates/ibc/src/core/ics24_host/identifier.rs @@ -184,6 +184,7 @@ fn parse_chain_id_string(chain_id_str: &str) -> Result<(&str, u64), IdentifierEr derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Into)] pub struct ClientId(String); diff --git a/crates/ibc/src/core/msgs.rs b/crates/ibc/src/core/msgs.rs index 66a2c6eaf..effbd3358 100644 --- a/crates/ibc/src/core/msgs.rs +++ b/crates/ibc/src/core/msgs.rs @@ -40,6 +40,7 @@ pub trait Msg: Clone { feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq)] pub enum MsgEnvelope { Client(ClientMsg), diff --git a/crates/ibc/src/core/timestamp.rs b/crates/ibc/src/core/timestamp.rs index e0c6079fb..a951b08f6 100644 --- a/crates/ibc/src/core/timestamp.rs +++ b/crates/ibc/src/core/timestamp.rs @@ -23,8 +23,11 @@ pub const ZERO_DURATION: Duration = Duration::from_secs(0); /// represented as a `u64` Unix timestamp in nanoseconds, with 0 representing the absence /// of timestamp. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(PartialEq, Eq, Copy, Clone, Debug, Default, PartialOrd, Ord)] pub struct Timestamp { + // Note: The schema representation is the timestamp in nanoseconds (as we do with borsh). + #[cfg_attr(feature = "schema", schemars(with = "u64"))] time: Option