Skip to content

List each swap token once per chain with its chain's logo - #699

Merged
n13 merged 3 commits into
mainfrom
n13/swap-token-chains
Oct 13, 2026
Merged

n13 merged 3 commits into
mainfrom
n13/swap-token-chains

Conversation

@n13

@n13 n13 commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

The swap picker showed one listing per symbol, so USDC could only be swapped on Ethereum. 1Click lists about 195 priced listings across 36 chains: USDC on 17 chains, USDT on 12, ETH on 9. Rows also showed only a chain code ("ETH") with a letter badge, while other wallets show the token logo with the chain's logo in the corner.

Changes

  • One row per token per chain: SwapService keeps every priced listing, one per symbol and chain.
    • Order: QTC first and USDC on Ethereum second, as before. Then each symbol's main listing by market cap, which matches the old list. Then every other chain listing, by market cap and then by chain.
    • Chain order: Ethereum, Bitcoin, Solana, Tron, BNB Chain, NEAR, Base, Arbitrum, Polygon, Optimism, Avalanche, then the rest.
    • Pure market-cap order was avoided because it puts 3 BTC, 9 ETH and 12 USDT rows ahead of BNB.
  • Left out:
    • Listings 1Click marks (DEPRECATED), such as USDT0(DEPRECATED).
    • A second listing of a symbol on the same chain. Today that's only USDC on Hypercore, listed once as HIP-1 and once as ERC-20; 1Click's first listing is kept.
  • Chain table: SwapToken names all 36 chains 1Click lists on. Each entry gives the name shown and the CoinGecko id for its logo.
    • 29 chains map to a CoinGecko asset platform.
    • 7 coin chains (BTC, ZEC, DOGE, LTC, BCH, DASH, ALEO) use the coin's own logo.
    • An unknown chain shows its code and keeps its letter badge.
  • Chain logos: CoinGeckoService.platformLogos reads /asset_platforms and keeps the 50 px logo for each mapped chain. It's cached for a week, alongside markets, and both caches share one helper.
    • The markets and platforms requests run in parallel, so a stalled CoinGecko still costs one 10 s timeout, not two.
    • A failure is logged and the badges keep their letters.
    • AppConstants.coingeckoEndpoint is now the API base.
  • Icon: TokenIcon shows the chain's logo in the corner, downloaded once and kept on disk through SwapTokenIconService.imageAt, the same cache as token logos. The letter shows until it loads.
  • Picker: rows show the chain's name ("Solana") under the symbol. Search matches the symbol, the chain name or the chain code, with the hint "Search token or chain".

Tests

  • swap_service_test: per-chain rows in two tiers, the chain order for USDT across six chains, deprecated and repeated listings left out, and chain logo addresses from a platform or from a coin.
  • coin_gecko_service_test: chain logos cached across restarts and refetched for a chain not yet seen, plus the existing markets cache tests on the new storage keys.
  • token_icon_test: the chain badge shows the letter until the logo is there, then the logo.
  • swap_flow_test: the picker lists USDC on Ethereum and on Solana, and filters by "usdc" and by "solana".
  • melos run analyze is clean.

Notes

  • The markets cache moved from coingecko_markets to coingecko_coin_markets, because cached entries now store their payload under data. The old entry from build 154 is no longer read.

The picker showed one listing per symbol. It now lists every priced 1Click
listing, one per symbol and chain: each symbol's main listing first, by
market cap as before, then its listings on other chains by market cap and
chain (Ethereum, Bitcoin, Solana, Tron, BNB Chain, NEAR, Base, Arbitrum,
Polygon, Optimism, Avalanche, then the rest). Deprecated listings and a
second listing of a symbol on the same chain are left out.

Each row shows the token's logo with its chain's logo in the corner and the
chain's name under the symbol, and search matches the chain too. Chain logos
come from CoinGecko's asset platforms, kept on the device for a week, or for
a coin's own chain from the coin; SwapToken names all 36 chains 1Click lists
on. A chain without a logo keeps its letter.
@n13 n13 added the bot-review Request automated review from review-bot label Oct 13, 2026

@n13 n13 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer model: GPT-6.1 Sol

Verdict (advisory): Approve

Reviewed head b56a75ef34dd87f64de85b072f8d6539eec7aa53 against base 572e6a5ea76ea9fbb4785debac3c28dcffe5a745.

No blocking findings. The per-chain listings retain their individual asset IDs through selection and quoting, saved addresses remain scoped by network, and the cache schema change avoids reading the old markets payload. The picker search and chain badges reuse the existing swap flow and image cache.

Validation:

  • SDK: flutter test --no-pub test/services/swap_service_test.dart test/services/coin_gecko_service_test.dart test/services/swap_token_icon_service_test.dart — 57 passed.
  • Mobile: flutter test --no-pub test/screens/swap_flow_test.dart test/unit/token_icon_test.dart — 35 passed.
  • A temporary probe using the live CoinGecko platform response confirmed the Bitcoin Cash coin-logo fallback — passed.
  • Read-only 1Click listing and CoinGecko platform checks matched the supported chain mappings and duplicate-listing behavior.
  • Changed Dart files: formatting passed (15 files, zero changes); git diff --check passed.

Workspace analysis was stopped at the required 10-second limit: cold-wallet and miner analysis completed cleanly, but SDK/mobile analysis remains incomplete. GitHub's Analyze check is still in progress.

@n13 n13 removed the bot-review Request automated review from review-bot label Oct 13, 2026
@n13

n13 commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

The chain badge is now half the token icon's diameter on every TokenIcon (picker, swap form, summary, progress), matching Vizor's picker. The badge size is derived from the icon size instead of being passed per call site.

@n13 n13 added the bot-review Request automated review from review-bot label Oct 13, 2026

@n13 n13 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer model: GPT-6.1 Sol

Verdict (advisory): Approve

Reviewed head e94d1ad385f9570b81bfd75f943d1946d6de743b against base 572e6a5ea76ea9fbb4785debac3c28dcffe5a745, including both badge-sizing commits.

No blocking findings. Listings remain distinct by asset ID through picker selection and quote requests, and saved addresses remain scoped by network. The main/secondary listing order, duplicate and deprecated filtering, cache schema migration, and shared image cache are consistent with the intended behavior. All TokenIcon callers use the new proportional badge size.

Validation:

  • SDK: flutter test --no-pub --reporter expanded test/services/swap_service_test.dart test/services/coin_gecko_service_test.dart test/services/swap_token_icon_service_test.dart — 57 passed.
  • Mobile: flutter test --no-pub --reporter expanded test/screens/swap_flow_test.dart test/unit/token_icon_test.dart — 35 passed again at the latest head, including per-chain search and the parallel CoinGecko timeout behavior.
  • Changed Dart files: dart format --output=none --set-exit-if-changed --line-length=120 — 18 files checked, zero changes. git diff --check passed.
  • Read-only checks of the 1Click token listing and CoinGecko asset platforms confirmed the supported chain mappings and the USDC/Hypercore duplicate pair.

Workspace analysis via dart run melos exec --concurrency=1 -- "flutter analyze . --fatal-infos" was stopped at the required 10-second limit. Cold-wallet and miner analysis completed cleanly; SDK/mobile analysis is incomplete. GitHub's Analyze check remains in progress, so CI is not yet confirmed green.

@n13 n13 removed the bot-review Request automated review from review-bot label Oct 13, 2026
@n13
n13 merged commit d100fa7 into main Oct 13, 2026
3 checks passed
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.

1 participant