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
76
77
78
79
80
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Coin, CustomQuery, Decimal};

use crate::denom::Denom;

/// KujiraQuery is an override of QueryRequest::Custom to access Terra-specific modules
#[cw_serde]
pub enum KujiraQuery {
    Bank(BankQuery),
    Denom(DenomQuery),
    Oracle(OracleQuery),
    Ica(IcaQuery),
}

impl CustomQuery for KujiraQuery {}

#[cw_serde]
pub enum BankQuery {
    Supply { denom: Denom },
}

/// This contains all queries that can be made to the denom module
#[cw_serde]
pub enum DenomQuery {
    /// Given a subdenom minted by a contract via `DenomMsg::MintTokens`,
    /// returns the full denom as used by `BankMsg::Send`.
    FullDenom {
        creator_addr: Addr,
        subdenom: String,
    },
    /// Returns the admin of a denom, if the denom is a Token Factory denom.
    DenomAdmin { subdenom: String },
}

/// This contains all queries that can be made to the oracle module
#[cw_serde]
pub enum OracleQuery {
    // ExchangeRate will return the rate of this denom.
    ExchangeRate { denom: String },
    // ExchangeRates will return the exchange rate between offer denom and all supported asks
    // ExchangeRates { offer: String },
}

/// This contains all queries that can be made to the cw-ica module
#[cw_serde]
pub enum IcaQuery {
    // AccountAddress will return the address of the interchain account.
    AccountAddress {
        owner: Addr,
        connection_id: String,
        account_id: String,
    },
}

/// ExchangeRateResponse is data format returned from OracleRequest::ExchangeRate query
#[cw_serde]
pub struct ExchangeRateResponse {
    pub rate: Decimal,
}

#[cw_serde]
pub struct SupplyResponse {
    pub amount: Coin,
}

#[cw_serde]
pub struct FullDenomResponse {
    pub denom: Denom,
}

#[cw_serde]
pub struct DenomAdminResponse {
    pub admin: Addr,
}

/// AccountAddressResponse is data format returned from CwIcaRequest::AccountAddress query
#[cw_serde]
pub struct AccountAddressResponse {
    pub address: String,
}