From f4142f99cefa4a990c92a5745c6bbbdfe1c7e813 Mon Sep 17 00:00:00 2001 From: jeffsmale90 <6363749+jeffsmale90@users.noreply.github.com> Date: Wed, 29 Mar 2023 11:00:58 +1300 Subject: [PATCH] Correctly handle errors from transaction decoder (#5341) We now correctly resolve the promise with undefined, causing the caller to display the raw log object. --- .../ethereum/common/services/TruffleIntegrationService.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/integrations/ethereum/common/services/TruffleIntegrationService.js b/src/integrations/ethereum/common/services/TruffleIntegrationService.js index b2cf5681e..0ea5a2eb3 100644 --- a/src/integrations/ethereum/common/services/TruffleIntegrationService.js +++ b/src/integrations/ethereum/common/services/TruffleIntegrationService.js @@ -185,10 +185,12 @@ class TruffleIntegrationService extends EventEmitter { return new Promise((resolve, reject) => { if (this.child !== null && this.child.connected) { this.once("decode-transaction-response", data => { - if (typeof data === "object") { - resolve(data); + if (data && data.error) { + reject(data.error); } else { - reject(data); + // data may be `undefined`, in which case the raw event will be displayed + // see https://github.com/trufflesuite/ganache-ui/issues/3805 for details + resolve(data); } });