Token and chain images for front ends built with the Squid SDK
-
Install system dependencies (
librsvg,webp,imagemagick,jq,wget,ffmpeg):yarn setup:macos # macOS yarn setup:linux # Linux
-
Install Node dependencies (uses Yarn 1, pinned via
packageManager):yarn install
-
Create a
.envfile in the repo root with credentials from the team:SQUID_API_URL= SQUID_INTEGRATOR_ID=These are required by
yarn update-tokensto call the Squid API.
Refreshes tokens from the Squid API. Runs three steps:
- Fetch tokens from Squid (
/v2/sdk-info) and list anything missing fromimages/migration/webp(skipping previously failed URLs inurl_fetch_errors.json). - Download each new image, resize to 128×128, and write it to
images/migration/webp/<chainId>_<tokenAddress>.webp. Handles SVG, PNG/JPEG, GIF (animated WebP), WebP, and AVIF inputs. - Run
yarn update-colors(see below).
Token file names follow <chainId>_<tokenAddress.toLowerCase().replace(/[/\:]/g, "")>.webp.
Recomputes colors without downloading new images:
- Converts WebPs in
images/migration/webpto PNGs inimages/migration/png(thecanvaslib used next doesn't read WebP). - For each chain and token, computes
bgColor(average) andtextColor(contrast) and saves them toscripts/update-tokens/colors.json. Failed URLs are recorded inscripts/update-tokens/url_fetch_errors.json. Entries that already have a non-emptybgColorare skipped.
Also requires SQUID_API_URL and SQUID_INTEGRATOR_ID.
Converts SVGs (and resizes PNGs) under images/master/{chains,wallets,providers} into images/png<SIZE>/... and images/webp<SIZE>/.... Default size is 128. Other master folders (tokens, onramps) are not processed by this script.
Prints du -sh for every subfolder under images/. Read-only.
Unit tests for the color utility helpers. No network, no file writes.
Regression suite for the update-tokens pipeline. Static checks plus end-to-end
runs that delete part of the local state and verify yarn update-tokens
restores it. Individual tests live under scripts/smoke-test/tests/ and can
be run directly (e.g. bash scripts/smoke-test/tests/05-api-failure.sh).
Integration tests are skipped if .env or SQUID_API_URL is not configured.
.
├── package.json
├── images
│ ├── master # source SVGs (input to `yarn convert`)
│ │ ├── chains/
│ │ ├── wallets/
│ │ ├── providers/
│ │ ├── onramps/
│ │ └── tokens/
│ ├── png128/ # output of `yarn convert` (size suffix matches --size)
│ ├── webp128/
│ └── migration
│ ├── webp/ # `yarn update-tokens` output — e.g. 1_0x...0.webp
│ └── png/ # intermediate PNGs for color extraction
└── scripts
├── convert.sh
├── compare_folders_size.sh
└── update-tokens/
├── fetch-new-tokens.js # entry: queues missing webps for download
├── save-new-tokens.sh # downloads + converts queued images
├── convert-webp-to-png.sh # webp → png so node-canvas can read them
├── colors.js # entry: extracts bgColor / textColor
├── squid-api.js # library: Squid /v2/sdk-info client
├── colors-utils.js # library: color math + token key helpers
├── assert-entry.js # library: guard against importing entry scripts
├── colors.json # generated: bgColor / textColor per chain & token
└── url_fetch_errors.json # generated: URLs that failed during fetch
The token refresh pipeline runs automatically every 6 hours via the GitHub Actions workflow at .github/workflows/update-tokens.yml. It calls yarn update-tokens and pushes any image / color diffs to main. You can also trigger it manually from the Actions tab ("Run workflow"). Repo variables SQUID_API_URL and SQUID_INTEGRATOR_ID must be configured (Settings → Secrets and variables → Actions → Variables) for the workflow to authenticate.