From 3b52b52ca938af34a035c59f5f74c6ef528268e7 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 8 Oct 2022 04:12:57 +0200 Subject: [PATCH 1/6] Explain how to set network type --- src/dfx/src/lib/nns/install_nns.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/dfx/src/lib/nns/install_nns.rs b/src/dfx/src/lib/nns/install_nns.rs index f5169b8dc6..fd04be4cc0 100644 --- a/src/dfx/src/lib/nns/install_nns.rs +++ b/src/dfx/src/lib/nns/install_nns.rs @@ -320,7 +320,28 @@ fn local_replica_type(env: &dyn Environment) -> anyhow::Result anyhow::Result<()> { match local_replica_type(env) { Ok(ReplicaSubnetType::System) => Ok(()), - other => Err(anyhow!("The replica subnet_type needs to be \"system\" to run NNS canisters. Current value: {other:?}. You can configure it by setting defaults.replica.subnet_type in your project's dfx.json or by setting local.replica.subnet_type in your global networks.json to \"system\".")), + other => Err(anyhow!( + r#"The replica subnet_type needs to be \"system\" to run NNS canisters. Current value: {other:?}. + + You can configure it by setting local.replica.subnet_type to "system" in your global networks.json: + + 1) Create or edit: {} + 2) Set the local config to: + {{ + "local": {{ + "bind": "127.0.0.1:8080", + "type": "ephemeral", + "replica": {{ + "subnet_type": "application" + }} + }} + }} + 3) Verify that you have no network configurations in dfx.json. + 4) Restart dfx: + dfx stop + dfx start --clean + + "#, env.get_networks_config().get_path().to_string_lossy())), } } From 85c0f8fe9b4c4d552d19eb898dd0fb72eb73b662 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 8 Oct 2022 04:34:28 +0200 Subject: [PATCH 2/6] Expose nns cli help --- src/dfx/src/commands/nns/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/dfx/src/commands/nns/mod.rs b/src/dfx/src/commands/nns/mod.rs index 90685a8197..02d3ea6df8 100644 --- a/src/dfx/src/commands/nns/mod.rs +++ b/src/dfx/src/commands/nns/mod.rs @@ -27,11 +27,9 @@ pub struct NnsOpts { /// Command line options for subcommands of `dfx nns`. #[derive(Parser)] enum SubCommand { - /// Options for importing NNS API definitions and canister IDs. - #[clap(hide(true))] + /// Import NNS API definitions and canister IDs. Import(import::ImportOpts), - /// Options for installing an NNS. - #[clap(hide(true))] + /// Install an NNS on the local dfx server. Install(install::InstallOpts), } From b370307e79d53c19466ca8b254db68a8e01b2db5 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 8 Oct 2022 04:41:39 +0200 Subject: [PATCH 3/6] Remove --network from nns --- src/dfx/src/commands/nns/mod.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/dfx/src/commands/nns/mod.rs b/src/dfx/src/commands/nns/mod.rs index 02d3ea6df8..34d577b5d4 100644 --- a/src/dfx/src/commands/nns/mod.rs +++ b/src/dfx/src/commands/nns/mod.rs @@ -3,7 +3,6 @@ use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::provider::create_agent_environment; -use crate::NetworkOpt; use clap::Parser; use tokio::runtime::Runtime; @@ -18,10 +17,6 @@ pub struct NnsOpts { /// `dfx nns` subcommand arguments. #[clap(subcommand)] subcmd: SubCommand, - - /// An argument to choose the network from those specified in dfx.json. - #[clap(flatten)] - network: NetworkOpt, } /// Command line options for subcommands of `dfx nns`. @@ -35,7 +30,7 @@ enum SubCommand { /// Executes `dfx nns` and its subcommands. pub fn exec(env: &dyn Environment, opts: NnsOpts) -> DfxResult { - let env = create_agent_environment(env, opts.network.network)?; + let env = create_agent_environment(env, None)?; let runtime = Runtime::new().expect("Unable to create a runtime"); runtime.block_on(async { match opts.subcmd { From 72e4cf412295d3d77ea0b9acb3cb60ad3acb0ebe Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 8 Oct 2022 04:58:12 +0200 Subject: [PATCH 4/6] Updated quotes --- src/dfx/src/lib/nns/install_nns.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dfx/src/lib/nns/install_nns.rs b/src/dfx/src/lib/nns/install_nns.rs index fd04be4cc0..6c5cb0f12f 100644 --- a/src/dfx/src/lib/nns/install_nns.rs +++ b/src/dfx/src/lib/nns/install_nns.rs @@ -321,7 +321,7 @@ pub fn verify_local_replica_type_is_system(env: &dyn Environment) -> anyhow::Res match local_replica_type(env) { Ok(ReplicaSubnetType::System) => Ok(()), other => Err(anyhow!( - r#"The replica subnet_type needs to be \"system\" to run NNS canisters. Current value: {other:?}. + r#"The replica subnet_type needs to be "system" to run NNS canisters. Current value: {other:?}. You can configure it by setting local.replica.subnet_type to "system" in your global networks.json: From 1079cc4511164c5c95b6f7b18171b7f6fd172379 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 8 Oct 2022 04:58:49 +0200 Subject: [PATCH 5/6] Updated quotes --- src/dfx/src/lib/nns/install_nns.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dfx/src/lib/nns/install_nns.rs b/src/dfx/src/lib/nns/install_nns.rs index 6c5cb0f12f..c318d238ba 100644 --- a/src/dfx/src/lib/nns/install_nns.rs +++ b/src/dfx/src/lib/nns/install_nns.rs @@ -321,7 +321,7 @@ pub fn verify_local_replica_type_is_system(env: &dyn Environment) -> anyhow::Res match local_replica_type(env) { Ok(ReplicaSubnetType::System) => Ok(()), other => Err(anyhow!( - r#"The replica subnet_type needs to be "system" to run NNS canisters. Current value: {other:?}. + r#"The replica subnet_type needs to be 'system' to run NNS canisters. Current value: {other:?}. You can configure it by setting local.replica.subnet_type to "system" in your global networks.json: From efbd1ad1caf2081737b4376741d93d34909aa5f4 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 8 Oct 2022 05:13:40 +0200 Subject: [PATCH 6/6] CHNAGELOG++ --- CHANGELOG.md | 8 ++++++++ src/dfx/src/lib/nns/install_nns.rs | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8643002fec..4d5caa64b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ ## DFX +### feat: NNS usability improvements + +The command line interface for nns commands has been updated to: + +- Give better help when the subnet type is incorrect +- Not offer --network as a flag given that it is unused +- List nns subcommands + ### fix: Compute Motoko dependencies in linear (not exponential) time by detecting visited imports. ### fix(generate): add missing typescript types and fix issues with bindings array in dfx.json diff --git a/src/dfx/src/lib/nns/install_nns.rs b/src/dfx/src/lib/nns/install_nns.rs index c318d238ba..2689b54b08 100644 --- a/src/dfx/src/lib/nns/install_nns.rs +++ b/src/dfx/src/lib/nns/install_nns.rs @@ -341,7 +341,9 @@ pub fn verify_local_replica_type_is_system(env: &dyn Environment) -> anyhow::Res dfx stop dfx start --clean - "#, env.get_networks_config().get_path().to_string_lossy())), + "#, + env.get_networks_config().get_path().to_string_lossy() + )), } }