diff options
author | Dan <danjm.com@gmail.com> | 2017-10-20 02:23:02 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-20 02:38:14 +0800 |
commit | bd11e60b8c128dd69ba1bcf58d25fa9323d91a33 (patch) | |
tree | 646ec2072445e3bc55ae90dcd2f8f2272da33675 /ui | |
parent | f01d119cc1a6237b88e543be821d91778bcbb128 (diff) | |
download | tangerine-wallet-browser-bd11e60b8c128dd69ba1bcf58d25fa9323d91a33.tar tangerine-wallet-browser-bd11e60b8c128dd69ba1bcf58d25fa9323d91a33.tar.gz tangerine-wallet-browser-bd11e60b8c128dd69ba1bcf58d25fa9323d91a33.tar.bz2 tangerine-wallet-browser-bd11e60b8c128dd69ba1bcf58d25fa9323d91a33.tar.lz tangerine-wallet-browser-bd11e60b8c128dd69ba1bcf58d25fa9323d91a33.tar.xz tangerine-wallet-browser-bd11e60b8c128dd69ba1bcf58d25fa9323d91a33.tar.zst tangerine-wallet-browser-bd11e60b8c128dd69ba1bcf58d25fa9323d91a33.zip |
Amount field shows insufficient funds error based on amoutn + gas total.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/conversion-util.js | 12 | ||||
-rw-r--r-- | ui/app/send-v2.js | 17 |
2 files changed, 22 insertions, 7 deletions
diff --git a/ui/app/conversion-util.js b/ui/app/conversion-util.js index 1ef276a39..e008ee1cb 100644 --- a/ui/app/conversion-util.js +++ b/ui/app/conversion-util.js @@ -132,12 +132,16 @@ const conversionUtil = (value, { }); const addCurrencies = (a, b, options = {}) => { - const { toNumericBase, numberOfDecimals } = options - const value = (new BigNumber(a)).add(b); + const { + aBase, + bBase, + ...conversionOptions, + } = options + const value = (new BigNumber(a, aBase)).add(b, bBase); + return converter({ value, - toNumericBase, - numberOfDecimals, + ...conversionOptions, }) } diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index e8a12670b..c0a03690a 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -12,7 +12,11 @@ const GasFeeDisplay = require('./components/send/gas-fee-display-v2') const { showModal } = require('./actions') -const { multiplyCurrencies, conversionGreaterThan } = require('./conversion-util') +const { + multiplyCurrencies, + conversionGreaterThan, + addCurrencies, +} = require('./conversion-util') const { isValidAddress } = require('./util') module.exports = SendTransactionScreen @@ -225,12 +229,19 @@ SendTransactionScreen.prototype.validateAmount = function (value) { conversionRate, primaryCurrency, toCurrency, - selectedToken + selectedToken, + gasTotal, } = this.props const amount = value let amountError = null + const totalAmount = addCurrencies(amount, gasTotal, { + aBase: 16, + bBase: 16, + toNumericBase: 'hex', + }) + const sufficientBalance = conversionGreaterThan( { value: balance, @@ -239,7 +250,7 @@ SendTransactionScreen.prototype.validateAmount = function (value) { conversionRate, }, { - value: amount, + value: totalAmount, fromNumericBase: 'hex', conversionRate: amountConversionRate, fromCurrency: selectedToken || primaryCurrency, |