#!/usr/bin/env bash # Complete next steps after IPFS logo wiring: # 1. Run migration 0013 (update token logo_url in explorer DB) # 2. Build token-aggregation (picks up new canonical-tokens IPFS URLs) # 3. Validate token list schema # # Prerequisites: DATABASE_URL in smom-dbis-138/services/token-aggregation/.env (or root .env) # Usage: ./scripts/complete-ipfs-logo-next-steps.sh set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" TA_DIR="$REPO_ROOT/smom-dbis-138/services/token-aggregation" MIGRATION_0013="$REPO_ROOT/explorer-monorepo/backend/database/migrations/0013_update_token_logos_ipfs.up.sql" log() { echo "[$(date +%H:%M:%S)] $*"; } err() { echo "ERROR: $*" >&2; } # Load env [[ -f "$REPO_ROOT/.env" ]] && set -a && source "$REPO_ROOT/.env" && set +a [[ -f "$TA_DIR/.env" ]] && set -a && source "$TA_DIR/.env" && set +a DATABASE_URL="${DATABASE_URL:-}" echo "==========================================" echo "Complete IPFS Logo Next Steps" echo "==========================================" echo "" # Step 1: Run migration 0013 log "Step 1: Running migration 0013 (update token logos to IPFS)..." if [[ ! -f "$MIGRATION_0013" ]]; then err "Migration file not found: $MIGRATION_0013" exit 1 fi if [[ -z "$DATABASE_URL" ]]; then log " SKIP: DATABASE_URL not set (set in .env or smom-dbis-138/services/token-aggregation/.env)" log " To run manually: psql \$DATABASE_URL -f $MIGRATION_0013" else if command -v psql &>/dev/null; then if psql "$DATABASE_URL" -f "$MIGRATION_0013" 2>/dev/null; then log " OK: Migration 0013 completed" else err " Migration 0013 failed (tokens table may not exist yet)" log " Run when explorer DB is available: psql \$DATABASE_URL -f $MIGRATION_0013" fi else log " SKIP: psql not found" fi fi echo "" # Step 2: Build token-aggregation log "Step 2: Building token-aggregation..." if [[ -d "$TA_DIR" ]]; then (cd "$TA_DIR" && pnpm run build 2>/dev/null || npm run build 2>/dev/null) && log " OK: Built" || err " Build failed" else log " SKIP: token-aggregation dir not found" fi echo "" # Step 3: Validate token list log "Step 3: Validating token list schema..." TOKEN_LISTS_DIR="${TOKEN_LISTS_DIR:-$REPO_ROOT/../token-lists}" if [[ -d "$TOKEN_LISTS_DIR" ]] && [[ -f "$REPO_ROOT/token-lists/lists/dbis-138.tokenlist.json" ]]; then (cd "$TOKEN_LISTS_DIR" && node -e " const Ajv = require('ajv'); const addFormats = require('ajv-formats'); const schema = require('./src/tokenlist.schema.json'); const ajv = new Ajv({ allErrors: true }); addFormats(ajv); const validate = ajv.compile(schema); const list = require('$REPO_ROOT/token-lists/lists/dbis-138.tokenlist.json'); if (validate(list)) { console.log(' OK: Token list valid'); process.exit(0); } console.error(' INVALID:', JSON.stringify(validate.errors, null, 2)); process.exit(1); " 2>/dev/null) && log " OK: Schema valid" || log " SKIP: token-lists or ajv not available" else log " SKIP: token-lists not found (set TOKEN_LISTS_DIR or clone to ../token-lists)" fi echo "" log "Done." echo "" echo "Next: Redeploy token-aggregation if running (systemctl restart token-aggregation)" echo " Explorer will show new logos after migration 0013 is applied to its DB."