Skip to content

Commit 77ff9f0

Browse files
authored
Merge pull request #594 from Mrwicks00/fix/incoming-streams-format-token-amount
fix(frontend): correct formatTokenAmount in IncomingStreams to use In…
2 parents 215b769 + 2f34a84 commit 77ff9f0

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

frontend/src/components/IncomingStreams.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@ import React, { useState } from 'react';
44
import type { Stream } from '@/lib/dashboard';
55
import { useStreamingAmount } from '@/hooks/useStreamingAmount';
66
import toast from 'react-hot-toast';
7-
import { formatAmount } from '@/lib/amount';
7+
88

99
interface IncomingStreamsProps {
1010
streams: Stream[];
1111
onWithdraw: (stream: Stream) => Promise<void>;
1212
withdrawingStreamId?: string | null;
1313
}
1414

15-
function formatTokenAmount(value: number, decimals: number = 7): string {
15+
/**
16+
* Format an already-human-scaled token amount (e.g. 10.5) for display.
17+
*
18+
* Values coming from the Stream interface have already been divided by 1e7
19+
* (stroops → token units) by the dashboard mapper, so we must NOT re-scale
20+
* them through formatAmount. Instead we format the number directly using
21+
* Intl.NumberFormat, consistent with IncomingStreamCard.
22+
*/
23+
function formatTokenAmount(value: number, maximumFractionDigits = 7): string {
1624
if (!Number.isFinite(value)) return '0.0000000';
17-
return formatAmount(BigInt(Math.floor(value)), decimals);
25+
return new Intl.NumberFormat('en-US', {
26+
minimumFractionDigits: 0,
27+
maximumFractionDigits,
28+
}).format(value);
1829
}
1930

2031
const ClaimableAmount: React.FC<{ stream: Stream }> = ({ stream }) => {

0 commit comments

Comments
 (0)