Skip to content

Commit

Permalink
fix(ibc): add missing dependencies for feature flags across multiple …
Browse files Browse the repository at this point in the history
…crates (#1060)

* fix: add missing dependencies for some feature flags

* fix: derive serde attr on ics20 serializer imports

* ease serde derive on ICS20 & ICS721 types

* imp: ease serde derive on ics20 and ics721 types

* nit: fix the name of v0.50.0 dir under changelog

* nit
  • Loading branch information
Farhad-Shabani authored Jan 26, 2024
1 parent 0546c6c commit 4718ca6
Show file tree
Hide file tree
Showing 32 changed files with 51 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [ibc] Add missing dependencies for some feature flags across multiple crates
([\#1059](https://github.com/cosmos/ibc-rs/issues/1059))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [ibc-apps] Ease `serde` derive on `ICS-20` and `ICS-721` types
([\#1060](https://github.com/cosmos/ibc-rs/pull/1060))
File renamed without changes.
1 change: 0 additions & 1 deletion ibc-apps/ics20-transfer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub mod types {
pub use ibc_app_transfer_types::*;
}

#[cfg(feature = "serde")]
pub mod context;
#[cfg(feature = "serde")]
pub mod handler;
Expand Down
5 changes: 3 additions & 2 deletions ibc-apps/ics20-transfer/types/src/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use core::str::FromStr;

use derive_more::{Display, From, Into};
use ibc_core::primitives::prelude::*;
#[cfg(feature = "serde")]
use ibc_core::primitives::serializers;
use primitive_types::U256;

Expand All @@ -15,8 +16,8 @@ use super::error::TokenTransferError;
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Display, From, Into)]
pub struct Amount(
#[cfg_attr(feature = "schema", schemars(with = "String"))]
#[serde(serialize_with = "serializers::serialize")]
#[serde(deserialize_with = "deserialize")]
#[cfg_attr(feature = "serde", serde(serialize_with = "serializers::serialize"))]
#[cfg_attr(feature = "serde", serde(deserialize_with = "deserialize"))]
U256,
);

Expand Down
1 change: 1 addition & 0 deletions ibc-apps/ics20-transfer/types/src/denom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use core::str::FromStr;
use derive_more::{Display, From};
use ibc_core::host::types::identifiers::{ChannelId, PortId};
use ibc_core::primitives::prelude::*;
#[cfg(feature = "serde")]
use ibc_core::primitives::serializers;
use ibc_proto::ibc::applications::transfer::v1::DenomTrace as RawDenomTrace;

Expand Down
19 changes: 5 additions & 14 deletions ibc-apps/ics20-transfer/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,18 @@
#[cfg(any(test, feature = "std"))]
extern crate std;

#[cfg(feature = "serde")]
mod amount;
#[cfg(feature = "serde")]
pub use amount::*;
#[cfg(feature = "serde")]
mod coin;
#[cfg(feature = "serde")]
pub use coin::*;
#[cfg(feature = "serde")]
mod denom;
#[cfg(feature = "serde")]
mod memo;

pub use amount::*;
pub use coin::*;
pub use denom::*;
#[cfg(feature = "serde")]
pub mod error;
pub mod events;
#[cfg(feature = "serde")]
pub mod msgs;
#[cfg(feature = "serde")]
pub mod packet;

pub mod error;
mod memo;
pub use memo::*;
/// Re-exports `U256` from `primitive-types` crate for convenience.
pub use primitive_types::U256;
Expand Down
1 change: 1 addition & 0 deletions ibc-apps/ics721-nft-transfer/types/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use derive_more::From;
use http::Uri;
use ibc_core::host::types::identifiers::{ChannelId, PortId};
use ibc_core::primitives::prelude::*;
#[cfg(feature = "serde")]
use ibc_core::primitives::serializers;
use ibc_proto::ibc::applications::nft_transfer::v1::ClassTrace as RawClassTrace;

Expand Down
6 changes: 6 additions & 0 deletions ibc-apps/ics721-nft-transfer/types/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
use core::fmt::{self, Display, Formatter};
use core::str::FromStr;

#[cfg(feature = "serde")]
use base64::prelude::BASE64_STANDARD;
#[cfg(feature = "serde")]
use base64::Engine;
use ibc_core::primitives::prelude::*;
use mime::Mime;
Expand All @@ -25,6 +27,7 @@ use crate::error::NftTransferError;
#[derive(Clone, Debug, Default, PartialEq, Eq, derive_more::From)]
pub struct Data(String);

#[cfg(feature = "serde")]
impl Data {
/// Parses the data in the format specified by ICS-721.
pub fn parse_as_ics721_data(&self) -> Result<Ics721Data, NftTransferError> {
Expand All @@ -46,6 +49,7 @@ impl FromStr for Data {
}
}

#[cfg(feature = "serde")]
impl serde::Serialize for Data {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -55,6 +59,7 @@ impl serde::Serialize for Data {
}
}

#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for Data {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
Expand Down Expand Up @@ -86,6 +91,7 @@ impl<'de> serde::Deserialize<'de> for Data {
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Ics721Data(BTreeMap<String, DataValue>);

#[cfg(feature = "serde")]
impl FromStr for Ics721Data {
type Err = NftTransferError;

Expand Down
21 changes: 6 additions & 15 deletions ibc-apps/ics721-nft-transfer/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,19 @@
#[cfg(any(test, feature = "std"))]
extern crate std;

#[cfg(feature = "serde")]
mod class;
#[cfg(feature = "serde")]
pub use class::*;
#[cfg(feature = "serde")]
mod data;
#[cfg(feature = "serde")]
pub use data::*;
#[cfg(feature = "serde")]
mod memo;
mod token;

pub mod events;
#[cfg(feature = "serde")]
pub mod msgs;
#[cfg(feature = "serde")]
pub use class::*;
pub use data::*;
pub mod packet;
#[cfg(feature = "serde")]
mod token;
#[cfg(feature = "serde")]
pub use memo::*;
pub use token::*;

pub mod error;
mod memo;
pub use memo::*;

/// Re-exports ICS-721 NFT transfer proto types from the `ibc-proto` crate.
pub mod proto {
Expand Down
6 changes: 4 additions & 2 deletions ibc-apps/ics721-nft-transfer/types/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use core::convert::TryFrom;
use base64::prelude::BASE64_STANDARD;
use base64::Engine;
use ibc_core::primitives::prelude::*;
use ibc_core::primitives::{serializers, Signer};
#[cfg(feature = "serde")]
use ibc_core::primitives::serializers;
use ibc_core::primitives::Signer;
use ibc_proto::ibc::applications::nft_transfer::v1::NonFungibleTokenPacketData as RawPacketData;

use crate::class::{ClassData, ClassUri, PrefixedClassId};
Expand All @@ -15,7 +17,7 @@ use crate::token::{TokenData, TokenIds, TokenUri};

/// Defines the structure of token transfers' packet bytes
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(
feature = "parity-scale-codec",
Expand Down
1 change: 1 addition & 0 deletions ibc-apps/ics721-nft-transfer/types/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use core::str::FromStr;

use http::Uri;
use ibc_core::primitives::prelude::*;
#[cfg(feature = "serde")]
use ibc_core::primitives::serializers;

use crate::data::Data;
Expand Down
1 change: 1 addition & 0 deletions ibc-clients/ics08-wasm/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ default = ["std"]
std = [
"ibc-core-client/std",
"ibc-core-host-types/std",
"ibc-primitives/std",
"ibc-proto/std",
"base64/std",
"serde/std"
Expand Down
5 changes: 5 additions & 0 deletions ibc-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ std = [
"ibc-core-host/std",
"ibc-core-router/std",
"ibc-core-handler/std",
"ibc-primitives/std",
]
serde = [
"ibc-core-client/serde",
Expand All @@ -46,6 +47,7 @@ serde = [
"ibc-core-host/serde",
"ibc-core-router/serde",
"ibc-core-handler/serde",
"ibc-primitives/serde",
]
borsh = [
"ibc-core-client/borsh",
Expand All @@ -55,6 +57,7 @@ borsh = [
"ibc-core-host/borsh",
"ibc-core-router/borsh",
"ibc-core-handler/borsh",
"ibc-primitives/borsh",
]
schema = [
"ibc-core-client/schema",
Expand All @@ -64,13 +67,15 @@ schema = [
"ibc-core-host/schema",
"ibc-core-router/schema",
"ibc-core-handler/schema",
"ibc-primitives/schema",
"serde",
"std"
]
parity-scale-codec = [
"ibc-core-client/parity-scale-codec",
"ibc-core-connection/parity-scale-codec",
"ibc-core-channel/parity-scale-codec",
"ibc-core-commitment-types/parity-scale-codec",
"ibc-core-host/parity-scale-codec",
"ibc-core-router/parity-scale-codec",
"ibc-core-handler/parity-scale-codec",
Expand Down
1 change: 1 addition & 0 deletions ibc-core/ics02-client/context/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ schema = [
"ibc-core-client-types/schema",
"ibc-core-host-types/schema",
"ibc-core-handler-types/schema",
"ibc-primitives/schema",
"serde",
"std"
]
Expand Down
3 changes: 2 additions & 1 deletion ibc-core/ics02-client/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ schema = [
parity-scale-codec = [
"dep:parity-scale-codec",
"dep:scale-info",
"ibc-core-commitment-types/parity-scale-codec",
"ibc-core-host-types/parity-scale-codec",
"ibc-core-commitment-types/parity-scale-codec",
"ibc-primitives/parity-scale-codec",
"ibc-proto/parity-scale-codec",
]
1 change: 1 addition & 0 deletions ibc-core/ics03-connection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ schema = [
"ibc-core-client/schema",
"ibc-core-connection-types/schema",
"ibc-core-host/schema",
"ibc-core-handler-types/schema",
"ibc-primitives/schema",
"serde",
"std"
Expand Down
2 changes: 2 additions & 0 deletions ibc-core/ics24-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ serde = [
]
schema = [
"ibc-core-client-types/schema",
"ibc-core-client-context/schema",
"ibc-core-connection-types/schema",
"ibc-core-channel-types/schema",
"ibc-core-commitment-types/schema",
Expand All @@ -73,6 +74,7 @@ schema = [
]
borsh = [
"ibc-core-client-types/borsh",
"ibc-core-client-context/borsh",
"ibc-core-connection-types/borsh",
"ibc-core-channel-types/borsh",
"ibc-core-commitment-types/borsh",
Expand Down
1 change: 1 addition & 0 deletions ibc-core/ics24-host/cosmos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ borsh = [
"dep:borsh",
"ibc-client-tendermint/borsh",
"ibc-core-client-types/borsh",
"ibc-core-client-context/borsh",
"ibc-core-connection-types/borsh",
"ibc-core-commitment-types/borsh",
"ibc-core-host-types/borsh",
Expand Down
4 changes: 4 additions & 0 deletions ibc-core/ics25-handler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ std = [
"ibc-core-host/std",
"ibc-core-router/std",
"ibc-core-handler-types/std",
"ibc-primitives/std",
]
serde = [
"ibc-core-client/serde",
Expand All @@ -46,6 +47,7 @@ serde = [
"ibc-core-host/serde",
"ibc-core-router/serde",
"ibc-core-handler-types/serde",
"ibc-primitives/serde",
]
borsh = [
"ibc-core-client/borsh",
Expand All @@ -55,6 +57,7 @@ borsh = [
"ibc-core-host/borsh",
"ibc-core-router/borsh",
"ibc-core-handler-types/borsh",
"ibc-primitives/borsh",
]
schema = [
"ibc-core-client/schema",
Expand All @@ -64,6 +67,7 @@ schema = [
"ibc-core-host/schema",
"ibc-core-router/schema",
"ibc-core-handler-types/schema",
"ibc-primitives/schema",
"serde",
"std"
]
Expand Down
3 changes: 3 additions & 0 deletions ibc-data-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ borsh = [
"ibc-core-client-types/borsh",
"ibc-core-connection-types/borsh",
"ibc-core-channel-types/borsh",
"ibc-core-commitment-types/borsh",
"ibc-core-host-types/borsh",
"ibc-core-router-types/borsh",
"ibc-core-handler-types/borsh",
Expand All @@ -73,6 +74,7 @@ schema = [
"ibc-core-client-types/schema",
"ibc-core-connection-types/schema",
"ibc-core-channel-types/schema",
"ibc-core-commitment-types/schema",
"ibc-core-host-types/schema",
"ibc-core-router-types/schema",
"ibc-core-handler-types/schema",
Expand All @@ -85,6 +87,7 @@ parity-scale-codec = [
"ibc-core-client-types/parity-scale-codec",
"ibc-core-connection-types/parity-scale-codec",
"ibc-core-channel-types/parity-scale-codec",
"ibc-core-commitment-types/parity-scale-codec",
"ibc-core-host-types/parity-scale-codec",
"ibc-core-router-types/parity-scale-codec",
"ibc-core-handler-types/parity-scale-codec",
Expand Down

0 comments on commit 4718ca6

Please sign in to comment.