Skip to content

Commit f8828f7

Browse files
fix(ibc): add missing dependencies for feature flags across multiple 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
1 parent bce09ca commit f8828f7

32 files changed

+51
-35
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [ibc] Add missing dependencies for some feature flags across multiple crates
2+
([\#1059](https://github.com/cosmos/ibc-rs/issues/1059))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [ibc-apps] Ease `serde` derive on `ICS-20` and `ICS-721` types
2+
([\#1060](https://github.com/cosmos/ibc-rs/pull/1060))
File renamed without changes.

ibc-apps/ics20-transfer/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub mod types {
2424
pub use ibc_app_transfer_types::*;
2525
}
2626

27-
#[cfg(feature = "serde")]
2827
pub mod context;
2928
#[cfg(feature = "serde")]
3029
pub mod handler;

ibc-apps/ics20-transfer/types/src/amount.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use core::str::FromStr;
44

55
use derive_more::{Display, From, Into};
66
use ibc_core::primitives::prelude::*;
7+
#[cfg(feature = "serde")]
78
use ibc_core::primitives::serializers;
89
use primitive_types::U256;
910

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

ibc-apps/ics20-transfer/types/src/denom.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use core::str::FromStr;
55
use derive_more::{Display, From};
66
use ibc_core::host::types::identifiers::{ChannelId, PortId};
77
use ibc_core::primitives::prelude::*;
8+
#[cfg(feature = "serde")]
89
use ibc_core::primitives::serializers;
910
use ibc_proto::ibc::applications::transfer::v1::DenomTrace as RawDenomTrace;
1011

ibc-apps/ics20-transfer/types/src/lib.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,18 @@
1515
#[cfg(any(test, feature = "std"))]
1616
extern crate std;
1717

18-
#[cfg(feature = "serde")]
1918
mod amount;
20-
#[cfg(feature = "serde")]
21-
pub use amount::*;
22-
#[cfg(feature = "serde")]
2319
mod coin;
24-
#[cfg(feature = "serde")]
25-
pub use coin::*;
26-
#[cfg(feature = "serde")]
2720
mod denom;
28-
#[cfg(feature = "serde")]
21+
mod memo;
22+
23+
pub use amount::*;
24+
pub use coin::*;
2925
pub use denom::*;
30-
#[cfg(feature = "serde")]
26+
pub mod error;
3127
pub mod events;
32-
#[cfg(feature = "serde")]
3328
pub mod msgs;
34-
#[cfg(feature = "serde")]
3529
pub mod packet;
36-
37-
pub mod error;
38-
mod memo;
3930
pub use memo::*;
4031
/// Re-exports `U256` from `primitive-types` crate for convenience.
4132
pub use primitive_types::U256;

ibc-apps/ics721-nft-transfer/types/src/class.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use derive_more::From;
66
use http::Uri;
77
use ibc_core::host::types::identifiers::{ChannelId, PortId};
88
use ibc_core::primitives::prelude::*;
9+
#[cfg(feature = "serde")]
910
use ibc_core::primitives::serializers;
1011
use ibc_proto::ibc::applications::nft_transfer::v1::ClassTrace as RawClassTrace;
1112

ibc-apps/ics721-nft-transfer/types/src/data.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
use core::fmt::{self, Display, Formatter};
33
use core::str::FromStr;
44

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

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

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

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

94+
#[cfg(feature = "serde")]
8995
impl FromStr for Ics721Data {
9096
type Err = NftTransferError;
9197

ibc-apps/ics721-nft-transfer/types/src/lib.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,19 @@
1717
#[cfg(any(test, feature = "std"))]
1818
extern crate std;
1919

20-
#[cfg(feature = "serde")]
2120
mod class;
22-
#[cfg(feature = "serde")]
23-
pub use class::*;
24-
#[cfg(feature = "serde")]
2521
mod data;
26-
#[cfg(feature = "serde")]
27-
pub use data::*;
28-
#[cfg(feature = "serde")]
22+
mod memo;
23+
mod token;
24+
2925
pub mod events;
30-
#[cfg(feature = "serde")]
3126
pub mod msgs;
32-
#[cfg(feature = "serde")]
27+
pub use class::*;
28+
pub use data::*;
3329
pub mod packet;
34-
#[cfg(feature = "serde")]
35-
mod token;
36-
#[cfg(feature = "serde")]
30+
pub use memo::*;
3731
pub use token::*;
38-
3932
pub mod error;
40-
mod memo;
41-
pub use memo::*;
4233

4334
/// Re-exports ICS-721 NFT transfer proto types from the `ibc-proto` crate.
4435
pub mod proto {

ibc-apps/ics721-nft-transfer/types/src/packet.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use core::convert::TryFrom;
55
use base64::prelude::BASE64_STANDARD;
66
use base64::Engine;
77
use ibc_core::primitives::prelude::*;
8-
use ibc_core::primitives::{serializers, Signer};
8+
#[cfg(feature = "serde")]
9+
use ibc_core::primitives::serializers;
10+
use ibc_core::primitives::Signer;
911
use ibc_proto::ibc::applications::nft_transfer::v1::NonFungibleTokenPacketData as RawPacketData;
1012

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

1618
/// Defines the structure of token transfers' packet bytes
1719
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18-
#[serde(rename_all = "camelCase")]
20+
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
1921
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2022
#[cfg_attr(
2123
feature = "parity-scale-codec",

ibc-apps/ics721-nft-transfer/types/src/token.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use core::str::FromStr;
44

55
use http::Uri;
66
use ibc_core::primitives::prelude::*;
7+
#[cfg(feature = "serde")]
78
use ibc_core::primitives::serializers;
89

910
use crate::data::Data;

ibc-clients/ics08-wasm/types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ default = ["std"]
3636
std = [
3737
"ibc-core-client/std",
3838
"ibc-core-host-types/std",
39+
"ibc-primitives/std",
3940
"ibc-proto/std",
4041
"base64/std",
4142
"serde/std"

ibc-core/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ std = [
3737
"ibc-core-host/std",
3838
"ibc-core-router/std",
3939
"ibc-core-handler/std",
40+
"ibc-primitives/std",
4041
]
4142
serde = [
4243
"ibc-core-client/serde",
@@ -46,6 +47,7 @@ serde = [
4647
"ibc-core-host/serde",
4748
"ibc-core-router/serde",
4849
"ibc-core-handler/serde",
50+
"ibc-primitives/serde",
4951
]
5052
borsh = [
5153
"ibc-core-client/borsh",
@@ -55,6 +57,7 @@ borsh = [
5557
"ibc-core-host/borsh",
5658
"ibc-core-router/borsh",
5759
"ibc-core-handler/borsh",
60+
"ibc-primitives/borsh",
5861
]
5962
schema = [
6063
"ibc-core-client/schema",
@@ -64,13 +67,15 @@ schema = [
6467
"ibc-core-host/schema",
6568
"ibc-core-router/schema",
6669
"ibc-core-handler/schema",
70+
"ibc-primitives/schema",
6771
"serde",
6872
"std"
6973
]
7074
parity-scale-codec = [
7175
"ibc-core-client/parity-scale-codec",
7276
"ibc-core-connection/parity-scale-codec",
7377
"ibc-core-channel/parity-scale-codec",
78+
"ibc-core-commitment-types/parity-scale-codec",
7479
"ibc-core-host/parity-scale-codec",
7580
"ibc-core-router/parity-scale-codec",
7681
"ibc-core-handler/parity-scale-codec",

ibc-core/ics02-client/context/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ schema = [
6363
"ibc-core-client-types/schema",
6464
"ibc-core-host-types/schema",
6565
"ibc-core-handler-types/schema",
66+
"ibc-primitives/schema",
6667
"serde",
6768
"std"
6869
]

ibc-core/ics02-client/types/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ schema = [
7777
parity-scale-codec = [
7878
"dep:parity-scale-codec",
7979
"dep:scale-info",
80-
"ibc-core-commitment-types/parity-scale-codec",
8180
"ibc-core-host-types/parity-scale-codec",
81+
"ibc-core-commitment-types/parity-scale-codec",
8282
"ibc-primitives/parity-scale-codec",
83+
"ibc-proto/parity-scale-codec",
8384
]

ibc-core/ics03-connection/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ schema = [
4343
"ibc-core-client/schema",
4444
"ibc-core-connection-types/schema",
4545
"ibc-core-host/schema",
46+
"ibc-core-handler-types/schema",
4647
"ibc-primitives/schema",
4748
"serde",
4849
"std"

ibc-core/ics24-host/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ serde = [
6262
]
6363
schema = [
6464
"ibc-core-client-types/schema",
65+
"ibc-core-client-context/schema",
6566
"ibc-core-connection-types/schema",
6667
"ibc-core-channel-types/schema",
6768
"ibc-core-commitment-types/schema",
@@ -73,6 +74,7 @@ schema = [
7374
]
7475
borsh = [
7576
"ibc-core-client-types/borsh",
77+
"ibc-core-client-context/borsh",
7678
"ibc-core-connection-types/borsh",
7779
"ibc-core-channel-types/borsh",
7880
"ibc-core-commitment-types/borsh",

ibc-core/ics24-host/cosmos/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ borsh = [
9090
"dep:borsh",
9191
"ibc-client-tendermint/borsh",
9292
"ibc-core-client-types/borsh",
93+
"ibc-core-client-context/borsh",
9394
"ibc-core-connection-types/borsh",
9495
"ibc-core-commitment-types/borsh",
9596
"ibc-core-host-types/borsh",

ibc-core/ics25-handler/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ std = [
3737
"ibc-core-host/std",
3838
"ibc-core-router/std",
3939
"ibc-core-handler-types/std",
40+
"ibc-primitives/std",
4041
]
4142
serde = [
4243
"ibc-core-client/serde",
@@ -46,6 +47,7 @@ serde = [
4647
"ibc-core-host/serde",
4748
"ibc-core-router/serde",
4849
"ibc-core-handler-types/serde",
50+
"ibc-primitives/serde",
4951
]
5052
borsh = [
5153
"ibc-core-client/borsh",
@@ -55,6 +57,7 @@ borsh = [
5557
"ibc-core-host/borsh",
5658
"ibc-core-router/borsh",
5759
"ibc-core-handler-types/borsh",
60+
"ibc-primitives/borsh",
5861
]
5962
schema = [
6063
"ibc-core-client/schema",
@@ -64,6 +67,7 @@ schema = [
6467
"ibc-core-host/schema",
6568
"ibc-core-router/schema",
6669
"ibc-core-handler-types/schema",
70+
"ibc-primitives/schema",
6771
"serde",
6872
"std"
6973
]

ibc-data-types/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ borsh = [
6262
"ibc-core-client-types/borsh",
6363
"ibc-core-connection-types/borsh",
6464
"ibc-core-channel-types/borsh",
65+
"ibc-core-commitment-types/borsh",
6566
"ibc-core-host-types/borsh",
6667
"ibc-core-router-types/borsh",
6768
"ibc-core-handler-types/borsh",
@@ -73,6 +74,7 @@ schema = [
7374
"ibc-core-client-types/schema",
7475
"ibc-core-connection-types/schema",
7576
"ibc-core-channel-types/schema",
77+
"ibc-core-commitment-types/schema",
7678
"ibc-core-host-types/schema",
7779
"ibc-core-router-types/schema",
7880
"ibc-core-handler-types/schema",
@@ -85,6 +87,7 @@ parity-scale-codec = [
8587
"ibc-core-client-types/parity-scale-codec",
8688
"ibc-core-connection-types/parity-scale-codec",
8789
"ibc-core-channel-types/parity-scale-codec",
90+
"ibc-core-commitment-types/parity-scale-codec",
8891
"ibc-core-host-types/parity-scale-codec",
8992
"ibc-core-router-types/parity-scale-codec",
9093
"ibc-core-handler-types/parity-scale-codec",

0 commit comments

Comments
 (0)