diff --git a/bin/dfx-network-deploy b/bin/dfx-network-deploy index 77551c79..e3c5f967 100755 --- a/bin/dfx-network-deploy +++ b/bin/dfx-network-deploy @@ -58,6 +58,7 @@ if [[ "$DFX_NETWORK" == "local" ]]; then dfx-nns-install --ic_commit "$DFX_IC_COMMIT" dfx-nns-import --network "$DFX_NETWORK" + dfx-canister-set-id --canister_name nns-icp-index --canister_id q3fc5-haaaa-aaaaa-aaahq-cai dfx-canister-set-id --canister_name nns-dapp --canister_id qsgjb-riaaa-aaaaa-aaaga-cai dfx-canister-set-id --canister_name sns_aggregator --canister_id sgymv-uiaaa-aaaaa-aaaia-cai dfx-canister-set-id --canister_name internet_identity --canister_id qhbym-qaaaa-aaaaa-aaafq-cai diff --git a/bin/dfx-software-nns-dapp-install b/bin/dfx-software-nns-dapp-install new file mode 100755 index 00000000..699f6e78 --- /dev/null +++ b/bin/dfx-software-nns-dapp-install @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +set -euo pipefail +SOURCE_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" +PATH="$SOURCE_DIR:$PATH" + +print_help() { + cat <<-EOF + + Fetches and installs the nns-dapp canister: + * Downloads the NNS dapp wasm. + * Adds the nns-dapp to dfx.json, if not already present. + * Deploys the downloaded wasm to the specified network. + EOF +} + +# Source the clap.bash file --------------------------------------------------- +source "$SOURCE_DIR/clap.bash" +# Define options +clap.define short=n long=network desc="The dfx network to use" variable=DFX_NETWORK default="local" +clap.define short=r long=release desc="The release name" variable=DFX_RELEASE default="pinned" +clap.define short=m long=mode desc="The install mode: install, reinstall, upgrade" variable=DFX_MODE default="reinstall" +# Source the output file ---------------------------------------------------------- +source "$(clap.build)" + +: 'Convert aliases such as "pinned" into actual release names...' +DFX_RELEASE="$(dfx-software-nns-dapp-version "${DFX_RELEASE}")" + +: 'Where to get the wasm from...' +WASM_URL="$(dfx-software-nns-dapp-ci-wasm-url --release "${DFX_RELEASE}")" + +: 'Where to put the wasm...' +# Note: We do NOT clobber the wasm pointed to by dfx.json. +WASM_FILE="wasms/nns-dapp_${DFX_RELEASE}.wasm" + +: 'Get the wasm if it is not already there.' +: 'We assume that releases are immutable, and the wasm filename contains the release and flavour.' +test -e "$WASM_FILE" || { + echo "Downloading wasm from: $WASM_URL" + mkdir -p "$(dirname "$WASM_FILE")" + curl --retry 5 --fail -sSL "${WASM_URL}" >"${WASM_FILE}.tmp" + mv "${WASM_FILE}.tmp" "${WASM_FILE}" + echo " saved wasm to: $WASM_FILE" +} + +: 'We need at least a minimal entry in dfx.json' +jq -e '.canisters."nns-dapp"' dfx.json >/dev/null || { + echo "Adding nns-dapp to dfx.json..." + # TODO: Include API declaration .did files in release, so that we can get the candid. + jq -s '.[0] * .[1]' <(echo '{"canisters": { "nns-dapp": { "type": "custom", "candid": "candid/nns-dapp.did", "wasm": "'"${WASM_FILE}"'", "build": "true" }}}') dfx.json | sponge dfx.json +} + +: "If the canister was remote, it isn't any more:" +DFX_NETWORK="$DFX_NETWORK" jq 'del(.canisters."nns-dapp".remote.id[env.DFX_NETWORK])' dfx.json | sponge dfx.json + +canister_id() { + local canister_name="$1" + dfx canister id "$canister_name" --network "$DFX_NETWORK" || { + echo "Canister $canister_name not found on network $DFX_NETWORK." >&2 + echo "not-found-canister-id" + } +} + +# These args are specific to localhost. For other networks, the args should +# still work for nns-dapp to be used as a backend but if you want to load the +# frontend directly from the canister, you should upgrade nns-dapp with args +# created by `config.sh` from the nns-dapp repo. +CANISTER_ARG="(opt record{ + args = vec { + record{ 0=\"API_HOST\"; 1=\"http://localhost:8080\" }; + record{ 0=\"CKBTC_INDEX_CANISTER_ID\"; 1=\"$(canister_id ckbtc_index)\" }; + record{ 0=\"CKBTC_LEDGER_CANISTER_ID\"; 1=\"$(canister_id ckbtc_ledger)\" }; + record{ 0=\"CKBTC_MINTER_CANISTER_ID\"; 1=\"$(canister_id ckbtc_minter)\" }; + record{ 0=\"CKETH_INDEX_CANISTER_ID\"; 1=\"$(canister_id cketh_index)\" }; + record{ 0=\"CKETH_LEDGER_CANISTER_ID\"; 1=\"$(canister_id cketh_ledger)\" }; + record{ 0=\"CKUSDC_INDEX_CANISTER_ID\"; 1=\"$(canister_id ckusdc_index)\" }; + record{ 0=\"CKUSDC_LEDGER_CANISTER_ID\"; 1=\"$(canister_id ckusdc_ledger)\" }; + record{ 0=\"CYCLES_MINTING_CANISTER_ID\"; 1=\"$(canister_id nns-cycles-minting)\" }; + record{ 0=\"DFX_NETWORK\"; 1=\"$DFX_NETWORK\" }; + record{ 0=\"FEATURE_FLAGS\"; 1=\"{\\\"ENABLE_CKBTC\\\":true,\\\"ENABLE_CKTESTBTC\\\":false}\" }; + record{ 0=\"FETCH_ROOT_KEY\"; 1=\"true\" }; + record{ 0=\"GOVERNANCE_CANISTER_ID\"; 1=\"$(canister_id nns-governance)\" }; + record{ 0=\"HOST\"; 1=\"http://localhost:8080\" }; + record{ 0=\"IDENTITY_SERVICE_URL\"; 1=\"http://$(canister_id internet_identity).localhost:8080\" }; + record{ 0=\"INDEX_CANISTER_ID\"; 1=\"$(canister_id nns-icp-index)\" }; + record{ 0=\"LEDGER_CANISTER_ID\"; 1=\"$(canister_id nns-ledger)\" }; + record{ 0=\"OWN_CANISTER_ID\"; 1=\"$(canister_id nns-dapp)\" }; + record{ 0=\"ROBOTS\"; 1=\"\" }; + record{ 0=\"SNS_AGGREGATOR_URL\"; 1=\"http://$(canister_id sns_aggregator).localhost:8080\" }; + record{ 0=\"STATIC_HOST\"; 1=\"http://localhost:8080\" }; + record{ 0=\"TVL_CANISTER_ID\"; 1=\"$(canister_id nns-dapp)\" }; + record{ 0=\"WASM_CANISTER_ID\"; 1=\"$(canister_id nns-sns-wasm)\" }; + }; +})" + +echo "Installing nns-dapp..." +# Note: We specify the wasm file explicitly as an existing wasm path may not point to the requested wasm. +dfx canister install nns-dapp --wasm "$WASM_FILE" --upgrade-unchanged --mode "$DFX_MODE" --yes --network "${DFX_NETWORK}" --argument "$CANISTER_ARG" +echo "Checking nns-dapp installation..." +dfx-canister-check-wasm-hash --canister nns-dapp --network "$DFX_NETWORK" --wasm "${WASM_FILE}" +echo "Finished installing nns-dapp. Enjoy!" diff --git a/bin/dfx-stock-deploy b/bin/dfx-stock-deploy index 6bd86f57..7a5b6fb2 100755 --- a/bin/dfx-stock-deploy +++ b/bin/dfx-stock-deploy @@ -94,6 +94,9 @@ dfx canister call cketh_ledger icrc1_transfer "(record {to=record{owner=principa dfx canister call ckusdc_ledger icrc1_transfer "(record {to=record{owner=principal \"$FAUCET_ADDRESS\"}; amount=10_000_000_000_000:nat})" dfx canister call ckred_ledger icrc1_transfer "(record {to=record{owner=principal \"$FAUCET_ADDRESS\"}; amount=10_000_000_000_000:nat})" +# Install nns-dapp last so all the canister IDs exist to pass as args. +dfx-software-nns-dapp-install --network "$DFX_NETWORK" --release pinned + : Add the nns root as a controller to the frontend canisters NNS_ROOT="$(dfx canister id nns-root --network "$DFX_NETWORK")" for canister in nns-dapp internet_identity; do diff --git a/bin/versions.bash b/bin/versions.bash index f56251b1..379c75dd 100644 --- a/bin/versions.bash +++ b/bin/versions.bash @@ -4,7 +4,7 @@ SNS_AGGREGATOR_RELEASE=proposal-129614-agg DFX_IC_COMMIT=094f99d173b860132c711bebdf4833f951e772d4 INTERNET_IDENTITY_RELEASE=release-2023-10-27 -NNS_DAPP_RELEASE=proposal-121690 +NNS_DAPP_RELEASE=proposal-133373 DIDC_VERSION=2023-07-25 QUILL_VERSION=0.4.0 IDL2JSON_VERSION=0.8.5