cosmwasm_std/query/
ibc.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use crate::ibc::IbcChannel;
5use crate::prelude::*;
6
7/// These are queries to the various IBC modules to see the state of the contract's
8/// IBC connection.
9/// Most of these will return errors if the contract is not "ibc enabled".
10#[non_exhaustive]
11#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
12#[serde(rename_all = "snake_case")]
13pub 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    #[deprecated = "Returns a potentially unbound number of results. If you think you have a valid usecase, please open an issue."]
23    ListChannels { port_id: Option<String> },
24    /// Lists all information for a (portID, channelID) pair.
25    /// If port_id is omitted, it will default to the contract's own channel.
26    /// (To save a PortId{} call)
27    ///
28    /// Returns a `ChannelResponse`.
29    Channel {
30        channel_id: String,
31        port_id: Option<String>,
32    },
33    /// Queries whether the given channel supports IBC fees.
34    /// If port_id is omitted, it will default to the contract's own channel.
35    /// (To save a PortId{} call)
36    ///
37    /// Returns a `FeeEnabledChannelResponse`.
38    #[cfg(feature = "cosmwasm_2_2")]
39    #[deprecated(
40        since = "2.2.3",
41        note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`."
42    )]
43    FeeEnabledChannel {
44        port_id: Option<String>,
45        channel_id: String,
46    },
47}
48
49#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
50#[non_exhaustive]
51pub struct PortIdResponse {
52    pub port_id: String,
53}
54
55impl_response_constructor!(PortIdResponse, port_id: String);
56
57#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
58#[non_exhaustive]
59pub struct ListChannelsResponse {
60    pub channels: Vec<IbcChannel>,
61}
62
63impl_response_constructor!(ListChannelsResponse, channels: Vec<IbcChannel>);
64
65#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
66#[non_exhaustive]
67pub struct ChannelResponse {
68    pub channel: Option<IbcChannel>,
69}
70
71impl_response_constructor!(ChannelResponse, channel: Option<IbcChannel>);
72
73#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
74#[non_exhaustive]
75#[deprecated(
76    since = "2.2.3",
77    note = "IBC fees have been removed from ibc-go `v10`, which is used in wasmd `v0.55.0`."
78)]
79pub struct FeeEnabledChannelResponse {
80    pub fee_enabled: bool,
81}
82
83impl_response_constructor!(FeeEnabledChannelResponse, fee_enabled: bool);