#!/usr/bin/env bash
# Deploy ISO-4217W Token System (ISO-009 to ISO-018)
# Requires: PRIVATE_KEY, RPC_URL (ChainID 138)
# Optional: CUSTODIAN_ADDRESS, RESERVE_MANAGER_ADDRESS, RESERVE_TRANSMITTER_1, RESERVE_TRANSMITTER_2

set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_ROOT"

source "$PROJECT_ROOT/scripts/load-env.sh" >/dev/null 2>&1 || true

: "${PRIVATE_KEY:?PRIVATE_KEY required}"
: "${RPC_URL:?RPC_URL required (e.g. http://192.168.11.250:8545)}"

echo "Deploying ISO-4217W Token System..."
forge script script/deploy/iso4217w/DeployISO4217WSystem.s.sol:DeployISO4217WSystem \
  --rpc-url "$RPC_URL" \
  --broadcast \
  --verify
