Skip to content

Commit

Permalink
Merge branch 'master' into test-uis-with-playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswanson-dfinity authored Dec 5, 2023
2 parents 837b2da + b179e51 commit 0dc025d
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 19 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/publish-dfxvm-install-script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish dfxvm install script

on:
push:
branches:
- sdk-1278-dfxvm-install-script

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# When getting Rust dependencies, retry on network error:
CARGO_NET_RETRY: 10
# Use the local .curlrc
CURL_HOME: .

jobs:
publish-manifest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install shfmt
run: go install mvdan.cc/sh/v3/cmd/shfmt@latest
- name: Generate
run: |
shellcheck --shell=sh public/install/*.sh --exclude SC2154,SC2034,SC3003,SC3014,SC3043
~/go/bin/shfmt -d -p -i 4 -ci -bn -s public/install/*.sh
sed -i "s/@revision@/${GITHUB_SHA}/" public/install/999_footer.sh
mkdir _out
cat public/install/*.sh > _out/install.sh
sed -i "
/#!.*/p
/##.*/p
/^ *$/d
/^ *#/d
s/ *#.*//
" _out/install.sh
- name: Upload Artifacts
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
single_commit: yes
branch: dfxvm-install-script
folder: _out/
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

# UNRELEASED

### feat: `dfx ledger top-up` also accepts canister names

Previously, `dfx ledger top-up` only accepted canister principals. Now it accepts both principals and canister names.

### fix: installer once again detects if curl supports tlsv1.2

A change to `curl --help` output made it so the install script did not detect
that the `--proto` and `--tlsv1.2` options are available.

# 0.15.2

### fix: `dfx canister delete <canister id>` removes the related entry from the canister id store

Previously, deleting a canister in the project by id rather than by name
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions docs/cli-reference/dfx-ledger.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ dfx ledger top-up [options] canister [flag] --network ic

You can specify the following argument for the `dfx ledger top-up` command.

| Argument | Description |
|------------|------------------------------------------------------------------|
| `canister` | Specifies the canister identifier that you would like to top up. |
| Argument | Description |
|------------|--------------------------------------------------------------------------|
| `canister` | Specifies the canister identifier or name that you would like to top up. |

### Options

Expand Down
6 changes: 6 additions & 0 deletions e2e/tests-dfx/ledger.bash
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ tc_to_num() {
assert_contains "Using transfer at block height $block_height" "$stdout"
# shellcheck disable=SC2154
assert_contains "Canister was topped up with" "$stdout"

# Top up canister by name instead of principal
dfx_new
assert_command dfx canister create e2e_project_backend
assert_command dfx ledger top-up e2e_project_backend --amount 5
assert_contains "Canister was topped up with 617283500000000 cycles"
}

@test "ledger create-canister" {
Expand Down
4 changes: 2 additions & 2 deletions e2e/utils/cycles-ledger.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CYCLES_LEDGER_VERSION="0.2.1"

build_artifact_url() {
echo "https://raw.githubusercontent.com/dfinity/sdk/cycles-ledger-prerelease/cycles-ledger-v$CYCLES_LEDGER_VERSION/${1}"
echo "https://github.com/dfinity/cycles-ledger/releases/download/cycles-ledger-v$CYCLES_LEDGER_VERSION/${1}"
}

downloaded_cycles_ledger_canisters_dir() {
Expand All @@ -22,7 +22,7 @@ download_cycles_ledger_canisters() {
for name in cycles-ledger cycles-depositor; do
for ext in wasm.gz wasm.gz.sha256 did; do
URL=$(build_artifact_url "${name}.${ext}")
curl -v --fail -o "$DOWNLOAD_DIR/${name}.${ext}" "$URL"
curl -v -L --fail -o "$DOWNLOAD_DIR/${name}.${ext}" "$URL"
done
done

Expand Down
2 changes: 1 addition & 1 deletion public/install/200_downloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ check_help_for() {
fi

for _arg in "$@"; do
if ! "$_cmd" --help | grep -q -- "$_arg"; then
if ! "$_cmd" --help all | grep -q -- "$_arg"; then
_ok="n"
fi
done
Expand Down
5 changes: 3 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tags": {
"latest": "0.15.1"
"latest": "0.15.2"
},
"versions": [
"0.5.0",
Expand Down Expand Up @@ -59,6 +59,7 @@
"0.14.3",
"0.14.4",
"0.15.0",
"0.15.1"
"0.15.1",
"0.15.2"
]
}
16 changes: 9 additions & 7 deletions src/dfx/src/commands/ledger/top_up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const MEMO_TOP_UP_CANISTER: u64 = 1347768404_u64;
/// Top up a canister with cycles minted from ICP
#[derive(Parser)]
pub struct TopUpOpts {
/// Specify the canister id to top up
/// Specify the canister id or name to top up
canister: String,

/// Subaccount to withdraw from
Expand Down Expand Up @@ -58,12 +58,14 @@ pub async fn exec(env: &dyn Environment, opts: TopUpOpts) -> DfxResult {

let memo = Memo(MEMO_TOP_UP_CANISTER);

let to = Principal::from_text(&opts.canister).with_context(|| {
format!(
"Failed to parse {:?} as target canister principal.",
&opts.canister
)
})?;
let to = Principal::from_text(&opts.canister)
.or_else(|_| env.get_canister_id_store()?.get(&opts.canister))
.with_context(|| {
format!(
"Failed to parse {:?} as target canister principal or name.",
&opts.canister
)
})?;

let agent = env.get_agent();

Expand Down

0 comments on commit 0dc025d

Please sign in to comment.