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/commands/nns/mod.rs b/src/dfx/src/commands/nns/mod.rs index 90685a8197..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,26 +17,20 @@ 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`. #[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), } /// 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 { diff --git a/src/dfx/src/lib/nns/install_nns.rs b/src/dfx/src/lib/nns/install_nns.rs index f5169b8dc6..2689b54b08 100644 --- a/src/dfx/src/lib/nns/install_nns.rs +++ b/src/dfx/src/lib/nns/install_nns.rs @@ -320,7 +320,30 @@ 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() + )), } }