Skip to content

Commit

Permalink
feat: add From derive for ICS26 messages (#938)
Browse files Browse the repository at this point in the history
Add derive_more::From to MsgEnvelope and encapsulated enums so that
it’s easier to construct those objects without having to spell out
their names or variants.
  • Loading branch information
mina86 authored Nov 2, 2023
1 parent 553bc79 commit 599644c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/938-add-from.md
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion crates/ibc/src/core/ics02_client/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion crates/ibc/src/core/ics03_connection/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions crates/ibc/src/core/ics04_channel/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion crates/ibc/src/core/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 599644c

Please sign in to comment.