diff options
Improve customize gas modal error handling
Diffstat (limited to 'ui/app/send-v2.js')
-rw-r--r-- | ui/app/send-v2.js | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 4986edf5f..16e4d7801 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -19,6 +19,9 @@ const { conversionGreaterThan, addCurrencies, } = require('./conversion-util') +const { + isBalanceSufficient, +} = require('./components/send/send-utils.js') const { isValidAddress } = require('./util') module.exports = SendTransactionScreen @@ -237,28 +240,16 @@ SendTransactionScreen.prototype.validateAmount = function (value) { let amountError = null - const totalAmount = addCurrencies(amount, gasTotal, { - aBase: 16, - bBase: 16, - toNumericBase: 'hex', + const sufficientBalance = isBalanceSufficient({ + amount, + gasTotal, + balance, + primaryCurrency, + selectedToken, + amountConversionRate, + conversionRate, }) - const sufficientBalance = conversionGreaterThan( - { - value: balance, - fromNumericBase: 'hex', - fromCurrency: primaryCurrency, - conversionRate, - }, - { - value: totalAmount, - fromNumericBase: 'hex', - conversionRate: amountConversionRate, - fromCurrency: selectedToken || primaryCurrency, - conversionRate: amountConversionRate, - }, - ) - const amountLessThanZero = conversionGreaterThan( { value: 0, fromNumericBase: 'dec' }, { value: amount, fromNumericBase: 'hex' }, @@ -387,7 +378,7 @@ SendTransactionScreen.prototype.renderFooter = function () { clearSend, errors: { amount: amountError, to: toError } } = this.props - + const noErrors = amountError === null && toError === null const errorClass = noErrors ? '' : '__disabled' |