From 7eb735651bcd1c3a4ef2b4da1be5d7444e282b44 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Sun, 29 Apr 2018 16:00:13 -0700 Subject: transactions - run event emitters outside context of _setTxStatus --- app/scripts/controllers/transactions/tx-state-manager.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'app/scripts/controllers/transactions') diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js index 53428c333..17938e70f 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.js +++ b/app/scripts/controllers/transactions/tx-state-manager.js @@ -398,13 +398,15 @@ class TransactionStateManager extends EventEmitter { _setTxStatus (txId, status) { const txMeta = this.getTx(txId) txMeta.status = status - this.emit(`${txMeta.id}:${status}`, txId) - this.emit(`tx:status-update`, txId, status) - if (['submitted', 'rejected', 'failed'].includes(status)) { - this.emit(`${txMeta.id}:finished`, txMeta) - } - this.updateTx(txMeta, `txStateManager: setting status to ${status}`) - this.emit('update:badge') + setTimeout(() => { + this.updateTx(txMeta, `txStateManager: setting status to ${status}`) + this.emit(`${txMeta.id}:${status}`, txId) + this.emit(`tx:status-update`, txId, status) + if (['submitted', 'rejected', 'failed'].includes(status)) { + this.emit(`${txMeta.id}:finished`, txMeta) + } + this.emit('update:badge') + }) } /** -- cgit From 706647785cee23d177d646c3a06f5dc2a2586feb Mon Sep 17 00:00:00 2001 From: frankiebee Date: Sun, 29 Apr 2018 16:33:46 -0700 Subject: log emitter errors --- app/scripts/controllers/transactions/tx-state-manager.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'app/scripts/controllers/transactions') diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js index 17938e70f..28b6d6d4f 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.js +++ b/app/scripts/controllers/transactions/tx-state-manager.js @@ -399,13 +399,17 @@ class TransactionStateManager extends EventEmitter { const txMeta = this.getTx(txId) txMeta.status = status setTimeout(() => { - this.updateTx(txMeta, `txStateManager: setting status to ${status}`) - this.emit(`${txMeta.id}:${status}`, txId) - this.emit(`tx:status-update`, txId, status) - if (['submitted', 'rejected', 'failed'].includes(status)) { - this.emit(`${txMeta.id}:finished`, txMeta) + try { + this.updateTx(txMeta, `txStateManager: setting status to ${status}`) + this.emit(`${txMeta.id}:${status}`, txId) + this.emit(`tx:status-update`, txId, status) + if (['submitted', 'rejected', 'failed'].includes(status)) { + this.emit(`${txMeta.id}:finished`, txMeta) + } + this.emit('update:badge') + } catch (error) { + log.error(error) } - this.emit('update:badge') }) } -- cgit From 98ae853b6c67bce137df00c2527e5ece25f1129e Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 30 Apr 2018 09:57:36 -0700 Subject: require log --- app/scripts/controllers/transactions/tx-state-manager.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/scripts/controllers/transactions') diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js index 28b6d6d4f..f05c7d095 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.js +++ b/app/scripts/controllers/transactions/tx-state-manager.js @@ -2,6 +2,7 @@ const extend = require('xtend') const EventEmitter = require('events') const ObservableStore = require('obs-store') const ethUtil = require('ethereumjs-util') +const log = require('loglevel') const txStateHistoryHelper = require('./lib/tx-state-history-helper') const createId = require('../../lib/random-id') const { getFinalStates } = require('./lib/util') -- cgit From 62dc6e20eb1f7188c6452519782e8ebe54c1c540 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 28 May 2018 17:57:45 +0200 Subject: Clean up user rejection error message --- app/scripts/controllers/transactions/index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'app/scripts/controllers/transactions') diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 541f1db73..586a80baf 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -111,6 +111,15 @@ class TransactionController extends EventEmitter { this.txStateManager.wipeTransactions(address) } + /** + Returns error without stack trace for better UI display + @param {Error} err - error which stack will be cleaned + */ + cleanErrorStack(err){ + err.stack = err.name + ': ' + err.message + return err + } + /** add a new unapproved transaction to the pipeline @@ -118,6 +127,8 @@ class TransactionController extends EventEmitter { @param txParams {object} - txParams for the transaction @param opts {object} - with the key origin to put the origin on the txMeta */ + + async newUnapprovedTransaction (txParams, opts = {}) { log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`) const initialTxMeta = await this.addUnapprovedTransaction(txParams) @@ -130,11 +141,11 @@ class TransactionController extends EventEmitter { case 'submitted': return resolve(finishedTxMeta.hash) case 'rejected': - return reject(new Error('MetaMask Tx Signature: User denied transaction signature.')) + return reject(this.cleanErrorStack(new Error('MetaMask Tx Signature: User denied transaction signature.'))) case 'failed': - return reject(new Error(finishedTxMeta.err.message)) + return reject(this.cleanErrorStack(new Error(finishedTxMeta.err.message))) default: - return reject(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`)) + return reject(this.cleanErrorStack(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`)) } }) }) -- cgit From 1d23a5c81b03b8b52225e942603c84b237d4e63c Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 28 May 2018 18:08:33 +0200 Subject: error message fix --- app/scripts/controllers/transactions/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app/scripts/controllers/transactions') diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 586a80baf..6609b80b0 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -128,7 +128,6 @@ class TransactionController extends EventEmitter { @param opts {object} - with the key origin to put the origin on the txMeta */ - async newUnapprovedTransaction (txParams, opts = {}) { log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`) const initialTxMeta = await this.addUnapprovedTransaction(txParams) @@ -145,7 +144,7 @@ class TransactionController extends EventEmitter { case 'failed': return reject(this.cleanErrorStack(new Error(finishedTxMeta.err.message))) default: - return reject(this.cleanErrorStack(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`)) + return reject(this.cleanErrorStack(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`))) } }) }) -- cgit From 71a6e97327a4c759942784ee81505e3bc5ed545e Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 28 May 2018 22:57:08 +0200 Subject: cleanErrorStack moved to separate library module more errors traces cleaned up --- app/scripts/controllers/transactions/index.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'app/scripts/controllers/transactions') diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 6609b80b0..aff5db984 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -8,6 +8,7 @@ const TxGasUtil = require('./tx-gas-utils') const PendingTransactionTracker = require('./pending-tx-tracker') const NonceTracker = require('./nonce-tracker') const txUtils = require('./lib/util') +const cleanErrorStack = require('../../lib/cleanErrorStack') const log = require('loglevel') /** @@ -111,15 +112,6 @@ class TransactionController extends EventEmitter { this.txStateManager.wipeTransactions(address) } - /** - Returns error without stack trace for better UI display - @param {Error} err - error which stack will be cleaned - */ - cleanErrorStack(err){ - err.stack = err.name + ': ' + err.message - return err - } - /** add a new unapproved transaction to the pipeline @@ -140,11 +132,11 @@ class TransactionController extends EventEmitter { case 'submitted': return resolve(finishedTxMeta.hash) case 'rejected': - return reject(this.cleanErrorStack(new Error('MetaMask Tx Signature: User denied transaction signature.'))) + return reject(cleanErrorStack(new Error('MetaMask Tx Signature: User denied transaction signature.'))) case 'failed': - return reject(this.cleanErrorStack(new Error(finishedTxMeta.err.message))) + return reject(cleanErrorStack(new Error(finishedTxMeta.err.message))) default: - return reject(this.cleanErrorStack(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`))) + return reject(cleanErrorStack(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`))) } }) }) -- cgit