From 1c8a4c88e29ed3da06e0400404e7272b1da8f06b Mon Sep 17 00:00:00 2001 From: Gabriel Montes Date: Tue, 8 Oct 2019 18:40:30 -0300 Subject: [PATCH] Bubble up tx signing errors (#3105) * Bubble up tx signing errors Resolves #2062 --- CHANGELOG.md | 1 + packages/web3-core-method/src/index.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1396607178b..30f11a60cd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,4 +65,5 @@ Released with 1.0.0-beta.37 code base. - Fix incorrectly populating chainId param with `net_version` when signing txs (#2378) - regeneratorRuntime error fixed (#3058) - Fix accessing event.name where event is undefined (#3014) +- Fix bubbling up tx signing errors (#2063, #3105) - HttpProvider: CORS issue with Firefox and Safari (#2978) diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js index e8012bf77c6..efe8fd974a7 100644 --- a/packages/web3-core-method/src/index.js +++ b/packages/web3-core-method/src/index.js @@ -533,7 +533,16 @@ Method.prototype.buildCall = function() { // If wallet was found, sign tx, and send using sendRawTransaction if (wallet && wallet.privateKey) { - return method.accounts.signTransaction(_.omit(tx, 'from'), wallet.privateKey).then(sendSignedTx); + return method.accounts.signTransaction(_.omit(tx, 'from'), wallet.privateKey) + .then(sendSignedTx) + .catch(function (err) { + if (_.isFunction(defer.eventEmitter.listeners) && defer.eventEmitter.listeners('error').length) { + defer.eventEmitter.emit('error', err); + defer.eventEmitter.removeAllListeners(); + defer.eventEmitter.catch(function () {}); + } + defer.reject(err); + }); } // ETH_SIGN