@@ -3,12 +3,12 @@ use crate::config::dfx_version;
3
3
use crate :: lib:: error:: DfxResult ;
4
4
use crate :: lib:: progress_bar:: ProgressBar ;
5
5
use crate :: lib:: warning:: { is_warning_disabled, DfxWarning :: MainnetPlainTextIdentity } ;
6
- use anyhow:: anyhow;
6
+ use anyhow:: { anyhow, bail } ;
7
7
use candid:: Principal ;
8
8
use dfx_core:: config:: cache:: Cache ;
9
9
use dfx_core:: config:: model:: canister_id_store:: CanisterIdStore ;
10
10
use dfx_core:: config:: model:: dfinity:: { Config , NetworksConfig } ;
11
- use dfx_core:: config:: model:: network_descriptor:: NetworkDescriptor ;
11
+ use dfx_core:: config:: model:: network_descriptor:: { NetworkDescriptor , NetworkTypeDescriptor } ;
12
12
use dfx_core:: error:: canister_id_store:: CanisterIdStoreError ;
13
13
use dfx_core:: error:: identity:: NewIdentityManagerError ;
14
14
use dfx_core:: error:: load_dfx_config:: LoadDfxConfigError ;
@@ -17,7 +17,7 @@ use dfx_core::identity::identity_manager::{IdentityManager, InitializeIdentity};
17
17
use fn_error_context:: context;
18
18
use ic_agent:: { Agent , Identity } ;
19
19
use semver:: Version ;
20
- use slog:: { warn , Logger , Record } ;
20
+ use slog:: { Logger , Record } ;
21
21
use std:: borrow:: Cow ;
22
22
use std:: cell:: RefCell ;
23
23
use std:: path:: PathBuf ;
@@ -288,11 +288,23 @@ impl<'a> AgentEnvironment<'a> {
288
288
identity_manager. instantiate_selected_identity ( & logger) ?
289
289
} ;
290
290
if network_descriptor. is_ic
291
+ && !matches ! (
292
+ network_descriptor. r#type,
293
+ NetworkTypeDescriptor :: Playground { .. }
294
+ )
291
295
&& identity. insecure
292
296
&& !is_warning_disabled ( MainnetPlainTextIdentity )
293
297
{
294
- warn ! ( logger, "The {} identity is not stored securely. Do not use it to control a lot of cycles/ICP. Create a new identity with `dfx identity new` \
295
- and use it in mainnet-facing commands with the `--identity` flag", identity. name( ) ) ;
298
+ bail ! (
299
+ "The {} identity is not stored securely. Do not use it to control a lot of cycles/ICP.
300
+ - For enhanced security, create a new identity using the command:
301
+ dfx identity new
302
+ Then, specify the new identity in mainnet-facing commands with the `--identity` flag.
303
+ - If you understand the risks and still wish to use the insecure plaintext identity, you can suppress this warning by running:
304
+ export DFX_WARNING=-mainnet_plaintext_identity
305
+ After setting this environment variable, re-run the command." ,
306
+ identity. name( )
307
+ ) ;
296
308
}
297
309
let url = network_descriptor. first_provider ( ) ?;
298
310
let effective_canister_id = if let Some ( d) = & network_descriptor. local_server_descriptor {
0 commit comments