ic_query/ic/model/requests/
icrc_analytics.rs1use super::IcDashboardRequest;
8
9use serde::Serialize;
10use std::fmt;
11
12#[derive(Clone, Debug, Eq, PartialEq)]
19pub struct IcIcrcAnalyticsRequest {
20 pub dashboard: IcDashboardRequest,
22 pub ledger_canister_id: String,
24}
25
26impl IcIcrcAnalyticsRequest {
27 #[must_use]
29 pub fn new(dashboard: IcDashboardRequest, ledger_canister_id: impl Into<String>) -> Self {
30 Self {
31 dashboard,
32 ledger_canister_id: ledger_canister_id.into(),
33 }
34 }
35}
36
37#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize)]
44#[serde(rename_all = "snake_case")]
45pub enum IcIcrcIndexedCountKind {
46 Account,
48 Holder,
50 Transaction,
52}
53
54impl IcIcrcIndexedCountKind {
55 #[must_use]
57 pub const fn as_str(self) -> &'static str {
58 match self {
59 Self::Account => "account",
60 Self::Holder => "holder",
61 Self::Transaction => "transaction",
62 }
63 }
64
65 #[cfg(feature = "dashboard-host")]
66 pub(crate) const fn resource_path_segment(self) -> &'static str {
67 match self {
68 Self::Account => "accounts",
69 Self::Holder => "holders",
70 Self::Transaction => "transactions",
71 }
72 }
73}
74
75impl fmt::Display for IcIcrcIndexedCountKind {
76 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
77 formatter.write_str(self.as_str())
78 }
79}
80
81#[derive(Clone, Debug, Eq, PartialEq)]
88pub struct IcIcrcIndexedCountRequest {
89 pub analytics: IcIcrcAnalyticsRequest,
91 pub kind: IcIcrcIndexedCountKind,
93}
94
95impl IcIcrcIndexedCountRequest {
96 #[must_use]
98 pub fn new(
99 dashboard: IcDashboardRequest,
100 ledger_canister_id: impl Into<String>,
101 kind: IcIcrcIndexedCountKind,
102 ) -> Self {
103 Self {
104 analytics: IcIcrcAnalyticsRequest::new(dashboard, ledger_canister_id),
105 kind,
106 }
107 }
108}
109
110#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
117pub struct IcIcrcTokenValueQuery {
118 pub start_unix_secs: u64,
120 pub end_unix_secs: u64,
122 pub limit: u16,
124}
125
126impl IcIcrcTokenValueQuery {
127 #[must_use]
129 pub const fn new(start_unix_secs: u64, end_unix_secs: u64, limit: u16) -> Self {
130 Self {
131 start_unix_secs,
132 end_unix_secs,
133 limit,
134 }
135 }
136}
137
138#[derive(Clone, Debug, Eq, PartialEq)]
145pub struct IcIcrcTokenValueRequest {
146 pub analytics: IcIcrcAnalyticsRequest,
148 pub query: IcIcrcTokenValueQuery,
150}
151
152impl IcIcrcTokenValueRequest {
153 #[must_use]
155 pub fn new(
156 dashboard: IcDashboardRequest,
157 ledger_canister_id: impl Into<String>,
158 query: IcIcrcTokenValueQuery,
159 ) -> Self {
160 Self {
161 analytics: IcIcrcAnalyticsRequest::new(dashboard, ledger_canister_id),
162 query,
163 }
164 }
165}
166
167#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
174pub struct IcIcrcTotalSupplyQuery {
175 pub start_unix_secs: u64,
177 pub end_unix_secs: u64,
179 pub step_secs: u32,
181}
182
183impl IcIcrcTotalSupplyQuery {
184 #[must_use]
186 pub const fn new(start_unix_secs: u64, end_unix_secs: u64, step_secs: u32) -> Self {
187 Self {
188 start_unix_secs,
189 end_unix_secs,
190 step_secs,
191 }
192 }
193}
194
195#[derive(Clone, Debug, Eq, PartialEq)]
202pub struct IcIcrcTotalSupplyRequest {
203 pub analytics: IcIcrcAnalyticsRequest,
205 pub query: IcIcrcTotalSupplyQuery,
207}
208
209impl IcIcrcTotalSupplyRequest {
210 #[must_use]
212 pub fn new(
213 dashboard: IcDashboardRequest,
214 ledger_canister_id: impl Into<String>,
215 query: IcIcrcTotalSupplyQuery,
216 ) -> Self {
217 Self {
218 analytics: IcIcrcAnalyticsRequest::new(dashboard, ledger_canister_id),
219 query,
220 }
221 }
222}