feat: explorer API, wallet, CCIP scripts, and config refresh
- Backend REST/gateway/track routes, analytics, Blockscout proxy paths. - Frontend wallet and liquidity surfaces; MetaMask token list alignment. - Deployment docs, verification scripts, address inventory updates. Check: go build ./... under backend/ (pass). Made-with: Cursor
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
#!/bin/bash
|
||||
# Fix database connection and run migration
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
echo "=== Database Connection Fix ==="
|
||||
echo ""
|
||||
|
||||
# Database credentials for custom explorer backend
|
||||
# Database credentials for the selected deployment mode
|
||||
DB_HOST="${DB_HOST:-localhost}"
|
||||
DB_PORT="${DB_PORT:-5432}"
|
||||
DB_USER="${DB_USER:-explorer}"
|
||||
DB_PASSWORD="${DB_PASSWORD:-L@ker\$2010}"
|
||||
DB_NAME="${DB_NAME:-explorer}"
|
||||
if [ -z "${DB_PASSWORD:-}" ]; then
|
||||
echo "❌ DB_PASSWORD is required"
|
||||
echo " Export DB_PASSWORD before running this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Testing connection with:"
|
||||
echo " Host: $DB_HOST:$DB_PORT"
|
||||
@@ -21,38 +25,77 @@ echo ""
|
||||
|
||||
export PGPASSWORD="$DB_PASSWORD"
|
||||
|
||||
sql_scalar() {
|
||||
local sql="$1"
|
||||
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -Atc "$sql" 2>/dev/null | tr -d ' '
|
||||
}
|
||||
|
||||
is_shared_blockscout_db() {
|
||||
sql_scalar "
|
||||
SELECT CASE
|
||||
WHEN EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public' AND table_name = 'addresses'
|
||||
) AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'addresses' AND column_name = 'address'
|
||||
)
|
||||
THEN 'yes'
|
||||
ELSE 'no'
|
||||
END;
|
||||
"
|
||||
}
|
||||
|
||||
# Test connection
|
||||
echo -n "Testing connection... "
|
||||
if psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "SELECT 1;" > /dev/null 2>&1; then
|
||||
echo "✅ Connected"
|
||||
|
||||
# Check if migration tables exist
|
||||
echo -n "Checking for track schema tables... "
|
||||
TABLE_COUNT=$(psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'public' AND table_name IN ('wallet_nonces', 'operator_roles', 'addresses', 'token_transfers');" -t 2>/dev/null | tr -d ' ')
|
||||
|
||||
if [ "$TABLE_COUNT" -ge "4" ]; then
|
||||
echo "✅ All tables exist ($TABLE_COUNT/4)"
|
||||
|
||||
if [ "$(is_shared_blockscout_db || echo no)" = "yes" ]; then
|
||||
echo "Mode: shared Blockscout DB detected"
|
||||
REQUIRED_TABLES=(operator_events operator_ip_whitelist operator_roles wallet_nonces)
|
||||
else
|
||||
echo "Mode: standalone explorer DB detected"
|
||||
REQUIRED_TABLES=(wallet_nonces operator_roles addresses token_transfers)
|
||||
fi
|
||||
|
||||
echo -n "Checking required tables... "
|
||||
table_list=""
|
||||
for table in "${REQUIRED_TABLES[@]}"; do
|
||||
if [ -n "$table_list" ]; then
|
||||
table_list+=", "
|
||||
fi
|
||||
table_list+="'$table'"
|
||||
done
|
||||
TABLE_COUNT=$(sql_scalar "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'public' AND table_name IN (${table_list});")
|
||||
|
||||
if [ "${TABLE_COUNT:-0}" -ge "${#REQUIRED_TABLES[@]}" ]; then
|
||||
echo "✅ All required tables exist (${TABLE_COUNT}/${#REQUIRED_TABLES[@]})"
|
||||
echo ""
|
||||
echo "✅ Database is ready!"
|
||||
else
|
||||
echo "⚠️ Tables missing ($TABLE_COUNT/4 found)"
|
||||
echo "⚠️ Tables missing (${TABLE_COUNT:-0}/${#REQUIRED_TABLES[@]} found)"
|
||||
echo ""
|
||||
echo "Running migration..."
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
MIGRATION_FILE="$PROJECT_ROOT/backend/database/migrations/0010_track_schema.up.sql"
|
||||
|
||||
if [ -f "$MIGRATION_FILE" ]; then
|
||||
if psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -f "$MIGRATION_FILE" 2>&1 | tail -10; then
|
||||
|
||||
if [ -f "$PROJECT_ROOT/scripts/run-migration-0010.sh" ]; then
|
||||
if DB_HOST="$DB_HOST" DB_PORT="$DB_PORT" DB_USER="$DB_USER" DB_PASSWORD="$DB_PASSWORD" DB_NAME="$DB_NAME" \
|
||||
bash "$PROJECT_ROOT/scripts/run-migration-0010.sh"; then
|
||||
echo ""
|
||||
echo "✅ Migration completed"
|
||||
else
|
||||
echo ""
|
||||
echo "⚠️ Migration may have partially completed or tables already exist"
|
||||
echo "❌ Migration failed"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "❌ Migration file not found: $MIGRATION_FILE"
|
||||
echo "❌ Migration helper not found: $PROJECT_ROOT/scripts/run-migration-0010.sh"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
@@ -66,7 +109,9 @@ else
|
||||
echo " PGPASSWORD='postgres-password' psql -h $DB_HOST -U postgres -c '\l'"
|
||||
echo "4. Verify password is correct"
|
||||
echo ""
|
||||
echo "Note: Custom explorer backend uses 'explorer' user, not 'blockscout'"
|
||||
echo "Use the credentials for your deployment mode:"
|
||||
echo " - standalone explorer DB: explorer / explorer"
|
||||
echo " - shared Blockscout DB: blockscout / blockscout"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -75,10 +120,10 @@ unset PGPASSWORD
|
||||
echo ""
|
||||
echo "=== Next Steps ==="
|
||||
echo "1. Restart API server with database password:"
|
||||
echo " export DB_PASSWORD='$DB_PASSWORD'"
|
||||
echo " export DB_PASSWORD='<your explorer DB password>'"
|
||||
echo " # Set DB_USER / DB_NAME too if you are using the shared Blockscout DB"
|
||||
echo " cd backend && ./bin/api-server"
|
||||
echo ""
|
||||
echo "2. Test health endpoint:"
|
||||
echo " curl http://localhost:8080/health"
|
||||
echo ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user