Skip to content

Commit

Permalink
chore: improve error message when asset wasm is not allowlisted in pl…
Browse files Browse the repository at this point in the history
…ayground
  • Loading branch information
sesi200 committed Dec 10, 2024
1 parent eb478df commit 6323cb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

This used to be a warning. A hard error can abort the command so that no insecure state will be on the mainnet.

Users can surpress this error by setting `export DFX_WARNING=-mainnet_plaintext_identity`.
Users can suppress this error by setting `export DFX_WARNING=-mainnet_plaintext_identity`.

The warning won't display when executing commands like `dfx deploy --playground`.

Expand Down Expand Up @@ -48,6 +48,9 @@ Please top up your cycles balance by converting ICP to cycles like below:
'dfx cycles convert --amount=0.123'.
```

If users run `dfx deploy --playground` but the backend is not updated with the latest frontend canister wasm
the error message will explain this properly and recommends asking for help on the forum since this can't be resolved by users.

### chore: improve `dfx cycles convert` messages.

If users run `dfx cycles convert` without enough ICP tokens, show additional messages to indicate what to do next.
Expand Down
14 changes: 12 additions & 2 deletions src/dfx/src/lib/operations/canister/motoko_playground.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::lib::diagnosis::DiagnosedError;
use crate::lib::{environment::Environment, error::DfxResult};
use anyhow::{bail, Context};
use anyhow::{anyhow, bail, Context};
use candid::{encode_args, CandidType, Decode, Deserialize, Encode, Principal};
use dfx_core::config::model::canister_id_store::AcquisitionDateTime;
use dfx_core::config::model::network_descriptor::{
Expand Down Expand Up @@ -210,7 +211,16 @@ pub async fn playground_install_code(
.update(&playground_canister, "installCode")
.with_arg(encoded_arg.as_slice())
.await
.context("install failed")?;
.map_err(|err| {
if is_asset_canister && err.to_string().contains("Wasm is not whitelisted") {
anyhow!(DiagnosedError {
error_explanation: Some("The frontend canister wasm needs to be allowlisted in the playground but it isn't. This is a mistake in the release process.".to_string()),
action_suggestion: Some("Please report this on forum.dfinity.org and mention your dfx version. You can get the version with 'dfx --version'.".to_string()),
})
} else {
anyhow!(err)
}
})?;
let out = Decode!(&result, CanisterInfo)?;
out.get_timestamp()
}
Expand Down

0 comments on commit 6323cb6

Please sign in to comment.