Skip to content

Commit

Permalink
Merge branch 'master' into severin/missing-ledger-error-message
Browse files Browse the repository at this point in the history
  • Loading branch information
sesi200 authored Nov 22, 2024
2 parents 9fb12d2 + 1c22db8 commit 2bd9e85
Show file tree
Hide file tree
Showing 24 changed files with 179 additions and 173 deletions.
17 changes: 9 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

# UNRELEASED

### feat: Bitcoin support in PocketIC
### feat: error when using insecure identity on mainnet

`dfx start --pocketic` is now compatible with `--bitcoin-node` and `--enable-bitcoin`.
This used to be a warning. A hard error can abort the command so that no insecure state will be on the mainnet.

### feat: all commands will use the DFX_NETWORK from the environment
Users can surpress this error by setting `export DFX_WARNING=-mainnet_plaintext_identity`.

If `DFX_NETWORK` is set in the environment, all commands will use that network by default.
The `--network` parameter will take precedence if provided.
The warning won't display when executing commands like `dfx deploy --playground`.

### fix: dfx generate now honors the --network parameter
This fixes an issue where `dfx deploy --playground` would fail if the project
had not been previously built for the local network.
# 0.24.3

### feat: Bitcoin support in PocketIC

`dfx start --pocketic` is now compatible with `--bitcoin-node` and `--enable-bitcoin`.

### feat: facade pull ICP, ckBTC, ckETH ledger canisters

Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docs/cli-reference/dfx-cycles.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ The following subcommands are available:

| Command | Description |
|---------------------------------------|--------------------------------------------------------------------------------------|
| [`approve`](#dfx-cycles-approve) | Approves a principal to spend cycles on your behalf. |
| [`balance`](#dfx-cycles-balance) | Prints the account balance of the user. |
| [`convert`](#dfx-cycles-convert) | Convert some of the user's ICP balance into cycles. |
| [`top-up`](#dfx-cycles-top-up) | Deposit cycles into a canister. |
| [`transfer`](#dfx-cycles-transfer) | Send cycles to another account. |
| `help` | Displays usage information message for a specified subcommand. |

Expand Down Expand Up @@ -135,7 +137,7 @@ You can specify the following arguments for the `dfx cycles convert` command.
| `--e8s <e8s>` | Specify ICP token fractional units—called e8s—as a whole number, where one e8 is the smallest fraction of an ICP token. For example, 1.05000000 is 1 ICP and 5000000 e8s. You can use this option on its own or in conjunction with the `--icp` option. |
| `--fee <fee>` | Specify a transaction fee. The default is 10000 e8s. |
| `--icp <icp>` | Specify ICP tokens as a whole number. You can use this option on its own or in conjunction with `--e8s`. |
| `--memo <memo>` | Memo used when depositing the minted cycles. |
| `--deposit-memo <memo>` | Memo used when depositing the minted cycles. |
| `--to-subaccount <subaccount>` | Subaccount where the cycles are deposited. |

### Examples
Expand Down
6 changes: 4 additions & 2 deletions e2e/tests-dfx/canister_url.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ load ../utils/_

setup() {
standard_setup

# some of the tests run on mainnet with default plaintext identity
# so we need to set this to avoid the error
export DFX_WARNING=-mainnet_plaintext_identity
dfx_new_assets hello
}

Expand Down Expand Up @@ -58,7 +60,7 @@ teardown() {
echo "{}" > canister_ids.json
jq '.hello_frontend.ic = "qsgof-4qaaa-aaaan-qekqq-cai"' canister_ids.json | sponge canister_ids.json
frontend_id=$(dfx canister id hello_frontend --ic)

assert_command dfx canister url hello_frontend --ic
assert_match "https://${frontend_id}.icp0.io"

Expand Down
2 changes: 1 addition & 1 deletion e2e/tests-dfx/cycles-ledger.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ teardown() {
start_and_install_nns() {
dfx_start_for_nns_install

dfx extension install nns --version 0.4.3
dfx extension install nns --version 0.4.7
dfx nns install --ledger-accounts "$(dfx ledger account-id --identity cycle-giver)"
}

Expand Down
54 changes: 51 additions & 3 deletions e2e/tests-dfx/extension.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,54 @@ teardown() {
standard_teardown
}

@test "run an extension command with a canister type defined by another extension" {
install_shared_asset subnet_type/shared_network_settings/system
dfx_start_for_nns_install

install_asset wasm/identity
CACHE_DIR=$(dfx cache show)
mkdir -p "$CACHE_DIR"/extensions/embera
cat > "$CACHE_DIR"/extensions/embera/extension.json <<EOF
{
"name": "embera",
"version": "0.1.0",
"homepage": "https://github.com/dfinity/dfx-extensions",
"authors": "DFINITY",
"summary": "Test extension for e2e purposes.",
"categories": [],
"keywords": [],
"canister_type": {
"evaluation_order": [ "wasm" ],
"defaults": {
"type": "custom",
"build": [
"echo the embera build step for canister {{canister_name}} with candid {{canister.candid}} and main file {{canister.main}} and gzip is {{canister.gzip}}",
"mkdir -p .embera/{{canister_name}}",
"cp main.wasm {{canister.wasm}}"
],
"gzip": true,
"wasm": ".embera/{{canister_name}}/{{canister_name}}.wasm"
}
}
}
EOF
cat > dfx.json <<EOF
{
"canisters": {
"c1": {
"type": "embera",
"candid": "main.did",
"main": "main-file.embera"
}
}
}
EOF

dfx extension install nns --version 0.4.7
dfx nns install
}


@test "extension canister type" {
dfx_start

Expand Down Expand Up @@ -187,14 +235,14 @@ install_extension_from_dfx_extensions_repo() {
assert_command dfx extension list
assert_match 'No extensions installed'

assert_command dfx extension install "$EXTENSION" --install-as snsx --version 0.2.1
assert_contains "Extension 'sns' version 0.2.1 installed successfully, and is available as 'snsx'"
assert_command dfx extension install "$EXTENSION" --install-as snsx --version 0.4.7
assert_contains "Extension 'sns' version 0.4.7 installed successfully, and is available as 'snsx'"

assert_command dfx extension list
assert_match 'snsx'

assert_command dfx --help
assert_match 'snsx.*Toolkit for'
assert_match 'snsx.*Initialize, deploy and interact with an SNS'

assert_command dfx snsx --help

Expand Down
2 changes: 2 additions & 0 deletions e2e/tests-dfx/fabricate_cycles.bash
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ teardown() {

@test "ledger fabricate-cycles fails on real IC" {
install_asset greet
# without DFX_WARNING, the command would fail with different error (Failed to create AgentEnvironment...)
export DFX_WARNING=-mainnet_plaintext_identity
assert_command_fail dfx ledger fabricate-cycles --all --network ic
assert_match "Cannot run this on the real IC."
assert_command_fail dfx ledger fabricate-cycles --all --ic
Expand Down
12 changes: 6 additions & 6 deletions e2e/tests-dfx/identity.bash
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ teardown() {
assert_eq '(blob "hello")' "$stdout"
}

@test "using an unencrypted identity on mainnet provokes a warning" {
assert_command dfx ledger balance --network ic
assert_match "WARN: The default identity is not stored securely." "$stderr"
@test "using an unencrypted identity on mainnet provokes a hard error which can be suppressed" {
assert_command_fail dfx ledger balance --network ic
assert_match "The default identity is not stored securely." "$stderr"
assert_command "${BATS_TEST_DIRNAME}/../assets/expect_scripts/init_alice_with_pw.exp"
assert_command "${BATS_TEST_DIRNAME}/../assets/expect_scripts/get_ledger_balance.exp"
dfx identity new bob --storage-mode plaintext
assert_command dfx ledger balance --network ic --identity bob
assert_match "WARN: The bob identity is not stored securely." "$stderr"

assert_command_fail dfx ledger balance --network ic --identity bob
assert_match "The bob identity is not stored securely." "$stderr"
# can suppress the error
export DFX_WARNING=-mainnet_plaintext_identity
assert_command dfx ledger balance --network ic --identity bob
assert_not_contains "not stored securely" "$stderr"
Expand Down
8 changes: 4 additions & 4 deletions e2e/tests-dfx/network.bash
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ teardown() {

assert_command_fail dfx diagnose --network ic
assert_contains "The test_id identity is not stored securely."
assert_contains "use it in mainnet-facing commands"
assert_contains "No wallet found; nothing to do"
assert_contains "in mainnet-facing commands"
assert_contains "you can suppress this warning"

assert_command_fail dfx diagnose --ic
assert_contains "The test_id identity is not stored securely."
assert_contains "use it in mainnet-facing commands"
assert_contains "No wallet found; nothing to do"
assert_contains "in mainnet-facing commands"
assert_contains "you can suppress this warning"

assert_command dfx diagnose
assert_not_contains "identity is not stored securely"
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests-dfx/sign_send.bash
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ teardown() {
cd "$E2E_TEMP_DIR"
mkdir not-a-project-dir
cd not-a-project-dir

# suppress the error
export DFX_WARNING=-mainnet_plaintext_identity
assert_command dfx canister sign --query rwlgt-iiaaa-aaaaa-aaaaa-cai read --network ic
assert_match "Query message generated at \[message.json\]"
}
Expand Down
1 change: 0 additions & 1 deletion src/dfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ shell-words = "1.1.0"
slog = { workspace = true, features = ["max_level_trace"] }
slog-async.workspace = true
slog-term.workspace = true
socket2 = "0.5.5"
supports-color = "2.1.0"
sysinfo = "0.28.4"
tar.workspace = true
Expand Down
Loading

0 comments on commit 2bd9e85

Please sign in to comment.