From 0c1975d37c3ef1fc22d29ff769cbe6bd7175d0d2 Mon Sep 17 00:00:00 2001 From: Max Murphy Date: Mon, 16 Sep 2024 17:40:46 +0200 Subject: [PATCH 1/2] Add cycles canisters --- dfx.json | 19 +++++++++ scripts/build.cycles_depositor.args.sh | 37 ++++++++++++++++ scripts/build.cycles_depositor.sh | 59 ++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100755 scripts/build.cycles_depositor.args.sh create mode 100755 scripts/build.cycles_depositor.sh diff --git a/dfx.json b/dfx.json index 0cdc06837..477a54d46 100644 --- a/dfx.json +++ b/dfx.json @@ -64,6 +64,25 @@ } } }, + "cycles_ledger": { + "type": "custom", + "candid": "https://github.com/dfinity/cycles-ledger/releases/download/cycles-ledger-v1.0.1/cycles-ledger.did", + "wasm": "https://github.com/dfinity/cycles-ledger/releases/download/cycles-ledger-v1.0.1/cycles-ledger.wasm.gz", + "init_arg": "( variant { Init = record { index_id = null; max_blocks_per_request = 9_999 : nat64 }},)", + "remote": { + "id": { + "ic": "um5iw-rqaaa-aaaaq-qaaba-cai" + } + } + }, + "cycles_depositor": { + "dependencies": ["cycles_ledger"], + "type": "custom", + "build": "scripts/build.cycles_depositor.sh", + "init_arg_file": "out/cycles_depositor.args.did", + "wasm": "out/cycles_depositor.wasm", + "candid": "out/cycles_depositor.did" + }, "pouh_issuer": { "type": "custom", "candid": "https://github.com/dfinity/verifiable-credentials-sdk/releases/download/release-2024-07-01/dummy_issuer.did", diff --git a/scripts/build.cycles_depositor.args.sh b/scripts/build.cycles_depositor.args.sh new file mode 100755 index 000000000..c5a888271 --- /dev/null +++ b/scripts/build.cycles_depositor.args.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -euo pipefail + +print_help() { + cat <<-EOF + Creates the cycles_depositor installation arguments. + + The file is installed at the location defined for 'cycles_depositor' in 'dfx.json'. + EOF +} + +[[ "${1:-}" != "--help" ]] || { + print_help + exit 0 +} + +DFX_NETWORK="${DFX_NETWORK:-local}" +ARG_FILE="$(jq -r .canisters.cycles_depositor.init_arg_file dfx.json)" + +#### +# Computes the install args, overwriting any existing args file. + +CANISTER_ID_CYCLES_LEDGER="${CANISTER_ID_CYCLES_LEDGER:-$(dfx canister id cycles_ledger --network "$DFX_NETWORK")}" + +# .. Creates the init args file +rm -f "$ARG_FILE" +mkdir -p "$(dirname "$ARG_FILE")" +cat <"$ARG_FILE" +(record { ledger_id = principal "$CANISTER_ID_CYCLES_LEDGER" }) +EOF + +#### +# Success +cat <"$CANDID_FILE" +fi + +#### +# Downloads the Wasm file, if it does not exist already. +if test -e "$WASM_FILE"; then + echo "Using existing cycles_depositor Wasm file" +else + mkdir -p "$(dirname "$WASM_FILE")" + curl -sSL "$WASM_URL" >"$WASM_FILE" +fi + +#### +# Computes the install args, overwriting any existing args file. +scripts/build.cycles_depositor.args.sh + +# Success +cat < Date: Mon, 16 Sep 2024 17:52:23 +0200 Subject: [PATCH 2/2] fmt --- dfx.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/dfx.json b/dfx.json index 477a54d46..6bd67ec4b 100644 --- a/dfx.json +++ b/dfx.json @@ -64,25 +64,25 @@ } } }, - "cycles_ledger": { - "type": "custom", - "candid": "https://github.com/dfinity/cycles-ledger/releases/download/cycles-ledger-v1.0.1/cycles-ledger.did", - "wasm": "https://github.com/dfinity/cycles-ledger/releases/download/cycles-ledger-v1.0.1/cycles-ledger.wasm.gz", - "init_arg": "( variant { Init = record { index_id = null; max_blocks_per_request = 9_999 : nat64 }},)", - "remote": { - "id": { - "ic": "um5iw-rqaaa-aaaaq-qaaba-cai" - } - } - }, - "cycles_depositor": { - "dependencies": ["cycles_ledger"], - "type": "custom", - "build": "scripts/build.cycles_depositor.sh", - "init_arg_file": "out/cycles_depositor.args.did", - "wasm": "out/cycles_depositor.wasm", - "candid": "out/cycles_depositor.did" - }, + "cycles_ledger": { + "type": "custom", + "candid": "https://github.com/dfinity/cycles-ledger/releases/download/cycles-ledger-v1.0.1/cycles-ledger.did", + "wasm": "https://github.com/dfinity/cycles-ledger/releases/download/cycles-ledger-v1.0.1/cycles-ledger.wasm.gz", + "init_arg": "( variant { Init = record { index_id = null; max_blocks_per_request = 9_999 : nat64 }},)", + "remote": { + "id": { + "ic": "um5iw-rqaaa-aaaaq-qaaba-cai" + } + } + }, + "cycles_depositor": { + "dependencies": ["cycles_ledger"], + "type": "custom", + "build": "scripts/build.cycles_depositor.sh", + "init_arg_file": "out/cycles_depositor.args.did", + "wasm": "out/cycles_depositor.wasm", + "candid": "out/cycles_depositor.did" + }, "pouh_issuer": { "type": "custom", "candid": "https://github.com/dfinity/verifiable-credentials-sdk/releases/download/release-2024-07-01/dummy_issuer.did",