mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
Adds max amount feature for send token
This commit is contained in:
parent
319779ab08
commit
c420249fb9
@ -321,18 +321,25 @@ SendTransactionScreen.prototype.setAmountToMax = function () {
|
||||
updateGasPrice,
|
||||
updateGasLimit,
|
||||
updateGasTotal,
|
||||
tokenBalance,
|
||||
selectedToken,
|
||||
} = this.props
|
||||
const { decimals } = selectedToken || {}
|
||||
const multiplier = Math.pow(10, Number(decimals || 0))
|
||||
|
||||
const maxAmount = subtractCurrencies(
|
||||
ethUtil.addHexPrefix(balance),
|
||||
ethUtil.addHexPrefix(MIN_GAS_TOTAL),
|
||||
{ toNumericBase: 'hex' }
|
||||
)
|
||||
const maxAmount = selectedToken
|
||||
? multiplyCurrencies(tokenBalance, multiplier, {toNumericBase: 'hex'})
|
||||
: subtractCurrencies(
|
||||
ethUtil.addHexPrefix(balance),
|
||||
ethUtil.addHexPrefix(gasTotal),
|
||||
{ toNumericBase: 'hex' }
|
||||
)
|
||||
|
||||
updateSendErrors({ amount: null })
|
||||
updateGasPrice(MIN_GAS_PRICE_HEX)
|
||||
updateGasLimit(MIN_GAS_LIMIT_HEX)
|
||||
updateGasTotal(MIN_GAS_TOTAL)
|
||||
|
||||
updateSendAmount(maxAmount)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user