fix(wallet): order token cards at the figure they display - #701
Merged
Conversation
The wallet's card stack sorted on `StoredBalance.usdf`, which carries six decimals against the two USD renders. Reserves sit at exactly 1.000000, while a launchpad currency's USD worth is a bonding-curve result landing on arbitrary sixth decimals that moves on every price refresh. With both cards reading $1.00, each refresh re-decided which was greater and the two traded places on screen. The stack positions cards by index with no per-card position animation, so the swap reads as a jump. Extract the comparator as `StoredBalance.walletOrder` and compare the values rounded to USD display precision. The existing alphabetical-by-name tiebreak then settles cards showing the same figure, identically on every refresh. Ports the Android fix in code-payments/code-android-app#1369.
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.
Two wallet cards showing the same $1.00 — Dollars (USDF reserves) and a launchpad currency — swap places on screen while the user watches. Observed on Android, and
Session.balancessorts the same way, so the same swap is latent here.The sort compared
StoredBalance.usdf, which carries six decimals against the two USD renders. Reserves sit at exactly 1.000000; a launchpad currency's USD worth is a bonding-curve result that lands on arbitrary sixth decimals and moves on every price refresh. Each refresh re-decided which of the two was greater and the cards traded places. The stack positions cards by index with no per-card position animation, so it reads as a jump rather than a reorder.Change
StoredBalance.walletOrder— the comparator, named and lifted out ofSession.balances, now comparing values rounded to USD display precision. The existing alphabetical-by-name tiebreak settles cards showing the same figure, and no refresh changes a name.StoredBalance.displayedUSDF— the stored value at the cents a user actually sees, following the rounding shape already used inAddMoneyGateandUserFlags.Ports code-payments/code-android-app#1369 (
efdba1d3e), which extracted the same comparator asBalanceOrderand switched it tonativeAmount.toDouble(). Android's comparator was written to match this one, tiebreak included, so the two stay in step.Tests
SessionBalanceOrderTestsdrives the realSession.balancesthrough a database refresh, mirroring Android's two regression tests:The launchpad amounts are picked so the curve sells inside a single 100-token pricing step, which makes each USD figure exact and hand-checkable.