fix(frontend): correct formatTokenAmount in IncomingStreams to use In…#594
Open
Mrwicks00 wants to merge 1 commit into
Open
fix(frontend): correct formatTokenAmount in IncomingStreams to use In…#594Mrwicks00 wants to merge 1 commit into
Mrwicks00 wants to merge 1 commit into
Conversation
…tl.NumberFormat The value passed to formatTokenAmount is already a human-scaled token amount (stroops divided by 1e7 in the dashboard mapper). The previous implementation incorrectly passed it through formatAmount(BigInt(Math.floor(value)), 7), re-interpreting it as raw base units and dividing by 1e7 a second time. This caused the Deposited, Withdrawn, and Claimable columns to display wildly wrong (tiny) values — e.g. 10.5 XLM was rendered as 0.0000010. Fix: format the human number directly via Intl.NumberFormat with up to 7 fraction digits, consistent with IncomingStreamCard. Remove the now-unused formatAmount import. Closes LabsCrypt#575
Contributor
|
hey, #706 just merged and fixes a broken test-mock pattern that was causing 'Failed Suites' / 'is not a function' / '0 tests' on backend integration tests. please rebase to pick it up: git fetch upstream
git rebase upstream/main
git push --force-with-lease |
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.
…tl.NumberFormat
Summary
Fixes the
formatTokenAmounthelper inIncomingStreams.tsxwhich wasdouble-scaling already-human-readable token amounts, causing the
Deposited, Withdrawn, and Claimable columns in the incoming-streams
table to display wildly wrong (tiny) values.
Closes #575
Root Cause
Streamvalues (deposited,withdrawn,ratePerSecond,claimable) arealready human-scaled token amounts — the dashboard mapper in
lib/dashboard.tsdivides raw stroops by1e7before storing them on theStreamobject:The old
formatTokenAmountinIncomingStreams.tsxthen passed these valuesthrough
formatAmount(BigInt(Math.floor(value)), 7), which re-interpretedthem as raw base units and divided by
1e7a second time:Effect:
10.5XLM →Math.floor(10.5)=10→BigInt(10)→formatAmountdivides by1e7→0.0000010. Every amount in the tablewas seven orders of magnitude too small.
Fix
Replace the broken helper with a direct
Intl.NumberFormatcall — the sameapproach already used in
IncomingStreamCard.tsx:Also removes the now-unused
import { formatAmount } from '@/lib/amount'.Files Changed
frontend/src/components/IncomingStreams.tsxformatTokenAmount; remove deadformatAmountimportBefore / After
10.50.000001010.51234.5670.00012341,234.5670.00000010.00000000.0000001Infinity/NaN0.00000000.0000000Testing
correct magnitudes in the incoming-streams table
Infinity/NaNguard still returns'0.0000000'1,234.567) consistent withIncomingStreamCardformatAmountimport causes no TypeScript errorsOut of Scope