#!/usr/bin/env bash # Sync DUAL_CHAIN_TOKEN_LIST and DUAL_CHAIN_NETWORKS to all locations. # Run from repo root. Source of truth: explorer-monorepo/backend/api/rest/config/metamask/ # Usage: ./scripts/sync-dual-chain-configs.sh [--dry-run] set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" SRC="$REPO_ROOT/explorer-monorepo/backend/api/rest/config/metamask" DRY_RUN=false for a in "$@"; do [[ "$a" == "--dry-run" ]] && DRY_RUN=true && break; done TOKEN_LIST="DUAL_CHAIN_TOKEN_LIST.tokenlist.json" NETWORKS="DUAL_CHAIN_NETWORKS.json" if [[ ! -f "$SRC/$TOKEN_LIST" ]] || [[ ! -f "$SRC/$NETWORKS" ]]; then echo "Error: Source files not found at $SRC" >&2 exit 1 fi TARGETS=( "$REPO_ROOT/docs/04-configuration/metamask" "$REPO_ROOT/metamask-integration/provider/config" ) for dir in "${TARGETS[@]}"; do if [[ -d "$dir" ]]; then if $DRY_RUN; then echo "[dry-run] Would copy to $dir" else cp "$SRC/$TOKEN_LIST" "$dir/" cp "$SRC/$NETWORKS" "$dir/" echo "Synced to $dir" fi fi done echo "Done. Source: $SRC"