mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Amount field shows insufficient funds error based on amoutn + gas total.
This commit is contained in:
parent
f01d119cc1
commit
bd11e60b8c
@ -132,12 +132,16 @@ const conversionUtil = (value, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const addCurrencies = (a, b, options = {}) => {
|
const addCurrencies = (a, b, options = {}) => {
|
||||||
const { toNumericBase, numberOfDecimals } = options
|
const {
|
||||||
const value = (new BigNumber(a)).add(b);
|
aBase,
|
||||||
|
bBase,
|
||||||
|
...conversionOptions,
|
||||||
|
} = options
|
||||||
|
const value = (new BigNumber(a, aBase)).add(b, bBase);
|
||||||
|
|
||||||
return converter({
|
return converter({
|
||||||
value,
|
value,
|
||||||
toNumericBase,
|
...conversionOptions,
|
||||||
numberOfDecimals,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,11 @@ const GasFeeDisplay = require('./components/send/gas-fee-display-v2')
|
|||||||
|
|
||||||
const { showModal } = require('./actions')
|
const { showModal } = require('./actions')
|
||||||
|
|
||||||
const { multiplyCurrencies, conversionGreaterThan } = require('./conversion-util')
|
const {
|
||||||
|
multiplyCurrencies,
|
||||||
|
conversionGreaterThan,
|
||||||
|
addCurrencies,
|
||||||
|
} = require('./conversion-util')
|
||||||
const { isValidAddress } = require('./util')
|
const { isValidAddress } = require('./util')
|
||||||
|
|
||||||
module.exports = SendTransactionScreen
|
module.exports = SendTransactionScreen
|
||||||
@ -225,12 +229,19 @@ SendTransactionScreen.prototype.validateAmount = function (value) {
|
|||||||
conversionRate,
|
conversionRate,
|
||||||
primaryCurrency,
|
primaryCurrency,
|
||||||
toCurrency,
|
toCurrency,
|
||||||
selectedToken
|
selectedToken,
|
||||||
|
gasTotal,
|
||||||
} = this.props
|
} = this.props
|
||||||
const amount = value
|
const amount = value
|
||||||
|
|
||||||
let amountError = null
|
let amountError = null
|
||||||
|
|
||||||
|
const totalAmount = addCurrencies(amount, gasTotal, {
|
||||||
|
aBase: 16,
|
||||||
|
bBase: 16,
|
||||||
|
toNumericBase: 'hex',
|
||||||
|
})
|
||||||
|
|
||||||
const sufficientBalance = conversionGreaterThan(
|
const sufficientBalance = conversionGreaterThan(
|
||||||
{
|
{
|
||||||
value: balance,
|
value: balance,
|
||||||
@ -239,7 +250,7 @@ SendTransactionScreen.prototype.validateAmount = function (value) {
|
|||||||
conversionRate,
|
conversionRate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: amount,
|
value: totalAmount,
|
||||||
fromNumericBase: 'hex',
|
fromNumericBase: 'hex',
|
||||||
conversionRate: amountConversionRate,
|
conversionRate: amountConversionRate,
|
||||||
fromCurrency: selectedToken || primaryCurrency,
|
fromCurrency: selectedToken || primaryCurrency,
|
||||||
|
Loading…
Reference in New Issue
Block a user