From 7af696bfbe721db74efad91ca916b18198070e76 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Oct 2017 14:56:59 -0700 Subject: [PATCH 1/7] pending tx tracker - dont throw on load failure --- app/scripts/lib/pending-tx-tracker.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/scripts/lib/pending-tx-tracker.js b/app/scripts/lib/pending-tx-tracker.js index 3d358b00e..48d1e1d06 100644 --- a/app/scripts/lib/pending-tx-tracker.js +++ b/app/scripts/lib/pending-tx-tracker.js @@ -137,7 +137,6 @@ module.exports = class PendingTransactionTracker extends EventEmitter { message: 'There was a problem loading this transaction.', } this.emit('tx:warning', txMeta) - throw err } } From 22eaf92ec2c948ed88df30bc3a3b26f140359f09 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Oct 2017 15:00:23 -0700 Subject: [PATCH 2/7] pending tx tracker - resubmit - warn dont error on unknown error --- app/scripts/lib/pending-tx-tracker.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/pending-tx-tracker.js b/app/scripts/lib/pending-tx-tracker.js index 48d1e1d06..dcaa1d716 100644 --- a/app/scripts/lib/pending-tx-tracker.js +++ b/app/scripts/lib/pending-tx-tracker.js @@ -86,12 +86,15 @@ module.exports = class PendingTransactionTracker extends EventEmitter { // other || errorMessage.includes('gateway timeout') || errorMessage.includes('nonce too low') - || txMeta.retryCount > 1 ) // ignore resubmit warnings, return early if (isKnownTx) return // encountered real error - transition to error state - this.emit('tx:failed', txMeta.id, err) + txMeta.warning = { + error: errorMessage, + message: 'There was an error when resubmitting this transaction.', + } + this.emit('tx:warning', txMeta) })) } From a86f6d6d90bda273861079b464c290dff6ef5c0e Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Oct 2017 15:14:15 -0700 Subject: [PATCH 3/7] pending tx tracker - test - rename tests to match event name --- test/unit/pending-tx-test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/pending-tx-test.js b/test/unit/pending-tx-test.js index 4da0eff5d..097564033 100644 --- a/test/unit/pending-tx-test.js +++ b/test/unit/pending-tx-test.js @@ -57,7 +57,7 @@ describe('PendingTransactionTracker', function () { const block = Proxy.revocable({}, {}).revoke() pendingTxTracker.checkForTxInBlock(block) }) - it('should emit \'txFailed\' if the txMeta does not have a hash', function (done) { + it('should emit \'tx:failed\' if the txMeta does not have a hash', function (done) { const block = Proxy.revocable({}, {}).revoke() pendingTxTracker.getPendingTransactions = () => [txMetaNoHash] pendingTxTracker.once('tx:failed', (txId, err) => { @@ -105,7 +105,7 @@ describe('PendingTransactionTracker', function () { }) describe('#_checkPendingTx', function () { - it('should emit \'txFailed\' if the txMeta does not have a hash', function (done) { + it('should emit \'tx:failed\' if the txMeta does not have a hash', function (done) { pendingTxTracker.once('tx:failed', (txId, err) => { assert(txId, txMetaNoHash.id, 'should pass txId') done() @@ -172,7 +172,7 @@ describe('PendingTransactionTracker', function () { .catch(done) pendingTxTracker.resubmitPendingTxs() }) - it('should not emit \'txFailed\' if the txMeta throws a known txError', function (done) { + it('should not emit \'tx:failed\' if the txMeta throws a known txError', function (done) { knownErrors =[ // geth ' Replacement transaction Underpriced ', @@ -199,7 +199,7 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.resubmitPendingTxs() }) - it('should emit \'txFailed\' if it encountered a real error', function (done) { + it('should emit \'tx:failed\' if it encountered a real error', function (done) { pendingTxTracker.once('tx:failed', (id, err) => err.message === 'im some real error' ? txList[id - 1].resolve() : done(err)) pendingTxTracker.getPendingTransactions = () => txList From ed77304e73e91f252e6e0a3f682569ad17a0d52d Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Oct 2017 15:20:01 -0700 Subject: [PATCH 4/7] pending tx tracker - tx:warning event includes err obj --- app/scripts/lib/pending-tx-tracker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/pending-tx-tracker.js b/app/scripts/lib/pending-tx-tracker.js index dcaa1d716..474c4d5a2 100644 --- a/app/scripts/lib/pending-tx-tracker.js +++ b/app/scripts/lib/pending-tx-tracker.js @@ -94,7 +94,7 @@ module.exports = class PendingTransactionTracker extends EventEmitter { error: errorMessage, message: 'There was an error when resubmitting this transaction.', } - this.emit('tx:warning', txMeta) + this.emit('tx:warning', txMeta, err) })) } @@ -139,7 +139,7 @@ module.exports = class PendingTransactionTracker extends EventEmitter { error: err, message: 'There was a problem loading this transaction.', } - this.emit('tx:warning', txMeta) + this.emit('tx:warning', txMeta, err) } } From 25a80932a64f718ba1a39ab399b17395f0fd5d88 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Oct 2017 15:20:18 -0700 Subject: [PATCH 5/7] pending tx tracker - test - expect warning event on resubmit failure --- test/unit/pending-tx-test.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/unit/pending-tx-test.js b/test/unit/pending-tx-test.js index 097564033..6b62bb5b1 100644 --- a/test/unit/pending-tx-test.js +++ b/test/unit/pending-tx-test.js @@ -199,8 +199,15 @@ describe('PendingTransactionTracker', function () { pendingTxTracker.resubmitPendingTxs() }) - it('should emit \'tx:failed\' if it encountered a real error', function (done) { - pendingTxTracker.once('tx:failed', (id, err) => err.message === 'im some real error' ? txList[id - 1].resolve() : done(err)) + it('should emit \'tx:warning\' if it encountered a real error', function (done) { + pendingTxTracker.once('tx:warning', (txMeta, err) => { + if (err.message === 'im some real error') { + const matchingTx = txList.find(tx => tx.id === txMeta.id) + matchingTx.resolve() + } else { + done(err) + } + }) pendingTxTracker.getPendingTransactions = () => txList pendingTxTracker._resubmitTx = async (tx) => { throw new TypeError('im some real error') } From 062eaa6a82f6730eb180c1a1fb61f035eb123451 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Oct 2017 15:39:11 -0700 Subject: [PATCH 6/7] pending tx tracker - on tx:warn append error message instead of error obj --- app/scripts/lib/pending-tx-tracker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/lib/pending-tx-tracker.js b/app/scripts/lib/pending-tx-tracker.js index 474c4d5a2..6f1601586 100644 --- a/app/scripts/lib/pending-tx-tracker.js +++ b/app/scripts/lib/pending-tx-tracker.js @@ -136,7 +136,7 @@ module.exports = class PendingTransactionTracker extends EventEmitter { } } catch (err) { txMeta.warning = { - error: err, + error: err.message, message: 'There was a problem loading this transaction.', } this.emit('tx:warning', txMeta, err) From 2113d8348969f4da3c61ddf1cee4aa38f7a5958a Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Oct 2017 15:39:44 -0700 Subject: [PATCH 7/7] ui - tx history - simplify error+warning display code --- ui/app/components/transaction-list-item.js | 34 ++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/ui/app/components/transaction-list-item.js b/ui/app/components/transaction-list-item.js index 0e5c0b5a3..a9961f47c 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-list-item.js @@ -133,7 +133,7 @@ function recipientField (txParams, transaction, isTx, isMsg) { }, }, [ message, - failIfFailed(transaction), + renderErrorOrWarning(transaction), ]) } @@ -141,25 +141,35 @@ function formatDate (date) { return vreme.format(new Date(date), 'March 16 2014 14:30') } -function failIfFailed (transaction) { - if (transaction.status === 'rejected') { +function renderErrorOrWarning (transaction) { + const { status, err, warning } = transaction + + // show rejected + if (status === 'rejected') { return h('span.error', ' (Rejected)') } - if (transaction.err || transaction.warning) { - const { err, warning = {} } = transaction - const errFirst = !!(( err && warning ) || err) - const message = errFirst ? err.message : warning.message - - errFirst ? err.message : warning.message + // show error + if (err) { + const message = err.message || '' + return ( + h(Tooltip, { + title: message, + position: 'bottom', + }, [ + h(`span.error`, ` (Failed)`), + ]) + ) + } + // show warning + if (warning) { + const message = warning.message return h(Tooltip, { title: message, position: 'bottom', }, [ - h(`span.${errFirst ? 'error' : 'warning'}`, - ` (${errFirst ? 'Failed' : 'Warning'})` - ), + h(`span.warning`, ` (Warning)`), ]) } }