Skip to content

feat(swap): pick the pay asset across every account, then the account to pay from, and restore the paying account from Swap History [PER-3082] - #2455

Merged
filipetamota merged 3 commits into
mainfrom
fmota/per-3082
Nov 16, 2026
Merged

filipetamota merged 3 commits into
mainfrom
fmota/per-3082

Conversation

@filipetamota

Copy link
Copy Markdown
Collaborator

Pull Request Template

Description

Swap could only pay with assets held by the account selected in the header, so finding an asset meant guessing which account held it and switching first. Per the new design, Swap From now lists what every account holds, asks which account pays when several hold the chosen asset, and Swap History chips bring back the account that paid as well as the pair.

  • Swap From across accounts: useSwapPayHoldings (swaps package) groups every swap-signing account's holdings into one row per asset and network, totalled, with each row's holders largest first; hidden tokens, collectibles and networks an account can't pay from are left out, as before. It lists nothing until every account's holdings are read, so a quick tap can't skip the account choice.
  • Select account step: when more than one account holds the picked asset, the sheet shows one card per holder (SwapSourceAccountList), with a back arrow through a new onBack on SheetHeader; with a single holder the step is skipped.
  • Picking an account switches to it: the pick sets the app-wide selected account, so the header and the Balance line follow it. A new pairAccountId in the swaps store, written by setAccountPair, marks the pair as chosen for that account, so the form's reset on account switch and the screen's reset on network change no longer wipe it.
  • An account switch on the same network keeps the To side, as picking another asset on the same account already did; moving to another network resets it to that network's default.
  • Swap History chips across accounts: the router's source_account is now parsed into SwapHistoryItem.sourceAccount, and useRecentSwapPairsQuery matches each pair to the account that paid. Tapping a chip restores the pair and switches to that account and its network; a pair with a leg on another network, or one its payer can no longer pay on, is left out.
  • The history request names every account, batched 20 per request, rather than relying on the device's registered accounts: in production the device registration doesn't carry EVM addresses, so those swaps would drop out. Batches run in parallel, merge newest first, and one failed batch doesn't hide the others' chips.
  • Accounts on a network the router has no id for, such as a custom node, are left out of the history request instead of failing it, so the other accounts' chips still show.
  • Swap From rows and the account cards show {chain} network under the asset name, per the design, through a new useChainNetworkLabel in chain-ui that useChainLabel now builds on.
  • useAccountsHoldingsAcrossChainsQuery (accounts package) reads many accounts' holdings across chains under the existing per-account cache keys; the single-account version wraps it.
  • Swap To, See all, Top 5 Swaps and the header account selector are unchanged, since the design has no frames for them. Same-network swaps still receive into the paying account; whether the ticket's (and to) needs its own receiving-account step is open with product.

Covered by package specs for the pay holdings, grouping, recent pairs, payer matching, batched history query (including a failed batch and a custom-node account), account addresses, source-chain resolver, router ids, store and the CAIP-10 parsing, and app specs for the form's account switch, the screen's chain-change guard, the asset/account selection sheet and the history chips. An Ethereum integration flow picks a token two accounts hold, chooses the second, and checks the swap pays from it with the token kept.

Related Issues

Closes https://linear.app/algorandfoundation/issue/PER-3082/apply-new-asset-selection-flow-to-swaps

Checklist

  • Have you tested your changes locally?
  • Have you reviewed the code for any potential issues?
  • Have you documented any necessary changes in the project's documentation?
  • Have you added any necessary tests for your changes?
  • Have you updated any relevant dependencies?

Additional Notes

  • Add any additional notes or comments that may be helpful for reviewers.

… to pay from, and restore the paying account from Swap History
@filipetamota
filipetamota requested a review from a team as a code owner November 16, 2026 12:54
@linear-code

linear-code Bot commented Nov 16, 2026

Copy link
Copy Markdown

PER-3082

@github-actions

Copy link
Copy Markdown

Device e2e flows affected

Every suite (22 suites, 255 scenarios, 47 p0): a change under a path every screen depends on.

  • apps/mobile/src/i18n/locales/de.json
  • apps/mobile/src/i18n/locales/en.json
  • apps/mobile/src/i18n/locales/es.json
  • apps/mobile/src/i18n/locales/fr.json
  • apps/mobile/src/i18n/locales/pt-BR.json
  • apps/mobile/src/i18n/locales/tr.json
  • apps/mobile/src/modules/bottom-sheet/components/SheetHeader/SheetHeader.tsx
  • packages/accounts/src/hooks/useAccountBalancesQuery.ts

Run them:

  • BrowserStack: the E2E / BrowserStack workflow with include left empty
  • A device: e2e/tools/run.sh <android|ios>

@yasin-ce yasin-ce left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This makes Swap From list holdings across all accounts, adds a Select account step when several accounts hold the asset, and makes the Swap History chips work across accounts and switch to the account that paid. The logic sits in the swaps package, the app hooks are thin, every new hook and util has a spec, and the integration flow covers the main path. I don't see anything blocking. Below are a few minor points on duplicated filtering logic and two edge cases in the batched history read.

…tory per batch and per deployment so one failure or a testnet account doesn't hide the rest
@filipetamota
filipetamota merged commit 0965839 into main Nov 16, 2026
28 checks passed
@filipetamota
filipetamota deleted the fmota/per-3082 branch November 16, 2026 14:12
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