cw_ibc_query/
msg.rs

1use cosmwasm_std::Timestamp;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5use crate::state::ChannelData;
6
7/// This needs no info. Owner of the contract is whoever signed the InstantiateMsg.
8#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
9#[serde(rename_all = "snake_case")]
10pub struct InstantiateMsg {}
11
12#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
13#[serde(rename_all = "snake_case")]
14pub enum QueryMsg {
15    // Shows all open accounts (incl. remote info)
16    ListChannels {},
17    // Get account for one channel
18    Channel { id: String },
19}
20
21#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
22pub struct ListChannelsResponse {
23    pub channels: Vec<ChannelInfo>,
24}
25
26#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
27pub struct ChannelInfo {
28    pub channel_id: String,
29    pub creation_time: Timestamp,
30}
31
32impl ChannelInfo {
33    pub fn convert(channel_id: String, input: ChannelData) -> Self {
34        ChannelInfo {
35            channel_id,
36            creation_time: input.creation_time,
37        }
38    }
39}
40
41#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
42pub struct ChannelResponse {
43    pub creation_time: Timestamp,
44}
45
46impl From<ChannelData> for ChannelResponse {
47    fn from(input: ChannelData) -> Self {
48        ChannelResponse {
49            creation_time: input.creation_time,
50        }
51    }
52}