aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pending-tx/confirm-send-token.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-04-03 07:28:33 +0800
committerkumavis <aaron@kumavis.me>2018-04-03 07:28:33 +0800
commit655593ea62b04a47cde18b785d1a88d0d0d0f726 (patch)
tree37cdbef5ef0f042c1ce3713e3b11efdec3a315b8 /ui/app/components/pending-tx/confirm-send-token.js
parentbd6f5547667bdae00e8990551f3a0ea39ab8d971 (diff)
parentc14ec4191741c444dcf5b7c3e177c17a10374c16 (diff)
downloadtangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.gz
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.bz2
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.lz
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.xz
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.zst
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.zip
Merge branch 'master' of github.com:MetaMask/metamask-extension into build-perf
Diffstat (limited to 'ui/app/components/pending-tx/confirm-send-token.js')
-rw-r--r--ui/app/components/pending-tx/confirm-send-token.js53
1 files changed, 45 insertions, 8 deletions
diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js
index dd9fdc23f..19e591fd6 100644
--- a/ui/app/components/pending-tx/confirm-send-token.js
+++ b/ui/app/components/pending-tx/confirm-send-token.js
@@ -147,21 +147,56 @@ function ConfirmSendToken () {
this.onSubmit = this.onSubmit.bind(this)
}
-ConfirmSendToken.prototype.componentWillMount = function () {
- const { tokenContract, selectedAddress, updateSendErrors} = this.props
+ConfirmSendToken.prototype.updateComponentSendErrors = function (prevProps) {
+ const {
+ balance: oldBalance,
+ conversionRate: oldConversionRate,
+ } = prevProps
+ const {
+ updateSendErrors,
+ balance,
+ conversionRate,
+ send: {
+ errors: {
+ simulationFails,
+ },
+ },
+ } = this.props
const txMeta = this.gatherTxMeta()
- const balanceIsSufficient = this.isBalanceSufficient(txMeta)
+
+ const shouldUpdateBalanceSendErrors = balance && [
+ balance !== oldBalance,
+ conversionRate !== oldConversionRate,
+ ].some(x => Boolean(x))
+
+ if (shouldUpdateBalanceSendErrors) {
+ const balanceIsSufficient = this.isBalanceSufficient(txMeta)
+ updateSendErrors({
+ insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'),
+ })
+ }
+
+ const shouldUpdateSimulationSendError = Boolean(txMeta.simulationFails) !== Boolean(simulationFails)
+
+ if (shouldUpdateSimulationSendError) {
+ updateSendErrors({
+ simulationFails: !txMeta.simulationFails ? false : this.context.t('transactionError'),
+ })
+ }
+}
+
+ConfirmSendToken.prototype.componentWillMount = function () {
+ const { tokenContract, selectedAddress } = this.props
tokenContract && tokenContract
.balanceOf(selectedAddress)
.then(usersToken => {
})
this.props.updateTokenExchangeRate()
+ this.updateComponentSendErrors({})
+}
- updateSendErrors({
- insufficientFunds: balanceIsSufficient
- ? false
- : this.context.t('insufficientFunds'),
- })
+ConfirmSendToken.prototype.componentDidUpdate = function (prevProps) {
+ this.updateComponentSendErrors(prevProps)
}
ConfirmSendToken.prototype.getAmount = function () {
@@ -467,8 +502,10 @@ ConfirmSendToken.prototype.render = function () {
]),
h('form#pending-tx-form', {
+ className: 'confirm-screen-form',
onSubmit: this.onSubmit,
}, [
+ this.renderErrorMessage('simulationFails'),
h('.page-container__footer', [
// Cancel Button
h('button.btn-cancel.page-container__footer-button.allcaps', {