Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve error message when asset wasm is not allowlisted in playground #4035

Merged
merged 2 commits into from
Dec 11, 2024
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
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
Loading