1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
34use crate::ibc::IbcChannel;
5use crate::prelude::*;
67use crate::utils::impl_hidden_constructor;
89/// 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`.
21PortId {},
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`.
31Channel {
32 channel_id: String,
33 port_id: Option<String>,
34 },
35}
3637#[derive(
38 Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
39)]
40#[non_exhaustive]
41pub struct PortIdResponse {
42pub port_id: String,
43}
4445impl_hidden_constructor!(PortIdResponse, port_id: String);
4647#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
48#[non_exhaustive]
49pub struct ChannelResponse {
50pub channel: Option<IbcChannel>,
51}
5253impl_hidden_constructor!(ChannelResponse, channel: Option<IbcChannel>);