#[cfg(feature = "host")]
use serde::Deserialize as SerdeDeserialize;
use serde::Serialize;
#[cfg_attr(feature = "host", derive(SerdeDeserialize))]
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct NnsKnownNeuronData {
pub name: String,
pub description: Option<String>,
pub links: Vec<String>,
}
#[cfg_attr(feature = "host", derive(SerdeDeserialize))]
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct NnsNeuronBallotRow {
pub proposal_id: Option<u64>,
pub vote: i32,
pub vote_text: String,
}
#[cfg_attr(feature = "host", derive(SerdeDeserialize))]
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct NnsNeuronRow {
pub neuron_id: u64,
pub state: i32,
pub state_text: String,
pub visibility: Option<i32>,
pub visibility_text: String,
pub neuron_type: Option<i32>,
pub neuron_type_text: String,
pub stake_e8s: u64,
pub staked_maturity_e8s_equivalent: Option<u64>,
pub dissolve_delay_seconds: u64,
pub age_seconds: u64,
pub created_timestamp_seconds: u64,
pub retrieved_at_timestamp_seconds: u64,
pub voting_power: u64,
pub deciding_voting_power: Option<u64>,
pub potential_voting_power: Option<u64>,
pub voting_power_refreshed_timestamp_seconds: Option<u64>,
pub joined_community_fund_timestamp_seconds: Option<u64>,
pub eight_year_gang_bonus_base_e8s: Option<u64>,
pub known_neuron_data: Option<NnsKnownNeuronData>,
pub recent_ballots: Vec<NnsNeuronBallotRow>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct NnsNeuronListRequest {
pub network: String,
pub source_endpoint: String,
pub now_unix_secs: u64,
pub limit: u32,
pub exclusive_start_neuron_id: Option<u64>,
pub verbose: bool,
}
impl NnsNeuronListRequest {
#[must_use]
pub fn new(
network: impl Into<String>,
source_endpoint: impl Into<String>,
now_unix_secs: u64,
limit: u32,
) -> Self {
Self {
network: network.into(),
source_endpoint: source_endpoint.into(),
now_unix_secs,
limit,
exclusive_start_neuron_id: None,
verbose: false,
}
}
#[must_use]
pub const fn with_exclusive_start_neuron_id(mut self, neuron_id: u64) -> Self {
self.exclusive_start_neuron_id = Some(neuron_id);
self
}
#[must_use]
pub const fn with_verbose(mut self, verbose: bool) -> Self {
self.verbose = verbose;
self
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct NnsNeuronInfoRequest {
pub network: String,
pub source_endpoint: String,
pub now_unix_secs: u64,
pub neuron_id: u64,
pub verbose: bool,
}
impl NnsNeuronInfoRequest {
#[must_use]
pub fn new(
network: impl Into<String>,
source_endpoint: impl Into<String>,
now_unix_secs: u64,
neuron_id: u64,
) -> Self {
Self {
network: network.into(),
source_endpoint: source_endpoint.into(),
now_unix_secs,
neuron_id,
verbose: false,
}
}
#[must_use]
pub const fn with_verbose(mut self, verbose: bool) -> Self {
self.verbose = verbose;
self
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct NnsNeuronListReport {
pub schema_version: u32,
pub network: String,
pub governance_canister_id: String,
pub fetched_at: String,
pub source_endpoint: String,
pub fetched_by: String,
pub cache_path: Option<String>,
pub from_cache: bool,
pub requested_limit: u32,
pub exclusive_start_neuron_id: Option<u64>,
pub next_start_neuron_id: Option<u64>,
pub total_neuron_count: Option<usize>,
pub point_in_time_guaranteed: bool,
pub returned_neuron_count: usize,
pub verbose: bool,
pub neurons: Vec<NnsNeuronRow>,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct NnsNeuronInfoReport {
pub schema_version: u32,
pub network: String,
pub governance_canister_id: String,
pub fetched_at: String,
pub source_endpoint: String,
pub fetched_by: String,
pub cache_path: Option<String>,
pub from_cache: bool,
pub verbose: bool,
pub neuron: NnsNeuronRow,
}