From cc9d73e5d5d69ac765aaa2e97f6755dc1cac359d Mon Sep 17 00:00:00 2001 From: Phan Anh Tuan Date: Wed, 16 Aug 2023 13:40:44 +0700 Subject: [PATCH] fix: use bigint to count tx statistic --- .../statistics/account_statistics.service.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/services/statistics/account_statistics.service.ts b/src/services/statistics/account_statistics.service.ts index e40d8acd7..dd97d64bf 100644 --- a/src/services/statistics/account_statistics.service.ts +++ b/src/services/statistics/account_statistics.service.ts @@ -338,10 +338,13 @@ export default class AccountStatisticsService extends BullableService { BigInt(0) ) .toString(); - const dayStatTxSent = dayStat.reduce( - (init: number, accStat: AccountStatistics) => init + accStat.tx_sent, - 0 - ); + const dayStatTxSent = dayStat + .reduce( + (init: bigint, accStat: AccountStatistics) => + init + BigInt(accStat.tx_sent), + BigInt(0) + ) + .toString(); const dayStatGasUsed = dayStat .reduce( (init: bigint, accStat: AccountStatistics) => @@ -372,7 +375,11 @@ export default class AccountStatisticsService extends BullableService { topTxSent.push({ address: stat.address, amount: stat.tx_sent, - percentage: (stat.tx_sent * 100) / dayStatTxSent, + percentage: Number( + BigNumber(stat.tx_sent) + .multipliedBy(100) + .dividedBy(BigNumber(dayStatTxSent)) + ), }); topGasUsed.push({ address: stat.address,