#!/usr/bin/env bash # Run XDC-Zero registerapplications.js on xdcparentnet and chain138. # Prerequisites: applications[] filled in endpointconfig.json for each network; Endpoint owner key. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" # shellcheck source=/dev/null source "${PROJECT_ROOT}/scripts/lib/load-project-env.sh" EP="${XDC_ZERO_ENDPOINT_DIR:-${HOME}/projects/XDC-Zero/endpoint}" DRY=false [[ "${1:-}" == "--dry-run" ]] && DRY=true [[ -f "${EP}/endpointconfig.json" ]] || { echo "ERROR: missing ${EP}/endpointconfig.json" >&2 exit 1 } cd "$EP" if [[ ! -d node_modules ]]; then if command -v yarn >/dev/null 2>&1; then yarn install else npm install fi fi run() { local net="$1" if $DRY; then if command -v yarn >/dev/null 2>&1; then echo "DRY-RUN: yarn hardhat run scripts/registerapplications.js --network $net" else echo "DRY-RUN: npx hardhat run scripts/registerapplications.js --network $net" fi return 0 fi if command -v yarn >/dev/null 2>&1; then yarn hardhat run scripts/registerapplications.js --network "$net" else npx hardhat run scripts/registerapplications.js --network "$net" fi } run xdcparentnet run chain138 echo "Done."