Skip to content

Commit

Permalink
chore(nns): Cleanup internal types that should not be in API (#2430)
Browse files Browse the repository at this point in the history
Cleaning up some types that should not be in the Governance API crate.
  • Loading branch information
max-dfinity authored Nov 4, 2024
1 parent ab83fd7 commit 52e5c5a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 127 deletions.
56 changes: 1 addition & 55 deletions rs/nns/governance/api/src/ic_nns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,61 +356,7 @@ pub mod neuron {
DissolveDelaySeconds(u64),
}
}
/// Subset of Neuron that has no collections or big fields that might not exist in most neurons, and
/// the goal is to keep the size of the struct consistent and can be easily stored in a
/// StableBTreeMap. For the meaning of each field, see the Neuron struct.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AbridgedNeuron {
#[prost(bytes = "vec", tag = "2")]
#[serde(with = "serde_bytes")]
pub account: Vec<u8>,
#[prost(message, optional, tag = "3")]
pub controller: Option<PrincipalId>,
#[prost(uint64, tag = "5")]
pub cached_neuron_stake_e8s: u64,
#[prost(uint64, tag = "6")]
pub neuron_fees_e8s: u64,
#[prost(uint64, tag = "7")]
pub created_timestamp_seconds: u64,
#[prost(uint64, tag = "8")]
pub aging_since_timestamp_seconds: u64,
#[prost(uint64, optional, tag = "19")]
pub spawn_at_timestamp_seconds: Option<u64>,
#[prost(bool, tag = "13")]
pub kyc_verified: bool,
#[prost(uint64, tag = "15")]
pub maturity_e8s_equivalent: u64,
#[prost(uint64, optional, tag = "20")]
pub staked_maturity_e8s_equivalent: Option<u64>,
#[prost(bool, optional, tag = "21")]
pub auto_stake_maturity: Option<bool>,
#[prost(bool, tag = "16")]
pub not_for_profit: bool,
#[prost(uint64, optional, tag = "17")]
pub joined_community_fund_timestamp_seconds: Option<u64>,
#[prost(enumeration = "NeuronType", optional, tag = "22")]
pub neuron_type: Option<i32>,
#[prost(enumeration = "Visibility", optional, tag = "23")]
pub visibility: Option<i32>,
#[prost(uint64, optional, tag = "24")]
pub voting_power_refreshed_timestamp_seconds: ::core::option::Option<u64>,
#[prost(oneof = "abridged_neuron::DissolveState", tags = "9, 10")]
pub dissolve_state: Option<abridged_neuron::DissolveState>,
}
/// Nested message and enum types in `AbridgedNeuron`.
pub mod abridged_neuron {
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum DissolveState {
#[prost(uint64, tag = "9")]
WhenDissolvedTimestampSeconds(u64),
#[prost(uint64, tag = "10")]
DissolveDelaySeconds(u64),
}
}

/// Payload of a proposal that calls a function on another NNS
/// canister. The canister and function to call is derived from the
/// `nns_function`.
Expand Down
72 changes: 0 additions & 72 deletions rs/nns/governance/src/pb/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,78 +243,6 @@ impl From<pb_api::Visibility> for pb::Visibility {
}
}

impl From<pb::AbridgedNeuron> for pb_api::AbridgedNeuron {
fn from(item: pb::AbridgedNeuron) -> Self {
Self {
account: item.account,
controller: item.controller,
cached_neuron_stake_e8s: item.cached_neuron_stake_e8s,
neuron_fees_e8s: item.neuron_fees_e8s,
created_timestamp_seconds: item.created_timestamp_seconds,
aging_since_timestamp_seconds: item.aging_since_timestamp_seconds,
spawn_at_timestamp_seconds: item.spawn_at_timestamp_seconds,
kyc_verified: item.kyc_verified,
maturity_e8s_equivalent: item.maturity_e8s_equivalent,
staked_maturity_e8s_equivalent: item.staked_maturity_e8s_equivalent,
auto_stake_maturity: item.auto_stake_maturity,
not_for_profit: item.not_for_profit,
joined_community_fund_timestamp_seconds: item.joined_community_fund_timestamp_seconds,
neuron_type: item.neuron_type,
dissolve_state: item.dissolve_state.map(|x| x.into()),
visibility: item.visibility,
voting_power_refreshed_timestamp_seconds: item.voting_power_refreshed_timestamp_seconds,
}
}
}
impl From<pb_api::AbridgedNeuron> for pb::AbridgedNeuron {
fn from(item: pb_api::AbridgedNeuron) -> Self {
Self {
account: item.account,
controller: item.controller,
cached_neuron_stake_e8s: item.cached_neuron_stake_e8s,
neuron_fees_e8s: item.neuron_fees_e8s,
created_timestamp_seconds: item.created_timestamp_seconds,
aging_since_timestamp_seconds: item.aging_since_timestamp_seconds,
spawn_at_timestamp_seconds: item.spawn_at_timestamp_seconds,
kyc_verified: item.kyc_verified,
maturity_e8s_equivalent: item.maturity_e8s_equivalent,
staked_maturity_e8s_equivalent: item.staked_maturity_e8s_equivalent,
auto_stake_maturity: item.auto_stake_maturity,
not_for_profit: item.not_for_profit,
joined_community_fund_timestamp_seconds: item.joined_community_fund_timestamp_seconds,
neuron_type: item.neuron_type,
dissolve_state: item.dissolve_state.map(|x| x.into()),
visibility: item.visibility,
voting_power_refreshed_timestamp_seconds: item.voting_power_refreshed_timestamp_seconds,
}
}
}

impl From<pb::abridged_neuron::DissolveState> for pb_api::abridged_neuron::DissolveState {
fn from(item: pb::abridged_neuron::DissolveState) -> Self {
match item {
pb::abridged_neuron::DissolveState::WhenDissolvedTimestampSeconds(v) => {
pb_api::abridged_neuron::DissolveState::WhenDissolvedTimestampSeconds(v)
}
pb::abridged_neuron::DissolveState::DissolveDelaySeconds(v) => {
pb_api::abridged_neuron::DissolveState::DissolveDelaySeconds(v)
}
}
}
}
impl From<pb_api::abridged_neuron::DissolveState> for pb::abridged_neuron::DissolveState {
fn from(item: pb_api::abridged_neuron::DissolveState) -> Self {
match item {
pb_api::abridged_neuron::DissolveState::WhenDissolvedTimestampSeconds(v) => {
pb::abridged_neuron::DissolveState::WhenDissolvedTimestampSeconds(v)
}
pb_api::abridged_neuron::DissolveState::DissolveDelaySeconds(v) => {
pb::abridged_neuron::DissolveState::DissolveDelaySeconds(v)
}
}
}
}

impl From<pb::ExecuteNnsFunction> for pb_api::ExecuteNnsFunction {
fn from(item: pb::ExecuteNnsFunction) -> Self {
Self {
Expand Down

0 comments on commit 52e5c5a

Please sign in to comment.