mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix amount max for sending token.
This commit is contained in:
parent
da2e9b9765
commit
c156c85eaa
@ -36,6 +36,28 @@ CurrencyDisplay.prototype.getAmount = function (value) {
|
|||||||
: toHexWei(value)
|
: toHexWei(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CurrencyDisplay.prototype.getValueToRender = function () {
|
||||||
|
const { selectedToken, conversionRate, value } = this.props
|
||||||
|
|
||||||
|
const { decimals, symbol } = selectedToken || {}
|
||||||
|
const multiplier = Math.pow(10, Number(decimals || 0))
|
||||||
|
|
||||||
|
return selectedToken
|
||||||
|
? conversionUtil(value, {
|
||||||
|
fromNumericBase: 'hex',
|
||||||
|
toCurrency: symbol,
|
||||||
|
conversionRate: multiplier,
|
||||||
|
invertConversionRate: true,
|
||||||
|
})
|
||||||
|
: conversionUtil(value, {
|
||||||
|
fromNumericBase: 'hex',
|
||||||
|
toNumericBase: 'dec',
|
||||||
|
fromDenomination: 'WEI',
|
||||||
|
numberOfDecimals: 6,
|
||||||
|
conversionRate,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
CurrencyDisplay.prototype.render = function () {
|
CurrencyDisplay.prototype.render = function () {
|
||||||
const {
|
const {
|
||||||
className = 'currency-display',
|
className = 'currency-display',
|
||||||
@ -50,13 +72,7 @@ CurrencyDisplay.prototype.render = function () {
|
|||||||
handleChange,
|
handleChange,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const valueToRender = conversionUtil(value, {
|
const valueToRender = this.getValueToRender()
|
||||||
fromNumericBase: 'hex',
|
|
||||||
toNumericBase: 'dec',
|
|
||||||
fromDenomination: 'WEI',
|
|
||||||
numberOfDecimals: 6,
|
|
||||||
conversionRate,
|
|
||||||
})
|
|
||||||
|
|
||||||
const convertedValue = conversionUtil(valueToRender, {
|
const convertedValue = conversionUtil(valueToRender, {
|
||||||
fromNumericBase: 'dec',
|
fromNumericBase: 'dec',
|
||||||
|
@ -328,9 +328,11 @@ SendTransactionScreen.prototype.setAmountToMax = function () {
|
|||||||
)
|
)
|
||||||
|
|
||||||
updateSendErrors({ amount: null })
|
updateSendErrors({ amount: null })
|
||||||
|
if (!selectedToken) {
|
||||||
updateGasPrice(MIN_GAS_PRICE_HEX)
|
updateGasPrice(MIN_GAS_PRICE_HEX)
|
||||||
updateGasLimit(MIN_GAS_LIMIT_HEX)
|
updateGasLimit(MIN_GAS_LIMIT_HEX)
|
||||||
updateGasTotal(MIN_GAS_TOTAL)
|
updateGasTotal(MIN_GAS_TOTAL)
|
||||||
|
}
|
||||||
updateSendAmount(maxAmount)
|
updateSendAmount(maxAmount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user