diff options
author | Alexander Tseung <alextsg@users.noreply.github.com> | 2018-07-28 09:02:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-28 09:02:21 +0800 |
commit | fa4423bab2886017996955f809b6e3102cbf1781 (patch) | |
tree | c90b370647750a54d262e70033236b192623cf51 /ui/app/helpers/confirm-transaction/util.js | |
parent | 9dc5d0cee07ea2599c25ce9d8c04c73842a98cef (diff) | |
parent | d0c901d081e3b40a191dcb826fda7925d16df92c (diff) | |
download | tangerine-wallet-browser-fa4423bab2886017996955f809b6e3102cbf1781.tar tangerine-wallet-browser-fa4423bab2886017996955f809b6e3102cbf1781.tar.gz tangerine-wallet-browser-fa4423bab2886017996955f809b6e3102cbf1781.tar.bz2 tangerine-wallet-browser-fa4423bab2886017996955f809b6e3102cbf1781.tar.lz tangerine-wallet-browser-fa4423bab2886017996955f809b6e3102cbf1781.tar.xz tangerine-wallet-browser-fa4423bab2886017996955f809b6e3102cbf1781.tar.zst tangerine-wallet-browser-fa4423bab2886017996955f809b6e3102cbf1781.zip |
Merge pull request #4895 from MetaMask/fix-confirm
Add rounding to large exponential numbers. Fix overflows
Diffstat (limited to 'ui/app/helpers/confirm-transaction/util.js')
-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 +} |