ic_query/icrc/model/contracts/reports/account.rs
1//! Module: icrc::model::contracts::reports::account
2//!
3//! Responsibility: serialized ICRC balance and allowance report contracts.
4//! Does not own: account history, ledger-wide reports, live transport, or rendering.
5//! Boundary: preserves raw account and allowance result fields.
6
7use serde::Serialize;
8
9///
10/// IcrcBalanceData
11///
12/// Raw balance result shared by sources and reports plus enough token metadata for display.
13///
14
15#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
16pub struct IcrcBalanceData {
17 /// Ledger token symbol.
18 pub token_symbol: String,
19 /// Ledger token decimal places.
20 pub decimals: u8,
21 /// Balance in raw decimal base units.
22 pub balance: String,
23}
24
25///
26/// IcrcAllowanceData
27///
28/// Raw allowance result shared by sources and reports plus enough token metadata for display.
29///
30
31#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
32pub struct IcrcAllowanceData {
33 /// Ledger token symbol.
34 pub token_symbol: String,
35 /// Ledger token decimal places.
36 pub decimals: u8,
37 /// Allowance in raw decimal base units.
38 pub allowance: String,
39 /// Optional expiry in raw decimal Unix nanoseconds.
40 pub expires_at_unix_nanos: Option<String>,
41}
42
43///
44/// IcrcBalanceReport
45///
46/// Serializable report for one generic ICRC account balance lookup.
47///
48
49#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
50pub struct IcrcBalanceReport {
51 pub schema_version: u32,
52 pub ledger_canister_id: String,
53 pub account_owner: String,
54 pub subaccount_hex: Option<String>,
55 pub fetched_at: String,
56 pub source_endpoint: String,
57 pub fetched_by: String,
58 /// Raw balance and token display metadata.
59 #[serde(flatten)]
60 pub value: IcrcBalanceData,
61}
62
63///
64/// IcrcAllowanceReport
65///
66/// Serializable report for one generic ICRC allowance lookup.
67///
68
69#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
70pub struct IcrcAllowanceReport {
71 pub schema_version: u32,
72 pub ledger_canister_id: String,
73 pub account_owner: String,
74 pub account_subaccount_hex: Option<String>,
75 pub spender_owner: String,
76 pub spender_subaccount_hex: Option<String>,
77 pub fetched_at: String,
78 pub source_endpoint: String,
79 pub fetched_by: String,
80 /// Raw allowance, expiry and token display metadata.
81 #[serde(flatten)]
82 pub value: IcrcAllowanceData,
83}