Skip to main content

ic_query/sns/report/model/reports/
upgrade.rs

1//! Module: sns::report::model::reports::upgrade
2//!
3//! Responsibility: bounded native SNS upgrade report DTOs.
4//! Does not own: Governance or SNS-W calls, source validation, lookup, or rendering.
5//! Boundary: preserves native deployed, pending, and next blessed SNS versions.
6
7use serde::Serialize;
8
9///
10/// SnsVersion
11///
12/// Native six-role SNS Wasm version represented as lowercase hexadecimal hashes.
13///
14
15#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
16pub struct SnsVersion {
17    /// Archive Wasm hash.
18    pub archive_wasm_hash_hex: String,
19    /// Root Wasm hash.
20    pub root_wasm_hash_hex: String,
21    /// Swap Wasm hash.
22    pub swap_wasm_hash_hex: String,
23    /// Ledger Wasm hash.
24    pub ledger_wasm_hash_hex: String,
25    /// Governance Wasm hash.
26    pub governance_wasm_hash_hex: String,
27    /// Ledger index Wasm hash.
28    pub index_wasm_hash_hex: String,
29}
30
31///
32/// SnsPendingUpgrade
33///
34/// Native pending-upgrade state reported by SNS Governance.
35///
36
37#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
38pub struct SnsPendingUpgrade {
39    /// Native deadline after which Governance may mark the upgrade failed.
40    pub mark_failed_at_seconds: u64,
41    /// Native Governance upgrade-lock checking value.
42    pub checking_upgrade_lock: u64,
43    /// NNS proposal that initiated the pending upgrade.
44    pub proposal_id: u64,
45    /// Pending target version, when Governance returned it.
46    pub target_version: Option<SnsVersion>,
47}
48
49///
50/// SnsUpgradeQueryGap
51///
52/// Failed next-version query retained after deployed-version collection succeeded.
53///
54
55#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
56pub struct SnsUpgradeQueryGap {
57    /// Native SNS-W method that failed.
58    pub method: String,
59    /// Transport, encoding, or decoding failure retained for diagnostics.
60    pub reason: String,
61}
62
63///
64/// SnsUpgradeReport
65///
66/// Bounded live report of one SNS deployed, pending, and next blessed version.
67///
68
69#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
70pub struct SnsUpgradeReport {
71    /// Report schema version.
72    pub schema_version: u32,
73    /// Requested IC network identity.
74    pub network: String,
75    /// Mainnet SNS-W canister used for discovery and next-version lookup.
76    pub sns_wasm_canister_id: String,
77    /// Collection timestamp in UTC.
78    pub fetched_at: String,
79    /// IC API endpoint used for all calls.
80    pub source_endpoint: String,
81    /// Collector identity recorded by the source request.
82    pub fetched_by: String,
83    /// SNS-W list id assigned to this deployed SNS.
84    pub id: usize,
85    /// SNS name resolved during discovery.
86    pub name: String,
87    /// Root canister identity used to resolve this SNS.
88    pub root_canister_id: String,
89    /// Governance canister queried for deployed and pending versions.
90    pub governance_canister_id: String,
91    /// Native Governance running-version method.
92    pub running_version_method: String,
93    /// Native SNS-W next-version method.
94    pub next_version_method: String,
95    /// Whether both component responses represent one authoritative point in time.
96    pub point_in_time_guaranteed: bool,
97    /// Fixed number of bounded upgrade component queries attempted.
98    pub component_query_count: usize,
99    /// Number of component queries that returned successfully.
100    pub successful_component_query_count: usize,
101    /// Number of retained next-version query gaps.
102    pub component_gap_count: usize,
103    /// Governance-reported deployed SNS version.
104    pub deployed_version: SnsVersion,
105    /// Governance-reported pending upgrade, when present.
106    pub pending_upgrade: Option<SnsPendingUpgrade>,
107    /// Next blessed SNS-W version, or `None` when no successor exists.
108    pub next_version: Option<SnsVersion>,
109    /// Failed next-version query, distinct from a successful response with no successor.
110    pub next_version_gap: Option<SnsUpgradeQueryGap>,
111}