neutron_sdk/bindings/query.rs
1use crate::bindings::marketmap::query::MarketMapQuery;
2use crate::bindings::oracle::query::OracleQuery;
3use crate::bindings::types::{Failure, InterchainQueryResult, RegisteredQuery};
4use cosmwasm_std::{Binary, CustomQuery, QueryRequest};
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7
8use super::dex::query::DexQuery;
9
10#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
11#[serde(rename_all = "snake_case")]
12/// The queries to interact with neutron specific blockchain modules.
13pub enum NeutronQuery {
14 /// Query a result of registered interchain query on remote chain
15 InterchainQueryResult {
16 /// **query_id** is an ID registered interchain query
17 query_id: u64,
18 },
19
20 /// Query a registered interchain account address for a specific connection_id
21 /// Every contract may have as many interchain accounts as necessary.
22 InterchainAccountAddress {
23 /// **owner_address** is an address of contract which registered interchain account
24 owner_address: String,
25
26 /// **interchain_account_id** is an identifier of your interchain account. Can be any string
27 /// This identifier allows contracts to have multiple interchain accounts on remote chains
28 interchain_account_id: String,
29
30 /// **connection_id** is an IBC connection identifier between Neutron and remote chain
31 connection_id: String,
32 },
33
34 /// Query all registered interchain queries on all remote chains
35 RegisteredInterchainQueries {
36 owners: Vec<String>,
37 connection_id: String,
38 pagination: PageRequest,
39 },
40
41 /// Query registered interchain query with a specific query_id
42 RegisteredInterchainQuery {
43 /// **query_id** is an ID registered interchain query
44 query_id: u64,
45 },
46
47 /// Query total amount of burned neutron fees
48 TotalBurnedNeutronsAmount {},
49
50 /// Query minimum IBC fee
51 MinIbcFee {},
52
53 /// TokenFactory query. Given a subdenom minted by a contract via
54 /// [`NeutronMsg::MintTokens`](crate::bindings::msg::NeutronMsg::MintTokens),
55 /// returns the full denom as used by [`BankMsg::Send`](cosmwasm_std::BankMsg::Send).
56 FullDenom {
57 creator_addr: String,
58 subdenom: String,
59 },
60
61 /// TokenFactory query. Returns the admin of a denom, if the denom is a TokenFactory denom.
62 DenomAdmin {
63 subdenom: String,
64 },
65
66 /// TokenFactory query. Returns the before send hook address of a denom, if the denom is a TokenFactory denom.
67 BeforeSendHook {
68 denom: String,
69 },
70
71 /// Contractmanager query. Returns the failures for a particular contract address.
72 Failures {
73 address: String,
74 pagination: PageRequest,
75 },
76
77 Dex(DexQuery),
78
79 MarketMap(MarketMapQuery),
80
81 Oracle(OracleQuery),
82}
83
84#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
85#[serde(rename_all = "snake_case")]
86pub struct PageRequest {
87 /// **key** is a value returned in PageResponse.next_key to begin
88 /// querying the next page most efficiently. Only one of offset or key
89 /// should be set.
90 pub key: Binary,
91 /// **offset** is a numeric offset that can be used when key is unavailable.
92 /// It is less efficient than using key. Only one of offset or key should
93 /// be set.
94 pub offset: u64,
95 /// **limit** is the total number of results to be returned in the result page.
96 /// If left empty it will default to a value to be set by each app.
97 pub limit: u64,
98 /// **count_total** is set to true to indicate that the result set should include
99 /// a count of the total number of items available for pagination in UIs.
100 /// count_total is only respected when offset is used. It is ignored when key
101 /// is set.
102 pub count_total: bool,
103 /// reverse is set to true if results are to be returned in the descending order.
104 pub reverse: bool,
105}
106
107#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
108#[serde(rename_all = "snake_case")]
109pub struct PageResponse {
110 /// **next_key** is the key to be passed to PageRequest.key to
111 /// query the next page most efficiently. It will be empty if
112 /// there are no more results.
113 pub next_key: Option<Binary>,
114 /// **total** is total number of results available if PageRequest.count_total
115 /// was set, its value is undefined otherwise
116 pub total: Option<u64>,
117}
118
119#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
120#[serde(rename_all = "snake_case")]
121pub struct QueryRegisteredQueriesResponse {
122 /// **registered_queries** is a list of registered queries
123 pub registered_queries: Vec<RegisteredQuery>,
124}
125
126#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
127#[serde(rename_all = "snake_case")]
128pub struct QueryRegisteredQueryResponse {
129 /// **registered_query** is a registered query
130 pub registered_query: RegisteredQuery,
131}
132
133#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
134#[serde(rename_all = "snake_case")]
135pub struct QueryRegisteredQueryResultResponse {
136 pub result: InterchainQueryResult,
137}
138
139#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
140#[serde(rename_all = "snake_case")]
141pub struct QueryInterchainAccountAddressResponse {
142 /// **interchain_account_address** is a interchain account address on the remote chain
143 pub interchain_account_address: String,
144}
145
146#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
147#[serde(rename_all = "snake_case")]
148pub struct QueryFailuresResponse {
149 /// **failures** is a list of failures of sudo handler calls
150 pub failures: Vec<Failure>,
151}
152
153impl CustomQuery for NeutronQuery {}
154
155impl From<DexQuery> for QueryRequest<NeutronQuery> {
156 fn from(msg: DexQuery) -> Self {
157 QueryRequest::Custom(NeutronQuery::Dex(msg))
158 }
159}
160
161impl From<MarketMapQuery> for QueryRequest<NeutronQuery> {
162 fn from(msg: MarketMapQuery) -> Self {
163 QueryRequest::Custom(NeutronQuery::MarketMap(msg))
164 }
165}
166
167impl From<OracleQuery> for QueryRequest<NeutronQuery> {
168 fn from(msg: OracleQuery) -> Self {
169 QueryRequest::Custom(NeutronQuery::Oracle(msg))
170 }
171}