Skip to content

Commit d51427d

Browse files
author
tiendn
committed
fix: hotfix bignumber with point non-decimal number
1 parent d5761ab commit d51427d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

utils/helper.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import qs from 'qs'
88
import { CONFIG } from './constants'
99
import { ErcTypeEnum } from './enum'
1010

11+
BN.config({ ROUNDING_MODE: 2 })
12+
1113
export const ellipseBetweenText = (
1214
address: string,
1315
left = CONFIG.TXS_MOBILE_SPLIT_LENGTH,
@@ -43,7 +45,8 @@ export const convertBalanceToView = (value: number | string, decimals = 18) => {
4345
} catch (err) {
4446
// bignumber (ethers) error with 500100000000.000000000000000000
4547
// bignumber.js caught this. but ethers not
46-
return returnValue(formatEther(BN(value).toString(10)))
48+
// must convert value to decimal, sometimes round this value
49+
return returnValue(formatEther(BN(value).integerValue(BN.ROUND_DOWN).toString(10)))
4750
}
4851
}
4952

0 commit comments

Comments
 (0)