cosmwasm_std/query/
ibc.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use crate::ibc::IbcChannel;
5use crate::prelude::*;
6
7use crate::utils::impl_hidden_constructor;
8
9/// These are queries to the various IBC modules to see the state of the contract's
10/// IBC connection.
11/// Most of these will return errors if the contract is not "ibc enabled".
12#[non_exhaustive]
13#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
14#[serde(rename_all = "snake_case")]
15pub enum IbcQuery {
16    /// Gets the Port ID the current contract is bound to.
17    ///
18    /// Returns a `PortIdResponse`.
19    PortId {},
20    //
21    // ListChannels was removed in CosmWasm 3 due to potentially unbound number of results.
22    // See https://github.com/CosmWasm/cosmwasm/issues/2223
23    //
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}
34
35#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
36#[non_exhaustive]
37pub struct PortIdResponse {
38    pub port_id: String,
39}
40
41impl_hidden_constructor!(PortIdResponse, port_id: String);
42
43#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
44#[non_exhaustive]
45pub struct ChannelResponse {
46    pub channel: Option<IbcChannel>,
47}
48
49impl_hidden_constructor!(ChannelResponse, channel: Option<IbcChannel>);