#!/usr/bin/env bash
# Add WETH9 and WETH10 to genesis.json via alloc

set -e

cd "$(dirname "$0")/../.."

# Color codes

echo "=== Adding WETH9 and WETH10 to Genesis ==="

GENESIS_FILE="config/genesis.json"

if [ ! -f "$GENESIS_FILE" ]; then
    log_error "❌ Genesis file not found: $GENESIS_FILE"
    exit 1
fi

# WETH9 and WETH10 addresses
WETH9_ADDR="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
WETH10_ADDR="0xf4BB2e28688e89fCcE3c0580D37d36A7672E8A9f"

# Check if already present
if grep -q "$WETH9_ADDR" "$GENESIS_FILE" 2>/dev/null; then
    log_success "✅ WETH9 already in genesis"
else
    log_warn "⚠️  WETH9 not in genesis - needs to be added"
    echo "  Use: scripts/genesis/add-predeployed-weth-mainnet.sh"
fi

if grep -q "$WETH10_ADDR" "$GENESIS_FILE" 2>/dev/null; then
    log_success "✅ WETH10 already in genesis"
else
    log_warn "⚠️  WETH10 not in genesis - needs to be added"
    echo "  Use: scripts/genesis/add-predeployed-weth-mainnet.sh"
fi

echo "Note: WETH contracts should be predeployed via alloc in genesis.json"
echo "  This ensures they exist at canonical addresses from block 0"
