Skip to content

Commit

Permalink
ChannelOrderingAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Oct 26, 2022
1 parent b8b3fc9 commit fa89bc2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/ibc/src/core/ics04_channel/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ impl Order {
/// Yields the Order as a string
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "UNINITIALIZED",
// Note: taken from [ibc-go](https://github.com/cosmos/ibc-go/blob/e3a32a61098d463cd00b8937e18cb671bd20c6b7/modules/core/04-channel/types/channel.pb.go#L95-L97)
Self::None => "ORDER_NONE_UNSPECIFIED",
Self::Unordered => "ORDER_UNORDERED",
Self::Ordered => "ORDER_ORDERED",
}
Expand Down
16 changes: 16 additions & 0 deletions crates/ibc/src/core/ics04_channel/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::events::{IbcEvent, IbcEventType};
use crate::prelude::*;
use crate::timestamp::Timestamp;

use super::channel::Order;
use super::packet::Sequence;
use super::timeout::TimeoutHeight;
use super::Version;
Expand All @@ -33,6 +34,7 @@ pub const PKT_SRC_PORT_ATTRIBUTE_KEY: &str = "packet_src_port";
pub const PKT_SRC_CHANNEL_ATTRIBUTE_KEY: &str = "packet_src_channel";
pub const PKT_DST_PORT_ATTRIBUTE_KEY: &str = "packet_dst_port";
pub const PKT_DST_CHANNEL_ATTRIBUTE_KEY: &str = "packet_dst_channel";
pub const PKT_CHANNEL_ORDERING_ATTRIBUTE_KEY: &str = "packet_channel_ordering";
pub const PKT_TIMEOUT_HEIGHT_ATTRIBUTE_KEY: &str = "packet_timeout_height";
pub const PKT_TIMEOUT_TIMESTAMP_ATTRIBUTE_KEY: &str = "packet_timeout_timestamp";
pub const PKT_ACK_ATTRIBUTE_KEY: &str = "packet_ack";
Expand Down Expand Up @@ -632,6 +634,20 @@ impl From<SequenceAttribute> for Tag {
}
}

#[derive(Debug, From)]
struct ChannelOrderingAttribute {
order: Order,
}

impl From<ChannelOrderingAttribute> for Tag {
fn from(attr: ChannelOrderingAttribute) -> Self {
Tag {
key: PKT_CHANNEL_ORDERING_ATTRIBUTE_KEY.parse().unwrap(),
value: attr.order.as_str().parse().unwrap(),
}
}
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct SendPacket {
pub packet: Packet,
Expand Down

0 comments on commit fa89bc2

Please sign in to comment.