aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/helpers/confirm-transaction
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/helpers/confirm-transaction')
-rw-r--r--ui/app/helpers/confirm-transaction/util.js9
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
+}