Skip to content

Commit 1aa7f0b

Browse files
author
Daniel Thurau
committed
Merge branch 'NNS1-2232' into 'master'
NNS1-2232: Add the restricted_countries and confirmation_text to CreateServiceNervousSystem Proposal Closes NNS1-2232 Closes NNS1-2232 See merge request dfinity-lab/public/ic!12547
2 parents 2740201 + 3ba6ed4 commit 1aa7f0b

File tree

9 files changed

+93
-21
lines changed

9 files changed

+93
-21
lines changed

rs/nns/governance/canister/governance.did

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type Command_2 = variant {
9797
};
9898
type Committed = record { sns_governance_canister_id : opt principal };
9999
type Configure = record { operation : opt Operation };
100+
type Countries = record { iso_codes : vec text };
100101
type CreateServiceNervousSystem = record {
101102
url : opt text;
102103
governance_parameters : opt GovernanceParameters;
@@ -474,10 +475,12 @@ type SwapDistribution = record { total : opt Tokens };
474475
type SwapParameters = record {
475476
minimum_participants : opt nat64;
476477
neuron_basket_construction_parameters : opt NeuronBasketConstructionParameters;
478+
confirmation_text : opt text;
477479
maximum_participant_icp : opt Tokens;
478480
minimum_icp : opt Tokens;
479481
minimum_participant_icp : opt Tokens;
480482
maximum_icp : opt Tokens;
483+
restricted_countries : opt Countries;
481484
};
482485
type Tally = record {
483486
no : nat64;

rs/nns/governance/canister/governance_test.did

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type Command_2 = variant {
9797
};
9898
type Committed = record { sns_governance_canister_id : opt principal };
9999
type Configure = record { operation : opt Operation };
100+
type Countries = record { iso_codes : vec text };
100101
type CreateServiceNervousSystem = record {
101102
url : opt text;
102103
governance_parameters : opt GovernanceParameters;
@@ -474,10 +475,12 @@ type SwapDistribution = record { total : opt Tokens };
474475
type SwapParameters = record {
475476
minimum_participants : opt nat64;
476477
neuron_basket_construction_parameters : opt NeuronBasketConstructionParameters;
478+
confirmation_text : opt text;
477479
maximum_participant_icp : opt Tokens;
478480
minimum_icp : opt Tokens;
479481
minimum_participant_icp : opt Tokens;
480482
maximum_icp : opt Tokens;
483+
restricted_countries : opt Countries;
481484
};
482485
type Tally = record {
483486
no : nat64;

rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,10 @@ message CreateServiceNervousSystem {
16341634
}
16351635

16361636
NeuronBasketConstructionParameters neuron_basket_construction_parameters = 6;
1637+
1638+
optional string confirmation_text = 7;
1639+
1640+
optional ic_nervous_system.pb.v1.Countries restricted_countries = 8;
16371641
}
16381642

16391643
SwapParameters swap_parameters = 8;

rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,6 +2245,11 @@ pub mod create_service_nervous_system {
22452245
#[prost(message, optional, tag = "6")]
22462246
pub neuron_basket_construction_parameters:
22472247
::core::option::Option<swap_parameters::NeuronBasketConstructionParameters>,
2248+
#[prost(string, optional, tag = "7")]
2249+
pub confirmation_text: ::core::option::Option<::prost::alloc::string::String>,
2250+
#[prost(message, optional, tag = "8")]
2251+
pub restricted_countries:
2252+
::core::option::Option<::ic_nervous_system_proto::pb::v1::Countries>,
22482253
}
22492254
/// Nested message and enum types in `SwapParameters`.
22502255
pub mod swap_parameters {

rs/nns/governance/src/governance.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8400,7 +8400,7 @@ impl TryFrom<CreateServiceNervousSystem> for SnsInitPayload {
84008400

84018401
initial_token_distribution,
84028402

8403-
swap_parameters: _, // Not used.
8403+
swap_parameters,
84048404
ledger_parameters,
84058405
governance_parameters,
84068406
} = src;
@@ -8409,6 +8409,7 @@ impl TryFrom<CreateServiceNervousSystem> for SnsInitPayload {
84098409

84108410
let ledger_parameters = ledger_parameters.unwrap_or_default();
84118411
let governance_parameters = governance_parameters.unwrap_or_default();
8412+
let swap_parameters = swap_parameters.unwrap_or_default();
84128413

84138414
let create_service_nervous_system::LedgerParameters {
84148415
transaction_fee,
@@ -8515,6 +8516,10 @@ impl TryFrom<CreateServiceNervousSystem> for SnsInitPayload {
85158516
canisters: dapp_canisters,
85168517
});
85178518

8519+
let confirmation_text = swap_parameters.confirmation_text;
8520+
8521+
let restricted_countries = swap_parameters.restricted_countries;
8522+
85188523
if !defects.is_empty() {
85198524
return Err(format!(
85208525
"Failed to convert proposal to SnsInitPayload:\n{}",
@@ -8545,8 +8550,8 @@ impl TryFrom<CreateServiceNervousSystem> for SnsInitPayload {
85458550
initial_voting_period_seconds,
85468551
wait_for_quiet_deadline_increase_seconds,
85478552
dapp_canisters,
8548-
confirmation_text: None, // TODO[NNS1-2232]
8549-
restricted_countries: None, // TODO[NNS1-2232]
8553+
confirmation_text,
8554+
restricted_countries,
85508555
};
85518556

85528557
result.validate().map_err(|err| err.to_string())?;

rs/nns/governance/src/governance/test_data.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod src {
1818
developer_distribution::NeuronDistribution, DeveloperDistribution, SwapDistribution,
1919
TreasuryDistribution,
2020
},
21-
GovernanceParameters, InitialTokenDistribution, LedgerParameters,
21+
GovernanceParameters, InitialTokenDistribution, LedgerParameters, SwapParameters,
2222
};
2323
} // end mod src
2424

@@ -114,7 +114,19 @@ lazy_static! {
114114
id: Some(CanisterId::from_u64(1000).get())
115115
}],
116116

117-
// Not used.
118-
swap_parameters: None,
117+
swap_parameters: Some(src::SwapParameters {
118+
confirmation_text: Some("Confirm you are a human".to_string()),
119+
restricted_countries: Some(pb::Countries {
120+
iso_codes: vec!["CH".to_string()]
121+
}),
122+
123+
// Not used.
124+
minimum_participants: None,
125+
minimum_icp: None,
126+
maximum_icp: None,
127+
minimum_participant_icp: None,
128+
maximum_participant_icp: None,
129+
neuron_basket_construction_parameters: None,
130+
})
119131
};
120132
}

rs/nns/governance/src/governance/tests.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,11 @@ mod convert_from_create_service_nervous_system_to_sns_init_payload_tests {
11231123
.as_ref()
11241124
.unwrap();
11251125

1126+
let original_swap_parameters: &_ = CREATE_SERVICE_NERVOUS_SYSTEM
1127+
.swap_parameters
1128+
.as_ref()
1129+
.unwrap();
1130+
11261131
assert_eq!(
11271132
SnsInitPayload {
11281133
initial_token_distribution: None, // We'll look at this separately.
@@ -1195,11 +1200,10 @@ mod convert_from_create_service_nervous_system_to_sns_init_payload_tests {
11951200
id: Some(CanisterId::from_u64(1000).get()),
11961201
}],
11971202
}),
1203+
confirmation_text: original_swap_parameters.confirmation_text.clone(),
1204+
restricted_countries: original_swap_parameters.restricted_countries.clone(),
11981205

11991206
initial_token_distribution: None,
1200-
1201-
confirmation_text: None,
1202-
restricted_countries: None,
12031207
},
12041208
);
12051209

rs/registry/admin/src/main.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,10 +3806,10 @@ struct ProposeToCreateServiceNervousSystemCmd {
38063806
// Canister Control
38073807
// ----------------
38083808
#[clap(long)]
3809-
fallback_controller_principal_ids: Vec<PrincipalId>,
3809+
fallback_controller_principal_id: Vec<PrincipalId>,
38103810

38113811
#[clap(long)]
3812-
dapp_canisters: Vec<PrincipalId>,
3812+
dapp_canister: Vec<PrincipalId>,
38133813

38143814
// Initial SNS Tokens and Neurons
38153815
// ------------------------------
@@ -3851,6 +3851,12 @@ struct ProposeToCreateServiceNervousSystemCmd {
38513851
#[clap(long, value_parser=parse_tokens)]
38523852
swap_maximum_participant_icp: nervous_system_pb::Tokens,
38533853

3854+
#[clap(long)]
3855+
confirmation_text: Option<String>,
3856+
3857+
#[clap(long)]
3858+
restrict_swap_in_country: Option<Vec<String>>,
3859+
38543860
#[clap(long)]
38553861
swap_neuron_count: u64,
38563862

@@ -3922,9 +3928,10 @@ impl TryFrom<ProposeToCreateServiceNervousSystemCmd> for CreateServiceNervousSys
39223928
description,
39233929
url,
39243930
logo,
3925-
3926-
fallback_controller_principal_ids,
3927-
dapp_canisters,
3931+
// Deconstruct to a more indicative name
3932+
fallback_controller_principal_id: fallback_controller_principal_ids,
3933+
// Deconstruct to a more indicative name
3934+
dapp_canister: dapp_canisters,
39283935

39293936
developer_neuron_controller,
39303937
developer_neuron_dissolve_delay,
@@ -3942,6 +3949,9 @@ impl TryFrom<ProposeToCreateServiceNervousSystemCmd> for CreateServiceNervousSys
39423949
swap_maximum_participant_icp,
39433950
swap_neuron_count,
39443951
swap_neuron_dissolve_delay,
3952+
confirmation_text,
3953+
// Deconstruct to a more indicative name
3954+
restrict_swap_in_country: restricted_countries,
39453955

39463956
transaction_fee,
39473957
token_name,
@@ -4067,13 +4077,17 @@ impl TryFrom<ProposeToCreateServiceNervousSystemCmd> for CreateServiceNervousSys
40674077
})
40684078
};
40694079

4080+
let restricted_countries =
4081+
restricted_countries.map(|iso_codes| nervous_system_pb::Countries { iso_codes });
4082+
40704083
Some(SwapParameters {
40714084
minimum_participants,
40724085
minimum_icp,
40734086
maximum_icp,
40744087
minimum_participant_icp,
40754088
maximum_participant_icp,
4076-
4089+
confirmation_text,
4090+
restricted_countries,
40774091
neuron_basket_construction_parameters,
40784092
})
40794093
};

rs/registry/admin/src/main_tests.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,14 @@ fn convert_from_flags_to_create_service_nervous_system() {
119119
"https://www.example.com",
120120
"--logo",
121121
logo,
122-
"--fallback-controller-principal-ids",
122+
"--fallback-controller-principal-id",
123123
&PrincipalId::new_user_test_id(354_886).to_string(),
124-
"--dapp-canisters",
124+
"--fallback-controller-principal-id",
125+
&PrincipalId::new_user_test_id(354_887).to_string(),
126+
"--dapp-canister",
125127
&CanisterId::from_u64(800_219).to_string(),
128+
"--dapp-canister",
129+
&CanisterId::from_u64(800_220).to_string(),
126130
// Developer 1
127131
"--developer-neuron-controller",
128132
&PrincipalId::new_user_test_id(308_651).to_string(),
@@ -159,6 +163,12 @@ fn convert_from_flags_to_create_service_nervous_system() {
159163
"2_T",
160164
"--swap-maximum-participant-icp",
161165
"100_T",
166+
"--confirmation-text",
167+
"I confirm that I am a human",
168+
"--restrict-swap-in-country",
169+
"CH",
170+
"--restrict-swap-in-country",
171+
"US",
162172
"--swap-neuron-count",
163173
"3",
164174
"--swap-neuron-dissolve-delay",
@@ -214,10 +224,18 @@ fn convert_from_flags_to_create_service_nervous_system() {
214224
base64_encoding: Some(logo.to_string())
215225
}),
216226

217-
fallback_controller_principal_ids: vec![PrincipalId::new_user_test_id(354_886)],
218-
dapp_canisters: vec![nervous_system_pb::Canister {
219-
id: Some(PrincipalId::try_from(CanisterId::from_u64(800_219)).unwrap()),
220-
},],
227+
fallback_controller_principal_ids: vec![
228+
PrincipalId::new_user_test_id(354_886),
229+
PrincipalId::new_user_test_id(354_887)
230+
],
231+
dapp_canisters: vec![
232+
nervous_system_pb::Canister {
233+
id: Some(PrincipalId::try_from(CanisterId::from_u64(800_219)).unwrap()),
234+
},
235+
nervous_system_pb::Canister {
236+
id: Some(PrincipalId::try_from(CanisterId::from_u64(800_220)).unwrap())
237+
}
238+
],
221239
swap_parameters: Some(SwapParameters {
222240
minimum_participants: Some(42),
223241
minimum_icp: Some(nervous_system_pb::Tokens {
@@ -238,6 +256,10 @@ fn convert_from_flags_to_create_service_nervous_system() {
238256
}),
239257
}
240258
),
259+
confirmation_text: Some("I confirm that I am a human".to_string()),
260+
restricted_countries: Some(nervous_system_pb::Countries {
261+
iso_codes: vec!["CH".to_string(), "US".to_string()],
262+
}),
241263
}),
242264
ledger_parameters: Some(LedgerParameters {
243265
transaction_fee: Some(nervous_system_pb::Tokens { e8s: Some(10_000) }),

0 commit comments

Comments
 (0)