ic-query 0.37.1

Internet Computer query library for CloudEngine, NNS, SNS, ICRC, system canisters, and public network metadata
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
//! Module: ic::model::data
//!
//! Responsibility: host-only Dashboard source request and returned-data contracts.
//! Does not own: public reports, caller requests, errors, transport, or validation.
//! Boundary: preserves source inputs and raw returned evidence for validation.

use super::{
    reports::{
        IcBoundaryNodeDataCenterRow, IcCanisterPageRow, IcCanisterUpgrade, IcDailyStatsRow,
        IcIcrcTotalSupplyObservation, IcMetricSeries, IcNodeProviderRewardHistoryObservation,
        IcNodeProviderRewardRow, IcReplicaVersionListRow, IcReplicaVersionSubnetRollout,
    },
    requests::{
        IcCanisterFilters, IcDailyStatsQuery, IcIcrcAccountListQuery, IcIcrcHolderListQuery,
        IcIcrcIndexedCountKind, IcIcrcTokenValueQuery, IcIcrcTotalSupplyQuery, IcMetricQuery,
        IcNodeProviderRewardHistoryQuery, IcNodeProviderRewardListQuery, IcReplicaVersionListQuery,
    },
};

///
/// IcSourceRequest
///
/// Shared endpoint and collection provenance for IC Dashboard source calls and results.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcSourceRequest {
    /// Dashboard API base endpoint.
    pub endpoint: String,
    /// Collection timestamp in UTC.
    pub fetched_at: String,
    /// Collector identity recorded in report provenance.
    pub fetched_by: String,
}

impl IcSourceRequest {
    /// Construct source-call provenance.
    #[must_use]
    pub fn new(
        endpoint: impl Into<String>,
        fetched_at: impl Into<String>,
        fetched_by: impl Into<String>,
    ) -> Self {
        Self {
            endpoint: endpoint.into(),
            fetched_at: fetched_at.into(),
            fetched_by: fetched_by.into(),
        }
    }
}

///
/// IcCanisterSourceData
///
/// Raw canister metadata and provenance returned by an IC Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcCanisterSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Canister principal returned by the Dashboard.
    pub canister_id: String,
    /// Dashboard database row identifier.
    pub dashboard_id: u64,
    /// Raw optional Dashboard canister classification.
    pub canister_type: Option<String>,
    /// Raw Dashboard canister name.
    pub name: String,
    /// Subnet principal returned by the Dashboard.
    pub subnet_id: String,
    /// Controller principals returned by the Dashboard.
    pub controllers: Vec<String>,
    /// Raw Dashboard language label.
    pub language: String,
    /// Raw current module hash.
    pub module_hash: String,
    /// Raw Dashboard row update timestamp.
    pub dashboard_updated_at: String,
    /// Proposal-linked upgrades, or `None` when the Dashboard returned `null`.
    pub upgrades: Option<Vec<IcCanisterUpgrade>>,
}

///
/// IcCanisterCountSourceData
///
/// Raw filtered count and provenance returned by a Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcCanisterCountSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Filters applied by the source.
    pub filters: IcCanisterFilters,
    /// Number of matching Dashboard canister records.
    pub total: u64,
}

///
/// IcCanisterPageSourceData
///
/// Raw bounded canister page and provenance returned by a Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcCanisterPageSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Filters applied by the source.
    pub filters: IcCanisterFilters,
    /// Maximum rows requested from the source.
    pub requested_limit: u16,
    /// Exclusive forward cursor supplied to the source.
    pub after: Option<String>,
    /// Exclusive backward cursor supplied to the source.
    pub before: Option<String>,
    /// Cursor for an explicit request for the preceding page.
    pub previous_cursor: Option<String>,
    /// Cursor for an explicit request for the following page.
    pub next_cursor: Option<String>,
    /// Canister discovery rows returned by the source.
    pub rows: Vec<IcCanisterPageRow>,
}

///
/// IcMetricSourceData
///
/// Raw bounded metric series and provenance returned by a Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcMetricSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Metric query applied by the source.
    pub query: IcMetricQuery,
    /// Raw named time series returned by the source.
    pub series: Vec<IcMetricSeries>,
}

///
/// IcIcrcTotalSupplySourceData
///
/// Raw bounded ICRC total-supply series and provenance returned by a source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcIcrcTotalSupplySourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Canonical ledger canister principal queried by the source.
    pub ledger_canister_id: String,
    /// Total-supply query applied by the source.
    pub query: IcIcrcTotalSupplyQuery,
    /// Raw observations returned by the source.
    pub observations: Vec<IcIcrcTotalSupplyObservation>,
}

///
/// IcIcrcIndexedCountSourceData
///
/// Raw scalar count and provenance returned by an official ICRC analytics source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcIcrcIndexedCountSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Canonical ledger canister principal queried by the source.
    pub ledger_canister_id: String,
    /// Indexed resource counted by the source.
    pub kind: IcIcrcIndexedCountKind,
    /// Number of matching resources reported by the source.
    pub total: u64,
}

///
/// IcIcrcAccountSourceRow
///
/// One untrusted raw account record returned by the official ICRC index.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcIcrcAccountSourceRow {
    /// Opaque account id returned by the API.
    pub account_id: String,
    /// Raw owner principal returned by the API.
    pub owner: String,
    /// Raw subaccount text returned by the API.
    pub subaccount: String,
    /// Raw indexed balance in ledger base units.
    pub balance_base_units: String,
    /// Raw indexed transaction count.
    pub total_transactions: u64,
    /// Raw creation timestamp as Unix nanoseconds.
    pub created_at_unix_nanos: u64,
    /// Raw ledger canister principal carried by the row.
    pub ledger_canister_id: String,
    /// Raw latest indexed transaction.
    pub latest_transaction_index: u64,
    /// Raw Dashboard update timestamp.
    pub dashboard_updated_at: String,
    /// Raw active fee-collector classification.
    pub active_fee_collector: bool,
    /// Raw fee-collector block-range arrays.
    pub fee_collector_block_ranges: Vec<Vec<serde_json::Value>>,
}

///
/// IcIcrcAccountListSourceData
///
/// Raw bounded account page and provenance returned by an official ICRC index source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcIcrcAccountListSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Canonical ledger canister principal requested by the source.
    pub ledger_canister_id: String,
    /// Account page query applied by the source.
    pub query: IcIcrcAccountListQuery,
    /// Raw opaque cursor for the preceding page.
    pub previous_cursor: Option<String>,
    /// Raw opaque cursor for the following page.
    pub next_cursor: Option<String>,
    /// Raw account rows returned by the source.
    pub rows: Vec<IcIcrcAccountSourceRow>,
}

///
/// IcIcrcAccountInfoSourceData
///
/// Raw exact account record and provenance returned by an official ICRC index source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcIcrcAccountInfoSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Raw exact account record returned by the source.
    pub account: IcIcrcAccountSourceRow,
}

///
/// IcIcrcHolderSourceRow
///
/// One untrusted raw holder record returned by the official ICRC index.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcIcrcHolderSourceRow {
    /// Raw holder principal returned by the API.
    pub principal: String,
    /// Raw aggregate indexed balance in ledger base units.
    pub balance_base_units: String,
    /// Raw aggregate indexed transaction count.
    pub total_transactions: u64,
    /// Raw earliest creation timestamp as Unix nanoseconds.
    pub created_at_unix_nanos: u64,
    /// Raw ledger canister principal carried by the row.
    pub ledger_canister_id: String,
    /// Raw latest indexed transaction.
    pub latest_transaction_index: u64,
    /// Raw numeric supply percentage.
    pub percentage: serde_json::Value,
    /// Raw nullable USD value.
    pub value_usd: serde_json::Value,
    /// Raw Dashboard update timestamp.
    pub dashboard_updated_at: String,
}

///
/// IcIcrcHolderListSourceData
///
/// Raw bounded holder page and provenance returned by an official ICRC index source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcIcrcHolderListSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Canonical ledger canister principal requested by the source.
    pub ledger_canister_id: String,
    /// Holder page query applied by the source.
    pub query: IcIcrcHolderListQuery,
    /// Raw opaque cursor for the preceding page.
    pub previous_cursor: Option<String>,
    /// Raw opaque cursor for the following page.
    pub next_cursor: Option<String>,
    /// Raw holder rows returned by the source.
    pub rows: Vec<IcIcrcHolderSourceRow>,
}

///
/// IcIcrcTokenValueSourceRow
///
/// One untrusted raw token-value record returned by an analytics source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcIcrcTokenValueSourceRow {
    /// Raw legacy price field, when returned.
    pub price: Option<String>,
    /// Raw legacy 24-hour volume field, when returned.
    pub volume_24h: Option<String>,
    /// Raw explicit price-in-USD field, when returned.
    pub price_usd: Option<String>,
    /// Raw explicit 24-hour volume-in-USD field, when returned.
    pub volume_24h_usd: Option<String>,
    /// External value provider, when returned.
    pub source: Option<String>,
    /// External value-provider URL, when returned.
    pub source_url: Option<String>,
    /// Raw optional observation timestamp returned by the source.
    pub timestamp_unix_secs: Option<u64>,
}

///
/// IcIcrcTokenValueSourceData
///
/// Raw bounded token-value series and provenance returned by a source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcIcrcTokenValueSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Canonical ledger canister principal queried by the source.
    pub ledger_canister_id: String,
    /// Token-value query applied by the source.
    pub query: IcIcrcTokenValueQuery,
    /// Untrusted raw rows returned by the source.
    pub rows: Vec<IcIcrcTokenValueSourceRow>,
}

///
/// IcDailyStatsSourceData
///
/// Raw bounded daily network-activity rows and provenance returned by a source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcDailyStatsSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Daily-statistics query applied by the source.
    pub query: IcDailyStatsQuery,
    /// Selected raw daily rows returned by the source.
    pub rows: Vec<IcDailyStatsRow>,
}

///
/// IcBoundaryNodeDataCentersSourceData
///
/// Raw boundary-node data-center rows and provenance returned by a Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcBoundaryNodeDataCentersSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Raw data-center rows returned by the source.
    pub rows: Vec<IcBoundaryNodeDataCenterRow>,
}

///
/// IcNodeProviderRewardListSourceData
///
/// Raw bounded node-provider reward page and provenance returned by a Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcNodeProviderRewardListSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Page query applied by the source.
    pub query: IcNodeProviderRewardListQuery,
    /// Reward-index ceiling selected by the source.
    pub resolved_max_reward_index: u64,
    /// Number of reward records matching the selected ceiling.
    pub total_reward_records: u64,
    /// Raw reward rows returned by the source.
    pub rows: Vec<IcNodeProviderRewardRow>,
}

///
/// IcNodeProviderRewardInfoSourceData
///
/// Raw exact node-provider reward record and provenance returned by a Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcNodeProviderRewardInfoSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Raw reward record returned by the source.
    pub reward: IcNodeProviderRewardRow,
}

///
/// IcNodeProviderRewardHistorySourceData
///
/// Raw bounded node-provider reward history and provenance returned by a Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcNodeProviderRewardHistorySourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// History query applied by the source.
    pub query: IcNodeProviderRewardHistoryQuery,
    /// Raw aggregate observations returned by the source.
    pub observations: Vec<IcNodeProviderRewardHistoryObservation>,
}

///
/// IcReplicaVersionListSourceData
///
/// Raw bounded replica-version page and provenance returned by a Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcReplicaVersionListSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Page query applied by the source.
    pub query: IcReplicaVersionListQuery,
    /// Proposal-index ceiling selected by the source.
    pub resolved_max_proposal_index: u64,
    /// Number of release records matching the selected ceiling.
    pub total_proposals: u64,
    /// Raw release rows returned by the source.
    pub rows: Vec<IcReplicaVersionListRow>,
}

///
/// IcReplicaVersionInfoSourceData
///
/// Raw exact replica-version record and provenance returned by a Dashboard source.
///

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcReplicaVersionInfoSourceData {
    /// Source request and provenance preserved by the source.
    pub source: IcSourceRequest,
    /// Replica-version identifier returned by the source.
    pub replica_version_id: String,
    /// NNS proposal that elected this version.
    pub proposal_id: u64,
    /// Election proposal execution time as raw Unix seconds.
    pub executed_timestamp_seconds: u64,
    /// Raw proposal title.
    pub title: String,
    /// Raw proposal discussion URL.
    pub url: String,
    /// Raw release-note summary.
    pub summary: String,
    /// Raw Dashboard-recorded Subnet assignments.
    pub subnets: Vec<IcReplicaVersionSubnetRollout>,
}