diff --git a/src/ASMCode.js b/src/ASMCode.js index 496b505675..4e774d2fc3 100644 --- a/src/ASMCode.js +++ b/src/ASMCode.js @@ -1,5 +1,5 @@ 'use strict' -var style = require('./basicStyles') +var style = require('./styles/basicStyles') var yo = require('yo-yo') var CodeManager = require('./code/codeManager') var ui = require('./helpers/ui') @@ -17,8 +17,8 @@ function ASMCode (_parent, _traceManager, _web3) { ASMCode.prototype.render = function () { var view = ( yo`` + ${this.codeView} + ` ) if (!this.view) { this.view = view diff --git a/src/BasicPanel.js b/src/BasicPanel.js index 4e5bddf72e..9d0a1e60f4 100644 --- a/src/BasicPanel.js +++ b/src/BasicPanel.js @@ -1,5 +1,5 @@ 'use strict' -var style = require('./basicStyles') +var style = require('./styles/basicStyles') var yo = require('yo-yo') var ui = require('./helpers/ui') diff --git a/src/ButtonNavigator.js b/src/ButtonNavigator.js index a4340ec8a8..2498247ae7 100644 --- a/src/ButtonNavigator.js +++ b/src/ButtonNavigator.js @@ -49,7 +49,7 @@ ButtonNavigator.prototype.stepChanged = function (step) { if (!this.traceManager) { this.intoForwardDisabled = true this.overForwardDisabled = true - this.NextCallDisabled = true + this.nextCallDisabled = true } else { var self = this this.traceManager.getLength(function (error, length) { @@ -58,7 +58,7 @@ ButtonNavigator.prototype.stepChanged = function (step) { self.overBackDisabled = true self.intoForwardDisabled = true self.overForwardDisabled = true - self.NextcallDisabled = true + self.nextCallDisabled = true console.log(error) } else { self.intoForwardDisabled = step >= length - 1 diff --git a/src/Ethdebugger.js b/src/Ethdebugger.js index 14b8fc9c1d..b9b730654d 100644 --- a/src/Ethdebugger.js +++ b/src/Ethdebugger.js @@ -3,7 +3,8 @@ var TxBrowser = require('./TxBrowser') var StepManager = require('./StepManager') var TraceManager = require('./trace/traceManager') var VmDebugger = require('./VmDebugger') -var style = require('./basicStyles') +var Sticker = require('./Sticker') +var style = require('./styles/basicStyles') var util = require('./helpers/global') var EventManager = require('./lib/eventManager') var yo = require('yo-yo') @@ -31,14 +32,20 @@ function Ethdebugger () { self.stepChanged(stepIndex) }) this.vmDebugger = new VmDebugger(this, this.traceManager, this.web3) + this.sticker = new Sticker(this, this.traceManager, this.web3) } Ethdebugger.prototype.render = function () { return ( yo`
-

Eth Debugger

- ${this.txBrowser.render()} - ${this.stepManager.render()} +

VM Debugger

+
+ ${this.txBrowser.render()} + ${this.stepManager.render()} +
+
+ ${this.sticker.render()} +
${this.vmDebugger.render()}
` ) @@ -46,7 +53,7 @@ Ethdebugger.prototype.render = function () { Ethdebugger.prototype.unLoad = function () { this.traceManager.init() - this.stepManager.init() + this.stepManager.reset() this.trigger('traceUnloaded') } diff --git a/src/Slider.js b/src/Slider.js index f6af04162b..2824d09822 100644 --- a/src/Slider.js +++ b/src/Slider.js @@ -1,5 +1,5 @@ 'use strict' -var style = require('./sliderStyles') +var style = require('./styles/sliderStyles') var util = require('./helpers/global') var EventManager = require('./lib/eventManager') var yo = require('yo-yo') @@ -33,18 +33,11 @@ Slider.prototype.render = function () { return view } -Slider.prototype.init = function () { - var self = this - this.traceManager.getLength(function (error, length) { - if (error) { - console.log(error) - } else { - self.max = length - self.disabled = length === 0 - yo.update(self.view, self.render()) - self.setValue(0) - } - }) +Slider.prototype.init = function (length) { + this.max = length + this.disabled = length === 0 + yo.update(this.view, this.render()) + this.setValue(0) } Slider.prototype.onMouseUp = function (event) { diff --git a/src/StepManager.js b/src/StepManager.js index 9564662ead..7f847fdb72 100644 --- a/src/StepManager.js +++ b/src/StepManager.js @@ -1,7 +1,7 @@ 'use strict' var ButtonNavigator = require('./ButtonNavigator') var Slider = require('./Slider') -var style = require('./basicStyles') +var style = require('./styles/basicStyles') var util = require('./helpers/global') var EventManager = require('./lib/eventManager') var yo = require('yo-yo') @@ -14,10 +14,13 @@ function StepManager (_parent, _traceManager) { var self = this this.parent.register('newTraceLoaded', this, function () { - self.traceManager.getLength(function (length) { - self.slider.max = length - self.slider.init() - self.init() + self.traceManager.getLength(function (error, length) { + if (error) { + console.log(error) + } else { + self.slider.init(length) + self.init() + } }) }) @@ -53,6 +56,12 @@ StepManager.prototype.render = function () { ) } +StepManager.prototype.reset = function () { + this.slider.setValue(0) + this.currentStepIndex = 0 + this.buttonNavigator.stepChanged(0) +} + StepManager.prototype.init = function () { this.slider.setValue(0) this.changeState(0) diff --git a/src/Sticker.js b/src/Sticker.js index 4ac2d61aa9..2d44b41de8 100644 --- a/src/Sticker.js +++ b/src/Sticker.js @@ -5,23 +5,25 @@ function Sticker (_parent, _traceManager) { this.parent = _parent this.traceManager = _traceManager - this.vmTraceStep - this.step - this.addmemory - this.gas - this.remainingGas + this.vmTraceStep = '-' + this.step = '-' + this.addmemory = '-' + this.gas = '-' + this.remainingGas = '-' + this.loadedAddress = '-' + this.hide = true this.view this.init() } Sticker.prototype.render = function () { - var view = yo`
+ var view = yo`
+ + + +
- vmtracestep + VMtracestep: ${this.vmTraceStep} @@ -29,7 +31,7 @@ Sticker.prototype.render = function () {
- step + Step: ${this.step} @@ -37,7 +39,7 @@ Sticker.prototype.render = function () {
- add memory + Add memory: ${this.addmemory} @@ -45,7 +47,7 @@ Sticker.prototype.render = function () {
- gas + Gas: ${this.gas} @@ -53,12 +55,20 @@ Sticker.prototype.render = function () {
- remaining gas + Remaining gas: ${this.remainingGas}
+ Loaded address: + + ${this.loadedAddress} +
` @@ -70,6 +80,16 @@ Sticker.prototype.render = function () { Sticker.prototype.init = function () { var self = this + this.parent.register('traceUnloaded', this, function () { + self.hide = true + yo.update(self.view, self.render()) + }) + + this.parent.register('newTraceLoaded', this, function () { + self.hide = false + yo.update(self.view, self.render()) + }) + this.parent.register('indexChanged', this, function (index) { if (index < 0) return @@ -78,7 +98,7 @@ Sticker.prototype.init = function () { self.traceManager.getCurrentStep(index, function (error, step) { if (error) { console.log(error) - self.step = '' + self.step = '-' } else { self.step = step } @@ -88,7 +108,7 @@ Sticker.prototype.init = function () { self.traceManager.getMemExpand(index, function (error, addmem) { if (error) { console.log(error) - self.addmemory = '' + self.addmemory = '-' } else { self.addmemory = addmem } @@ -98,17 +118,27 @@ Sticker.prototype.init = function () { self.traceManager.getStepCost(index, function (error, gas) { if (error) { console.log(error) - self.gas = gas + self.gas = '-' } else { self.gas = gas } yo.update(self.view, self.render()) }) + self.traceManager.getCurrentCalledAddressAt(index, function (error, address) { + if (error) { + console.log(error) + self.loadedAddress = '-' + } else { + self.loadedAddress = address + } + yo.update(self.view, self.render()) + }) + self.traceManager.getRemainingGas(index, function (error, remaingas) { if (error) { console.log(error) - self.remainingGas = '' + self.remainingGas = '-' } else { self.remainingGas = remaingas } diff --git a/src/TxBrowser.js b/src/TxBrowser.js index 523f638105..127e1ff231 100644 --- a/src/TxBrowser.js +++ b/src/TxBrowser.js @@ -1,4 +1,4 @@ -var style = require('./basicStyles') +var style = require('./styles/basicStyles') var util = require('./helpers/global') var EventManager = require('./lib/eventManager') var traceHelper = require('./helpers/traceHelper') @@ -10,13 +10,14 @@ function TxBrowser (_web3) { this.web3 = _web3 this.blockNumber - this.txNumber = '0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4' + this.txNumber this.hash this.from this.to this.view -} + this.setDefaultValues() +} // 0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff // creation 0xa9619e1d0a35b2c1d686f5b661b3abd87f998d2844e8e9cc905edb57fc9ce349 @@ -25,6 +26,14 @@ function TxBrowser (_web3) { // creation: 0x72908de76f99fca476f9e3a3b5d352f350a98cd77d09cebfc59ffe32a6ecaa0b // invokation: 0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51 +TxBrowser.prototype.setDefaultValues = function () { + this.from = ' - ' + this.to = ' - ' + this.hash = ' - ' + this.blockNumber = null + this.txNumber = '0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4' +} + TxBrowser.prototype.submit = function () { if (!this.txNumber) { return @@ -47,11 +56,15 @@ TxBrowser.prototype.submit = function () { this.from = tx.from this.to = tx.to this.hash = tx.hash - yo.update(this.view, this.render()) this.trigger('newTxRequested', [this.blockNumber, this.txNumber, tx]) } else { + var mes = '' + this.from = mes + this.to = mes + this.hash = mes console.log('cannot find ' + this.blockNumber + ' ' + this.txNumber) } + yo.update(this.view, this.render()) } TxBrowser.prototype.updateBlockN = function (ev) { @@ -62,6 +75,11 @@ TxBrowser.prototype.updateTxN = function (ev) { this.txNumber = ev.target.value } +TxBrowser.prototype.init = function (ev) { + this.setDefaultValues() + yo.update(this.view, this.render()) +} + TxBrowser.prototype.render = function () { var self = this var view = yo`
diff --git a/src/VmDebugger.js b/src/VmDebugger.js index 4c7beab263..f0ad431c48 100644 --- a/src/VmDebugger.js +++ b/src/VmDebugger.js @@ -1,6 +1,5 @@ 'use strict' -var Sticker = require('./Sticker') -var style = require('./basicStyles') +var style = require('./styles/basicStyles') var ASMCode = require('./ASMCode') var CalldataPanel = require('./CalldataPanel') var MemoryPanel = require('./MemoryPanel') @@ -11,7 +10,6 @@ var yo = require('yo-yo') var ui = require('./helpers/ui') function VmDebugger (_parent, _traceManager, _web3) { - this.sticker = new Sticker(_parent, _traceManager, _web3) this.asmCode = new ASMCode(_parent, _traceManager, _web3) this.stackPanel = new StackPanel(_parent, _traceManager) this.storagePanel = new StoragePanel(_parent, _traceManager) @@ -35,10 +33,8 @@ VmDebugger.prototype.render = function () { + ${this.asmCode.render()} -
- ${this.sticker.render()} -
${this.stackPanel.render()} diff --git a/src/basicStyles.js b/src/styles/basicStyles.js similarity index 94% rename from src/basicStyles.js rename to src/styles/basicStyles.js index eb15ecbf2a..4cb06a09cf 100644 --- a/src/basicStyles.js +++ b/src/styles/basicStyles.js @@ -11,8 +11,8 @@ module.exports = { 'font-style': 'italic' }, instructionsList: { - 'width': '320px', - 'height': '300px' + 'width': '600px', + 'height': '330px' }, transactionInfo: { 'margin-top': '5px' diff --git a/src/sliderStyles.js b/src/styles/sliderStyles.js similarity index 100% rename from src/sliderStyles.js rename to src/styles/sliderStyles.js