Skip to content

Commit

Permalink
Show the correct command according to the network.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-dfinity committed Nov 27, 2024
1 parent 891e24b commit 44a03aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Error explanation:
Insufficient cycles balance to create the canister.
How to resolve the error:
Please top up your cycles balance by converting ICP to cycles like below:
'dfx cycles convert --amount=0.123 --ic'.
'dfx cycles convert --amount=0.123'.
```

# 0.24.3
Expand Down
21 changes: 18 additions & 3 deletions src/dfx/src/lib/diagnosis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::lib::cycles_ledger_types::create_canister::CreateCanisterError;
use crate::lib::error_code;
use anyhow::Error as AnyhowError;
use dfx_core::error::root_key::FetchRootKeyError;
use dfx_core::network::provider::get_network_context;
use ic_agent::agent::{RejectCode, RejectResponse};
use ic_agent::AgentError;
use ic_asset::error::{GatherAssetDescriptorsError, SyncError, UploadContentError};
Expand Down Expand Up @@ -275,8 +276,22 @@ fn insufficient_cycles(err: &CreateCanisterError) -> bool {
}

fn diagnose_insufficient_cycles() -> Diagnosis {
let network = match get_network_context() {
Ok(value) => {
if value == "local" {
"".to_string()
} else {
format!(" --network {}", value)
}
}
Err(_) => "".to_string(),
};

let explanation = "Insufficient cycles balance to create the canister.";
let suggestion = "Please top up your cycles balance by converting ICP to cycles like below:
'dfx cycles convert --amount=0.123 --ic'.";
(Some(explanation.to_string()), Some(suggestion.to_string()))
let suggestion = format!(
"Please top up your cycles balance by converting ICP to cycles like below:
'dfx cycles convert --amount=0.123{}'",
network
);
(Some(explanation.to_string()), Some(suggestion))
}

0 comments on commit 44a03aa

Please sign in to comment.