gui changes

pull/7/head
yann300 8 years ago
parent 037d201605
commit 9d03238bd1
  1. 1
      package.json
  2. 78
      src/code/opcodes.js
  3. 4
      src/helpers/traceHelper.js
  4. 8
      src/helpers/ui.js
  5. 2
      src/trace/traceAnalyser.js
  6. 4
      src/trace/traceManager.js
  7. 55
      src/ui/ASMCode.js
  8. 12
      src/ui/ButtonNavigator.js
  9. 16
      src/ui/CalldataPanel.js
  10. 16
      src/ui/CallstackPanel.js
  11. 78
      src/ui/DropdownPanel.js
  12. 10
      src/ui/Ethdebugger.js
  13. 24
      src/ui/FullStoragesChanges.js
  14. 65
      src/ui/ListView.js
  15. 6
      src/ui/MemoryPanel.js
  16. 10
      src/ui/StackPanel.js
  17. 105
      src/ui/StepDetail.js
  18. 4
      src/ui/StepManager.js
  19. 150
      src/ui/Sticker.js
  20. 16
      src/ui/StoragePanel.js
  21. 74
      src/ui/TxBrowser.js
  22. 60
      src/ui/VmDebugger.js
  23. BIN
      src/ui/img/play-arrow.png
  24. 36
      src/ui/styles/basicStyles.js
  25. 28
      src/ui/styles/dropdownPanel.js

@ -18,6 +18,7 @@
}, },
"devDependencies": { "devDependencies": {
"browserify": "^13.0.1", "browserify": "^13.0.1",
"clipboard": "^1.5.12",
"ethereumjs-util": "^4.5.0", "ethereumjs-util": "^4.5.0",
"http-server": "^0.9.0", "http-server": "^0.9.0",
"nightwatch": "^0.9.5", "nightwatch": "^0.9.5",

@ -102,45 +102,45 @@ var codes = {
0x7e: ['PUSH', 3, 0, 1, false], 0x7e: ['PUSH', 3, 0, 1, false],
0x7f: ['PUSH', 3, 0, 1, false], 0x7f: ['PUSH', 3, 0, 1, false],
0x80: ['DUP', 3, 0, 1, false], 0x80: ['DUP1', 3, 0, 1, false],
0x81: ['DUP', 3, 0, 1, false], 0x81: ['DUP2', 3, 0, 1, false],
0x82: ['DUP', 3, 0, 1, false], 0x82: ['DUP3', 3, 0, 1, false],
0x83: ['DUP', 3, 0, 1, false], 0x83: ['DUP4', 3, 0, 1, false],
0x84: ['DUP', 3, 0, 1, false], 0x84: ['DUP5', 3, 0, 1, false],
0x85: ['DUP', 3, 0, 1, false], 0x85: ['DUP6', 3, 0, 1, false],
0x86: ['DUP', 3, 0, 1, false], 0x86: ['DUP7', 3, 0, 1, false],
0x87: ['DUP', 3, 0, 1, false], 0x87: ['DUP8', 3, 0, 1, false],
0x88: ['DUP', 3, 0, 1, false], 0x88: ['DUP9', 3, 0, 1, false],
0x89: ['DUP', 3, 0, 1, false], 0x89: ['DUP10', 3, 0, 1, false],
0x8a: ['DUP', 3, 0, 1, false], 0x8a: ['DUP11', 3, 0, 1, false],
0x8b: ['DUP', 3, 0, 1, false], 0x8b: ['DUP12', 3, 0, 1, false],
0x8c: ['DUP', 3, 0, 1, false], 0x8c: ['DUP13', 3, 0, 1, false],
0x8d: ['DUP', 3, 0, 1, false], 0x8d: ['DUP14', 3, 0, 1, false],
0x8e: ['DUP', 3, 0, 1, false], 0x8e: ['DUP15', 3, 0, 1, false],
0x8f: ['DUP', 3, 0, 1, false], 0x8f: ['DUP16', 3, 0, 1, false],
0x90: ['SWAP', 3, 0, 0, false], 0x90: ['SWAP1', 3, 0, 0, false],
0x91: ['SWAP', 3, 0, 0, false], 0x91: ['SWAP2', 3, 0, 0, false],
0x92: ['SWAP', 3, 0, 0, false], 0x92: ['SWAP3', 3, 0, 0, false],
0x93: ['SWAP', 3, 0, 0, false], 0x93: ['SWAP4', 3, 0, 0, false],
0x94: ['SWAP', 3, 0, 0, false], 0x94: ['SWAP5', 3, 0, 0, false],
0x95: ['SWAP', 3, 0, 0, false], 0x95: ['SWAP6', 3, 0, 0, false],
0x96: ['SWAP', 3, 0, 0, false], 0x96: ['SWAP7', 3, 0, 0, false],
0x97: ['SWAP', 3, 0, 0, false], 0x97: ['SWAP8', 3, 0, 0, false],
0x98: ['SWAP', 3, 0, 0, false], 0x98: ['SWAP9', 3, 0, 0, false],
0x99: ['SWAP', 3, 0, 0, false], 0x99: ['SWAP10', 3, 0, 0, false],
0x9a: ['SWAP', 3, 0, 0, false], 0x9a: ['SWAP11', 3, 0, 0, false],
0x9b: ['SWAP', 3, 0, 0, false], 0x9b: ['SWAP12', 3, 0, 0, false],
0x9c: ['SWAP', 3, 0, 0, false], 0x9c: ['SWAP13', 3, 0, 0, false],
0x9d: ['SWAP', 3, 0, 0, false], 0x9d: ['SWAP14', 3, 0, 0, false],
0x9e: ['SWAP', 3, 0, 0, false], 0x9e: ['SWAP15', 3, 0, 0, false],
0x9f: ['SWAP', 3, 0, 0, false], 0x9f: ['SWAP16', 3, 0, 0, false],
0xa0: ['LOG', 375, 2, 0, false], 0xa0: ['LOG0', 375, 2, 0, false],
0xa1: ['LOG', 375, 3, 0, false], 0xa1: ['LOG1', 375, 3, 0, false],
0xa2: ['LOG', 375, 4, 0, false], 0xa2: ['LOG2', 375, 4, 0, false],
0xa3: ['LOG', 375, 5, 0, false], 0xa3: ['LOG3', 375, 5, 0, false],
0xa4: ['LOG', 375, 6, 0, false], 0xa4: ['LOG4', 375, 6, 0, false],
// '0xf0' range - closures // '0xf0' range - closures
0xf0: ['CREATE', 32000, 3, 1, true], 0xf0: ['CREATE', 32000, 3, 1, true],

@ -25,6 +25,10 @@ module.exports = {
return step.op === 'RETURN' return step.op === 'RETURN'
}, },
isStopInstruction: function (step) {
return step.op === 'STOP'
},
isSSTOREInstruction: function (step) { isSSTOREInstruction: function (step) {
return step.op === 'SSTORE' return step.op === 'SSTORE'
}, },

@ -1,7 +1,7 @@
'use strict' 'use strict'
module.exports = { module.exports = {
formatMemory: function (mem, width) { formatMemory: function (mem, width) {
var ret = '' var ret = {}
if (!mem) { if (!mem) {
return ret return ret
} }
@ -13,7 +13,7 @@ module.exports = {
for (var k = 0; k < mem.length; k += (width * 2)) { for (var k = 0; k < mem.length; k += (width * 2)) {
var memory = mem.substr(k, width * 2) var memory = mem.substr(k, width * 2)
var content = this.tryConvertAsciiFormat(memory) var content = this.tryConvertAsciiFormat(memory)
ret += '0x' + (k / 2).toString(16) + '\t\t' + content.raw + '\t' + content.ascii + '\n' ret['0x' + (k / 2).toString(16)] = content.raw + '\t' + content.ascii
} }
return ret return ret
}, },
@ -51,5 +51,9 @@ module.exports = {
} }
hex = hex.replace(/^0+/, '') hex = hex.replace(/^0+/, '')
return '0x' + hex return '0x' + hex
},
runInBrowser: function () {
return typeof window !== 'undefined'
} }
} }

@ -118,7 +118,7 @@ TraceAnalyser.prototype.buildDepth = function (index, step, tx, callStack, conte
this.traceCache.pushSteps(index, context.currentCallIndex) this.traceCache.pushSteps(index, context.currentCallIndex)
context.lastCallIndex = context.currentCallIndex context.lastCallIndex = context.currentCallIndex
context.currentCallIndex = 0 context.currentCallIndex = 0
} else if (traceHelper.isReturnInstruction(step)) { } else if (traceHelper.isReturnInstruction(step) || traceHelper.isStopInstruction(step)) {
if (index + 1 < this.trace.length) { if (index + 1 < this.trace.length) {
callStack.pop() callStack.pop()
this.traceCache.pushCallChanges(step, index + 1) this.traceCache.pushCallChanges(step, index + 1)

@ -222,7 +222,11 @@ TraceManager.prototype.getReturnValue = function (stepIndex, callback) {
if (check) { if (check) {
return callback(check, null) return callback(check, null)
} }
if (!this.traceCache.returnValues[stepIndex]) {
callback('current step is not a return step')
} else {
callback(null, this.traceCache.returnValues[stepIndex]) callback(null, this.traceCache.returnValues[stepIndex])
}
} }
TraceManager.prototype.getCurrentStep = function (stepIndex, callback) { TraceManager.prototype.getCurrentStep = function (stepIndex, callback) {

@ -1,55 +0,0 @@
'use strict'
var style = require('./styles/basicStyles')
var yo = require('yo-yo')
var ui = require('../helpers/ui')
function ASMCode (_parent, _codeManager) {
this.parent = _parent
this.codeManager = _codeManager
this.code
this.address
this.codeView
this.init()
}
ASMCode.prototype.render = function () {
var view = (
yo`<select size='10' id='asmitems' ref='itemsList' style=${ui.formatCss(style.instructionsList)}>
${this.codeView}
</select>`
)
if (!this.view) {
this.view = view
}
return view
}
ASMCode.prototype.init = function () {
this.codeManager.register('changed', this, this.changed)
}
ASMCode.prototype.indexChanged = function (index) {
document.getElementById('asmitems').value = index
}
ASMCode.prototype.changed = function (code, address, index) {
if (this.address !== address) {
this.code = code
this.address = address
this.renderAssemblyItems()
yo.update(this.view, this.render())
}
this.indexChanged(index)
}
ASMCode.prototype.renderAssemblyItems = function () {
if (this.code) {
this.codeView = this.code.map(function (item, i) {
return yo`<option key=${i} value=${i}>${item}</option>`
})
return this.codeView
}
}
module.exports = ASMCode

@ -1,6 +1,8 @@
'use strict' 'use strict'
var util = require('../helpers/global') var util = require('../helpers/global')
var EventManager = require('../lib/eventManager') var EventManager = require('../lib/eventManager')
var style = require('./styles/basicStyles')
var ui = require('../helpers/ui')
var yo = require('yo-yo') var yo = require('yo-yo')
function ButtonNavigator (_traceManager) { function ButtonNavigator (_traceManager) {
@ -21,19 +23,19 @@ module.exports = ButtonNavigator
ButtonNavigator.prototype.render = function () { ButtonNavigator.prototype.render = function () {
var self = this var self = this
var view = yo`<div> var view = yo`<div>
<button id='overback' onclick=${function () { self.trigger('stepOverBack') }} disabled=${this.overBackDisabled} > <button id='overback' style=${ui.formatCss(style.button)} onclick=${function () { self.trigger('stepOverBack') }} disabled=${this.overBackDisabled} >
Step Over Back Step Over Back
</button> </button>
<button id='intoback' onclick=${function () { self.trigger('stepIntoBack') }} disabled=${this.intoBackDisabled} > <button id='intoback' style=${ui.formatCss(style.button)} onclick=${function () { self.trigger('stepIntoBack') }} disabled=${this.intoBackDisabled} >
Step Into Back Step Into Back
</button> </button>
<button id='intoforward' onclick=${function () { self.trigger('stepIntoForward') }} disabled=${this.intoForwardDisabled} > <button id='intoforward' style=${ui.formatCss(style.button)} onclick=${function () { self.trigger('stepIntoForward') }} disabled=${this.intoForwardDisabled} >
Step Into Forward Step Into Forward
</button> </button>
<button id='overforward' onclick=${function () { self.trigger('stepOverForward') }} disabled=${this.overForwardDisabled} > <button id='overforward' style=${ui.formatCss(style.button)} onclick=${function () { self.trigger('stepOverForward') }} disabled=${this.overForwardDisabled} >
Step Over Forward Step Over Forward
</button> </button>
<button id='nextcall' onclick=${function () { self.trigger('jumpNextCall') }} disabled=${this.nextCallDisabled} > <button id='nextcall' style=${ui.formatCss(style.button)} onclick=${function () { self.trigger('jumpNextCall') }} disabled=${this.nextCallDisabled} >
Jump Next Call Jump Next Call
</button> </button>
</div>` </div>`

@ -1,11 +1,11 @@
'use strict' 'use strict'
var BasicPanel = require('./BasicPanel') var DropdownPanel = require('./DropdownPanel')
var yo = require('yo-yo') var yo = require('yo-yo')
function CalldataPanel (_parent, _traceManager) { function CalldataPanel (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new BasicPanel('Call Data') this.basicPanel = new DropdownPanel('Call Data')
this.init() this.init()
} }
@ -21,22 +21,14 @@ CalldataPanel.prototype.init = function () {
self.traceManager.getCallDataAt(index, function (error, calldata) { self.traceManager.getCallDataAt(index, function (error, calldata) {
if (error) { if (error) {
self.basicPanel.data = '' self.basicPanel.data = {}
console.log(error) console.log(error)
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = self.format(calldata) self.basicPanel.data = calldata
} }
self.basicPanel.update() self.basicPanel.update()
}) })
}) })
} }
CalldataPanel.prototype.format = function (calldata) {
var ret = ''
for (var key in calldata) {
ret += calldata[key] + '\n'
}
return ret
}
module.exports = CalldataPanel module.exports = CalldataPanel

@ -1,11 +1,11 @@
'use strict' 'use strict'
var BasicPanel = require('./BasicPanel') var DropdownPanel = require('./DropdownPanel')
var yo = require('yo-yo') var yo = require('yo-yo')
function CallstackPanel (_parent, _traceManager) { function CallstackPanel (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new BasicPanel('Call Stack') this.basicPanel = new DropdownPanel('Call Stack')
this.init() this.init()
} }
@ -22,21 +22,13 @@ CallstackPanel.prototype.init = function () {
self.traceManager.getCallStackAt(index, function (error, callstack) { self.traceManager.getCallStackAt(index, function (error, callstack) {
if (error) { if (error) {
console.log(error) console.log(error)
self.basicPanel.data = '' self.basicPanel.data = {}
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = self.format(callstack) self.basicPanel.data = callstack
} }
self.basicPanel.update() self.basicPanel.update()
}) })
}) })
} }
CallstackPanel.prototype.format = function (callstack) {
var ret = ''
for (var key in callstack) {
ret += callstack[key] + '\n'
}
return ret
}
module.exports = CallstackPanel module.exports = CallstackPanel

@ -0,0 +1,78 @@
'use strict'
var yo = require('yo-yo')
var ui = require('../helpers/ui')
var styleDropdown = require('./styles/dropdownPanel')
var style = require('./styles/basicStyles')
var basicStyles = require('./styles/basicStyles')
var Clipboard
if (ui.runInBrowser()) {
Clipboard = require('clipboard')
}
function DropdownPanel (_name, _raw) {
this.data
this.name = _name
this.view
this.clipboard
_raw = _raw === undefined ? false : _raw
this.raw = _raw
}
DropdownPanel.prototype.update = function () {
this.view.querySelector('.dropdownpanel div').innerHTML = ''
if (!this.raw) {
var data = JSON.stringify(this.data, null, '\t')
if (!this.data || data === '[]' || data === '{}') {
this.data = ['Empty']
}
var div = document.createElement('div')
if (Array.isArray(this.data)) {
this.data.map(function (item, i) {
div.appendChild(yo`<div><span>${item}</span></div>`)
})
} else {
for (var k in this.data) {
div.appendChild(yo`<div><div style=${ui.formatCss(basicStyles.truncate, {display: 'inline-block', 'width': '100px'})} >${k}</div><div style=${ui.formatCss(basicStyles.truncate, {display: 'inline-block', 'width': '355px'})} >${this.data[k]}</div></div>`)
}
}
this.view.querySelector('.dropdownpanel div').appendChild(div)
this.view.querySelector('.btn').setAttribute('data-clipboard-text', data)
if (Clipboard && !this.clipboard) {
this.clipboard = new Clipboard(this.view.querySelector('.btn'))
}
} else {
this.view.querySelector('.dropdownpanel div').appendChild(this.data)
this.view.querySelector('.btn').style.display = 'none'
}
}
DropdownPanel.prototype.render = function (overridestyle) {
overridestyle === undefined ? {} : overridestyle
var self = this
var view = yo`<div>
<div style=${ui.formatCss(styleDropdown.title)}>
<div onclick=${function () { self.toggle() }} style=${ui.formatCss(styleDropdown.inner, styleDropdown.titleInner)}>${this.name}</div>
</div>
<div class='dropdownpanel' style=${ui.formatCss(styleDropdown.content)} style='display:none'>
<button style=${ui.formatCss(style.button, styleDropdown.copyBtn)} class="btn" type="button">
Copy to clipboard
</button>
<div style=${ui.formatCss(styleDropdown.inner, overridestyle)}><span>Empty</span></div>
</div>
</div>`
if (!this.view) {
this.view = view
}
return view
}
DropdownPanel.prototype.toggle = function () {
var el = this.view.querySelector('.dropdownpanel')
if (el.style.display === '') {
el.style.display = 'none'
} else {
el.style.display = ''
}
}
module.exports = DropdownPanel

@ -3,7 +3,6 @@ var TxBrowser = require('./TxBrowser')
var StepManager = require('./StepManager') var StepManager = require('./StepManager')
var TraceManager = require('../trace/traceManager') var TraceManager = require('../trace/traceManager')
var VmDebugger = require('./VmDebugger') var VmDebugger = require('./VmDebugger')
var Sticker = require('./Sticker')
var style = require('./styles/basicStyles') var style = require('./styles/basicStyles')
var util = require('../helpers/global') var util = require('../helpers/global')
var EventManager = require('../lib/eventManager') var EventManager = require('../lib/eventManager')
@ -49,7 +48,6 @@ function Ethdebugger () {
self.stepChanged(stepIndex) self.stepChanged(stepIndex)
}) })
this.vmDebugger = new VmDebugger(this, this.traceManager, this.codeManager) this.vmDebugger = new VmDebugger(this, this.traceManager, this.codeManager)
this.sticker = new Sticker(this, this.traceManager)
} }
Ethdebugger.prototype.web3 = function () { Ethdebugger.prototype.web3 = function () {
@ -83,14 +81,10 @@ Ethdebugger.prototype.debug = function (tx) {
Ethdebugger.prototype.render = function () { Ethdebugger.prototype.render = function () {
var view = yo`<div style=${ui.formatCss(style.font)}> var view = yo`<div style=${ui.formatCss(style.font)}>
<h1 style=${ui.formatCss(style.container)}>VM Debugger</h1> <div style='margin: auto; width: 604px'>
<div style='display:inline-block'>
${this.txBrowser.render()} ${this.txBrowser.render()}
${this.stepManager.render()} ${this.stepManager.render()}
</div> </div>
<div style='display:inline-block'>
${this.sticker.render()}
</div>
<div style=${ui.formatCss(style.statusMessage)} >${this.statusMessage}</div> <div style=${ui.formatCss(style.statusMessage)} >${this.statusMessage}</div>
${this.vmDebugger.render()} ${this.vmDebugger.render()}
</div>` </div>`
@ -121,7 +115,7 @@ Ethdebugger.prototype.startDebugging = function (blockNumber, txIndex, tx) {
this.tx = tx this.tx = tx
var self = this var self = this
this.traceManager.resolveTrace(tx, function (error, result) { this.traceManager.resolveTrace(tx, function (error, result) {
console.log('trace loaded ' + result + ' ' + error) console.log('trace loaded ' + result)
if (result) { if (result) {
self.statusMessage = '' self.statusMessage = ''
yo.update(self.view, self.render()) yo.update(self.view, self.render())

@ -1,5 +1,5 @@
'use strict' 'use strict'
var BasicPanel = require('./BasicPanel') var DropdownPanel = require('./DropdownPanel')
var yo = require('yo-yo') var yo = require('yo-yo')
function FullStoragesChanges (_parent, _traceManager) { function FullStoragesChanges (_parent, _traceManager) {
@ -8,7 +8,7 @@ function FullStoragesChanges (_parent, _traceManager) {
this.addresses = [] this.addresses = []
this.view this.view
this.traceLength this.traceLength
this.basicPanel = new BasicPanel('Full Storages Changes', '1205px', '100px') this.basicPanel = new DropdownPanel('Full Storages Changes')
this.init() this.init()
} }
@ -20,14 +20,6 @@ FullStoragesChanges.prototype.render = function () {
return view return view
} }
FullStoragesChanges.prototype.hide = function () {
this.view.style.display = 'none'
}
FullStoragesChanges.prototype.show = function () {
this.view.style.display = 'block'
}
FullStoragesChanges.prototype.init = function () { FullStoragesChanges.prototype.init = function () {
var self = this var self = this
this.parent.register('newTraceLoaded', this, function (length) { this.parent.register('newTraceLoaded', this, function (length) {
@ -35,9 +27,8 @@ FullStoragesChanges.prototype.init = function () {
self.traceManager.getAddresses(function (error, addresses) { self.traceManager.getAddresses(function (error, addresses) {
if (!error) { if (!error) {
self.addresses = addresses self.addresses = addresses
self.basicPanel.data = '' self.basicPanel.data = {}
yo.update(self.view, self.render()) self.basicPanel.update()
self.hide()
} }
}) })
@ -58,14 +49,11 @@ FullStoragesChanges.prototype.init = function () {
self.traceManager.getStorageAt(index, null, function (error, result) { self.traceManager.getStorageAt(index, null, function (error, result) {
if (!error) { if (!error) {
storageJSON[self.addresses[k]] = result storageJSON[self.addresses[k]] = result
self.basicPanel.data = JSON.stringify(storageJSON, null, '\t') self.basicPanel.data = storageJSON
yo.update(self.view, self.render()) self.basicPanel.update()
self.show()
} }
}, self.addresses[k]) }, self.addresses[k])
} }
} else {
self.hide()
} }
}) })
} }

@ -0,0 +1,65 @@
'use strict'
var style = require('./styles/basicStyles')
var yo = require('yo-yo')
var ui = require('../helpers/ui')
var DropdownPanel = require('./DropdownPanel')
function ListView (_parent, _codeManager) {
this.parent = _parent
this.codeManager = _codeManager
this.code
this.address
this.codeView
this.itemSelected
this.basicPanel = new DropdownPanel('Assembly', true)
this.init()
}
ListView.prototype.render = function () {
return yo`<div id='asmcodes' >${this.basicPanel.render({height: style.instructionsList.height})}</div>`
}
ListView.prototype.init = function () {
var self = this
this.codeManager.register('changed', this, this.changed)
this.parent.register('traceUnloaded', this, function () {
self.changed([], '', -1)
})
}
ListView.prototype.indexChanged = function (index) {
if (index >= 0) {
if (this.itemSelected) {
this.itemSelected.removeAttribute('style')
this.itemSelected.firstChild.removeAttribute('style')
}
this.itemSelected = this.codeView.children[index]
this.itemSelected.setAttribute('style', ui.formatCss({'background-color': '#eeeeee'}))
this.itemSelected.firstChild.setAttribute('style', ui.formatCss({'margin-left': '2px'}))
this.codeView.scrollTop = this.itemSelected.offsetTop - parseInt(this.codeView.style.height.replace('px', ''))
}
}
ListView.prototype.changed = function (code, address, index) {
if (this.address !== address) {
this.code = code
this.address = address
this.codeView = this.renderAssemblyItems()
this.basicPanel.data = this.codeView
this.basicPanel.update()
}
this.indexChanged(index)
}
ListView.prototype.renderAssemblyItems = function () {
if (this.code) {
var codeView = this.code.map(function (item, i) {
return yo`<li key=${i} value=${i}><span>${item}</span></li>`
})
return yo`<ul id='asmitems' ref='itemsList' style=${ui.formatCss(style.instructionsList)}>
${codeView}
</ul>`
}
}
module.exports = ListView

@ -1,12 +1,12 @@
'use strict' 'use strict'
var BasicPanel = require('./BasicPanel') var DropdownPanel = require('./DropdownPanel')
var util = require('../helpers/ui') var util = require('../helpers/ui')
var yo = require('yo-yo') var yo = require('yo-yo')
function MemoryPanel (_parent, _traceManager) { function MemoryPanel (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new BasicPanel('Memory') this.basicPanel = new DropdownPanel('Memory')
this.init() this.init()
} }
@ -23,7 +23,7 @@ MemoryPanel.prototype.init = function () {
self.traceManager.getMemoryAt(index, function (error, memory) { self.traceManager.getMemoryAt(index, function (error, memory) {
if (error) { if (error) {
console.log(error) console.log(error)
self.basicPanel.data = '' self.basicPanel.data = {}
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = util.formatMemory(memory, 16) self.basicPanel.data = util.formatMemory(memory, 16)
} }

@ -1,12 +1,12 @@
'use strict' 'use strict'
var BasicPanel = require('./BasicPanel') var DropdownPanel = require('./DropdownPanel')
var ui = require('../helpers/ui') var ui = require('../helpers/ui')
var yo = require('yo-yo') var yo = require('yo-yo')
function StackPanel (_parent, _traceManager) { function StackPanel (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new BasicPanel('Stack') this.basicPanel = new DropdownPanel('Stack')
this.init() this.init()
} }
@ -22,7 +22,7 @@ StackPanel.prototype.init = function () {
self.traceManager.getStackAt(index, function (error, stack) { self.traceManager.getStackAt(index, function (error, stack) {
if (error) { if (error) {
self.basicPanel.data = '' self.basicPanel.data = {}
console.log(error) console.log(error)
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = self.format(stack) self.basicPanel.data = self.format(stack)
@ -33,10 +33,10 @@ StackPanel.prototype.init = function () {
} }
StackPanel.prototype.format = function (stack) { StackPanel.prototype.format = function (stack) {
var ret = '' var ret = []
for (var key in stack) { for (var key in stack) {
var hex = ui.normalizeHex(stack[key]) var hex = ui.normalizeHex(stack[key])
ret += hex + '\n' ret.push(hex)
} }
return ret return ret
} }

@ -0,0 +1,105 @@
'use strict'
var yo = require('yo-yo')
var DropdownPanel = require('./DropdownPanel')
function StepDetail (_parent, _traceManager) {
this.parent = _parent
this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Step detail')
this.detail = initDetail()
this.view
this.init()
}
StepDetail.prototype.render = function () {
return yo`<div id='sticker' >${this.basicPanel.render()}</div>`
}
StepDetail.prototype.init = function () {
var self = this
this.parent.register('traceUnloaded', this, function () {
self.detail = initDetail()
self.basicPanel.update()
})
this.parent.register('newTraceLoaded', this, function () {
self.detail = initDetail()
self.basicPanel.update()
})
this.parent.register('indexChanged', this, function (index) {
if (index < 0) return
self.detail.vmTraceStep = index
self.traceManager.getCurrentStep(index, function (error, step) {
if (error) {
console.log(error)
self.detail.step = '-'
} else {
self.detail.step = step
}
self.basicPanel.data = self.detail
self.basicPanel.update()
})
self.traceManager.getMemExpand(index, function (error, addmem) {
if (error) {
console.log(error)
self.detail.addmemory = '-'
} else {
self.detail.addmemory = addmem
}
self.basicPanel.data = self.detail
self.basicPanel.update()
})
self.traceManager.getStepCost(index, function (error, gas) {
if (error) {
console.log(error)
self.detail.gas = '-'
} else {
self.detail.gas = gas
}
self.basicPanel.data = self.detail
self.basicPanel.update()
})
self.traceManager.getCurrentCalledAddressAt(index, function (error, address) {
if (error) {
console.log(error)
self.detail.loadedAddress = '-'
} else {
self.detail.loadedAddress = address
}
self.basicPanel.data = self.detail
self.basicPanel.update()
})
self.traceManager.getRemainingGas(index, function (error, remaingas) {
if (error) {
console.log(error)
self.detail.remainingGas = '-'
} else {
self.detail.remainingGas = remaingas
}
self.basicPanel.data = self.detail
self.basicPanel.update()
})
})
}
module.exports = StepDetail
function initDetail () {
return {
vmTraceStep: '-',
step: '-',
addmemory: '',
gas: '',
remainingGas: '-',
loadedAddress: '-'
}
}

@ -1,11 +1,9 @@
'use strict' 'use strict'
var ButtonNavigator = require('./ButtonNavigator') var ButtonNavigator = require('./ButtonNavigator')
var Slider = require('./Slider') var Slider = require('./Slider')
var style = require('./styles/basicStyles')
var util = require('../helpers/global') var util = require('../helpers/global')
var EventManager = require('../lib/eventManager') var EventManager = require('../lib/eventManager')
var yo = require('yo-yo') var yo = require('yo-yo')
var ui = require('../helpers/ui')
function StepManager (_parent, _traceManager) { function StepManager (_parent, _traceManager) {
util.extend(this, new EventManager()) util.extend(this, new EventManager())
@ -49,7 +47,7 @@ function StepManager (_parent, _traceManager) {
StepManager.prototype.render = function () { StepManager.prototype.render = function () {
return ( return (
yo`<div style=${ui.formatCss(style.container)}> yo`<div>
${this.slider.render()} ${this.slider.render()}
${this.buttonNavigator.render()} ${this.buttonNavigator.render()}
</div>` </div>`

@ -1,150 +0,0 @@
'use strict'
var yo = require('yo-yo')
function Sticker (_parent, _traceManager) {
this.parent = _parent
this.traceManager = _traceManager
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`<div style=${this.hide ? 'display: none' : 'display: block'}>
<table>
<tbody>
<tr key='vmtracestep'>
<td>
VMtracestep:
</td>
<td id='vmtracestepinfo' >
${this.vmTraceStep}
</td>
</tr>
<tr key='step'>
<td>
Step:
</td>
<td id='stepinfo'>
${this.step}
</td>
</tr>
<tr key='addmemory'>
<td>
Add memory:
</td>
<td id='addmemoryinfo'>
${this.addmemory}
</td>
</tr>
<tr key='gas'>
<td>
Gas:
</td>
<td id='gasinfo'>
${this.gas}
</td>
</tr>
<tr key='remaininggas'>
<td>
Remaining gas:
</td>
<td id='remaininggasinfo'>
${this.remainingGas}
</td>
</tr>
<tr key='loadedaddress'>
<td>
Loaded address:
</td>
<td id='loadedaddressinfo'>
${this.loadedAddress}
</td>
</tr>
</tbody>
</table>
</div>`
if (!this.view) {
this.view = view
}
return view
}
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
self.vmTraceStep = index
self.traceManager.getCurrentStep(index, function (error, step) {
if (error) {
console.log(error)
self.step = '-'
} else {
self.step = step
}
yo.update(self.view, self.render())
})
self.traceManager.getMemExpand(index, function (error, addmem) {
if (error) {
console.log(error)
self.addmemory = '-'
} else {
self.addmemory = addmem
}
yo.update(self.view, self.render())
})
self.traceManager.getStepCost(index, function (error, gas) {
if (error) {
console.log(error)
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 = '-'
} else {
self.remainingGas = remaingas
}
yo.update(self.view, self.render())
})
})
}
module.exports = Sticker

@ -1,11 +1,11 @@
'use strict' 'use strict'
var BasicPanel = require('./BasicPanel') var DropdownPanel = require('./DropdownPanel')
var yo = require('yo-yo') var yo = require('yo-yo')
function StoragePanel (_parent, _traceManager, _address) { function StoragePanel (_parent, _traceManager, _address) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new BasicPanel('Storage Changes') this.basicPanel = new DropdownPanel('Storage Changes')
this.address = _address this.address = _address
this.init() this.init()
this.disabled = false this.disabled = false
@ -25,21 +25,13 @@ StoragePanel.prototype.init = function () {
self.traceManager.getStorageAt(index, self.parent.tx, function (error, storage) { self.traceManager.getStorageAt(index, self.parent.tx, function (error, storage) {
if (error) { if (error) {
console.log(error) console.log(error)
self.basicPanel.data = self.formatStorage(storage) self.basicPanel.data = {}
} else if (self.parent.currentStepIndex === index) { } else if (self.parent.currentStepIndex === index) {
self.basicPanel.data = self.formatStorage(storage) self.basicPanel.data = storage
} }
self.basicPanel.update() self.basicPanel.update()
}, self.address) }, self.address)
}) })
} }
StoragePanel.prototype.formatStorage = function (storage) {
var ret = ''
for (var key in storage) {
ret += key + ' ' + storage[key] + '\n'
}
return ret
}
module.exports = StoragePanel module.exports = StoragePanel

@ -5,17 +5,17 @@ var traceHelper = require('../helpers/traceHelper')
var yo = require('yo-yo') var yo = require('yo-yo')
var ui = require('../helpers/ui') var ui = require('../helpers/ui')
var init = require('../helpers/init') var init = require('../helpers/init')
var DropdownPanel = require('./DropdownPanel')
function TxBrowser (_parent) { function TxBrowser (_parent) {
util.extend(this, new EventManager()) util.extend(this, new EventManager())
this.blockNumber this.blockNumber
this.txNumber this.txNumber
this.hash
this.from
this.to
this.view this.view
this.displayConnectionSetting = true this.displayConnectionSetting = true
this.basicPanel = new DropdownPanel('Transaction')
this.basicPanel.data = {}
var self = this var self = this
_parent.register('providerChanged', this, function (provider) { _parent.register('providerChanged', this, function (provider) {
self.displayConnectionSetting = provider === 'INTERNAL' self.displayConnectionSetting = provider === 'INTERNAL'
@ -33,12 +33,11 @@ function TxBrowser (_parent) {
// invokation: 0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51 // invokation: 0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51
TxBrowser.prototype.setDefaultValues = function () { TxBrowser.prototype.setDefaultValues = function () {
this.from = ' - '
this.to = ' - '
this.hash = ' - '
this.blockNumber = null this.blockNumber = null
this.txNumber = '' this.txNumber = ''
this.connectInfo = '' this.connectInfo = ''
this.basicPanel.data = {}
this.basicPanel.update()
this.updateWeb3Url(util.web3.currentProvider.host) this.updateWeb3Url(util.web3.currentProvider.host)
} }
@ -57,23 +56,24 @@ TxBrowser.prototype.submit = function () {
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
console.log(JSON.stringify(tx)) var info = {}
if (tx) { if (tx) {
if (!tx.to) { if (!tx.to) {
tx.to = traceHelper.contractCreationToken('0') tx.to = traceHelper.contractCreationToken('0')
} }
this.from = tx.from info.from = tx.from
this.to = tx.to info.to = tx.to
this.hash = tx.hash info.hash = tx.hash
this.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) this.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx])
} else { } else {
var mes = '<not found>' var mes = '<not found>'
this.from = mes info.from = mes
this.to = mes info.to = mes
this.hash = mes info.hash = mes
console.log('cannot find ' + this.blockNumber + ' ' + this.txNumber) console.log('cannot find ' + this.blockNumber + ' ' + this.txNumber)
} }
yo.update(this.view, this.render()) this.basicPanel.data = info
this.basicPanel.update()
} }
TxBrowser.prototype.updateWeb3Url = function (newhost) { TxBrowser.prototype.updateWeb3Url = function (newhost) {
@ -110,13 +110,16 @@ TxBrowser.prototype.updateTxN = function (ev) {
TxBrowser.prototype.load = function (txHash) { TxBrowser.prototype.load = function (txHash) {
this.txNumber = txHash this.txNumber = txHash
yo.update(this.view, this.render())
this.submit() this.submit()
} }
TxBrowser.prototype.unload = function (txHash) {
this.trigger('unloadRequested')
this.init()
}
TxBrowser.prototype.init = function (ev) { TxBrowser.prototype.init = function (ev) {
this.setDefaultValues() this.setDefaultValues()
yo.update(this.view, this.render())
} }
TxBrowser.prototype.connectionSetting = function () { TxBrowser.prototype.connectionSetting = function () {
@ -131,43 +134,16 @@ TxBrowser.prototype.connectionSetting = function () {
TxBrowser.prototype.render = function () { TxBrowser.prototype.render = function () {
var self = this var self = this
var view = yo`<div style=${ui.formatCss(style.container)}> var view = yo`<div>
${this.connectionSetting()} ${this.connectionSetting()}
<input onkeyup=${function () { self.updateBlockN(arguments[0]) }} type='text' placeholder=${'Block number (default 1000110)' + this.blockNumber} /> <input onkeyup=${function () { self.updateBlockN(arguments[0]) }} type='text' placeholder=${'Block number'} style='width: 231px' />
<input id='txinput' onkeyup=${function () { self.updateTxN(arguments[0]) }} type='text' value=${this.txNumber} placeholder=${'Transaction Number or hash (default 2) ' + this.txNumber} /> <input id='txinput' onkeyup=${function () { self.updateTxN(arguments[0]) }} type='text' placeholder=${'Transaction index or hash'} style='width: 266px' />
<button id='load' onclick=${function () { self.submit() }}> <button id='load' onclick=${function () { self.submit() }} style=${ui.formatCss(style.button)}>
Load Load
</button> </button>
<button id='unload' onclick=${function () { self.trigger('unloadRequested') }}>Unload</button> <button id='unload' onclick=${function () { self.unload() }} style=${ui.formatCss(style.button)}>Reset</button>
<div style=${ui.formatCss(style.transactionInfo)}> <div style=${ui.formatCss(style.transactionInfo)}>
<table> ${this.basicPanel.render()}
<tbody>
<tr>
<td>
Hash:
</td>
<td id='txhash' >
${this.hash}
</td>
</tr>
<tr>
<td>
From:
</td>
<td id='txfrom'>
${this.from}
</td>
</tr>
<tr>
<td>
To:
</td>
<td id='txto' >
${this.to}
</td>
</tr>
</tbody>
</table>
</div> </div>
</div>` </div>`
if (!this.view) { if (!this.view) {

@ -1,39 +1,36 @@
'use strict' 'use strict'
var style = require('./styles/basicStyles') var ListView = require('./ListView')
var ASMCode = require('./ASMCode')
var CalldataPanel = require('./CalldataPanel') var CalldataPanel = require('./CalldataPanel')
var MemoryPanel = require('./MemoryPanel') var MemoryPanel = require('./MemoryPanel')
var CallstackPanel = require('./CallstackPanel') var CallstackPanel = require('./CallstackPanel')
var StackPanel = require('./StackPanel') var StackPanel = require('./StackPanel')
var StoragePanel = require('./StoragePanel') var StoragePanel = require('./StoragePanel')
var BasicPanel = require('./BasicPanel')
var FullStoragesChangesPanel = require('./FullStoragesChanges') var FullStoragesChangesPanel = require('./FullStoragesChanges')
var StepDetail = require('./StepDetail')
var DropdownPanel = require('./DropdownPanel')
var yo = require('yo-yo') var yo = require('yo-yo')
var ui = require('../helpers/ui')
function VmDebugger (_parent, _traceManager, _codeManager) { function VmDebugger (_parent, _traceManager, _codeManager) {
this.asmCode = new ASMCode(_parent, _codeManager) this.asmCode = new ListView(_parent, _codeManager)
this.stackPanel = new StackPanel(_parent, _traceManager) this.stackPanel = new StackPanel(_parent, _traceManager)
this.storagePanel = new StoragePanel(_parent, _traceManager) this.storagePanel = new StoragePanel(_parent, _traceManager)
this.memoryPanel = new MemoryPanel(_parent, _traceManager) this.memoryPanel = new MemoryPanel(_parent, _traceManager)
this.calldataPanel = new CalldataPanel(_parent, _traceManager) this.calldataPanel = new CalldataPanel(_parent, _traceManager)
this.callstackPanel = new CallstackPanel(_parent, _traceManager) this.callstackPanel = new CallstackPanel(_parent, _traceManager)
this.stepDetail = new StepDetail(_parent, _traceManager)
/* Return values - */ /* Return values - */
this.returnValuesPanel = new BasicPanel('Return Value', '1205px', '100px') this.returnValuesPanel = new DropdownPanel('Return Value')
this.returnValuesPanel.data = {}
_parent.register('indexChanged', this.returnValuesPanel, function (index) { _parent.register('indexChanged', this.returnValuesPanel, function (index) {
var self = this var self = this
_traceManager.getReturnValue(index, function (error, returnValue) { _traceManager.getReturnValue(index, function (error, returnValue) {
if (error) { if (error) {
console.log(error) self.data = [error]
self.data = ''
} else if (_parent.currentStepIndex === index) { } else if (_parent.currentStepIndex === index) {
self.data = returnValue self.data = [returnValue]
} }
self.update() self.update()
if (!returnValue) {
self.hide()
}
}) })
}) })
/* Return values - */ /* Return values - */
@ -52,45 +49,18 @@ function VmDebugger (_parent, _traceManager, _codeManager) {
VmDebugger.prototype.render = function () { VmDebugger.prototype.render = function () {
var view = yo`<div id='vmdebugger' style='display:none'> var view = yo`<div id='vmdebugger' style='display:none'>
<div style=${ui.formatCss(style.container)}> <div>
<table> <div>
<tbody>
<tr>
<td colspan='2'>
${this.returnValuesPanel.render()}
</td>
</tr>
<tr>
<td colspan='2'>
${this.fullStoragesChangesPanel.render()}
</td>
</tr>
<tr>
<td>
${this.asmCode.render()} ${this.asmCode.render()}
</td> ${this.stepDetail.render()}
<td>
${this.stackPanel.render()} ${this.stackPanel.render()}
</td>
</tr>
<tr>
<td>
${this.storagePanel.render()} ${this.storagePanel.render()}
</td>
<td>
${this.memoryPanel.render()} ${this.memoryPanel.render()}
</td>
</tr>
<tr>
<td>
${this.calldataPanel.render()} ${this.calldataPanel.render()}
</td>
<td>
${this.callstackPanel.render()} ${this.callstackPanel.render()}
</td> ${this.returnValuesPanel.render()}
</tr> ${this.fullStoragesChangesPanel.render()}
</tbody> </div>
</table>
</div> </div>
</div>` </div>`
if (!this.view) { if (!this.view) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -1,5 +1,11 @@
'use strict' 'use strict'
module.exports = { module.exports = {
truncate: {
'white-space': 'nowrap',
'overflow': 'hidden',
'text-overflow': 'ellipsis',
'margin-right': '5px'
},
font: { font: {
'font-family': 'arial,sans-serif' 'font-family': 'arial,sans-serif'
}, },
@ -14,8 +20,11 @@ module.exports = {
'font-style': 'italic' 'font-style': 'italic'
}, },
instructionsList: { instructionsList: {
'width': '600px', 'width': '72%',
'height': '330px' 'height': '330px',
'overflow-y': 'scroll',
'list-style-type': 'none',
'margin': 'auto'
}, },
transactionInfo: { transactionInfo: {
'margin-top': '5px' 'margin-top': '5px'
@ -53,5 +62,28 @@ module.exports = {
vmargin: { vmargin: {
'margin-top': '10px', 'margin-top': '10px',
'margin-bottom': '10px' 'margin-bottom': '10px'
},
button: {
'-moz-box-shadow': 'inset 0px 1px 0px 0px #ffffff',
'-webkit-box-shadow': 'inset 0px 1px 0px 0px #ffffff',
'box-shadow': 'inset 0px 1px 0px 0px #ffffff',
'background': '-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f9f9f9), color-stop(1, #e9e9e9))', // eslint-disable-line
'background': '-moz-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%)', // eslint-disable-line
'background': '-webkit-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%)', // eslint-disable-line
'background': '-o-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%)', // eslint-disable-line
'background': '-ms-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%)', // eslint-disable-line
'background': 'linear-gradient(to bottom, #f9f9f9 5%, #e9e9e9 100%)', // eslint-disable-line
'filter': "progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#e9e9e9',GradientType=0)", // eslint-disable-line
'background-color': '#f9f9f9',
'-moz-border-radius': '6px',
'-webkit-border-radius': '6px',
'border-radius': '6px',
'border': '1px solid #dcdcdc',
'display': 'inline-block',
'cursor': 'pointer',
'color': '#666666',
'font-family': 'Arial',
'text-decoration': 'none',
'text-shadow': '0px 1px 0px #ffffff'
} }
} }

@ -0,0 +1,28 @@
'use strict'
module.exports = {
title: {
'border': '1px solid #dadada',
'background-color': '#eeeeee',
'width': '100%',
'color': '#363f47',
'margin-top': '5px',
'font-style': 'italic'
},
titleInner: {
'display': 'inline-block',
'cursor': 'pointer'
},
content: {
'color': '#9b9b9b',
'width': '100%',
'font-family': 'monospace'
},
inner: {
'padding': '2px',
'margin-left': '10px'
},
copyBtn: {
'float': 'right',
'margin-top': '3px'
}
}
Loading…
Cancel
Save