Skip to main content

ic_query/nns/proposals/report/model/
reports.rs

1//! Module: nns::proposals::report::model::reports
2//!
3//! Responsibility: serialized NNS proposal report and row DTOs.
4//! Does not own: request selection, source transport, or text rendering.
5//! Boundary: defines the stable JSON contract for NNS proposal output.
6
7use super::selection::{
8    NnsProposalRewardStatus, NnsProposalStatus, NnsProposalTopic, NnsProposalVote,
9};
10use crate::report::{ReportDataSource, ReportResultScope};
11use serde::{Deserialize, Serialize};
12
13///
14/// NnsProposalListReport
15///
16/// Serializable report for a bounded NNS governance proposal listing.
17///
18
19#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
20pub struct NnsProposalListReport {
21    pub schema_version: u32,
22    pub network: String,
23    pub governance_canister_id: String,
24    pub fetched_at: String,
25    pub source_endpoint: String,
26    pub fetched_by: String,
27    pub data_source: ReportDataSource,
28    pub cache_path: Option<String>,
29    pub cache_complete: Option<bool>,
30    pub requested_limit: u32,
31    pub before_proposal_id: Option<u64>,
32    pub status_filter: String,
33    pub reward_status_filter: String,
34    pub topic_filter: String,
35    pub proposer_filter: Option<u64>,
36    pub query_filter: Option<String>,
37    pub sort: String,
38    pub sort_direction: String,
39    pub result_scope: ReportResultScope,
40    pub verbose: bool,
41    pub proposal_count: usize,
42    pub proposals: Vec<NnsProposalRow>,
43}
44
45///
46/// NnsProposalReport
47///
48/// Serializable report for one NNS governance proposal detail lookup.
49///
50
51#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
52pub struct NnsProposalReport {
53    pub schema_version: u32,
54    pub network: String,
55    pub governance_canister_id: String,
56    pub fetched_at: String,
57    pub source_endpoint: String,
58    pub fetched_by: String,
59    pub data_source: ReportDataSource,
60    pub cache_path: Option<String>,
61    pub cache_complete: Option<bool>,
62    pub proposal_id: u64,
63    pub show_ballots: bool,
64    pub verbose: bool,
65    pub proposal: NnsProposalRow,
66}
67
68///
69/// NnsProposalRow
70///
71/// Serializable row for one NNS governance proposal.
72///
73
74#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
75pub struct NnsProposalRow {
76    pub proposal_id: Option<u64>,
77    pub proposer_neuron_id: Option<u64>,
78    pub topic: i32,
79    pub topic_text: NnsProposalTopic,
80    pub status: i32,
81    pub status_text: NnsProposalStatus,
82    pub reward_status: i32,
83    pub reward_status_text: NnsProposalRewardStatus,
84    pub title: Option<String>,
85    pub summary: String,
86    pub url: String,
87    pub action_text: Option<String>,
88    pub reject_cost_e8s: u64,
89    pub proposal_timestamp_seconds: u64,
90    pub proposed_at: String,
91    pub deadline_timestamp_seconds: Option<u64>,
92    pub deadline_at: Option<String>,
93    pub decided_timestamp_seconds: u64,
94    pub decided_at: Option<String>,
95    pub executed_timestamp_seconds: u64,
96    pub executed_at: Option<String>,
97    pub failed_timestamp_seconds: u64,
98    pub failed_at: Option<String>,
99    pub reward_event_round: u64,
100    pub total_potential_voting_power: Option<u64>,
101    pub latest_tally: Option<NnsProposalTally>,
102    pub ballot_count: usize,
103    pub ballots: Vec<NnsProposalBallotRow>,
104}
105
106///
107/// NnsProposalBallotRow
108///
109/// Serializable NNS proposal ballot row.
110///
111
112#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
113pub struct NnsProposalBallotRow {
114    pub neuron_id: u64,
115    pub vote: i32,
116    pub vote_text: NnsProposalVote,
117    pub voting_power: u64,
118}
119
120///
121/// NnsProposalTally
122///
123/// Serializable NNS proposal vote tally.
124///
125
126#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
127pub struct NnsProposalTally {
128    pub timestamp_seconds: u64,
129    pub yes: u64,
130    pub no: u64,
131    pub total: u64,
132}