Skip to content

Conversation

@jcamor3s
Copy link

Overview

This PR introduces a comprehensive automated token list management system with three key components:

  • Automated PR Creation Script (create-pr.js)
  • Token List Generator (create-tokenlist.js)
  • GitHub Actions Workflow (tokenlist-fetch.yml)

Key Changes

🔧 Automated PR Creation Script (src/lib/scripts/create-pr.js)

New Features:

  • Environment Variable Support: Automatic loading of .env files for local development
  • CI/CD Integration: Automatic git configuration for GitHub Actions environment
  • Intelligent Change Detection: Analyzes token addresses and logo files to provide detailed statistics
  • Robust Repository Detection: Supports both HTTPS and SSH git remote formats
  • Comprehensive Logging: Timestamped logging with different severity levels (info, warning, error, success)
  • Error Handling: Graceful fallbacks when GitHub token is missing or API calls fail
  • CLI Interface: Commander.js integration with force and verbose options

Technical Improvements:

  • Configurable target files via environment variables
  • Automatic branch creation with timestamps
  • Detailed commit messages with changed file listings
  • GitHub API integration for automatic PR creation
  • Statistics tracking for new tokens and logos

📝 Token List Generator (src/lib/scripts/create-tokenlist.js)

New Features:

  • Template-based Token List Creation: Uses predefined templates to generate new token lists
  • Environment Variable Configuration: Supports TOKENLIST_NAME environment variable
  • Directory Structure Management: Automatically creates necessary directory structure
  • Error Handling: Graceful error handling with informative messages

⚡ GitHub Actions Workflow (.github/workflows/tokenlist-fetch.yml)

New Features:

  • Manual Workflow Dispatch: Configurable inputs for source URL, target file, and assets directory
  • Automated Token List Fetching: Downloads and processes token lists from external sources
  • Asset Management: Automatic logo downloading and organization
  • Change Detection: Only creates PRs when actual changes are detected
  • Automated PR Creation: Integrates with the create-pr.js script
  • PR Commenting: Adds informative comments to generated PRs with workflow details

Workflow Steps:

  1. Repository checkout with full history
  2. Node.js setup with dependency caching
  3. Git configuration for CI environment
  4. Token list fetching with environment variables
  5. Token list generation with API key support
  6. Change detection and conditional PR creation
  7. Automated PR commenting with workflow metadata

Configuration Options

Environment Variables Supported:

  • TARGET_TOKEN_FILE: Path to target token file (default: src/tokenlists/balancer/tokens/berachain.ts)
  • ASSETS_DIR: Assets directory for logos (default: src/assets/images/tokens)
  • TOKENLIST_NAME: Name for new token list creation
  • GITHUB_TOKEN: Required for automatic PR creation
  • INFURA_KEY & ALCHEMY_KEY: For token list generation

Workflow Inputs:

  • source_url: Source URL for token list fetching
  • target_token_file: Target file path for updates
  • assets_dir: Assets directory for logo management

Benefits

  1. Automation: Reduces manual work in token list management
  2. Consistency: Standardized process for token list updates
  3. Traceability: Comprehensive logging and change tracking
  4. Flexibility: Configurable for different token lists and sources
  5. CI/CD Integration: Seamless GitHub Actions integration
  6. Error Handling: Robust error handling with graceful fallbacks

@jcamor3s jcamor3s requested a review from schystz July 18, 2025 09:26
@jcamor3s jcamor3s force-pushed the feat/fetch-tokenlist-action branch from 6a65828 to f6addb8 Compare August 5, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants