From 615b8d05a15dcbc572f64d3aa7b8e9feab367bdc Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 26 Jun 2017 15:47:53 -0700 Subject: [PATCH 1/3] Prevent users from accidentally submitting two transactions by disabling button. --- ui/app/components/pending-tx.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 4b1a00eca..5d6954092 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -410,6 +410,8 @@ PendingTx.prototype.resetGasFields = function () { PendingTx.prototype.onSubmit = function (event) { event.preventDefault() + const acceptButton = document.querySelector('input.confirm') + acceptButton.disabled = true const txMeta = this.gatherTxMeta() const valid = this.checkValidity() this.setState({ valid }) @@ -417,6 +419,7 @@ PendingTx.prototype.onSubmit = function (event) { this.props.sendTransaction(txMeta, event) } else { this.props.dispatch(actions.displayWarning('Invalid Gas Parameters')) + acceptButton.disabled = false } } From f2cfbda1c968d4bb094cac4f80abe8eeb5225dcf Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 26 Jun 2017 15:48:41 -0700 Subject: [PATCH 2/3] Bump changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 754f076f8..4bfec12dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fix bug where slowly mined txs would sometimes be incorrectly marked as failed. - Fix bug where badge count did not reflect personal_sign pending messages. - Seed word confirmation wording is now scarier. +- Prevent users from submitting two duplicate transactions by disabling submit. ## 3.7.8 2017-6-12 From 9962a3068b25283e62963338f2c686818f0baef7 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 26 Jun 2017 15:57:46 -0700 Subject: [PATCH 3/3] Change disabling button as state property. --- ui/app/components/pending-tx.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 5d6954092..f33a5d948 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -27,6 +27,7 @@ function PendingTx () { this.state = { valid: true, txData: null, + submitting: false, } } @@ -316,7 +317,7 @@ PendingTx.prototype.render = function () { type: 'submit', value: 'ACCEPT', style: { marginLeft: '10px' }, - disabled: insufficientBalance || !this.state.valid || !isValidAddress, + disabled: insufficientBalance || !this.state.valid || !isValidAddress || this.state.submitting, }), h('button.cancel.btn-red', { @@ -410,16 +411,14 @@ PendingTx.prototype.resetGasFields = function () { PendingTx.prototype.onSubmit = function (event) { event.preventDefault() - const acceptButton = document.querySelector('input.confirm') - acceptButton.disabled = true const txMeta = this.gatherTxMeta() const valid = this.checkValidity() - this.setState({ valid }) + this.setState({ valid, submitting: true }) if (valid && this.verifyGasParams()) { this.props.sendTransaction(txMeta, event) } else { this.props.dispatch(actions.displayWarning('Invalid Gas Parameters')) - acceptButton.disabled = false + this.setState({ submitting: false }) } }