Skip to main content

ic_query/sns/report/model/reports/proposals/
row.rs

1//! Module: sns::report::model::reports::proposals::row
2//!
3//! Responsibility: define SNS proposal row and nested value DTOs.
4//! Does not own: source conversion, report-level metadata, or rendering.
5//! Boundary: preserves proposal detail fields for cache snapshots and JSON output.
6
7use serde::{Deserialize as SerdeDeserialize, Serialize};
8
9pub(in crate::sns::report) const SNS_PROPOSAL_DECISION_DECIDED: &str = "decided";
10pub(in crate::sns::report) const SNS_PROPOSAL_DECISION_EXECUTED: &str = "executed";
11pub(in crate::sns::report) const SNS_PROPOSAL_DECISION_FAILED: &str = "failed";
12pub(in crate::sns::report) const SNS_PROPOSAL_DECISION_OPEN: &str = "open";
13
14///
15/// SnsProposalRow
16///
17/// Serializable row for one SNS governance proposal.
18///
19
20#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
21pub struct SnsProposalRow {
22    pub proposal_id: Option<u64>,
23    pub action_id: u64,
24    pub action: String,
25    pub title: String,
26    pub summary: String,
27    pub url: Option<String>,
28    pub decision_state: String,
29    #[serde(default, skip_serializing_if = "Option::is_none")]
30    pub status: Option<i32>,
31    #[serde(default, skip_serializing_if = "Option::is_none")]
32    pub topic: Option<String>,
33    pub reject_cost_e8s: u64,
34    pub proposal_creation_timestamp_seconds: u64,
35    pub created_at: String,
36    pub decided_timestamp_seconds: Option<u64>,
37    pub decided_at: Option<String>,
38    pub executed_timestamp_seconds: Option<u64>,
39    pub executed_at: Option<String>,
40    pub failed_timestamp_seconds: Option<u64>,
41    pub failed_at: Option<String>,
42    pub failure_reason: Option<SnsProposalFailureReason>,
43    pub reward_event_round: u64,
44    pub reward_event_end_timestamp_seconds: Option<u64>,
45    pub is_eligible_for_rewards: bool,
46    pub latest_tally: Option<SnsProposalTally>,
47    pub ballot_count: usize,
48    pub ballots: Vec<SnsProposalBallotRow>,
49    pub payload_text_rendering: Option<String>,
50    pub proposer_neuron_id: Option<String>,
51}
52
53///
54/// SnsProposalBallotRow
55///
56/// Serializable row for one proposal ballot.
57///
58
59#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
60pub struct SnsProposalBallotRow {
61    pub neuron_id: String,
62    pub vote: i32,
63    pub vote_text: String,
64    pub cast_timestamp_seconds: u64,
65    pub cast_at: Option<String>,
66    pub voting_power: u64,
67}
68
69///
70/// SnsProposalFailureReason
71///
72/// Serializable SNS governance failure reason attached to a proposal.
73///
74
75#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
76pub struct SnsProposalFailureReason {
77    pub error_type: i32,
78    pub error_message: String,
79}
80
81///
82/// SnsProposalTally
83///
84/// Serializable SNS proposal vote tally.
85///
86
87#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
88pub struct SnsProposalTally {
89    pub timestamp_seconds: u64,
90    pub yes: u64,
91    pub no: u64,
92    pub total: u64,
93}