Skip to content

Commit 7754fd6

Browse files
authored
Fix send balance formatting (#13204)
### Description ### How Has This Been Tested? <img width="737" height="614" alt="Screenshot 2025-10-08 at 9 56 46 AM" src="https://github.com/user-attachments/assets/ecc64b93-89ea-4706-8024-60cae0c0c1d7" />
1 parent 73df22f commit 7754fd6

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

packages/web/src/components/send-tokens-modal/SendTokensConfirmation.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ const SendTokensConfirmation = ({
7272
)
7373
}
7474

75+
const formattedBalance =
76+
tokenBalance?.balance.toLocaleString('en-US', {
77+
minimumFractionDigits: 2,
78+
maximumFractionDigits: 2
79+
}) ?? ''
80+
7581
const handleCheckboxChange = (event: ChangeEvent<HTMLInputElement>) => {
7682
setIsConfirmed(event.target.checked)
7783
}
@@ -93,7 +99,7 @@ const SendTokensConfirmation = ({
9399
<CryptoBalanceSection
94100
tokenInfo={tokenInfo}
95101
name={tokenInfo.name}
96-
amount={tokenBalance?.balanceLocaleString ?? ''}
102+
amount={formattedBalance}
97103
/>
98104

99105
<Divider orientation='horizontal' />

packages/web/src/components/send-tokens-modal/SendTokensInput.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ const SendTokensInput = ({
6868
includeStaked: false
6969
})
7070
const tokenInfo = coin ? transformArtistCoinToTokenInfo(coin) : undefined
71+
const formattedBalance =
72+
tokenBalance?.balance.toLocaleString('en-US', {
73+
minimumFractionDigits: 2,
74+
maximumFractionDigits: 2
75+
}) ?? ''
7176

7277
const handleAmountChange = useCallback((value: string, weiAmount: bigint) => {
7378
setAmount(value)
@@ -158,9 +163,6 @@ const SendTokensInput = ({
158163
)
159164
}
160165

161-
// Use the pre-formatted balance from the tokenBalance hook
162-
const formattedBalance = tokenBalance?.balanceLocaleString ?? ''
163-
164166
return (
165167
<Flex direction='column' gap='xl' p='xl'>
166168
{/* Token Balance Section */}

packages/web/src/components/send-tokens-modal/SendTokensSuccess.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
transformArtistCoinToTokenInfo
55
} from '@audius/common/api'
66
import { makeSolanaTransactionLink } from '@audius/common/utils'
7-
import { FixedDecimal } from '@audius/fixed-decimal'
7+
import { AUDIO, FixedDecimal } from '@audius/fixed-decimal'
88
import {
99
Button,
1010
Text,
@@ -17,6 +17,7 @@ import {
1717
} from '@audius/harmony'
1818

1919
import { CryptoBalanceSection } from 'components/buy-sell-modal/CryptoBalanceSection'
20+
import { env } from 'services/env'
2021

2122
interface SendTokensSuccessProps {
2223
mint: string
@@ -52,6 +53,7 @@ const SendTokensSuccess = ({
5253
const currentBalance = tokenBalance?.balance
5354
? tokenBalance.balance.value
5455
: BigInt(0)
56+
const isAudio = mint === env.WAUDIO_MINT_ADDRESS
5557

5658
const formatAmount = (amount: bigint) => {
5759
return new FixedDecimal(amount, tokenInfo?.decimals).toLocaleString(
@@ -64,6 +66,12 @@ const SendTokensSuccess = ({
6466
}
6567

6668
const formatBalance = (balance: bigint) => {
69+
if (isAudio) {
70+
return AUDIO(balance).toLocaleString('en-US', {
71+
minimumFractionDigits: 2,
72+
maximumFractionDigits: 2
73+
})
74+
}
6775
return new FixedDecimal(balance, tokenInfo?.decimals).toLocaleString(
6876
'en-US',
6977
{

0 commit comments

Comments
 (0)