Skip to content

Commit 4116723

Browse files
authored
Merge pull request #95 from oasisprotocol/lw/thousands-separator
Format prize pool amount with thousands separator
2 parents 89ca208 + 0ffbfb9 commit 4116723

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

frontend/src/App.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ const SOCIAL_SHARE_TEXT = `I'm in! 🎄
4444
Just got my tickets for the Oasis Xmas Roffle — 10 winners sharing up to 1M $ROSE!
4545
Get yours here: ${window.location.href}`
4646

47+
/** Adds thousands separators but might lose precision */
48+
function formatEtherLocale(valueInBaseUnits: bigint) {
49+
return parseFloat(formatEther(valueInBaseUnits)).toLocaleString()
50+
}
51+
4752
export function App() {
4853
const acc = useAccount()
4954
const { chains: wagmiChains } = useConfig()
@@ -326,8 +331,10 @@ export function App() {
326331
Join the Oasis Christmas raffle!
327332
<br />
328333
<br />
329-
The prize pool starts at {initialPot?.data ? formatEther(initialPot.data) : '...'} ROSE and
330-
grows with every ticket purchased.
334+
The prize pool starts at {initialPot?.data
335+
? formatEtherLocale(initialPot.data)
336+
: '...'}{' '}
337+
ROSE and grows with every ticket purchased.
331338
<br />
332339
Each ticket costs {ticketPrice.data ? formatEther(ticketPrice.data) : '...'} ROSE.
333340
</p>
@@ -652,7 +659,7 @@ export function App() {
652659
Current prize pool
653660
</p>
654661
<p className="font-['Mountains_of_Christmas',cursive] leading-[56px] text-[48px] text-white">
655-
{raffleBalance.data?.value ? formatEther(raffleBalance.data?.value) : ''}
662+
{raffleBalance.data?.value ? formatEtherLocale(raffleBalance.data?.value) : ''}
656663
<span className="hero-text-muted">ROSE</span>
657664
</p>
658665
</div>

0 commit comments

Comments
 (0)