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:
commit
1d4ee6bf76
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user