diff options
Diffstat (limited to 'ui/app/selectors/confirm-transaction.js')
-rw-r--r-- | ui/app/selectors/confirm-transaction.js | 13 |
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 { |