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
9#[cfg(feature = "host")]
10pub(in crate::sns::report) const SNS_PROPOSAL_DECISION_DECIDED: &str = "decided";
11#[cfg(feature = "host")]
12pub(in crate::sns::report) const SNS_PROPOSAL_DECISION_EXECUTED: &str = "executed";
13#[cfg(feature = "host")]
14pub(in crate::sns::report) const SNS_PROPOSAL_DECISION_FAILED: &str = "failed";
15#[cfg(feature = "host")]
16pub(in crate::sns::report) const SNS_PROPOSAL_DECISION_OPEN: &str = "open";
17
18///
19/// SnsProposalRow
20///
21/// Serializable row for one SNS governance proposal.
22///
23
24#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
25pub struct SnsProposalRow {
26    pub proposal_id: Option<u64>,
27    pub action_id: u64,
28    pub action: String,
29    pub title: String,
30    pub summary: String,
31    pub url: Option<String>,
32    pub decision_state: String,
33    #[serde(default, skip_serializing_if = "Option::is_none")]
34    pub status: Option<i32>,
35    #[serde(default, skip_serializing_if = "Option::is_none")]
36    pub topic: Option<String>,
37    pub reject_cost_e8s: u64,
38    pub proposal_creation_timestamp_seconds: u64,
39    pub created_at: String,
40    pub decided_timestamp_seconds: Option<u64>,
41    pub decided_at: Option<String>,
42    pub executed_timestamp_seconds: Option<u64>,
43    pub executed_at: Option<String>,
44    pub failed_timestamp_seconds: Option<u64>,
45    pub failed_at: Option<String>,
46    pub failure_reason: Option<SnsProposalFailureReason>,
47    pub reward_event_round: u64,
48    pub reward_event_end_timestamp_seconds: Option<u64>,
49    pub is_eligible_for_rewards: bool,
50    pub latest_tally: Option<SnsProposalTally>,
51    pub ballot_count: usize,
52    pub ballots: Vec<SnsProposalBallotRow>,
53    pub payload_text_rendering: Option<String>,
54    pub proposer_neuron_id: Option<String>,
55}
56
57///
58/// SnsProposalBallotRow
59///
60/// Serializable row for one proposal ballot.
61///
62
63#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
64pub struct SnsProposalBallotRow {
65    pub neuron_id: String,
66    pub vote: i32,
67    pub vote_text: String,
68    pub cast_timestamp_seconds: u64,
69    pub cast_at: Option<String>,
70    pub voting_power: u64,
71}
72
73///
74/// SnsProposalFailureReason
75///
76/// Serializable SNS governance failure reason attached to a proposal.
77///
78
79#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
80pub struct SnsProposalFailureReason {
81    pub error_type: i32,
82    pub error_message: String,
83}
84
85///
86/// SnsProposalTally
87///
88/// Serializable SNS proposal vote tally.
89///
90
91#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
92pub struct SnsProposalTally {
93    pub timestamp_seconds: u64,
94    pub yes: u64,
95    pub no: u64,
96    pub total: u64,
97}