aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/selectors/confirm-transaction.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-07-27 03:15:34 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-07-28 03:22:10 +0800
commitd0c901d081e3b40a191dcb826fda7925d16df92c (patch)
tree13b8b5a75531f0bec35118bc5747ad39fe90c03a /ui/app/selectors/confirm-transaction.js
parentcd2b67cdd956cd7f2a29f94292939a4bb939b7b3 (diff)
downloadtangerine-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/selectors/confirm-transaction.js')
-rw-r--r--ui/app/selectors/confirm-transaction.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/ui/app/selectors/confirm-transaction.js b/ui/app/selectors/confirm-transaction.js
index 8f8e0ea74..9548cf75e 100644
--- a/ui/app/selectors/confirm-transaction.js
+++ b/ui/app/selectors/confirm-transaction.js
@@ -1,6 +1,7 @@
import { createSelector } from 'reselect'
import txHelper from '../../lib/tx-helper'
import { calcTokenAmount } from '../token-util'
+import { roundExponential } from '../helpers/confirm-transaction/util'
const unapprovedTxsSelector = state => state.metamask.unapprovedTxs
const unapprovedMsgsSelector = state => state.metamask.unapprovedMsgs
@@ -133,7 +134,8 @@ export const tokenAmountAndToAddressSelector = createSelector(
const toParam = params.find(param => param.name === TOKEN_PARAM_TO)
const valueParam = params.find(param => param.name === TOKEN_PARAM_VALUE)
toAddress = toParam ? toParam.value : params[0].value
- tokenAmount = valueParam ? Number(valueParam.value) : Number(params[1].value)
+ const value = valueParam ? Number(valueParam.value) : Number(params[1].value)
+ tokenAmount = roundExponential(value)
}
return {
@@ -151,7 +153,8 @@ export const approveTokenAmountAndToAddressSelector = createSelector(
if (params && params.length) {
toAddress = params.find(param => param.name === TOKEN_PARAM_SPENDER).value
- tokenAmount = Number(params.find(param => param.name === TOKEN_PARAM_VALUE).value)
+ const value = Number(params.find(param => param.name === TOKEN_PARAM_VALUE).value)
+ tokenAmount = roundExponential(value)
}
return {
@@ -170,11 +173,13 @@ export const sendTokenTokenAmountAndToAddressSelector = createSelector(
if (params && params.length) {
toAddress = params.find(param => param.name === TOKEN_PARAM_TO).value
- tokenAmount = Number(params.find(param => param.name === TOKEN_PARAM_VALUE).value)
+ let value = Number(params.find(param => param.name === TOKEN_PARAM_VALUE).value)
if (tokenDecimals) {
- tokenAmount = calcTokenAmount(tokenAmount, tokenDecimals)
+ value = calcTokenAmount(value, tokenDecimals)
}
+
+ tokenAmount = roundExponential(value)
}
return {