Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions rs/nns/governance/api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4598,6 +4598,7 @@ pub enum SelfDescribingValue {
Null,
Array(Vec<SelfDescribingValue>),
Map(HashMap<String, SelfDescribingValue>),
Bool(bool),
}

impl From<String> for SelfDescribingValue {
Expand Down Expand Up @@ -4636,6 +4637,12 @@ impl From<PrincipalId> for SelfDescribingValue {
}
}

impl From<bool> for SelfDescribingValue {
fn from(value: bool) -> Self {
SelfDescribingValue::Bool(value)
}
}

#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, Debug, Clone, PartialEq)]
pub struct SelfDescribingProposalAction {
pub type_name: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions rs/nns/governance/canister/governance.did
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,7 @@ type SelfDescribingProposalAction = record {
type SelfDescribingValue = variant {
Blob : blob;
Text : text;
Bool : bool;
Nat : nat;
Int : int;
Array : vec SelfDescribingValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,7 @@ message SelfDescribingValue {
SelfDescribingValueArray array = 5;
SelfDescribingValueMap map = 6;
Empty null = 7;
bool bool = 8;
}
}

Expand Down
7 changes: 6 additions & 1 deletion rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4191,7 +4191,10 @@ pub struct FinalizeDisburseMaturity {
::prost::Message,
)]
pub struct SelfDescribingValue {
#[prost(oneof = "self_describing_value::Value", tags = "1, 2, 3, 4, 5, 6, 7")]
#[prost(
oneof = "self_describing_value::Value",
tags = "1, 2, 3, 4, 5, 6, 7, 8"
)]
pub value: ::core::option::Option<self_describing_value::Value>,
}
/// Nested message and enum types in `SelfDescribingValue`.
Expand Down Expand Up @@ -4221,6 +4224,8 @@ pub mod self_describing_value {
Map(super::SelfDescribingValueMap),
#[prost(message, tag = "7")]
Null(super::Empty),
#[prost(bool, tag = "8")]
Bool(bool),
}
}
#[derive(
Expand Down
1 change: 1 addition & 0 deletions rs/nns/governance/src/pb/proposal_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ fn convert_self_describing_value(
api::SelfDescribingValue::Int(int)
}
pb::self_describing_value::Value::Null(_) => api::SelfDescribingValue::Null,
pb::self_describing_value::Value::Bool(v) => api::SelfDescribingValue::Bool(*v),
pb::self_describing_value::Value::Array(v) => api::SelfDescribingValue::Array(
v.values
.iter()
Expand Down
4 changes: 2 additions & 2 deletions rs/nns/governance/src/proposals/install_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ mod tests {
"install_mode".to_string() => SelfDescribingValue::from("Upgrade"),
"wasm_module_hash".to_string() => SelfDescribingValue::from(wasm_hash),
"arg_hash".to_string() => SelfDescribingValue::from(arg_hash),
"skip_stopping_before_installing".to_string() => SelfDescribingValue::from(1_u64),
"skip_stopping_before_installing".to_string() => SelfDescribingValue::from(true),
})
);
}
Expand All @@ -503,7 +503,7 @@ mod tests {
"install_mode".to_string() => SelfDescribingValue::from("Install"),
"wasm_module_hash".to_string() => SelfDescribingValue::from(Sha256::hash(&[1, 2, 3]).to_vec()),
"arg_hash".to_string() => SelfDescribingValue::from(Sha256::hash(&[]).to_vec()),
"skip_stopping_before_installing".to_string() => SelfDescribingValue::from(0_u64),
"skip_stopping_before_installing".to_string() => SelfDescribingValue::from(false),
})
);
}
Expand Down
4 changes: 2 additions & 2 deletions rs/nns/governance/src/proposals/manage_neuron_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn test_command_configure_change_auto_stake_maturity_to_self_describing() {
}),
SelfDescribingValue::Map(hashmap! {
"ChangeAutoStakeMaturity".to_string() => SelfDescribingValue::Map(hashmap! {
"requested_setting_for_auto_stake_maturity".to_string() => SelfDescribingValue::from(1_u64),
"requested_setting_for_auto_stake_maturity".to_string() => SelfDescribingValue::from(true),
}),
}),
);
Expand Down Expand Up @@ -389,7 +389,7 @@ fn test_command_disburse_to_neuron_to_self_describing() {
"new_controller".to_string() => SelfDescribingValue::from(principal),
"amount_e8s".to_string() => SelfDescribingValue::from(200_000_000_u64),
"dissolve_delay_seconds".to_string() => SelfDescribingValue::from(31_536_000_u64),
"kyc_verified".to_string() => SelfDescribingValue::from(1_u64),
"kyc_verified".to_string() => SelfDescribingValue::from(true),
"nonce".to_string() => SelfDescribingValue::from(7_777_u64),
}),
}),
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/governance/src/proposals/self_describing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl From<Vec<u8>> for SelfDescribingValue {
impl From<bool> for SelfDescribingValue {
fn from(value: bool) -> Self {
SelfDescribingValue {
value: Some(to_self_describing_nat(if value { 1_u8 } else { 0_u8 })),
value: Some(Value::Bool(value)),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/governance/src/proposals/self_describing_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn test_create_service_nervous_system_to_self_describing() {
"duration".to_string() => SelfDescribingValue::Map(hashmap! {
"seconds".to_string() => SelfDescribingValue::from(604_800_u64),
}),
"neurons_fund_participation".to_string() => SelfDescribingValue::from(0_u64),
"neurons_fund_participation".to_string() => SelfDescribingValue::from(false),
"minimum_icp".to_string() => SelfDescribingValue::Null,
"maximum_icp".to_string() => SelfDescribingValue::Null,
"neurons_fund_investment_icp".to_string() => SelfDescribingValue::Null,
Expand Down