Skip to content

Commit

Permalink
fix: use bigint to count tx statistic
Browse files Browse the repository at this point in the history
  • Loading branch information
fibonacci998 committed Aug 16, 2023
1 parent 69ee010 commit cc9d73e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/services/statistics/account_statistics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit cc9d73e

Please sign in to comment.