-
Notifications
You must be signed in to change notification settings - Fork 341
/
ibc.rs
75 lines (65 loc) · 2.46 KB
/
ibc.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::ibc::IbcChannel;
use crate::prelude::*;
/// These are queries to the various IBC modules to see the state of the contract's
/// IBC connection.
/// Most of these will return errors if the contract is not "ibc enabled".
#[non_exhaustive]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum IbcQuery {
/// Gets the Port ID the current contract is bound to.
///
/// Returns a `PortIdResponse`.
PortId {},
/// Lists all channels that are bound to a given port.
/// If `port_id` is omitted, this list all channels bound to the contract's port.
///
/// Returns a `ListChannelsResponse`.
#[deprecated = "Returns a potentially unbound number of results. If you think you have a valid usecase, please open an issue."]
ListChannels { port_id: Option<String> },
/// Lists all information for a (portID, channelID) pair.
/// If port_id is omitted, it will default to the contract's own channel.
/// (To save a PortId{} call)
///
/// Returns a `ChannelResponse`.
Channel {
channel_id: String,
port_id: Option<String>,
},
/// Queries whether the given channel supports IBC fees.
/// If port_id is omitted, it will default to the contract's own channel.
/// (To save a PortId{} call)
///
/// Returns a `FeeEnabledChannelResponse`.
#[cfg(feature = "cosmwasm_2_2")]
FeeEnabledChannel {
port_id: Option<String>,
channel_id: String,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[non_exhaustive]
pub struct PortIdResponse {
pub port_id: String,
}
impl_response_constructor!(PortIdResponse, port_id: String);
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[non_exhaustive]
pub struct ListChannelsResponse {
pub channels: Vec<IbcChannel>,
}
impl_response_constructor!(ListChannelsResponse, channels: Vec<IbcChannel>);
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[non_exhaustive]
pub struct ChannelResponse {
pub channel: Option<IbcChannel>,
}
impl_response_constructor!(ChannelResponse, channel: Option<IbcChannel>);
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[non_exhaustive]
pub struct FeeEnabledChannelResponse {
pub fee_enabled: bool,
}
impl_response_constructor!(FeeEnabledChannelResponse, fee_enabled: bool);