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