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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 3 additions & 10 deletions src/dfx/src/commands/nns/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
25 changes: 24 additions & 1 deletion src/dfx/src/lib/nns/install_nns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,30 @@ fn local_replica_type(env: &dyn Environment) -> anyhow::Result<ReplicaSubnetType
pub fn verify_local_replica_type_is_system(env: &dyn Environment) -> 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()
)),
}
}

Expand Down