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: include #4172 in 0.26.0 #4178

Merged
merged 1 commit into from
Mar 31, 2025
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
23 changes: 12 additions & 11 deletions docs/cli-reference/dfx-info.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ dfx info [type] [flag]

These are the types of information that the `dfx info` command can display.

| Information | Description |
|----------------------|----------------------------------------------------------------------------------------------------------------------|
| candid-ui-url | The URL of the Candid UI canister. |
| config-json-path | Path to DFX configuration `config.json`. |
| networks-json-path | Path to network definition file `networks.json`. |
| replica-port | The listening port of the replica. |
| pocketic-config-port | The listening port of PocketIC. |
| replica-rev | The revision of the bundled replica. |
| security-policy | Show the headers that gets applied to assets in `.ic-assets.json5` if "security_policy" is "standard" or "hardened". |
| telemetry-log-path | Show the path to the telemetry log. |
| webserver-port | The local webserver port. |
| Information | Description |
|-------------------------------|----------------------------------------------------------------------------------------------------------------------|
| candid-ui-url | The URL of the Candid UI canister. |
| config-json-path | Path to DFX configuration `config.json`. |
| networks-json-path | Path to network definition file `networks.json`. |
| default-effective-canister-id | The effective canister ID that dfx will use for management canister calls that don't imply one. |
| replica-port | The listening port of the replica. |
| pocketic-config-port | The listening port of PocketIC. |
| replica-rev | The revision of the bundled replica. |
| security-policy | Show the headers that gets applied to assets in `.ic-assets.json5` if "security_policy" is "standard" or "hardened". |
| telemetry-log-path | Show the path to the telemetry log. |
| webserver-port | The local webserver port. |

## Options

Expand Down
16 changes: 16 additions & 0 deletions e2e/tests-dfx/info.bash
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,19 @@ teardown() {
assert_command test -f "$cfg"
assert_command jq . "$cfg"
}

@test "prints the pocket-ic default effective canister id" {
dfx_start
if [[ $USE_REPLICA ]]; then
assert_command dfx info default-effective-canister-id
assert_eq "$stdout" rwlgt-iiaaa-aaaaa-aaaaa-cai
else
local topology expected_id64 expected_id
topology=$(curl "http://localhost:$(get_webserver_port)/_/topology")
expected_id64=$(jq -r .default_effective_canister_id.canister_id <<<"$topology")
expected_id=$(cat <(crc32 <(base64 -d <<<"$expected_id64") | xxd -r -p) <(base64 -d <<<"$expected_id64") | base32 \
| tr -d = | tr '[:upper:]' '[:lower:]' | fold -w5 | paste -sd- -)
assert_command dfx info default-effective-canister-id
assert_eq "$stdout" "$expected_id"
fi
}
3 changes: 3 additions & 0 deletions scripts/workflows/provision-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ if [ "$E2E_TEST" = "tests-dfx/identity_encryption.bash" ] \
then
sudo apt-get install --yes expect
fi
if [ "$E2E_TEST" = "tests-dfx/info.bash" ]; then
sudo apt-get install --yes libarchive-zip-perl
fi

# Set environment variables.
echo "$HOME/bin" >> "$GITHUB_PATH"
Expand Down
6 changes: 6 additions & 0 deletions src/dfx/src/commands/info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ enum InfoType {
PocketicConfigPort,
/// Show the path to the telemetry log file
TelemetryLogPath,
/// Show the effective canister ID that dfx will use for management canister calls that don't imply one
DefaultEffectiveCanisterId,
}

#[derive(Parser)]
Expand All @@ -60,6 +62,10 @@ pub fn exec(env: &dyn Environment, opts: InfoOpts) -> DfxResult {
),
}
}
InfoType::DefaultEffectiveCanisterId => {
let env = create_anonymous_agent_environment(env, opts.network.to_network_name())?;
env.get_effective_canister_id().to_text()
}
InfoType::SecurityPolicy => {
ic_asset::security_policy::SecurityPolicy::Standard.to_json5_str()
}
Expand Down