From a9ebd08714ccba522a8efde45947ef5c615b441d Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 16 May 2019 15:09:52 +0200 Subject: [PATCH] Update TxBrowser --- src/app/debugger/debuggerUI.js | 3 +- src/app/debugger/debuggerUI/TxBrowser.js | 57 ++++++++++++------------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 30f69c8f1d..425115eff0 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -128,10 +128,10 @@ class DebuggerUI { }) this.listenToEvents() - this.debugger.debug(blockNumber, txNumber, tx, () => { self.stepManager = new StepManagerUI(this.debugger.step_manager) self.vmDebugger = new VmDebugger(this.debugger.vmDebuggerLogic) + self.txBrowser.setState({ blockNumber, txNumber, debugging: true }) self.renderDebugger() }) }) @@ -167,6 +167,7 @@ class DebuggerUI { yo.update(this.stepManagerView, yo`
`) if (this.vmDebugger) this.vmDebugger.remove() if (this.stepManager) this.stepManager.remove() + if (this.txBrowser) this.txBrowser.setState({debugging: false}) this.vmDebugger = null this.stepManager = null this.event.trigger('traceUnloaded') diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index 6659a466f1..3d6430b1dc 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -43,32 +43,16 @@ function TxBrowser () { this.blockNumber this.txNumber this.view - this.setDefaultValues() + this.debugging = false } -TxBrowser.prototype.setDefaultValues = function () { - this.connectInfo = '' - if (this.view) { - yo.update(this.view, this.render()) - } -} - -TxBrowser.prototype.submit = function (tx) { - this.event.trigger('requestDebug', [this.blockNumber, this.txNumber, tx]) -} - -TxBrowser.prototype.update = function (error, tx) { - if (error) { - this.view.querySelector('#error').innerHTML = error - return +TxBrowser.prototype.submit = function () { + if (this.debugging) { + this.unload() + } else { + this.event.trigger('requestDebug', [this.blockNumber, this.txNumber]) } - - if (!tx) { - this.view.querySelector('#error').innerHTML = 'Cannot find transaction with reference. Block number: ' + this.blockNumber + '. Transaction index/hash: ' + this.txNumber - return - } - - this.view.querySelector('#error').innerHTML = '' + yo.update(this.view, this.render()) } TxBrowser.prototype.updateBlockN = function (ev) { @@ -83,9 +67,25 @@ TxBrowser.prototype.load = function (txHash, tx) { this.txNumber = txHash } -TxBrowser.prototype.unload = function (txHash) { +TxBrowser.prototype.unload = function () { this.event.trigger('unloadRequested') - this.setDefaultValues() +} + +TxBrowser.prototype.setState = function (state) { + if (state.debugging !== undefined) this.debugging = state.debugging + if (state.blockNumber !== undefined) this.blockNumber = state.blockNumber + if (state.txNumber !== undefined) this.txNumber = state.txNumber + if (this.view) { + yo.update(this.view, this.render()) + } +} + +TxBrowser.prototype.setTx = function (blockNumber, txNumber) { + this.blockNumber = blockNumber + this.txNumber = txNumber + if (this.view) { + yo.update(this.view, this.render()) + } } TxBrowser.prototype.render = function () { @@ -93,12 +93,11 @@ TxBrowser.prototype.render = function () { var view = yo`
- - + +
- - +