1use serde::Serialize;
8use serde_json::Value as JsonValue;
9
10#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
17pub struct IcrcTokenReport {
18 pub schema_version: u32,
19 pub ledger_canister_id: String,
20 pub fetched_at: String,
21 pub source_endpoint: String,
22 pub fetched_by: String,
23 pub token_name: String,
24 pub token_symbol: String,
25 pub decimals: u8,
26 pub transfer_fee: String,
27 pub total_supply: String,
28 pub minting_account_owner: Option<String>,
29 pub minting_account_subaccount_hex: Option<String>,
30 pub supported_standards: Vec<IcrcTokenStandardRow>,
31 pub metadata: Vec<IcrcTokenMetadataRow>,
32}
33
34#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
41pub struct IcrcIndexReport {
42 pub schema_version: u32,
43 pub ledger_canister_id: String,
44 pub fetched_at: String,
45 pub source_endpoint: String,
46 pub fetched_by: String,
47 pub index_canister_id: Option<String>,
48 pub index_error: Option<String>,
49}
50
51#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
58pub struct IcrcTransactionsReport {
59 pub schema_version: u32,
60 pub ledger_canister_id: String,
61 pub fetched_at: String,
62 pub source_endpoint: String,
63 pub fetched_by: String,
64 pub requested_start: String,
65 pub requested_limit: u32,
66 pub follow_archives: bool,
67 pub log_length: Option<String>,
68 pub blocks: Vec<IcrcTransactionBlockRow>,
69 pub archived_blocks: Vec<IcrcArchivedBlocksRow>,
70 pub followed_archive_blocks: Vec<IcrcFollowedArchiveBlockRow>,
71 pub archive_follow_errors: Vec<IcrcArchiveFollowErrorRow>,
72}
73
74#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
81pub struct IcrcBlockTypesReport {
82 pub schema_version: u32,
83 pub ledger_canister_id: String,
84 pub fetched_at: String,
85 pub source_endpoint: String,
86 pub fetched_by: String,
87 pub block_types: Vec<IcrcBlockTypeRow>,
88}
89
90#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
97pub struct IcrcArchivesReport {
98 pub schema_version: u32,
99 pub ledger_canister_id: String,
100 pub from_canister_id: Option<String>,
101 pub fetched_at: String,
102 pub source_endpoint: String,
103 pub fetched_by: String,
104 pub archives: Vec<IcrcArchiveRow>,
105}
106
107#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
114pub struct IcrcTipCertificateReport {
115 pub schema_version: u32,
116 pub ledger_canister_id: String,
117 pub fetched_at: String,
118 pub source_endpoint: String,
119 pub fetched_by: String,
120 pub certificate_present: bool,
121 pub certificate_hex: Option<String>,
122 pub certificate_bytes: Option<usize>,
123 pub hash_tree_hex: Option<String>,
124 pub hash_tree_bytes: Option<usize>,
125}
126
127#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
134pub struct IcrcCapabilitiesReport {
135 pub schema_version: u32,
136 pub ledger_canister_id: String,
137 pub fetched_at: String,
138 pub source_endpoint: String,
139 pub fetched_by: String,
140 pub supported_standards: Vec<IcrcTokenStandardRow>,
141 pub capabilities: Vec<IcrcCapabilityRow>,
142}
143
144#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
151pub struct IcrcCapabilityRow {
152 pub capability: String,
153 pub method: String,
154 pub status: IcrcCapabilityStatus,
155 pub details: Option<String>,
156 pub error: Option<String>,
157}
158
159#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
166#[serde(rename_all = "snake_case")]
167pub enum IcrcCapabilityStatus {
168 Available,
170 Unsupported,
172 Error,
174}
175
176impl IcrcCapabilityStatus {
177 #[must_use]
179 pub const fn as_str(self) -> &'static str {
180 match self {
181 Self::Available => "available",
182 Self::Unsupported => "unsupported",
183 Self::Error => "error",
184 }
185 }
186}
187
188#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
195pub struct IcrcTokenStandardRow {
196 pub name: String,
197 pub url: String,
198}
199
200#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
207pub struct IcrcTokenMetadataRow {
208 pub key: String,
209 pub value_type: String,
210 pub value: JsonValue,
211}
212
213#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
220pub struct IcrcTransactionBlockRow {
221 pub index: String,
222 pub block_type: Option<String>,
223 pub transaction_kind: Option<String>,
224 pub timestamp_unix_nanos: Option<String>,
225 pub amount_base_units: Option<String>,
226 pub raw_block: JsonValue,
227}
228
229#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
236pub struct IcrcArchivedBlocksRow {
237 pub callback_canister_id: String,
238 pub callback_method: String,
239 pub ranges: Vec<IcrcArchivedRangeRow>,
240}
241
242#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
249pub struct IcrcArchivedRangeRow {
250 pub start: String,
251 pub length: String,
252}
253
254#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
261pub struct IcrcFollowedArchiveBlockRow {
262 pub archive_canister_id: String,
263 pub callback_method: String,
264 pub index: String,
265 pub block_type: Option<String>,
266 pub transaction_kind: Option<String>,
267 pub timestamp_unix_nanos: Option<String>,
268 pub amount_base_units: Option<String>,
269 pub raw_block: JsonValue,
270}
271
272#[cfg(test)]
273mod tests {
274 use super::*;
275
276 #[test]
277 fn capability_status_labels_are_stable() {
278 for (status, label) in [
279 (IcrcCapabilityStatus::Available, "available"),
280 (IcrcCapabilityStatus::Unsupported, "unsupported"),
281 (IcrcCapabilityStatus::Error, "error"),
282 ] {
283 assert_eq!(
284 serde_json::to_string(&status).unwrap(),
285 format!("\"{label}\"")
286 );
287 assert_eq!(status.as_str(), label);
288 }
289 }
290}
291
292#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
299pub struct IcrcArchiveFollowErrorRow {
300 pub callback_canister_id: String,
301 pub callback_method: String,
302 pub ranges: Vec<IcrcArchivedRangeRow>,
303 pub error: String,
304}
305
306#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
313pub struct IcrcBlockTypeRow {
314 pub block_type: String,
315 pub url: String,
316}
317
318#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
325pub struct IcrcArchiveRow {
326 pub canister_id: String,
327 pub start: String,
328 pub end: String,
329}