prov_cosmwasm_std/query/
ibc.rs

1#![cfg(feature = "stargate")]
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use 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")]
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    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)]
36pub struct PortIdResponse {
37    pub port_id: String,
38}
39
40#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
41pub struct ListChannelsResponse {
42    pub channels: Vec<IbcChannel>,
43}
44
45#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
46pub struct ChannelResponse {
47    pub channel: Option<IbcChannel>,
48}