Skip to content

Commit 330a6ea

Browse files
committed
refactor(web): switch to tofixed function -S
1 parent e9e0773 commit 330a6ea

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

web/src/pages/Courts/CourtDetails/Stats.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import StatDisplay, { IStatDisplay } from "components/StatDisplay";
88
import BalanceIcon from "svgs/icons/law-balance.svg";
99
import MinStake from "svgs/icons/min-stake.svg";
1010
import { commify } from "utils/commify";
11-
import { roundDecimals } from "utils/roundDecimals";
1211
import VoteStake from "svgs/icons/vote-stake.svg";
1312
import PNKIcon from "svgs/icons/pnk.svg";
1413
import PNKRedistributedIcon from "svgs/icons/redistributed-pnk.svg";
@@ -62,7 +61,7 @@ const stats: IStat[] = [
6261
{
6362
title: "PNK Staked",
6463
coinId: 0,
65-
getText: (data) => commify(roundDecimals(formatUnits(data?.stake, 18), 0)),
64+
getText: (data) => commify(Number(formatUnits(data?.stake, 18)).toFixed(0)),
6665
getSubtext: (data, coinPrice) =>
6766
(parseInt(formatUnits(data?.stake, 18)) * (coinPrice ?? 0)).toFixed(2).toString() + "$",
6867
color: "purple",
@@ -85,7 +84,7 @@ const stats: IStat[] = [
8584
{
8685
title: "ETH paid to Jurors",
8786
coinId: 1,
88-
getText: (data) => commify(roundDecimals(formatEther(BigInt(data?.paidETH)), 4)),
87+
getText: (data) => commify(Number(formatEther(BigInt(data?.paidETH))).toFixed(4)),
8988
getSubtext: (data, coinPrice) =>
9089
(Number(formatUnits(data?.paidETH, 18)) * (coinPrice ?? 0)).toFixed(2).toString() + "$",
9190
color: "blue",
@@ -94,7 +93,7 @@ const stats: IStat[] = [
9493
{
9594
title: "PNK redistributed",
9695
coinId: 0,
97-
getText: (data) => commify(roundDecimals(formatUnits(data?.paidPNK, 18), 0)),
96+
getText: (data) => commify(Number(formatUnits(data?.paidPNK, 18)).toFixed(0)),
9897
getSubtext: (data, coinPrice) =>
9998
(parseInt(formatUnits(data?.paidPNK, 18)) * (coinPrice ?? 0)).toFixed(2).toString() + "$",
10099
color: "purple",

web/src/pages/Home/CourtOverview/Stats.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import BalanceIcon from "svgs/icons/law-balance.svg";
1111
import { KLEROS_CONTRACT_ADDRESS, WETH_CONTRACT_ADDRESS } from "src/consts/index";
1212
import { commify } from "utils/commify";
1313
import { isUndefined } from "utils/index";
14-
import { roundDecimals } from "utils/roundDecimals";
1514
import { useHomePageContext, HomePageQuery, HomePageQueryDataPoints } from "hooks/useHomePageContext";
1615
import { useCoinPrice } from "hooks/useCoinPrice";
1716

@@ -40,7 +39,7 @@ const stats: IStat[] = [
4039
{
4140
title: "PNK staked",
4241
coinId: 0,
43-
getText: (counters) => commify(roundDecimals(formatUnits(getLastOrZero(counters, "stakedPNK"), 18), 0)),
42+
getText: (counters) => commify(Number(formatUnits(getLastOrZero(counters, "stakedPNK"), 18)).toFixed(0)),
4443
getSubtext: (counters, coinPrice) =>
4544
(parseInt(formatUnits(getLastOrZero(counters, "stakedPNK"), 18)) * (coinPrice ?? 0)).toFixed(2).toString() + "$",
4645
color: "purple",
@@ -49,7 +48,7 @@ const stats: IStat[] = [
4948
{
5049
title: "ETH Paid to jurors",
5150
coinId: 1,
52-
getText: (counters) => commify(roundDecimals(formatEther(getLastOrZero(counters, "paidETH")), 4)),
51+
getText: (counters) => commify(Number(formatEther(getLastOrZero(counters, "paidETH"))).toFixed(4)),
5352
getSubtext: (counters, coinPrice) =>
5453
(Number(formatUnits(getLastOrZero(counters, "paidETH"), 18)) * (coinPrice ?? 0)).toFixed(2).toString() + "$",
5554
color: "blue",
@@ -58,7 +57,7 @@ const stats: IStat[] = [
5857
{
5958
title: "PNK redistributed",
6059
coinId: 0,
61-
getText: (counters) => commify(roundDecimals(formatUnits(getLastOrZero(counters, "redistributedPNK"), 18), 0)),
60+
getText: (counters) => commify(Number(formatUnits(getLastOrZero(counters, "redistributedPNK"), 18)).toFixed(0)),
6261
getSubtext: (counters, coinPrice) =>
6362
(parseInt(formatUnits(getLastOrZero(counters, "redistributedPNK"), 18)) * (coinPrice ?? 0))
6463
.toFixed(2)

web/src/utils/roundDecimals.ts

-5
This file was deleted.

0 commit comments

Comments
 (0)