Skip to content

Commit b78a776

Browse files
authored
restore serialize impls for ClientState, ChannelEnd, ConnectionEnd (#34)
* add Serialize and Deserialize for ClientState * add Serialize and Deserialize for ConnectionEnd * add ChannelEnd::Serialize and ChannelEnd::deserialize
1 parent e512c6f commit b78a776

File tree

10 files changed

+19
-0
lines changed

10 files changed

+19
-0
lines changed

crates/ibc-types-core-channel/src/channel.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use ibc_types_core_connection::ConnectionId;
1414
use crate::{ChannelError, ChannelId, PortId, Version};
1515

1616
#[derive(Clone, Debug, PartialEq, Eq)]
17+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1718
pub struct IdentifiedChannelEnd {
1819
pub port_id: PortId,
1920
pub channel_id: ChannelId,
@@ -72,6 +73,7 @@ impl From<IdentifiedChannelEnd> for RawIdentifiedChannel {
7273
}
7374

7475
#[derive(Clone, Debug, PartialEq, Eq)]
76+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7577
pub struct ChannelEnd {
7678
pub state: State,
7779
pub ordering: Order,
@@ -238,6 +240,7 @@ impl ChannelEnd {
238240
}
239241

240242
#[derive(Clone, Debug, Default, PartialEq, Eq)]
243+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
241244
pub struct Counterparty {
242245
pub port_id: PortId,
243246
pub channel_id: Option<ChannelId>,
@@ -320,6 +323,7 @@ impl From<Counterparty> for RawCounterparty {
320323
}
321324

322325
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
326+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
323327
pub enum Order {
324328
None = 0isize,
325329
Unordered = 1isize,
@@ -378,6 +382,7 @@ impl FromStr for Order {
378382
}
379383

380384
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
385+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
381386
pub enum State {
382387
Uninitialized = 0isize,
383388
Init = 1isize,

crates/ibc-types-core-channel/src/identifier.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use ibc_types_identifier::{
1010
use crate::prelude::*;
1111

1212
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
13+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1314
pub struct PortId(pub String);
1415

1516
impl PortId {
@@ -57,6 +58,7 @@ impl Default for PortId {
5758
}
5859

5960
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
61+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6062
pub struct ChannelId(pub String);
6163

6264
impl ChannelId {

crates/ibc-types-core-channel/src/version.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::prelude::*;
1414
/// No explicit validation is necessary, and the
1515
/// spec (v1) currently allows empty strings.
1616
#[derive(Clone, Debug, PartialEq, Eq)]
17+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1718
pub struct Version(pub String);
1819

1920
impl Version {

crates/ibc-types-core-client/src/client_id.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::{client_type::ClientType, prelude::*};
1414
/// derived from the client type `ctype`, and a monotonically increasing
1515
/// `counter`; these are separated by a dash "-".
1616
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Into)]
17+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1718
pub struct ClientId(pub(crate) String);
1819

1920
impl ClientId {

crates/ibc-types-core-client/src/height.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::error::Error;
1212

1313
/// An IBC height, containing a revision number (epoch) and a revision height (block height).
1414
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
15+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1516
pub struct Height {
1617
/// Previously known as "epoch"
1718
pub revision_number: u64,

crates/ibc-types-core-connection/src/connection.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use crate::{ConnectionError, ConnectionId, Version};
2222

2323
//#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2424
#[derive(Clone, Debug, PartialEq, Eq)]
25+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2526
pub struct IdentifiedConnectionEnd {
2627
pub connection_id: ConnectionId,
2728
pub connection_end: ConnectionEnd,
@@ -93,6 +94,7 @@ impl From<IdentifiedConnectionEnd> for RawIdentifiedConnection {
9394

9495
//#[derive(Clone, Debug, PartialEq, Eq, Hash)]
9596
#[derive(Clone, Debug, PartialEq, Eq)]
97+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9698
pub struct ConnectionEnd {
9799
pub state: State,
98100
pub client_id: ClientId,
@@ -190,6 +192,7 @@ impl ConnectionEnd {
190192
}
191193

192194
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
195+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
193196
pub struct Counterparty {
194197
pub client_id: ClientId,
195198
pub connection_id: Option<ConnectionId>,
@@ -243,6 +246,7 @@ impl From<Counterparty> for RawCounterparty {
243246
}
244247

245248
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
249+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
246250
pub enum State {
247251
Uninitialized = 0isize,
248252
Init = 1isize,

crates/ibc-types-core-connection/src/identifier.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::prelude::*;
1818
///
1919
/// Also, contrast with tendermint-rs `ChainId` type.
2020
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
21+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2122
pub struct ChainId {
2223
pub id: String,
2324
pub version: u64,
@@ -159,6 +160,7 @@ impl From<String> for ChainId {
159160
}
160161

161162
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
163+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
162164
pub struct ConnectionId(pub String);
163165

164166
impl ConnectionId {

crates/ibc-types-core-connection/src/version.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::ConnectionError;
1010

1111
/// Stores the identifier and the features supported by a version
1212
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
13+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1314
pub struct Version {
1415
/// unique version identifier
1516
pub identifier: String,

crates/ibc-types-lightclients-tendermint/src/client_state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use crate::{Error, TrustThreshold};
2828
pub const TENDERMINT_CLIENT_STATE_TYPE_URL: &str = "/ibc.lightclients.tendermint.v1.ClientState";
2929

3030
#[derive(Clone, Debug, PartialEq)]
31+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3132
pub struct ClientState {
3233
pub chain_id: ChainId,
3334
pub trust_level: TrustThreshold,

crates/ibc-types-lightclients-tendermint/src/trust_threshold.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::error::Error;
2020
/// This type accepts even a value of 0, (numerator = 0, denominator = 0),
2121
/// which is used in the client state of an upgrading client.
2222
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
23+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2324
pub struct TrustThreshold {
2425
pub numerator: u64,
2526
pub denominator: u64,

0 commit comments

Comments
 (0)