#!/bin/bash

echo "Testing KRAIKEN Ponder indexer local setup..."

# Kill any existing Anvil instance
pkill -f anvil || true

echo "Starting Anvil fork of Base mainnet..."
anvil --fork-url https://base.llamarpc.com --port 8545 &
ANVIL_PID=$!

# Wait for Anvil to start
sleep 5

echo "Starting Ponder indexer for local network..."
export PONDER_NETWORK=BASE_SEPOLIA_LOCAL_FORK
timeout 30 npm run dev

# Cleanup
kill $ANVIL_PID 2>/dev/null

echo "Test completed!"
