Skip to main content

ic_query/icrc/model/contracts/requests/
ledger_history.rs

1//! Module: icrc::model::contracts::requests::ledger_history
2//!
3//! Responsibility: ICRC ledger-wide transaction and archive request contracts.
4//! Does not own: account-index history, live transport, archive following, or reports.
5//! Boundary: captures bounded ledger history and archive discovery intent.
6
7use super::IcrcLedgerRequest;
8
9///
10/// IcrcTransactionsRequest
11///
12/// Request accepted by the generic ICRC transaction history report builder.
13///
14
15#[derive(Clone, Debug, Eq, PartialEq)]
16pub struct IcrcTransactionsRequest {
17    /// Shared ledger identity, explicit endpoint and caller collection clock.
18    pub ledger: IcrcLedgerRequest,
19    pub start: u64,
20    pub limit: u32,
21    pub follow_archives: bool,
22}
23
24impl IcrcTransactionsRequest {
25    #[must_use]
26    pub const fn new(ledger: IcrcLedgerRequest, start: u64, limit: u32) -> Self {
27        Self {
28            ledger,
29            start,
30            limit,
31            follow_archives: false,
32        }
33    }
34
35    #[must_use]
36    pub const fn with_follow_archives(mut self, follow_archives: bool) -> Self {
37        self.follow_archives = follow_archives;
38        self
39    }
40}
41
42///
43/// IcrcArchivesRequest
44///
45/// Request accepted by the generic ICRC archives report builder.
46///
47
48#[derive(Clone, Debug, Eq, PartialEq)]
49pub struct IcrcArchivesRequest {
50    /// Shared ledger identity, explicit endpoint and caller collection clock.
51    pub ledger: IcrcLedgerRequest,
52    pub from_canister_id: Option<String>,
53}
54
55impl IcrcArchivesRequest {
56    #[must_use]
57    pub const fn new(ledger: IcrcLedgerRequest) -> Self {
58        Self {
59            ledger,
60            from_canister_id: None,
61        }
62    }
63
64    #[must_use]
65    pub fn with_from_canister_id(mut self, from_canister_id: impl Into<String>) -> Self {
66        self.from_canister_id = Some(from_canister_id.into());
67        self
68    }
69}