Skip to content

Commit 5732836

Browse files
committed
Move IbcQuery to queries/ibc module
1 parent 5b63cf6 commit 5732836

File tree

5 files changed

+58
-47
lines changed

5 files changed

+58
-47
lines changed

contracts/reflect/schema/query_msg.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
"description": "These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not \"ibc enabled\"",
165165
"anyOf": [
166166
{
167-
"description": "Gets the Port ID the current contract is bound to. Returns PortIdResponse",
167+
"description": "Gets the Port ID the current contract is bound to.\n\nReturns a `PortIdResponse`.",
168168
"type": "object",
169169
"required": [
170170
"port_id"
@@ -177,7 +177,7 @@
177177
"additionalProperties": false
178178
},
179179
{
180-
"description": "Lists all channels that are bound to a given port. If `port_id` is omitted, this list all channels bound to the contract's port. Returns a `ListChannelsResponse`.",
180+
"description": "Lists all channels that are bound to a given port. If `port_id` is omitted, this list all channels bound to the contract's port.\n\nReturns a `ListChannelsResponse`.",
181181
"type": "object",
182182
"required": [
183183
"list_channels"
@@ -198,7 +198,7 @@
198198
"additionalProperties": false
199199
},
200200
{
201-
"description": "Lists all information for a (portID, channelID) pair. If port_id is omitted, it will default to the contract's own channel. (To save a PortId{} call) Returns ChannelResponse.",
201+
"description": "Lists all information for a (portID, channelID) pair. If port_id is omitted, it will default to the contract's own channel. (To save a PortId{} call)\n\nReturns a `ChannelResponse`.",
202202
"type": "object",
203203
"required": [
204204
"channel"

packages/std/src/ibc.rs

-39
Original file line numberDiff line numberDiff line change
@@ -57,45 +57,6 @@ pub enum IbcMsg {
5757
CloseChannel { channel_id: String },
5858
}
5959

60-
/// These are queries to the various IBC modules to see the state of the contract's
61-
/// IBC connection. These will return errors if the contract is not "ibc enabled"
62-
#[non_exhaustive]
63-
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
64-
#[serde(rename_all = "snake_case")]
65-
pub enum IbcQuery {
66-
/// Gets the Port ID the current contract is bound to.
67-
/// Returns PortIdResponse
68-
PortId {},
69-
/// Lists all channels that are bound to a given port.
70-
/// If `port_id` is omitted, this list all channels bound to the contract's port.
71-
/// Returns a `ListChannelsResponse`.
72-
ListChannels { port_id: Option<String> },
73-
/// Lists all information for a (portID, channelID) pair.
74-
/// If port_id is omitted, it will default to the contract's own channel.
75-
/// (To save a PortId{} call)
76-
/// Returns ChannelResponse.
77-
Channel {
78-
channel_id: String,
79-
port_id: Option<String>,
80-
},
81-
// TODO: Add more
82-
}
83-
84-
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
85-
pub struct PortIdResponse {
86-
pub port_id: String,
87-
}
88-
89-
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
90-
pub struct ListChannelsResponse {
91-
pub channels: Vec<IbcChannel>,
92-
}
93-
94-
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
95-
pub struct ChannelResponse {
96-
pub channel: Option<IbcChannel>,
97-
}
98-
9960
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
10061
pub struct IbcEndpoint {
10162
pub port_id: String,

packages/std/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ pub use crate::errors::{
3333
};
3434
#[cfg(feature = "stargate")]
3535
pub use crate::ibc::{
36-
ChannelResponse, IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcEndpoint, IbcMsg,
37-
IbcOrder, IbcPacket, IbcQuery, IbcReceiveResponse, IbcTimeoutBlock, ListChannelsResponse,
38-
PortIdResponse,
36+
IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcEndpoint, IbcMsg, IbcOrder, IbcPacket,
37+
IbcReceiveResponse, IbcTimeoutBlock,
3938
};
4039
#[cfg(feature = "iterator")]
4140
#[allow(deprecated)]
@@ -49,6 +48,8 @@ pub use crate::query::{
4948
AllDelegationsResponse, AllValidatorsResponse, BondedDenomResponse, Delegation, FullDelegation,
5049
StakingQuery, Validator, ValidatorResponse,
5150
};
51+
#[cfg(feature = "stargate")]
52+
pub use crate::query::{ChannelResponse, IbcQuery, ListChannelsResponse, PortIdResponse};
5253
pub use crate::results::{
5354
attr, wasm_execute, wasm_instantiate, Attribute, BankMsg, ContractResult, CosmosMsg, Empty,
5455
Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubcallResponse, SystemResult, WasmMsg,

packages/std/src/query/ibc.rs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#![cfg(feature = "stargate")]
2+
3+
use schemars::JsonSchema;
4+
use serde::{Deserialize, Serialize};
5+
6+
use crate::ibc::IbcChannel;
7+
8+
/// These are queries to the various IBC modules to see the state of the contract's
9+
/// IBC connection. These will return errors if the contract is not "ibc enabled"
10+
#[non_exhaustive]
11+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
12+
#[serde(rename_all = "snake_case")]
13+
pub enum IbcQuery {
14+
/// Gets the Port ID the current contract is bound to.
15+
///
16+
/// Returns a `PortIdResponse`.
17+
PortId {},
18+
/// Lists all channels that are bound to a given port.
19+
/// If `port_id` is omitted, this list all channels bound to the contract's port.
20+
///
21+
/// Returns a `ListChannelsResponse`.
22+
ListChannels { port_id: Option<String> },
23+
/// Lists all information for a (portID, channelID) pair.
24+
/// If port_id is omitted, it will default to the contract's own channel.
25+
/// (To save a PortId{} call)
26+
///
27+
/// Returns a `ChannelResponse`.
28+
Channel {
29+
channel_id: String,
30+
port_id: Option<String>,
31+
},
32+
// TODO: Add more
33+
}
34+
35+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
36+
pub struct PortIdResponse {
37+
pub port_id: String,
38+
}
39+
40+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
41+
pub struct ListChannelsResponse {
42+
pub channels: Vec<IbcChannel>,
43+
}
44+
45+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
46+
pub struct ChannelResponse {
47+
pub channel: Option<IbcChannel>,
48+
}

packages/std/src/query/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
use schemars::JsonSchema;
22
use serde::{Deserialize, Serialize};
33

4-
#[cfg(feature = "stargate")]
5-
use crate::ibc::IbcQuery;
64
#[cfg(feature = "stargate")]
75
use crate::Binary;
86
use crate::Empty;
97

108
mod bank;
9+
mod ibc;
1110
mod staking;
1211
mod stargate;
1312
mod wasm;
1413

1514
pub use bank::{AllBalanceResponse, BalanceResponse, BankQuery};
15+
#[cfg(feature = "stargate")]
16+
pub use ibc::{ChannelResponse, IbcQuery, ListChannelsResponse, PortIdResponse};
1617
#[cfg(feature = "staking")]
1718
pub use staking::{
1819
AllDelegationsResponse, AllValidatorsResponse, BondedDenomResponse, Delegation,

0 commit comments

Comments
 (0)