#!/bin/bash
# Get public keys from Web3Signer
# Usage: ./scripts/get-web3signer-public-keys.sh

WEB3SIGNER_HOST="192.168.11.111"

echo "═══════════════════════════════════════════════════════════════"
echo "🔑 WEB3SIGNER PUBLIC KEYS"
echo "═══════════════════════════════════════════════════════════════"
echo ""

echo "Fetching public keys from Web3Signer..."
echo ""

PUBLIC_KEYS=$(curl -s http://$WEB3SIGNER_HOST:9000/api/v1/eth1/publicKeys 2>/dev/null)

if [ -z "$PUBLIC_KEYS" ] || [ "$PUBLIC_KEYS" = "[]" ]; then
    echo "⚠️  No keys found in Web3Signer"
    echo ""
    echo "To add keys:"
    echo "  1. Generate test keys: ./scripts/generate-test-keys.sh"
    echo "  2. Setup keys: ./scripts/setup-web3signer-keys.sh"
    exit 0
fi

echo "Public Keys (addresses):"
echo "$PUBLIC_KEYS" | jq -r '.[]' 2>/dev/null || echo "$PUBLIC_KEYS"

echo ""
echo "═══════════════════════════════════════════════════════════════"
echo "💡 TIP: Use these addresses in wallet allowlist configuration"
echo "═══════════════════════════════════════════════════════════════"
