move getTx to debugger logic

pull/1/head
Iuri Matias 6 years ago committed by yann300
parent 143ffa6c57
commit 683fa62936
  1. 30
      src/app/debugger/debugger/debugger.js
  2. 42
      src/app/debugger/debuggerUI.js

@ -2,6 +2,7 @@
var Ethdebugger = require('remix-debug').EthDebugger var Ethdebugger = require('remix-debug').EthDebugger
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
var traceHelper = remixLib.helpers.trace
var StepManager = require('./stepManager') var StepManager = require('./stepManager')
var VmDebuggerLogic = require('./VmDebugger') 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 const self = this
this.step_manager = new StepManager(this.debugger, this.debugger.traceManager) this.step_manager = new StepManager(this.debugger, this.debugger.traceManager)

@ -8,7 +8,6 @@ var SourceHighlighter = require('../editor/sourceHighlighter')
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
var traceHelper = remixLib.helpers.trace
var executionContext = require('../../execution-context') var executionContext = require('../../execution-context')
var globalRegistry = require('../../global/registry') var globalRegistry = require('../../global/registry')
@ -98,7 +97,7 @@ class DebuggerUI {
txBrowser.event.register('requestDebug', function (blockNumber, txNumber, tx) { txBrowser.event.register('requestDebug', function (blockNumber, txNumber, tx) {
self.debugger.unLoad() self.debugger.unLoad()
self.unLoad() self.unLoad()
self.getTxAndDebug(blockNumber, txNumber, tx) self.startDebugging(blockNumber, txNumber, tx)
}) })
txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) { txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) {
@ -111,35 +110,6 @@ class DebuggerUI {
return this.isActive 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) { startDebugging (blockNumber, txNumber, tx) {
const self = this const self = this
@ -147,10 +117,10 @@ class DebuggerUI {
return return
} }
this.transactionDebugger.debug(tx, () => { this.transactionDebugger.debug(blockNumber, txNumber, tx, () => {
self.stepManager = new StepManagerUI(this.transactionDebugger.step_manager) self.stepManager = new StepManagerUI(this.transactionDebugger.step_manager)
self.vmDebugger = new VmDebugger(this.transactionDebugger.vmDebuggerLogic) self.vmDebugger = new VmDebugger(this.transactionDebugger.vmDebuggerLogic)
self.andAddVmDebugger() self.renderDebugger()
}) })
} }
@ -165,10 +135,10 @@ class DebuggerUI {
if (tx instanceof Object) { if (tx instanceof Object) {
self.txBrowser.load(tx.hash, tx) self.txBrowser.load(tx.hash, tx)
self.getTxAndDebug(null, tx.hash, tx) self.startDebugging(null, tx.hash, tx)
} else if (tx instanceof String) { } else if (tx instanceof String) {
self.txBrowser.load(tx) self.txBrowser.load(tx)
self.getTxAndDebug(null, tx) self.startDebugging(null, tx)
} }
}) })
} }
@ -204,7 +174,7 @@ class DebuggerUI {
this.event.trigger('traceUnloaded') this.event.trigger('traceUnloaded')
} }
andAddVmDebugger () { renderDebugger () {
yo.update(this.debuggerHeadPanelsView, this.vmDebugger.renderHead()) yo.update(this.debuggerHeadPanelsView, this.vmDebugger.renderHead())
yo.update(this.debuggerPanelsView, this.vmDebugger.render()) yo.update(this.debuggerPanelsView, this.vmDebugger.render())
yo.update(this.stepManagerView, this.stepManager.render()) yo.update(this.stepManagerView, this.stepManager.render())

Loading…
Cancel
Save