Skip to content

Commit

Permalink
Re-export the ics23.cosmos.v1 Protobuf definitions from the ics23
Browse files Browse the repository at this point in the history
… crate (#92)

Closes: #10

The proto definitions are exported both under the `ibc_proto::cosmos::ics23::v1` module and under the `ibc_proto::ics23` module for backward source compatiblity.

This is nonetheless a breaking change as it may break compilation or trigger warnings in code which relied on these definitions being different than the ones in `ics23`.

Note that because the code generated by `pbjson-build` is not `no_std` compatible, the serde annotations on the generated protos are only emitted when the `std` feature of `ibc-proto` is enabled, which is unfortunate but I didn't find a way around that.

* Use `ics23` crate Protobuf definitions for `ics23.cosmos.v1` protos

* Run Clippy on all possible features combinations using `cargo-hack` on CI

* Add changelog entry

* Use `pbjson`-based protos

* Use master branch

* Use latest published version of `ics23`

* Only emit serde annotations when `std` feature is enabled

* Fix compilation with std enabled
  • Loading branch information
romac authored May 1, 2023
1 parent 134f8c2 commit 0caffd8
Show file tree
Hide file tree
Showing 21 changed files with 293 additions and 662 deletions.
5 changes: 5 additions & 0 deletions .changelog/unreleased/breaking-changes/10-extern-ics23.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Re-export the `ics23.cosmos.v1` Protobuf definitions from the `ics23` crate instead of including them directly in this crate.
The proto definitions are exported both under the `ibc_proto::cosmos::ics23::v1` module and under the `ibc_proto::ics23` module
for backward source compatiblity. This is nonetheless a breaking change as it may break compilation or trigger warnings
in code which relied on these definitions being different than the ones in `ics23`.
([\#10](https://github.com/cosmos/ibc-proto-rs/issues/10))
13 changes: 13 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
args: --no-default-features

check_features_powerset:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v1
- run: cargo hack clippy --feature-powerset --no-dev-deps

test-stable:
runs-on: ubuntu-latest
timeout-minutes: 30
Expand Down
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ scale-info = { version = "2.1.2", default-features = false, features = [
## for borsh encode or decode
borsh = { version = "0.10.0", default-features = false, optional = true }

[dependencies.ics23]
version = "0.10.1"
default-features = false

[dependencies.tendermint-proto]
version = "0.31"
default-features = false

[features]
default = ["std", "client"]
std = []
std = ["prost/std", "bytes/std", "subtle-encoding/std", "base64/std", "flex-error/std", "ics23/std", "ics23/serde"]
client = ["std", "tonic", "tonic/codegen", "tonic/transport", "tonic/prost"]
json-schema = ["std", "schemars"]
server = ["std", "tonic", "tonic/codegen", "tonic/transport", "tonic/prost"]
Expand Down
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ pub mod cosmos {
include_proto!("cosmos.gov.v1beta1.rs");
}
}
pub mod ics23 {
pub use ics23 as v1;
}
}

pub mod ibc {
Expand Down Expand Up @@ -217,9 +220,8 @@ pub mod ibc {
}
}

pub mod ics23 {
include_proto!("ics23.rs");
}
// Re-export `ics23` definitions for backward compatibility
pub use ics23;

pub mod interchain_security {
pub mod ccv {
Expand Down Expand Up @@ -248,6 +250,7 @@ pub mod stride {
}
}

#[cfg(feature = "std")]
pub(crate) mod base64 {
use alloc::string::String;
use alloc::vec::Vec;
Expand Down
66 changes: 33 additions & 33 deletions src/prost/cosmos.bank.v1beta1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Params defines the parameters for the bank module.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Params {
Expand All @@ -10,7 +10,7 @@ pub struct Params {
}
/// SendEnabled maps coin denom to a send_enabled status (whether a denom is
/// sendable).
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SendEnabled {
Expand All @@ -20,7 +20,7 @@ pub struct SendEnabled {
pub enabled: bool,
}
/// Input models transaction input.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Input {
Expand All @@ -30,7 +30,7 @@ pub struct Input {
pub coins: ::prost::alloc::vec::Vec<super::super::base::v1beta1::Coin>,
}
/// Output models transaction outputs.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Output {
Expand All @@ -42,7 +42,7 @@ pub struct Output {
/// Supply represents a struct that passively keeps track of the total supply
/// amounts in the network.
/// This message is deprecated now that supply is indexed by denom.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Supply {
Expand All @@ -51,7 +51,7 @@ pub struct Supply {
}
/// DenomUnit represents a struct that describes a given
/// denomination unit of the basic token.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DenomUnit {
Expand All @@ -71,7 +71,7 @@ pub struct DenomUnit {
}
/// Metadata represents a struct that describes
/// a basic token.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Metadata {
Expand Down Expand Up @@ -111,7 +111,7 @@ pub struct Metadata {
pub uri_hash: ::prost::alloc::string::String,
}
/// MsgSend represents a message to send coins from one account to another.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgSend {
Expand All @@ -123,12 +123,12 @@ pub struct MsgSend {
pub amount: ::prost::alloc::vec::Vec<super::super::base::v1beta1::Coin>,
}
/// MsgSendResponse defines the Msg/Send response type.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgSendResponse {}
/// MsgMultiSend represents an arbitrary multi-in, multi-out send message.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgMultiSend {
Expand All @@ -138,7 +138,7 @@ pub struct MsgMultiSend {
pub outputs: ::prost::alloc::vec::Vec<Output>,
}
/// MsgMultiSendResponse defines the Msg/MultiSend response type.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgMultiSendResponse {}
Expand Down Expand Up @@ -511,7 +511,7 @@ pub mod msg_server {
}
}
/// QueryBalanceRequest is the request type for the Query/Balance RPC method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryBalanceRequest {
Expand All @@ -523,7 +523,7 @@ pub struct QueryBalanceRequest {
pub denom: ::prost::alloc::string::String,
}
/// QueryBalanceResponse is the response type for the Query/Balance RPC method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryBalanceResponse {
Expand All @@ -532,7 +532,7 @@ pub struct QueryBalanceResponse {
pub balance: ::core::option::Option<super::super::base::v1beta1::Coin>,
}
/// QueryBalanceRequest is the request type for the Query/AllBalances RPC method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryAllBalancesRequest {
Expand All @@ -547,7 +547,7 @@ pub struct QueryAllBalancesRequest {
}
/// QueryAllBalancesResponse is the response type for the Query/AllBalances RPC
/// method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryAllBalancesResponse {
Expand All @@ -564,7 +564,7 @@ pub struct QueryAllBalancesResponse {
/// an account's spendable balances.
///
/// Since: cosmos-sdk 0.46
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QuerySpendableBalancesRequest {
Expand All @@ -581,7 +581,7 @@ pub struct QuerySpendableBalancesRequest {
/// an account's spendable balances.
///
/// Since: cosmos-sdk 0.46
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QuerySpendableBalancesResponse {
Expand All @@ -596,7 +596,7 @@ pub struct QuerySpendableBalancesResponse {
}
/// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC
/// method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryTotalSupplyRequest {
Expand All @@ -610,7 +610,7 @@ pub struct QueryTotalSupplyRequest {
}
/// QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC
/// method
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryTotalSupplyResponse {
Expand All @@ -626,7 +626,7 @@ pub struct QueryTotalSupplyResponse {
>,
}
/// QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QuerySupplyOfRequest {
Expand All @@ -635,7 +635,7 @@ pub struct QuerySupplyOfRequest {
pub denom: ::prost::alloc::string::String,
}
/// QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QuerySupplyOfResponse {
Expand All @@ -644,20 +644,20 @@ pub struct QuerySupplyOfResponse {
pub amount: ::core::option::Option<super::super::base::v1beta1::Coin>,
}
/// QueryParamsRequest defines the request type for querying x/bank parameters.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsRequest {}
/// QueryParamsResponse defines the response type for querying x/bank parameters.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsResponse {
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
}
/// QueryDenomsMetadataRequest is the request type for the Query/DenomsMetadata RPC method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDenomsMetadataRequest {
Expand All @@ -669,7 +669,7 @@ pub struct QueryDenomsMetadataRequest {
}
/// QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC
/// method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDenomsMetadataResponse {
Expand All @@ -683,7 +683,7 @@ pub struct QueryDenomsMetadataResponse {
>,
}
/// QueryDenomMetadataRequest is the request type for the Query/DenomMetadata RPC method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDenomMetadataRequest {
Expand All @@ -693,7 +693,7 @@ pub struct QueryDenomMetadataRequest {
}
/// QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC
/// method.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDenomMetadataResponse {
Expand All @@ -704,7 +704,7 @@ pub struct QueryDenomMetadataResponse {
/// QueryDenomOwnersRequest defines the request type for the DenomOwners RPC query,
/// which queries for a paginated set of all account holders of a particular
/// denomination.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDenomOwnersRequest {
Expand All @@ -722,7 +722,7 @@ pub struct QueryDenomOwnersRequest {
/// balance of the denominated token.
///
/// Since: cosmos-sdk 0.46
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DenomOwner {
Expand All @@ -736,7 +736,7 @@ pub struct DenomOwner {
/// QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query.
///
/// Since: cosmos-sdk 0.46
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDenomOwnersResponse {
Expand Down Expand Up @@ -1699,15 +1699,15 @@ pub mod query_server {
/// the granter's account.
///
/// Since: cosmos-sdk 0.43
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SendAuthorization {
#[prost(message, repeated, tag = "1")]
pub spend_limit: ::prost::alloc::vec::Vec<super::super::base::v1beta1::Coin>,
}
/// GenesisState defines the bank module's genesis state.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenesisState {
Expand All @@ -1727,7 +1727,7 @@ pub struct GenesisState {
}
/// Balance defines an account address and balance pair used in the bank module's
/// genesis state.
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Balance {
Expand Down
4 changes: 2 additions & 2 deletions src/prost/cosmos.base.query.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Foo some_parameter = 1;
/// PageRequest pagination = 2;
/// }
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageRequest {
Expand Down Expand Up @@ -42,7 +42,7 @@ pub struct PageRequest {
/// repeated Bar results = 1;
/// PageResponse page = 2;
/// }
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(feature = "std", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PageResponse {
Expand Down
Loading

0 comments on commit 0caffd8

Please sign in to comment.