feat(swap): default the "You receive" token to USDC - #2940
Conversation
|
PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-db549df9ccb149d4c4df (SDF collaborators only — install instructions in the release description) |
There was a problem hiding this comment.
Pull request overview
Defaults swap destinations to network USDC, falling back to XLM when swapping from USDC.
Changes:
- Adds network-specific USDC defaults and initialization logic.
- Resolves destination icons from token lists.
- Removes the empty-state plus icon and adds tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
@shared/constants/stellar.ts |
Defines network USDC destinations. |
extension/src/popup/views/Swap/index.tsx |
Applies destination defaults. |
extension/src/popup/views/__tests__/Swap.destinationDefault.test.tsx |
Tests default-selection behavior. |
extension/src/popup/components/swap/SwapAmount/hooks/useGetSwapAmountData.tsx |
Resolves non-held destination icons. |
extension/src/popup/components/amount/AmountCard/index.tsx |
Removes the plus icon. |
extension/src/popup/components/amount/AmountCard/styles.scss |
Adjusts selector sizing and padding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
const requiresTrustline = !!destinationTokenDetails?.requiresTrustline;
Net effect: the user signs a two-op transaction that locks 0.5 XLM of reserve, with no disclosure anywhere in the flow. The fee is correctly doubled but unexplained. Same stale gate at Suggest threading |
What
Closes #2914.
Selectstate.+icon from the emptySelectpill.Main Changes
Trustline Flag
destRequiresTrustlineis derived from balances and drives everything that depends on "this swap adds a trustline":getBuiltTx,useGetBalancesnow exposes the pre-filter list, so a hidden held asset never gets a redundant changeTrust, doubled fee, false reserve block, or a trustline limit reset to the SDK defaultswapTrustlineAddedtelemetry gates on the changeTrust op in the submitted XDR itself, so it can't disagree with what settled on-chainDestination icon
getAssetIconsgainsadditionalAssetIds(mirroring token prices') so the unheld destination's logo resolves through the held-token pipeline.Testing
Swap.destinationDefault.test.tsx: network defaults, USDC-source → XLM, param precedence, unconfigured networksgetBuiltTxtests: changeTrust prepended for unheld destinations, asset taken fromdestAssetReviewTx.trustlineBannertests: banner renders from the derived flag with no snapshot; derived flag overrides a stale snapshotUpdated 08/14
https://github.com/user-attachments/assets/a0872e72-62ae-4167-a257-dabb3ac3bbb6