1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #4986 from MetaMask/approve-calc-token-decimals

Use token decimals when calculating confirm screen token approval amount
This commit is contained in:
Dan J Miller 2018-08-08 16:26:03 -02:30 committed by GitHub
commit 1d4ee6bf76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -147,14 +147,20 @@ export const tokenAmountAndToAddressSelector = createSelector(
export const approveTokenAmountAndToAddressSelector = createSelector(
tokenDataParamsSelector,
params => {
tokenDecimalsSelector,
(params, tokenDecimals) => {
let toAddress = ''
let tokenAmount = 0
if (params && params.length) {
toAddress = params.find(param => param.name === TOKEN_PARAM_SPENDER).value
const value = Number(params.find(param => param.name === TOKEN_PARAM_VALUE).value)
tokenAmount = roundExponential(value)
if (tokenDecimals) {
tokenAmount = calcTokenAmount(value, tokenDecimals)
}
tokenAmount = roundExponential(tokenAmount)
}
return {