Skip to content

Commit

Permalink
Merge pull request #1795 from CosmWasm/export-responses
Browse files Browse the repository at this point in the history
Export missing responses & less feature-gating
  • Loading branch information
chipshort authored Jul 26, 2023
2 parents f3d57ce + 9c94a88 commit 17c060d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 52 deletions.
1 change: 0 additions & 1 deletion packages/std/src/ibc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![cfg(feature = "stargate")]
// The CosmosMsg variants are defined in results/cosmos_msg.rs
// The rest of the IBC related functionality is defined here

Expand Down
20 changes: 6 additions & 14 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pub use crate::errors::{
RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError,
};
pub use crate::hex_binary::HexBinary;
#[cfg(feature = "stargate")]
pub use crate::ibc::{
Ibc3ChannelOpenResponse, IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg,
IbcChannelConnectMsg, IbcChannelOpenMsg, IbcChannelOpenResponse, IbcEndpoint, IbcMsg, IbcOrder,
Expand All @@ -58,21 +57,14 @@ pub use crate::math::{
pub use crate::metadata::{DenomMetadata, DenomUnit};
pub use crate::never::Never;
pub use crate::pagination::PageRequest;
#[cfg(feature = "cosmwasm_1_2")]
pub use crate::query::CodeInfoResponse;
#[cfg(feature = "cosmwasm_1_1")]
pub use crate::query::SupplyResponse;
pub use crate::query::{
AllBalanceResponse, BalanceResponse, BankQuery, ContractInfoResponse, CustomQuery,
QueryRequest, WasmQuery,
AllBalanceResponse, AllDelegationsResponse, AllDenomMetadataResponse, AllValidatorsResponse,
BalanceResponse, BankQuery, BondedDenomResponse, ChannelResponse, CodeInfoResponse,
ContractInfoResponse, CustomQuery, Delegation, DelegationResponse,
DelegatorWithdrawAddressResponse, DenomMetadataResponse, DistributionQuery, FullDelegation,
IbcQuery, ListChannelsResponse, PortIdResponse, QueryRequest, StakingQuery, SupplyResponse,
Validator, ValidatorResponse, WasmQuery,
};
#[cfg(feature = "staking")]
pub use crate::query::{
AllDelegationsResponse, AllValidatorsResponse, BondedDenomResponse, Delegation,
DelegationResponse, FullDelegation, StakingQuery, Validator, ValidatorResponse,
};
#[cfg(feature = "stargate")]
pub use crate::query::{ChannelResponse, IbcQuery, ListChannelsResponse, PortIdResponse};
#[allow(deprecated)]
pub use crate::results::SubMsgExecutionResponse;
#[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))]
Expand Down
12 changes: 2 additions & 10 deletions packages/std/src/query/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use serde::{Deserialize, Serialize};
use crate::Coin;

#[cfg(feature = "cosmwasm_1_3")]
use crate::{Binary, DenomMetadata, PageRequest};
use crate::PageRequest;
use crate::{Binary, DenomMetadata};

use super::query_response::QueryResponseType;

Expand Down Expand Up @@ -34,7 +35,6 @@ pub enum BankQuery {
AllDenomMetadata { pagination: Option<PageRequest> },
}

#[cfg(feature = "cosmwasm_1_1")]
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
Expand All @@ -44,10 +44,8 @@ pub struct SupplyResponse {
pub amount: Coin,
}

#[cfg(feature = "cosmwasm_1_1")]
impl_response_constructor!(SupplyResponse, amount: Coin);

#[cfg(feature = "cosmwasm_1_1")]
impl QueryResponseType for SupplyResponse {}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq, JsonSchema)]
Expand All @@ -73,7 +71,6 @@ impl_response_constructor!(AllBalanceResponse, amount: Vec<Coin>);

impl QueryResponseType for AllBalanceResponse {}

#[cfg(feature = "cosmwasm_1_3")]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
Expand All @@ -82,13 +79,10 @@ pub struct DenomMetadataResponse {
pub metadata: DenomMetadata,
}

#[cfg(feature = "cosmwasm_1_3")]
impl_response_constructor!(DenomMetadataResponse, metadata: DenomMetadata);

#[cfg(feature = "cosmwasm_1_3")]
impl QueryResponseType for DenomMetadataResponse {}

#[cfg(feature = "cosmwasm_1_3")]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
Expand All @@ -98,14 +92,12 @@ pub struct AllDenomMetadataResponse {
pub next_key: Option<Binary>,
}

#[cfg(feature = "cosmwasm_1_3")]
impl_response_constructor!(
AllDenomMetadataResponse,
metadata: Vec<DenomMetadata>,
next_key: Option<Binary>
);

#[cfg(feature = "cosmwasm_1_3")]
impl QueryResponseType for AllDenomMetadataResponse {}

#[cfg(test)]
Expand Down
2 changes: 0 additions & 2 deletions packages/std/src/query/ibc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(feature = "stargate")]

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down
22 changes: 5 additions & 17 deletions packages/std/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,11 @@ mod query_response;
mod staking;
mod wasm;

#[cfg(feature = "cosmwasm_1_1")]
pub use bank::SupplyResponse;
pub use bank::{AllBalanceResponse, BalanceResponse, BankQuery};
#[cfg(feature = "cosmwasm_1_3")]
pub use bank::{AllDenomMetadataResponse, DenomMetadataResponse};
#[cfg(feature = "cosmwasm_1_3")]
pub use distribution::{DelegatorWithdrawAddressResponse, DistributionQuery};
#[cfg(feature = "stargate")]
pub use ibc::{ChannelResponse, IbcQuery, ListChannelsResponse, PortIdResponse};
#[cfg(feature = "staking")]
pub use staking::{
AllDelegationsResponse, AllValidatorsResponse, BondedDenomResponse, Delegation,
DelegationResponse, FullDelegation, StakingQuery, Validator, ValidatorResponse,
};
#[cfg(feature = "cosmwasm_1_2")]
pub use wasm::CodeInfoResponse;
pub use wasm::{ContractInfoResponse, WasmQuery};
pub use bank::*;
pub use distribution::*;
pub use ibc::*;
pub use staking::*;
pub use wasm::*;

#[non_exhaustive]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
Expand Down
2 changes: 0 additions & 2 deletions packages/std/src/query/staking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(feature = "staking")]

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down
7 changes: 1 addition & 6 deletions packages/std/src/query/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::Binary;
#[cfg(feature = "cosmwasm_1_2")]
use crate::HexBinary;
use crate::{Binary, HexBinary};

use super::query_response::QueryResponseType;

Expand Down Expand Up @@ -76,7 +74,6 @@ impl ContractInfoResponse {
/// [CodeInfoResponse]: https://github.com/CosmWasm/wasmd/blob/v0.30.0/proto/cosmwasm/wasm/v1/query.proto#L184-L199
#[non_exhaustive]
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)]
#[cfg(feature = "cosmwasm_1_2")]
pub struct CodeInfoResponse {
pub code_id: u64,
/// The address that initially stored the code
Expand All @@ -85,15 +82,13 @@ pub struct CodeInfoResponse {
pub checksum: HexBinary,
}

#[cfg(feature = "cosmwasm_1_2")]
impl_response_constructor!(
CodeInfoResponse,
code_id: u64,
creator: String,
checksum: HexBinary
);

#[cfg(feature = "cosmwasm_1_2")]
impl QueryResponseType for CodeInfoResponse {}

#[cfg(test)]
Expand Down

0 comments on commit 17c060d

Please sign in to comment.