diff --git a/.changelog/unreleased/feature/259-add-borsh-and-scale-codec.md b/.changelog/unreleased/feature/259-add-borsh-and-scale-codec.md new file mode 100644 index 00000000..d2d8f25c --- /dev/null +++ b/.changelog/unreleased/feature/259-add-borsh-and-scale-codec.md @@ -0,0 +1,2 @@ +- Add serialization and deserialization features for codec and borsh to the host + type in ics24 ([#259](https://github.com/cosmos/ibc-rs/issues/259)) \ No newline at end of file diff --git a/crates/ibc/Cargo.toml b/crates/ibc/Cargo.toml index 48ac9179..2a4cf39e 100644 --- a/crates/ibc/Cargo.toml +++ b/crates/ibc/Cargo.toml @@ -37,6 +37,8 @@ std = [ "tendermint/std", ] clock = ["tendermint/clock", "time/std"] +parity-scale-codec = ["dep:parity-scale-codec", "dep:scale-info"] +borsh = ["dep:borsh"] # This feature guards the unfinished implementation of ADR 5. val_exec_ctx = [] @@ -66,6 +68,11 @@ derive_more = { version = "0.99.17", default-features = false, features = ["from uint = { version = "0.9", default-features = false } primitive-types = { version = "0.12.0", default-features = false, features = ["serde_no_std"] } dyn-clone = "1.0.8" +## for codec encode or decode +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["full"], optional = true } +scale-info = { version = "2.1.2", default-features = false, features = ["derive"], optional = true } +## for borsh encode or decode +borsh = {version = "0.9.3", default-features = false, optional = true } [dependencies.tendermint] version = "0.28" diff --git a/crates/ibc/src/core/ics02_client/client_type.rs b/crates/ibc/src/core/ics02_client/client_type.rs index 62545331..d1059899 100644 --- a/crates/ibc/src/core/ics02_client/client_type.rs +++ b/crates/ibc/src/core/ics02_client/client_type.rs @@ -2,6 +2,18 @@ use crate::prelude::*; use core::fmt::{Display, Error as FmtError, Formatter}; use serde_derive::{Deserialize, Serialize}; +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] /// Type of the client, depending on the specific consensus algorithm. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct ClientType(String); diff --git a/crates/ibc/src/core/ics02_client/height.rs b/crates/ibc/src/core/ics02_client/height.rs index 08d30d67..c5655c36 100644 --- a/crates/ibc/src/core/ics02_client/height.rs +++ b/crates/ibc/src/core/ics02_client/height.rs @@ -12,6 +12,18 @@ use ibc_proto::ibc::core::client::v1::Height as RawHeight; use crate::core::ics02_client::error::ClientError; +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Height { /// Previously known as "epoch" diff --git a/crates/ibc/src/core/ics02_client/trust_threshold.rs b/crates/ibc/src/core/ics02_client/trust_threshold.rs index dd6cfeb6..d5ada107 100644 --- a/crates/ibc/src/core/ics02_client/trust_threshold.rs +++ b/crates/ibc/src/core/ics02_client/trust_threshold.rs @@ -23,6 +23,18 @@ use crate::core::ics02_client::error::ClientError; /// A typical trust threshold is 1/3 in practice. /// This type accepts even a value of 0, (numerator = 0, denominator = 0), /// which is used in the client state of an upgrading client. +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct TrustThreshold { numerator: u64, diff --git a/crates/ibc/src/core/ics03_connection/connection.rs b/crates/ibc/src/core/ics03_connection/connection.rs index 8c7fd76e..66289e7a 100644 --- a/crates/ibc/src/core/ics03_connection/connection.rs +++ b/crates/ibc/src/core/ics03_connection/connection.rs @@ -23,6 +23,18 @@ use crate::core::ics24_host::error::ValidationError; use crate::core::ics24_host::identifier::{ClientId, ConnectionId}; use crate::timestamp::ZERO_DURATION; +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct IdentifiedConnectionEnd { pub connection_id: ConnectionId, @@ -88,6 +100,10 @@ impl From for RawIdentifiedConnection { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive(parity_scale_codec::Encode, parity_scale_codec::Decode,) +)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct ConnectionEnd { pub state: State, @@ -97,6 +113,99 @@ pub struct ConnectionEnd { delay_period: Duration, } +mod sealed { + use super::*; + + #[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) + )] + struct InnerConnectionEnd { + pub state: State, + client_id: ClientId, + counterparty: Counterparty, + versions: Vec, + delay_period_secs: u64, + delay_period_nanos: u32, + } + + impl From for ConnectionEnd { + fn from(value: InnerConnectionEnd) -> Self { + Self { + state: value.state, + client_id: value.client_id, + counterparty: value.counterparty, + versions: value.versions, + delay_period: Duration::new(value.delay_period_secs, value.delay_period_nanos), + } + } + } + + impl From for InnerConnectionEnd { + fn from(value: ConnectionEnd) -> Self { + Self { + state: value.state, + client_id: value.client_id, + counterparty: value.counterparty, + versions: value.versions, + delay_period_secs: value.delay_period.as_secs(), + delay_period_nanos: value.delay_period.subsec_nanos(), + } + } + } + + #[cfg(feature = "borsh")] + impl borsh::BorshSerialize for ConnectionEnd { + fn serialize( + &self, + writer: &mut W, + ) -> borsh::maybestd::io::Result<()> { + let value = InnerConnectionEnd::from(self.clone()); + borsh::BorshSerialize::serialize(&value, writer) + } + } + + #[cfg(feature = "borsh")] + impl borsh::BorshDeserialize for ConnectionEnd { + fn deserialize(buf: &mut &[u8]) -> borsh::maybestd::io::Result { + let result = InnerConnectionEnd::deserialize(buf)?; + Ok(ConnectionEnd::from(result)) + } + } + + #[cfg(feature = "parity-scale-codec")] + impl scale_info::TypeInfo for ConnectionEnd { + type Identity = Self; + + fn type_info() -> scale_info::Type { + scale_info::Type::builder() + .path(scale_info::Path::new("ConnectionEnd", module_path!())) + .composite( + scale_info::build::Fields::named() + .field(|f| f.ty::().name("state").type_name("State")) + .field(|f| f.ty::().name("client_id").type_name("ClientId")) + .field(|f| { + f.ty::() + .name("counterparty") + .type_name("Counterparty") + }) + .field(|f| { + f.ty::() + .name("counterparty") + .type_name("Counterparty") + }) + .field(|f| { + f.ty::>() + .name("versions") + .type_name("Vec") + }) + .field(|f| f.ty::().name("delay_period_secs").type_name("u64")) + .field(|f| f.ty::().name("delay_period_nanos").type_name("u32")), + ) + } + } +} + impl Default for ConnectionEnd { fn default() -> Self { Self { @@ -247,6 +356,18 @@ impl ConnectionEnd { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Counterparty { client_id: ClientId, @@ -329,12 +450,24 @@ impl Counterparty { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum State { - Uninitialized = 0, - Init = 1, - TryOpen = 2, - Open = 3, + Uninitialized = 0isize, + Init = 1isize, + TryOpen = 2isize, + Open = 3isize, } impl State { diff --git a/crates/ibc/src/core/ics03_connection/version.rs b/crates/ibc/src/core/ics03_connection/version.rs index 6f188599..368c5a8d 100644 --- a/crates/ibc/src/core/ics03_connection/version.rs +++ b/crates/ibc/src/core/ics03_connection/version.rs @@ -11,6 +11,18 @@ use crate::core::ics03_connection::error::ConnectionError; use crate::core::ics04_channel::channel::Order; /// Stores the identifier and the features supported by a version +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Version { /// unique version identifier diff --git a/crates/ibc/src/core/ics04_channel/channel.rs b/crates/ibc/src/core/ics04_channel/channel.rs index 2ddf222a..d217c9a5 100644 --- a/crates/ibc/src/core/ics04_channel/channel.rs +++ b/crates/ibc/src/core/ics04_channel/channel.rs @@ -15,6 +15,18 @@ use ibc_proto::ibc::core::channel::v1::{ use crate::core::ics04_channel::{error::ChannelError, Version}; use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId}; +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct IdentifiedChannelEnd { pub port_id: PortId, @@ -73,6 +85,18 @@ impl From for RawIdentifiedChannel { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct ChannelEnd { pub state: State, @@ -250,6 +274,18 @@ impl ChannelEnd { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct Counterparty { pub port_id: PortId, @@ -323,11 +359,23 @@ impl From for RawCounterparty { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)] pub enum Order { - None = 0, - Unordered = 1, - Ordered = 2, + None = 0isize, + Unordered = 1isize, + Ordered = 2isize, } impl Default for Order { @@ -381,13 +429,25 @@ impl FromStr for Order { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum State { - Uninitialized = 0, - Init = 1, - TryOpen = 2, - Open = 3, - Closed = 4, + Uninitialized = 0isize, + Init = 1isize, + TryOpen = 2isize, + Open = 3isize, + Closed = 4isize, } impl State { diff --git a/crates/ibc/src/core/ics04_channel/commitment.rs b/crates/ibc/src/core/ics04_channel/commitment.rs index 62f13bc4..b332949d 100644 --- a/crates/ibc/src/core/ics04_channel/commitment.rs +++ b/crates/ibc/src/core/ics04_channel/commitment.rs @@ -3,6 +3,18 @@ use crate::prelude::*; use serde_derive::{Deserialize, Serialize}; /// Packet commitment +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct PacketCommitment(Vec); @@ -25,6 +37,18 @@ impl From> for PacketCommitment { } /// Acknowledgement commitment to be stored +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct AcknowledgementCommitment(Vec); diff --git a/crates/ibc/src/core/ics04_channel/packet.rs b/crates/ibc/src/core/ics04_channel/packet.rs index fde42440..e128bc97 100644 --- a/crates/ibc/src/core/ics04_channel/packet.rs +++ b/crates/ibc/src/core/ics04_channel/packet.rs @@ -52,6 +52,18 @@ impl core::fmt::Display for PacketMsgType { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] /// The sequence number of a packet enforces ordering among packets from the same source. #[derive( Copy, Clone, Debug, Default, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize, @@ -99,6 +111,18 @@ impl core::fmt::Display for Sequence { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Default, Hash, PartialEq, Eq, Deserialize, Serialize)] pub struct Packet { pub sequence: Sequence, diff --git a/crates/ibc/src/core/ics04_channel/timeout.rs b/crates/ibc/src/core/ics04_channel/timeout.rs index 12dcc324..803fd0b0 100644 --- a/crates/ibc/src/core/ics04_channel/timeout.rs +++ b/crates/ibc/src/core/ics04_channel/timeout.rs @@ -17,6 +17,18 @@ use crate::prelude::*; /// is legal and meaningful, even though the Tendermint spec rejects this height /// as invalid. Thus, it must be parsed specially, where this special case means /// "no timeout". +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] pub enum TimeoutHeight { Never, diff --git a/crates/ibc/src/core/ics04_channel/version.rs b/crates/ibc/src/core/ics04_channel/version.rs index 68bbbc11..9f9f4db8 100644 --- a/crates/ibc/src/core/ics04_channel/version.rs +++ b/crates/ibc/src/core/ics04_channel/version.rs @@ -15,6 +15,18 @@ use crate::prelude::*; /// This field is opaque to the core IBC protocol. /// No explicit validation is necessary, and the /// spec (v1) currently allows empty strings. +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] 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 a74816f5..580b6974 100644 --- a/crates/ibc/src/core/ics23_commitment/commitment.rs +++ b/crates/ibc/src/core/ics23_commitment/commitment.rs @@ -109,6 +109,18 @@ impl TryFrom for RawMerkleProof { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, PartialEq, Eq, Hash, Deserialize, 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 fe1c522d..c0d4204b 100644 --- a/crates/ibc/src/core/ics24_host/identifier.rs +++ b/crates/ibc/src/core/ics24_host/identifier.rs @@ -18,6 +18,18 @@ use crate::prelude::*; /// See: . /// /// Also, contrast with tendermint-rs `ChainId` type. +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(from = "tendermint::chain::Id", into = "tendermint::chain::Id")] pub struct ChainId { @@ -162,6 +174,18 @@ impl From for ChainId { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Into)] pub struct ClientId(String); @@ -229,6 +253,18 @@ impl PartialEq for ClientId { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct ConnectionId(String); @@ -299,6 +335,18 @@ impl PartialEq for ConnectionId { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct PortId(String); @@ -346,6 +394,18 @@ impl Default for PortId { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct ChannelId(String); @@ -420,6 +480,18 @@ impl PartialEq for ChannelId { } } +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] /// A pair of [`PortId`] and [`ChannelId`] are used together for sending IBC packets. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct PortChannelId { diff --git a/crates/ibc/src/core/ics26_routing/context.rs b/crates/ibc/src/core/ics26_routing/context.rs index 3e5a677a..54ba93ff 100644 --- a/crates/ibc/src/core/ics26_routing/context.rs +++ b/crates/ibc/src/core/ics26_routing/context.rs @@ -46,6 +46,18 @@ pub trait RouterContext: #[derive(Debug, PartialEq, Eq)] pub struct InvalidModuleId; +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize)] pub struct ModuleId(String); diff --git a/crates/ibc/src/mock/context.rs b/crates/ibc/src/mock/context.rs index 05b48096..6ffffae1 100644 --- a/crates/ibc/src/mock/context.rs +++ b/crates/ibc/src/mock/context.rs @@ -1879,7 +1879,7 @@ mod tests { _relayer: &Signer, ) -> OnRecvPacketAck { OnRecvPacketAck::Successful( - Box::new(MockAck::default()), + Box::::default(), Box::new(|module| { let module = module.downcast_mut::().unwrap(); module.counter += 1; diff --git a/crates/ibc/src/signer.rs b/crates/ibc/src/signer.rs index ee273ed4..031f30c3 100644 --- a/crates/ibc/src/signer.rs +++ b/crates/ibc/src/signer.rs @@ -14,6 +14,18 @@ pub enum SignerError { #[cfg(feature = "std")] impl std::error::Error for SignerError {} +#[cfg_attr( + feature = "parity-scale-codec", + derive( + parity_scale_codec::Encode, + parity_scale_codec::Decode, + scale_info::TypeInfo + ) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh::BorshSerialize, borsh::BorshDeserialize) +)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Display)] pub struct Signer(String); diff --git a/crates/ibc/src/timestamp.rs b/crates/ibc/src/timestamp.rs index 191a11d2..5e2810c4 100644 --- a/crates/ibc/src/timestamp.rs +++ b/crates/ibc/src/timestamp.rs @@ -26,6 +26,71 @@ pub struct Timestamp { time: Option