#!/usr/bin/env bash
# Check verification status of all contracts on Blockscout
# Usage: ./check-contract-verification-status.sh

VERIFIER_URL="https://explorer.d-bis.org/api"

declare -A CONTRACTS=(
    ["Oracle Proxy"]="0x3304b747e565a97ec8ac220b0b6a1f6ffdb837e6"
    ["Oracle Aggregator"]="0x99b3511a2d315a497c8112c1fdd8d508d4b1e506"
    ["CCIP Router"]="0x8078A09637e47Fa5Ed34F626046Ea2094a5CDE5e"
    ["CCIP Sender"]="0x105F8A15b819948a89153505762444Ee9f324684"
    ["CCIPWETH9Bridge"]="0x89dd12025bfCD38A168455A44B400e913ED33BE2"
    ["CCIPWETH10Bridge"]="0xe0E93247376aa097dB308B92e6Ba36bA015535D0"
    ["Price Feed Keeper"]="0xD3AD6831aacB5386B8A25BB8D8176a6C8a026f04"
)

echo "========================================="
echo "Contract Verification Status Check"
echo "Blockscout: https://explorer.d-bis.org"
echo "========================================="
echo ""

VERIFIED=0
NOT_VERIFIED=0

for name in "${!CONTRACTS[@]}"; do
    addr="${CONTRACTS[$name]}"
    echo -n "Checking $name... "
    
    response=$(curl -s "${VERIFIER_URL%/api}/api/v2/smart-contracts/${addr}" 2>/dev/null || echo "")
    
    if echo "$response" | grep -q '"is_verified":true' || echo "$response" | grep -q '"verified":true'; then
        echo "✅ Verified"
        VERIFIED=$((VERIFIED + 1))
    else
        echo "⏳ Not Verified"
        NOT_VERIFIED=$((NOT_VERIFIED + 1))
    fi
done

echo ""
echo "========================================="
echo "Summary: $VERIFIED verified, $NOT_VERIFIED pending"
echo "========================================="
