aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorThomas Huang <tmashuang@users.noreply.github.com>2018-04-03 06:26:46 +0800
committerGitHub <noreply@github.com>2018-04-03 06:26:46 +0800
commit8cd2022169f50607812d1f36d408c098c0dc29ed (patch)
treeea1644f5cc5470452b9d895e47f6edda17a1549b /ui
parent331b62a6a2450aa5be6881877f5312a70ea92e63 (diff)
parent7ccf6163fd4dda52d4c75f57cb36d1f4b05b50ea (diff)
downloadtangerine-wallet-browser-8cd2022169f50607812d1f36d408c098c0dc29ed.tar
tangerine-wallet-browser-8cd2022169f50607812d1f36d408c098c0dc29ed.tar.gz
tangerine-wallet-browser-8cd2022169f50607812d1f36d408c098c0dc29ed.tar.bz2
tangerine-wallet-browser-8cd2022169f50607812d1f36d408c098c0dc29ed.tar.lz
tangerine-wallet-browser-8cd2022169f50607812d1f36d408c098c0dc29ed.tar.xz
tangerine-wallet-browser-8cd2022169f50607812d1f36d408c098c0dc29ed.tar.zst
tangerine-wallet-browser-8cd2022169f50607812d1f36d408c098c0dc29ed.zip
Merge pull request #3825 from danjm/i3668-warnusertxsimulationfails
Add simulation failure errors while improve send error handling on confirm screen
Diffstat (limited to 'ui')
-rw-r--r--ui/app/components/pending-tx/confirm-send-ether.js52
-rw-r--r--ui/app/components/pending-tx/confirm-send-token.js53
-rw-r--r--ui/app/css/itcss/components/confirm.scss11
3 files changed, 100 insertions, 16 deletions
diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js
index 2474516d4..d007e6661 100644
--- a/ui/app/components/pending-tx/confirm-send-ether.js
+++ b/ui/app/components/pending-tx/confirm-send-ether.js
@@ -109,16 +109,50 @@ function ConfirmSendEther () {
this.onSubmit = this.onSubmit.bind(this)
}
-ConfirmSendEther.prototype.componentWillMount = function () {
- const { updateSendErrors } = this.props
+ConfirmSendEther.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)
- updateSendErrors({
- insufficientFunds: balanceIsSufficient
- ? false
- : this.context.t('insufficientFunds'),
- })
+ 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'),
+ })
+ }
+}
+
+ConfirmSendEther.prototype.componentWillMount = function () {
+ this.updateComponentSendErrors({})
+}
+
+ConfirmSendEther.prototype.componentDidUpdate = function (prevProps) {
+ this.updateComponentSendErrors(prevProps)
}
ConfirmSendEther.prototype.getAmount = function () {
@@ -457,8 +491,10 @@ ConfirmSendEther.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', {
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', {
diff --git a/ui/app/css/itcss/components/confirm.scss b/ui/app/css/itcss/components/confirm.scss
index 85ff14e6e..47762e8de 100644
--- a/ui/app/css/itcss/components/confirm.scss
+++ b/ui/app/css/itcss/components/confirm.scss
@@ -312,6 +312,17 @@ section .confirm-screen-account-number,
}
}
+.confirm-screen-form {
+ position: relative;
+
+ .confirm-screen-error {
+ right: 0;
+ width: 100%;
+ margin-top: 7px;
+ text-align: center;
+ }
+}
+
.confirm-screen-confirm-button {
height: 50px;
border-radius: 4px;