mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #3446 from danjm/NewUI-handle-token-balance-on-edit
Gracefully handle null token balance in new ui send.
This commit is contained in:
commit
52b4876cf9
@ -361,8 +361,9 @@ SendTransactionScreen.prototype.validateAmount = function (value) {
|
||||
})
|
||||
}
|
||||
|
||||
const verifyTokenBalance = selectedToken && tokenBalance !== null
|
||||
let sufficientTokens
|
||||
if (selectedToken) {
|
||||
if (verifyTokenBalance) {
|
||||
sufficientTokens = isTokenBalanceSufficient({
|
||||
tokenBalance,
|
||||
amount,
|
||||
@ -377,7 +378,7 @@ SendTransactionScreen.prototype.validateAmount = function (value) {
|
||||
|
||||
if (conversionRate && !sufficientBalance) {
|
||||
amountError = 'Insufficient funds.'
|
||||
} else if (selectedToken && !sufficientTokens) {
|
||||
} else if (verifyTokenBalance && !sufficientTokens) {
|
||||
amountError = 'Insufficient tokens.'
|
||||
} else if (amountLessThanZero) {
|
||||
amountError = 'Can not send negative amounts of ETH.'
|
||||
@ -492,9 +493,12 @@ SendTransactionScreen.prototype.renderFooter = function () {
|
||||
goHome,
|
||||
clearSend,
|
||||
gasTotal,
|
||||
tokenBalance,
|
||||
selectedToken,
|
||||
errors: { amount: amountError, to: toError },
|
||||
} = this.props
|
||||
|
||||
const missingTokenBalance = selectedToken && !tokenBalance
|
||||
const noErrors = !amountError && toError === null
|
||||
|
||||
return h('div.page-container__footer', [
|
||||
@ -505,7 +509,7 @@ SendTransactionScreen.prototype.renderFooter = function () {
|
||||
},
|
||||
}, 'Cancel'),
|
||||
h('button.btn-clear.page-container__footer-button', {
|
||||
disabled: !noErrors || !gasTotal,
|
||||
disabled: !noErrors || !gasTotal || missingTokenBalance,
|
||||
onClick: event => this.onSubmit(event),
|
||||
}, 'Next'),
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user