Skip to main content

ic_query/ic/model/requests/
icrc_analytics.rs

1//! Module: ic::model::requests::icrc_analytics
2//!
3//! Responsibility: bounded official ICRC analytics request contracts.
4//! Does not own: native ledger queries, transport, source validation, or reports.
5//! Boundary: captures one ledger-scoped total-supply series and explicit time bounds.
6
7use serde::Serialize;
8
9///
10/// IcIcrcTotalSupplyQuery
11///
12/// One explicitly bounded total-supply series query for an ICRC ledger.
13///
14
15#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
16pub struct IcIcrcTotalSupplyQuery {
17    /// Inclusive query start as Unix seconds.
18    pub start_unix_secs: u64,
19    /// Inclusive query end as Unix seconds.
20    pub end_unix_secs: u64,
21    /// Requested observation interval in seconds.
22    pub step_secs: u32,
23}
24
25impl IcIcrcTotalSupplyQuery {
26    /// Construct one explicit total-supply query window.
27    #[must_use]
28    pub const fn new(start_unix_secs: u64, end_unix_secs: u64, step_secs: u32) -> Self {
29        Self {
30            start_unix_secs,
31            end_unix_secs,
32            step_secs,
33        }
34    }
35}
36
37///
38/// IcIcrcTotalSupplyRequest
39///
40/// Request accepted by the bounded official ICRC analytics report builder.
41///
42
43#[derive(Clone, Debug, Eq, PartialEq)]
44pub struct IcIcrcTotalSupplyRequest {
45    /// Official ICRC analytics API base endpoint.
46    pub source_endpoint: String,
47    /// Collection time as Unix seconds.
48    pub now_unix_secs: u64,
49    /// ICRC ledger canister principal requested from the analytics service.
50    pub ledger_canister_id: String,
51    /// Explicitly bounded total-supply query.
52    pub query: IcIcrcTotalSupplyQuery,
53}
54
55impl IcIcrcTotalSupplyRequest {
56    /// Construct one bounded live ICRC total-supply analytics request.
57    #[must_use]
58    pub fn new(
59        source_endpoint: impl Into<String>,
60        now_unix_secs: u64,
61        ledger_canister_id: impl Into<String>,
62        query: IcIcrcTotalSupplyQuery,
63    ) -> Self {
64        Self {
65            source_endpoint: source_endpoint.into(),
66            now_unix_secs,
67            ledger_canister_id: ledger_canister_id.into(),
68            query,
69        }
70    }
71}