Skip to main content

ic_query/icrc/model/reports/
account.rs

1//! Module: icrc::model::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    /// Shared record, flattened in serialized output.
52    #[serde(flatten)]
53    pub provenance: super::IcrcReportProvenance,
54    pub account_owner: String,
55    pub subaccount_hex: Option<String>,
56    /// Raw balance and token display metadata.
57    #[serde(flatten)]
58    pub value: IcrcBalanceData,
59}
60
61///
62/// IcrcAllowanceReport
63///
64/// Serializable report for one generic ICRC allowance lookup.
65///
66
67#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
68pub struct IcrcAllowanceReport {
69    /// Shared record, flattened in serialized output.
70    #[serde(flatten)]
71    pub provenance: super::IcrcReportProvenance,
72    pub account_owner: String,
73    pub account_subaccount_hex: Option<String>,
74    pub spender_owner: String,
75    pub spender_subaccount_hex: Option<String>,
76    /// Raw allowance, expiry and token display metadata.
77    #[serde(flatten)]
78    pub value: IcrcAllowanceData,
79}