#!/usr/bin/env bash # Submit Token List Script # Submits token list to CoinGecko, Uniswap, and other aggregators set -euo pipefail # Configuration SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/../lib/init.sh" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" # Load .env via dotenv (RPC CR/LF trim). Fallback: raw source. if [[ -f "$SCRIPT_DIR/../lib/deployment/dotenv.sh" ]]; then # shellcheck disable=SC1090 source "$SCRIPT_DIR/../lib/deployment/dotenv.sh" load_deployment_env --repo-root "${PROJECT_ROOT:-$REPO_ROOT}" elif [[ -n "${PROJECT_ROOT:-}" && -f "$PROJECT_ROOT/.env" ]]; then set -a # shellcheck disable=SC1090 source "$PROJECT_ROOT/.env" set +a elif [[ -n "${REPO_ROOT:-}" && -f "$REPO_ROOT/.env" ]]; then set -a # shellcheck disable=SC1090 source "$REPO_ROOT/.env" set +a fi TOKEN_LIST_FILE="${PROJECT_ROOT}/metamask/token-list.json" TOKEN_LIST_URL="https://raw.githubusercontent.com/Defi-Oracle-Tooling/smom-dbis-138/main/metamask/token-list.json" # Logging function log() { log_success "[$(date +'%Y-%m-%d %H:%M:%S')] $1" } error() { log_error "[ERROR] $1" exit 1 } warn() { log_warn "[WARNING] $1" } # Validate token list validate_token_list() { log "Validating token list..." if [ ! -f "$TOKEN_LIST_FILE" ]; then error "Token list file not found: $TOKEN_LIST_FILE" fi # Validate JSON syntax if ! jq empty "$TOKEN_LIST_FILE" 2>/dev/null; then error "Token list JSON syntax is invalid" fi # Validate schema (if ajv is available) if command -v ajv &> /dev/null; then if ajv validate -s "${PROJECT_ROOT}/metamask/token-list.schema.json" -d "$TOKEN_LIST_FILE"; then log "Token list schema validation passed" else error "Token list schema validation failed" fi else warn "ajv-cli not installed, skipping schema validation" fi log "Token list validation passed" } # Submit to CoinGecko submit_to_coingecko() { log "Submitting token list to CoinGecko..." warn "CoinGecko submission requires manual process:" warn " 1. Fork https://github.com/coingecko/token-lists" warn " 2. Add token list file to the repository" warn " 3. Create PR to coingecko/token-lists" warn " 4. Wait for review and merge" log "CoinGecko submission instructions:" log " - Repository: https://github.com/coingecko/token-lists" log " - Token list URL: $TOKEN_LIST_URL" log " - File location: Add to repository root or appropriate directory" } # Submit to Uniswap submit_to_uniswap() { log "Submitting token list to Uniswap..." warn "Uniswap submission requires manual process:" warn " 1. Fork https://github.com/Uniswap/token-lists" warn " 2. Add token list file to src/tokens/ directory" warn " 3. Update tokens.ts to include the list" warn " 4. Create PR to Uniswap/token-lists" warn " 5. Wait for review and merge" log "Uniswap submission instructions:" log " - Repository: https://github.com/Uniswap/token-lists" log " - Token list URL: $TOKEN_LIST_URL" log " - File location: src/tokens/defi-oracle-mainnet.json" } # Submit to Token Lists aggregator submit_to_token_lists() { log "Submitting token list to Token Lists aggregator..." warn "Token Lists aggregator submission requires manual process:" warn " 1. Visit https://tokenlists.org" warn " 2. Click 'Add Token List'" warn " 3. Enter token list URL: $TOKEN_LIST_URL" warn " 4. Submit for review" log "Token Lists aggregator submission instructions:" log " - Website: https://tokenlists.org" log " - Token list URL: $TOKEN_LIST_URL" } # Generate submission report generate_report() { log "Generating submission report..." local report_file="${PROJECT_ROOT}/token-list-submission-report.md" cat > "$report_file" <