diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-07-27 03:15:34 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-07-28 03:22:10 +0800 |
commit | d0c901d081e3b40a191dcb826fda7925d16df92c (patch) | |
tree | 13b8b5a75531f0bec35118bc5747ad39fe90c03a /ui/app/helpers | |
parent | cd2b67cdd956cd7f2a29f94292939a4bb939b7b3 (diff) | |
download | tangerine-wallet-browser-d0c901d081e3b40a191dcb826fda7925d16df92c.tar tangerine-wallet-browser-d0c901d081e3b40a191dcb826fda7925d16df92c.tar.gz tangerine-wallet-browser-d0c901d081e3b40a191dcb826fda7925d16df92c.tar.bz2 tangerine-wallet-browser-d0c901d081e3b40a191dcb826fda7925d16df92c.tar.lz tangerine-wallet-browser-d0c901d081e3b40a191dcb826fda7925d16df92c.tar.xz tangerine-wallet-browser-d0c901d081e3b40a191dcb826fda7925d16df92c.tar.zst tangerine-wallet-browser-d0c901d081e3b40a191dcb826fda7925d16df92c.zip |
Round large exponential numbers
Diffstat (limited to 'ui/app/helpers')
-rw-r--r-- | ui/app/helpers/confirm-transaction/util.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ui/app/helpers/confirm-transaction/util.js b/ui/app/helpers/confirm-transaction/util.js index f015b2bf5..a37778c19 100644 --- a/ui/app/helpers/confirm-transaction/util.js +++ b/ui/app/helpers/confirm-transaction/util.js @@ -3,6 +3,7 @@ import currencies from 'currency-formatter/currencies' import abi from 'human-standard-token-abi' import abiDecoder from 'abi-decoder' import ethUtil from 'ethereumjs-util' +import BigNumber from 'bignumber.js' abiDecoder.addABI(abi) @@ -137,3 +138,11 @@ export function convertTokenToFiat ({ export function hasUnconfirmedTransactions (state) { return unconfirmedTransactionsCountSelector(state) > 0 } + +export function roundExponential (value) { + const PRECISION = 4 + const bigNumberValue = new BigNumber(value) + + // In JS, numbers with exponentials greater than 20 get displayed as an exponential. + return bigNumberValue.e > 20 ? Number(bigNumberValue.toPrecision(PRECISION)) : value +} |