diff --git a/.changelog/unreleased/improvements/938-add-from.md b/.changelog/unreleased/improvements/938-add-from.md new file mode 100644 index 000000000..439e48b6c --- /dev/null +++ b/.changelog/unreleased/improvements/938-add-from.md @@ -0,0 +1,2 @@ +- Add From implementation for ICS26 enum types to make it simpler + to construct the types. ([\#938](https://github.com/cosmos/ibc-rs/pull/938)) diff --git a/crates/ibc/src/core/ics02_client/msgs.rs b/crates/ibc/src/core/ics02_client/msgs.rs index 221adbe3c..22140248f 100644 --- a/crates/ibc/src/core/ics02_client/msgs.rs +++ b/crates/ibc/src/core/ics02_client/msgs.rs @@ -21,7 +21,7 @@ pub mod upgrade_client; derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, derive_more::From)] pub enum ClientMsg { CreateClient(MsgCreateClient), UpdateClient(MsgUpdateClient), diff --git a/crates/ibc/src/core/ics03_connection/msgs.rs b/crates/ibc/src/core/ics03_connection/msgs.rs index 04b3da330..0de5e6153 100644 --- a/crates/ibc/src/core/ics03_connection/msgs.rs +++ b/crates/ibc/src/core/ics03_connection/msgs.rs @@ -29,7 +29,7 @@ pub mod conn_open_try; derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, derive_more::From)] pub enum ConnectionMsg { OpenInit(MsgConnectionOpenInit), OpenTry(MsgConnectionOpenTry), diff --git a/crates/ibc/src/core/ics04_channel/msgs.rs b/crates/ibc/src/core/ics04_channel/msgs.rs index 3757f2c5f..392a0c988 100644 --- a/crates/ibc/src/core/ics04_channel/msgs.rs +++ b/crates/ibc/src/core/ics04_channel/msgs.rs @@ -36,7 +36,7 @@ use crate::core::ics24_host::identifier::PortId; derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, derive_more::From)] pub enum ChannelMsg { OpenInit(MsgChannelOpenInit), OpenTry(MsgChannelOpenTry), @@ -52,7 +52,7 @@ pub enum ChannelMsg { derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, derive_more::From)] pub enum PacketMsg { Recv(MsgRecvPacket), Ack(MsgAcknowledgement), diff --git a/crates/ibc/src/core/msgs.rs b/crates/ibc/src/core/msgs.rs index bc3642d29..311b7ad71 100644 --- a/crates/ibc/src/core/msgs.rs +++ b/crates/ibc/src/core/msgs.rs @@ -40,7 +40,7 @@ pub trait Msg: Clone { derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, derive_more::From)] pub enum MsgEnvelope { Client(ClientMsg), Connection(ConnectionMsg),