feat(swap): asset clarity — confirm gate, network-everywhere, gas-on-top#264
Merged
Conversation
Four rules to make swap asset selection unambiguous: 1. Confirmation gate (both sides): every pick now funnels through a breakdown step in AssetPickerDialog showing symbol, network name + CAIP-2, gas-vs-token, routes, and full CAIP-19 before committing — stops a mis-tap or a substituted row from silently becoming the selection (the "jumping" symptom). 2. Network everywhere: AssetSelector cards and AssetListRow now render the network name + GAS/TOKEN badge + exact CAIP, so USDC-on-Ethereum and USDC-on-Optimism are no longer indistinguishable. 3. Gas on top: pickerTier floats native/gas assets above all tokens (below only held) and tags them with a GAS badge — a chain's own coin is never buried or mislabeled. 4. USDC/USDT priority: new priority-stable tier ranks USDC/USDT directly under gas, above the broad uncommon-stablecoin list. Tests updated for the new tier order; +2 cases for gas-leads and USDC/USDT-priority ordering. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- ellipsizeCaip(): shortens only the long hex/base58 reference segments (erc20 contract, bip122 genesis hash) and keeps the namespace prefixes (eip155:1/erc20:, …/slip44:) fully readable. Replaces the end-truncating CSS ellipsis on the swap cards, picker rows, held tiles, network tiles, contract-hit and alternative rows. - AssetSelector GAS/TOKEN badge now derives from parseCaip(caip).isToken (authoritative) and only falls back to contractAddress when no CAIP — a token CAIP with a missing contractAddress can no longer read as GAS. (addresses PR review comment) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…postors compareForPicker now sorts by provider/route count (desc) as the primary within-tier tiebreak, before discoveryRank. A confirmed route is the strongest signal of a real, common, swappable asset, so: - genuinely-routable assets float above same-symbol impostors that only matched by ticker (real USDC above a 0-route "Morpho USDC Pool" TRY QUOTE) - the rest order most-routes-first, surfacing common assets Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four rules to make swap asset selection unambiguous and stop the "jumping" where a selected output silently becomes a different asset.
handleSelect→ConfirmStep→commitSelect) that shows a full breakdown before committing: symbol, network name + CAIP-2, gas vs token, routes, and full CAIP-19. A mis-tap or aswappable-substituted row can no longer become the pick without an explicit confirm.AssetSelectorcards (SwapDialog) andAssetListRow(AssetPickerDialog) now render the network name + GAS/TOKEN badge + exact CAIP. USDC-on-Ethereum and USDC-on-Optimism are no longer rendered identically.pickerTierfloats native/gas assets above all tokens (below only held), tagged with aGASbadge. A chain's own coin is never buried or shown as a confusing bare "ETH / ETH".New
pickerTierorder: held-value(0) → held(1) → gas/native(2) → USDC/USDT(3) → other stables(4) → normal token(5) → junk(6) → unsupported(7).Files
src/shared/swap-discovery.ts—pickerTierreorder,PRIORITY_STABLE_SYMBOLS,isPriorityStableEntry,isGasAsset.src/mainview/components/AssetPickerDialog.tsx—ConfirmStepgate,GasTokenBadge, network name in rows.src/mainview/components/SwapDialog.tsx— network + GAS/TOKEN + CAIP on the FROM/TO cards.__tests__/swap-discovery.test.ts— tier expectations updated; +2 cases (gas-leads, USDC/USDT-priority).Test plan
bun test __tests__/swap-discovery.test.ts— 61 passtsc --noEmit— no new errors (pre-existingminimatchambient-type error only)Scope decisions (confirmed with requester)