Repository navigation
fix(wallet): trim exposed zeros in full-balance tooltips - #1012
Merged
Merged
Conversation
formatTokenBalanceFull promises "up to 4 significant digits with trailing zeros removed", but it trimmed the fraction before capping it to 4 digits. When the cut lands on a zero that was only interior in the untrimmed fraction, that zero becomes trailing and was still rendered: 1.20001 HD showed as "1.2000" and 1.00001 HD as "1.0000". Both branches now re-trim after the slice. The sub-1 branch keeps its leading zeros (they are emitted separately) and its first significant digit is non-zero, so a digit always survives. formatTokenBalance inherits the fix below the K threshold, where it delegates here.
Adds the ledger rows the first pass left untested: an interior zero kept while the cut's exposed tail goes, the sub-1 branch with no leading zeros at both 18 and 6 decimals, a fraction entirely past the 4-digit window, and a control pinning that the compact K path never reaches the changed lines.
…eFull tests One case per truncation branch, beside the existing formatter tests.
Contributor
|
…cs-pr-976-balance-formatting
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.
Full-balance tooltips could display zeros exposed by truncation:
1.20001became1.2000, and1.00001became1.0000. The original #976 fix trims those zeros after the four-digit cut, producing1.2and1; regression tests cover both fractional branches and an integer-only result. The LAT note documents this behavior.This PR retains #976's original commit history through a merge of
99429853dcd52593841b6f1074ab598967cb997band includes current main's audited dependencies. Its organization-ownedsprayberry-codefork cannot accept upstream maintainer pushes, so the existing supporting PR carries the validated integration. Merge this PR with a merge commit to keep #976's original head reachable. Thanks @askalf for the wallet fix and regression tests.Validation: all 34 wallet balance tests, both full TypeScript checks, full ESLint,
lat check,git diff --check, and the production dependency audit passed (zero vulnerabilities). The diff against main is three files with 20 additions and two deletions.