From 98494c3de63fd3d27b0982e327242db80a588bb2 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 22 Jul 2020 15:21:04 -0400 Subject: [PATCH] refactor buildCallPath --- libs/remix-debug/src/debugger/stepManager.js | 9 ++++----- libs/remix-lib/src/trace/traceManager.js | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libs/remix-debug/src/debugger/stepManager.js b/libs/remix-debug/src/debugger/stepManager.js index 9abf54a0ca..824bb3c7b1 100644 --- a/libs/remix-debug/src/debugger/stepManager.js +++ b/libs/remix-debug/src/debugger/stepManager.js @@ -41,11 +41,7 @@ class DebuggerStepManager { if (index < 0) return if (this.currentStepIndex !== index) return - this.traceManager.buildCallPath(index, (error, callsPath) => { - if (error) { - console.log(error) - return this.event.trigger('revertWarning', ['']) - } + this.traceManager.buildCallPath(index).then((callsPath) => { this.currentCall = callsPath[callsPath.length - 1] if (this.currentCall.reverted) { let revertedReason = this.currentCall.outofgas ? 'outofgas' : '' @@ -59,6 +55,9 @@ class DebuggerStepManager { this.event.trigger('revertWarning', ['parenthasthrown']) } this.event.trigger('revertWarning', ['']) + }).catch((error) => { + console.log(error) + this.event.trigger('revertWarning', ['']) }) }) } diff --git a/libs/remix-lib/src/trace/traceManager.js b/libs/remix-lib/src/trace/traceManager.js index 109b3b4ddf..09c186c644 100644 --- a/libs/remix-lib/src/trace/traceManager.js +++ b/libs/remix-lib/src/trace/traceManager.js @@ -101,15 +101,15 @@ TraceManager.prototype.getCallDataAt = function (stepIndex) { return [this.traceCache.callsData[callDataChange]] } -TraceManager.prototype.buildCallPath = function (stepIndex, callback) { +TraceManager.prototype.buildCallPath = function (stepIndex) { try { this.checkRequestedStep(stepIndex) } catch (check) { - return callback(check, null) + throw new Error(check) } const callsPath = util.buildCallPath(stepIndex, this.traceCache.callsTree.call) - if (callsPath === null) return callback('no call path built', null) - callback(null, callsPath) + if (callsPath === null) throw new Error('no call path built') + return callsPath } TraceManager.prototype.getCallStackAt = function (stepIndex) {