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(
14    Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
15)]
16#[serde(rename_all = "snake_case")]
17pub enum IbcQuery {
18    /// Gets the Port ID the current contract is bound to.
19    ///
20    /// Returns a `PortIdResponse`.
21    PortId {},
22    //
23    // ListChannels was removed in CosmWasm 3 due to potentially unbound number of results.
24    // See https://github.com/CosmWasm/cosmwasm/issues/2223
25    //
26    /// Lists all information for a (portID, channelID) pair.
27    /// If port_id is omitted, it will default to the contract's own channel.
28    /// (To save a PortId{} call)
29    ///
30    /// Returns a `ChannelResponse`.
31    Channel {
32        channel_id: String,
33        port_id: Option<String>,
34    },
35}
36
37#[derive(
38    Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
39)]
40#[non_exhaustive]
41pub struct PortIdResponse {
42    pub port_id: String,
43}
44
45impl_hidden_constructor!(PortIdResponse, port_id: String);
46
47#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
48#[non_exhaustive]
49pub struct ChannelResponse {
50    pub channel: Option<IbcChannel>,
51}
52
53impl_hidden_constructor!(ChannelResponse, channel: Option<IbcChannel>);