Conversation
Converting from Dollars opens with Dollars as the destination, and SwapViewModel swaps in the largest other entry in tokenBalances. That list can carry zero-balance rows, because TokenState.withAccounts only adds holdings. Bugsnag 6ac36f88991833fd09434aad: a user holding only Dollars got a leftover USDC row as the destination, and all six attempts failed with INVALID_SWAP "mint not found". Filter the fallback to held currencies with a displayable balance, which is what the destination picker (SelectTokenViewModel) and iOS (Session.balances(for:)) already do. With no candidate the destination stays on Dollars.
Collaborator
Author
|
Folded into #1679, which carries this commit along with the disabled Convert button. |
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.
Converting from Dollars opens with Dollars as the destination, and
SwapViewModelswaps in the largest other entry intokenBalances. That list can hold zero-balance rows, becauseTokenState.withAccountsonly ever adds holdings. In Bugsnag6ac36f88991833fd09434aad(2026.9.4), a user holding only Dollars got a leftover USDC row as the destination. All six attempts loggedbuy of USDCand failed withINVALID_SWAP: mint not found. The first three came before they opened the destination picker, so the fallback chose USDC, not the user.The fallback now only considers held currencies with a displayable balance. The destination picker (
SelectTokenViewModel) and iOS (Session.balances(for:)) already use that filter. With no candidate, the destination stays on Dollars.Two cases added to
SwapViewModelErrorTest: the fallback still picks the largest real holding, and an empty row is never picked.Not covered here:
ProceedWithConversionsets loading before bailing. What that user should see is still open.withAccountsnever prunes holdings, so stale rows still reach everytokenBalancesreader.