From 683fa629368f078eae3d83c03e6ded87eb37fc32 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 4 Oct 2018 16:18:22 -0400 Subject: [PATCH] move getTx to debugger logic --- src/app/debugger/debugger/debugger.js | 30 ++++++++++++++++++- src/app/debugger/debuggerUI.js | 42 ++++----------------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/app/debugger/debugger/debugger.js b/src/app/debugger/debugger/debugger.js index 1000e719b5..3a40a4bad8 100644 --- a/src/app/debugger/debugger/debugger.js +++ b/src/app/debugger/debugger/debugger.js @@ -2,6 +2,7 @@ var Ethdebugger = require('remix-debug').EthDebugger var remixLib = require('remix-lib') var EventManager = remixLib.EventManager +var traceHelper = remixLib.helpers.trace var StepManager = require('./stepManager') var VmDebuggerLogic = require('./VmDebugger') @@ -76,7 +77,34 @@ Debugger.prototype.registerAndHighlightCodeItem = function (index) { }) } -Debugger.prototype.debug = function (tx, loadingCb) { +Debugger.prototype.debug = function (blockNumber, txNumber, tx, loadingCb) { + const self = this + let web3 = this.executionContext.web3() + + if (tx) { + if (!tx.to) { + tx.to = traceHelper.contractCreationToken('0') + } + return self.debugTx(tx, loadingCb) + } + + try { + if (txNumber.indexOf('0x') !== -1) { + return web3.eth.getTransaction(txNumber, function (_error, result) { + let tx = result + self.debugTx(tx, loadingCb) + }) + } + web3.eth.getTransactionFromBlock(blockNumber, txNumber, function (_error, result) { + let tx = result + self.debugTx(tx, loadingCb) + }) + } catch (e) { + console.error(e.message) + } +} + +Debugger.prototype.debugTx = function (tx, loadingCb) { const self = this this.step_manager = new StepManager(this.debugger, this.debugger.traceManager) diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index c3b7ace5ed..2314d2e511 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -8,7 +8,6 @@ var SourceHighlighter = require('../editor/sourceHighlighter') var remixLib = require('remix-lib') var EventManager = remixLib.EventManager -var traceHelper = remixLib.helpers.trace var executionContext = require('../../execution-context') var globalRegistry = require('../../global/registry') @@ -98,7 +97,7 @@ class DebuggerUI { txBrowser.event.register('requestDebug', function (blockNumber, txNumber, tx) { self.debugger.unLoad() self.unLoad() - self.getTxAndDebug(blockNumber, txNumber, tx) + self.startDebugging(blockNumber, txNumber, tx) }) txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) { @@ -111,35 +110,6 @@ class DebuggerUI { return this.isActive } - getTxAndDebug (blockNumber, txNumber, tx) { - const self = this - let web3 = executionContext.web3() - - if (tx) { - if (!tx.to) { - tx.to = traceHelper.contractCreationToken('0') - } - return self.startDebugging(blockNumber, txNumber, tx) - } - - try { - if (txNumber.indexOf('0x') !== -1) { - return web3.eth.getTransaction(txNumber, function (error, result) { - let tx = result - self.txBrowser.update(error, result) - self.startDebugging(blockNumber, txNumber, tx) - }) - } - web3.eth.getTransactionFromBlock(blockNumber, txNumber, function (error, result) { - let tx = result - self.txBrowser.update(error, result) - self.startDebugging(blockNumber, txNumber, tx) - }) - } catch (e) { - console.error(e.message) - } - } - startDebugging (blockNumber, txNumber, tx) { const self = this @@ -147,10 +117,10 @@ class DebuggerUI { return } - this.transactionDebugger.debug(tx, () => { + this.transactionDebugger.debug(blockNumber, txNumber, tx, () => { self.stepManager = new StepManagerUI(this.transactionDebugger.step_manager) self.vmDebugger = new VmDebugger(this.transactionDebugger.vmDebuggerLogic) - self.andAddVmDebugger() + self.renderDebugger() }) } @@ -165,10 +135,10 @@ class DebuggerUI { if (tx instanceof Object) { self.txBrowser.load(tx.hash, tx) - self.getTxAndDebug(null, tx.hash, tx) + self.startDebugging(null, tx.hash, tx) } else if (tx instanceof String) { self.txBrowser.load(tx) - self.getTxAndDebug(null, tx) + self.startDebugging(null, tx) } }) } @@ -204,7 +174,7 @@ class DebuggerUI { this.event.trigger('traceUnloaded') } - andAddVmDebugger () { + renderDebugger () { yo.update(this.debuggerHeadPanelsView, this.vmDebugger.renderHead()) yo.update(this.debuggerPanelsView, this.vmDebugger.render()) yo.update(this.stepManagerView, this.stepManager.render())