coding standard

pull/7/head
yann300 9 years ago
parent b4d7d8c4ad
commit 592cddcf85
  1. 2
      .gitignore
  2. 12
      package.json
  3. 341
      src/assemblyItemsBrowser.js
  4. 40
      src/basicPanel.js
  5. 46
      src/basicStyles.js
  6. 10
      src/codeUtils.js
  7. 32
      src/debugger.js
  8. 16
      src/index.js
  9. 22
      src/slider.js
  10. 8
      src/sliderStyles.js
  11. 41
      src/sticker.js
  12. 41
      src/txBrowser.js
  13. 9
      src/vmTraceBrowser.js
  14. 37
      src/vmTraceButtonNavigator.js
  15. 5
      src/vmTraceManager.js
  16. 65
      src/web3Admin.js

2
.gitignore vendored

@ -0,0 +1,2 @@
node_modules
npm-debug.log

@ -20,12 +20,13 @@
}, },
"devDependencies": { "devDependencies": {
"babel-preset-react": "^6.5.0", "babel-preset-react": "^6.5.0",
"babelify": "^7.2.0" "babelify": "^7.2.0",
"standard": "^7.0.1"
}, },
"scripts": { "scripts": {
"install": "npm install --save react react-dom; npm install -g browserify; npm install --save babelify babel-preset-react; npm install web3",
"start_node": "eth --rpccorsdomain \"*\" -j -v 0", "start_node": "eth --rpccorsdomain \"*\" -j -v 0",
"build": "mkdir -p build; browserify -t [ babelify --presets [ react ] ] src/index.js -o build/app.js" "build": "mkdir -p build; browserify -t [ babelify --presets [ react ] ] src/index.js -o build/app.js",
"test" : "standard"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -36,5 +37,8 @@
"bugs": { "bugs": {
"url": "https://github.com/ethereum/remix/issues" "url": "https://github.com/ethereum/remix/issues"
}, },
"homepage": "https://github.com/ethereum/remix#readme" "homepage": "https://github.com/ethereum/remix#readme",
"standard": {
"global": ["web3"]
}
} }

@ -1,15 +1,13 @@
var React = require('react'); var React = require('react')
var BasicPanel = require('./basicPanel') var BasicPanel = require('./basicPanel')
var Sticker = require('./sticker') var Sticker = require('./sticker')
var ButtonNavigator = require('./vmTraceButtonNavigator') var ButtonNavigator = require('./vmTraceButtonNavigator')
var codeUtils = require('./codeUtils') var codeUtils = require('./codeUtils')
var style = require('./basicStyles') var style = require('./basicStyles')
var Slider = require('./slider'); var Slider = require('./slider')
module.exports = React.createClass({ module.exports = React.createClass({
getInitialState: function () {
getInitialState: function()
{
return { return {
currentSelected: -1, // current selected item in the vmTrace currentSelected: -1, // current selected item in the vmTrace
selectedInst: -1, // current selected item in the contract assembly code selectedInst: -1, // current selected item in the contract assembly code
@ -23,33 +21,45 @@ module.exports = React.createClass({
codes: {}, // assembly items instructions list by contract addesses codes: {}, // assembly items instructions list by contract addesses
instructionsIndexByBytesOffset: {}, // mapping between bytes offset and instructions index. instructionsIndexByBytesOffset: {}, // mapping between bytes offset and instructions index.
callStack: {} callStack: {}
}; }
}, },
getDefaultProps: function() getDefaultProps: function () {
{
return { return {
vmTrace: null vmTrace: null
}; }
}, },
render: function() render: function () {
{
return ( return (
<div style={this.props.vmTrace === null ? style.hidden : style.display}> <div style={this.props.vmTrace === null ? style.hidden : style.display}>
<div style={style.container}><span style={style.address}>Current code: {this.state.currentAddress}</span></div>
<div style={style.container}> <div style={style.container}>
<Slider ref="slider" onChange={this.selectState} min="0" max={this.props.vmTrace ? this.props.vmTrace.length : 0}/> <span style={style.address}>Current code: {this.state.currentAddress}</span>
</div>
<div style={style.container}>
<Slider
ref='slider'
onChange={this.selectState}
min='0'
max={this.props.vmTrace ? this.props.vmTrace.length : 0} />
<ButtonNavigator <ButtonNavigator
vmTraceLength={this.props.vmTrace ? this.props.vmTrace.length : 0} step={this.state.currentSelected} stepIntoBack={this.stepIntoBack} vmTraceLength={this.props.vmTrace ? this.props.vmTrace.length : 0}
stepIntoForward={this.stepIntoForward} stepOverBack={this.stepOverBack} stepOverForward={this.stepOverForward} /> step={this.state.currentSelected}
stepIntoBack={this.stepIntoBack}
stepIntoForward={this.stepIntoForward}
stepOverBack={this.stepOverBack}
stepOverForward={this.stepOverForward} />
</div> </div>
<div style={style.container}> <div style={style.container}>
<table> <table>
<tbody> <tbody>
<tr> <tr>
<td> <td>
<select size="10" ref='itemsList' style={style.instructionsList} value={this.state.selectedInst}> <select
size='10'
ref='itemsList'
style={style.instructionsList}
value={this.state.selectedInst}>
{this.renderAssemblyItems()} {this.renderAssemblyItems()}
</select> </select>
<div style={Object.assign(style.inline, style.sticker)}> <div style={Object.assign(style.inline, style.sticker)}>
@ -57,61 +67,74 @@ module.exports = React.createClass({
</div> </div>
</td> </td>
<td> <td>
<BasicPanel name="CallData" data={this.state.currentCallData} /> <BasicPanel name='CallData' data={this.state.currentCallData} />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<BasicPanel name="Stack" data={this.state.currentStack} /> <BasicPanel name='Stack' data={this.state.currentStack} />
</td> </td>
<td> <td>
<BasicPanel name="CallStack" data={this.state.currentCallStack} /> <BasicPanel name='CallStack' data={this.state.currentCallStack} />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<BasicPanel name="Storage" data={this.state.currentStorage} renderRow={this.renderStorageRow} /> <BasicPanel name='Storage' data={this.state.currentStorage} renderRow={this.renderStorageRow} />
</td> </td>
<td> <td>
<BasicPanel name="Memory" data={this.state.currentMemory} renderRow={this.renderMemoryRow} /> <BasicPanel name='Memory' data={this.state.currentMemory} renderRow={this.renderMemoryRow} />
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
); )
}, },
renderStorageRow: function(data) renderStorageRow: function (data) {
{
var ret = [] var ret = []
if (data) if (data) {
{ for (var key in data) {
for (var key in data) ret.push(
ret.push(<tr key={key} ><td>{key}</td><td>{data[key]}</td></tr>) <tr key={key}>
<td>
{key}
</td>
<td>
{data[key]}
</td>
</tr>)
}
} }
return ret return ret
}, },
renderMemoryRow: function(data) renderMemoryRow: function (data) {
{
var ret = [] var ret = []
if (data) if (data) {
{ for (var key in data) {
for (var key in data)
{
var memSlot = data[key] var memSlot = data[key]
ret.push(<tr key={key} ><td>{memSlot.address}</td><td>{memSlot.content.raw}</td><td>{memSlot.content.ascii}</td></tr>) ret.push(
<tr key={key}>
<td>
{memSlot.address}
</td>
<td>
{memSlot.content.raw}
</td>
<td>
{memSlot.content.ascii}
</td>
</tr>)
} }
} }
return ret return ret
}, },
resolveAddress: function(address) resolveAddress: function (address) {
{ if (!this.state.codes[address]) {
if (!this.state.codes[address])
{
var hexCode = web3.eth.getCode(address) var hexCode = web3.eth.getCode(address)
var code = codeUtils.nameOpCodes(new Buffer(hexCode.substring(2), 'hex')) var code = codeUtils.nameOpCodes(new Buffer(hexCode.substring(2), 'hex'))
this.state.codes[address] = code[0] this.state.codes[address] = code[0]
@ -119,216 +142,203 @@ module.exports = React.createClass({
} }
}, },
renderAssemblyItems: function() renderAssemblyItems: function () {
{ if (this.props.vmTrace) {
if (this.props.vmTrace) return this.state.codes[this.state.currentAddress].map(function (item, i) {
{ return <option key={i} value={i}>{item}</option>
return this.state.codes[this.state.currentAddress].map(function(item, i) })
{
return <option key={i} value={i} >{item}</option>;
});
} }
}, },
componentWillReceiveProps: function (nextProps) componentWillReceiveProps: function (nextProps) {
{ if (!nextProps.vmTrace) {
if (!nextProps.vmTrace)
return return
}
this.buildCallStack(nextProps.vmTrace) this.buildCallStack(nextProps.vmTrace)
this.setState({"currentSelected": -1}) this.setState({'currentSelected': -1})
this.updateState(nextProps, 0) this.updateState(nextProps, 0)
}, },
buildCallStack: function(vmTrace) buildCallStack: function (vmTrace) {
{ if (!vmTrace) {
if (!vmTrace)
return return
}
var callStack = [] var callStack = []
var depth = -1 var depth = -1
for (var k = 0; k < vmTrace.length; k++) for (var k = 0; k < vmTrace.length; k++) {
{
var trace = vmTrace[k] var trace = vmTrace[k]
if (trace.depth === undefined || trace.depth === depth) if (trace.depth === undefined || trace.depth === depth) {
continue continue
if (trace.depth > depth) }
if (trace.depth > depth) {
callStack.push(trace.address) // new context callStack.push(trace.address) // new context
else if (trace.depth < depth) } else if (trace.depth < depth) {
callStack.pop() // returning from context callStack.pop() // returning from context
}
depth = trace.depth depth = trace.depth
this.state.callStack[k] = callStack.slice(0) this.state.callStack[k] = callStack.slice(0)
} }
}, },
updateState: function(props, vmTraceIndex) updateState: function (props, vmTraceIndex) {
{ if (!props.vmTrace || !props.vmTrace[vmTraceIndex]) {
if (!props.vmTrace || !props.vmTrace[vmTraceIndex])
return return
}
var previousIndex = this.state.currentSelected var previousIndex = this.state.currentSelected
var stateChanges = {} var stateChanges = {}
if (props.vmTrace[vmTraceIndex].stack) // there's always a stack if (props.vmTrace[vmTraceIndex].stack) { // there's always a stack
{
var stack = props.vmTrace[vmTraceIndex].stack var stack = props.vmTrace[vmTraceIndex].stack
stack.reverse() stack.reverse()
stateChanges["currentStack"] = stack stateChanges['currentStack'] = stack
} }
var currentAddress = this.state.currentAddress var currentAddress = this.state.currentAddress
var addressIndex = this.shouldUpdateStateProperty("address", vmTraceIndex, previousIndex, props.vmTrace) var addressIndex = this.shouldUpdateStateProperty('address', vmTraceIndex, previousIndex, props.vmTrace)
if (addressIndex > -1) if (addressIndex > -1) {
{
currentAddress = props.vmTrace[addressIndex].address currentAddress = props.vmTrace[addressIndex].address
this.resolveAddress(currentAddress) this.resolveAddress(currentAddress)
Object.assign(stateChanges, { "currentAddress": currentAddress }) Object.assign(stateChanges, { 'currentAddress': currentAddress })
} }
var depthIndex = this.shouldUpdateStateProperty("depth", vmTraceIndex, previousIndex, props.vmTrace) var depthIndex = this.shouldUpdateStateProperty('depth', vmTraceIndex, previousIndex, props.vmTrace)
if (depthIndex > -1) if (depthIndex > -1) {
Object.assign(stateChanges, { "currentCallStack": this.state.callStack[depthIndex] }) Object.assign(stateChanges, { 'currentCallStack': this.state.callStack[depthIndex] })
}
var storageIndex = this.shouldUpdateStateProperty("storage", vmTraceIndex, previousIndex, props.vmTrace) var storageIndex = this.shouldUpdateStateProperty('storage', vmTraceIndex, previousIndex, props.vmTrace)
if (storageIndex > -1) if (storageIndex > -1) {
Object.assign(stateChanges, { "currentStorage": props.vmTrace[storageIndex].storage }) Object.assign(stateChanges, { 'currentStorage': props.vmTrace[storageIndex].storage })
}
var memoryIndex = this.shouldUpdateStateProperty("memory", vmTraceIndex, previousIndex, props.vmTrace) var memoryIndex = this.shouldUpdateStateProperty('memory', vmTraceIndex, previousIndex, props.vmTrace)
if (memoryIndex > -1) if (memoryIndex > -1) {
Object.assign(stateChanges, { "currentMemory": this.formatMemory(props.vmTrace[memoryIndex].memory, 16) }) Object.assign(stateChanges, { 'currentMemory': this.formatMemory(props.vmTrace[memoryIndex].memory, 16) })
}
var callDataIndex = this.shouldUpdateStateProperty("calldata", vmTraceIndex, previousIndex, props.vmTrace) var callDataIndex = this.shouldUpdateStateProperty('calldata', vmTraceIndex, previousIndex, props.vmTrace)
if (callDataIndex > -1) if (callDataIndex > -1) {
Object.assign(stateChanges, { "currentCallData": [props.vmTrace[callDataIndex].calldata] }) Object.assign(stateChanges, { 'currentCallData': [props.vmTrace[callDataIndex].calldata] })
}
stateChanges["selectedInst"] = this.state.instructionsIndexByBytesOffset[currentAddress][props.vmTrace[vmTraceIndex].pc] stateChanges['selectedInst'] = this.state.instructionsIndexByBytesOffset[currentAddress][props.vmTrace[vmTraceIndex].pc]
stateChanges["currentSelected"] = vmTraceIndex stateChanges['currentSelected'] = vmTraceIndex
stateChanges["currentStepInfo"] = [ stateChanges['currentStepInfo'] = [
"Current Step: " + props.vmTrace[vmTraceIndex].steps, 'Current Step: ' + props.vmTrace[vmTraceIndex].steps,
"Adding Memory: " + (props.vmTrace[vmTraceIndex].memexpand ? props.vmTrace[vmTraceIndex].memexpand : ""), 'Adding Memory: ' + (props.vmTrace[vmTraceIndex].memexpand ? props.vmTrace[vmTraceIndex].memexpand : ''),
"Step Cost: " + props.vmTrace[vmTraceIndex].gascost, 'Step Cost: ' + props.vmTrace[vmTraceIndex].gascost,
"Remaining Gas: " + props.vmTrace[vmTraceIndex].gas 'Remaining Gas: ' + props.vmTrace[vmTraceIndex].gas
] ]
this.refs.slider.setValue(vmTraceIndex) this.refs.slider.setValue(vmTraceIndex)
this.setState(stateChanges) this.setState(stateChanges)
}, },
shouldUpdateStateProperty: function(vmTraceName, nextIndex, previousIndex, vmTrace) shouldUpdateStateProperty: function (vmTraceName, nextIndex, previousIndex, vmTrace) {
{
var propIndex = -1 var propIndex = -1
if (previousIndex + 1 === nextIndex) if (previousIndex + 1 === nextIndex) {
propIndex = nextIndex propIndex = nextIndex
else } else {
propIndex = this.retrieveLastSeenProperty(nextIndex, vmTraceName, vmTrace) propIndex = this.retrieveLastSeenProperty(nextIndex, vmTraceName, vmTrace)
}
if (propIndex > -1 && vmTrace[propIndex][vmTraceName] !== undefined) if (propIndex > -1 && vmTrace[propIndex][vmTraceName] !== undefined) {
return propIndex return propIndex
else } else {
return -1 return -1
}
}, },
retrieveLastSeenProperty: function(currentIndex, propertyName, vmTrace) retrieveLastSeenProperty: function (currentIndex, propertyName, vmTrace) {
{
var index = currentIndex var index = currentIndex
while (index > 0) while (index > 0) {
{ if (vmTrace[index][propertyName]) {
if (vmTrace[index][propertyName])
break break
}
index-- index--
} }
return index return index
}, },
stepIntoBack: function() stepIntoBack: function () {
{
this.moveSelection(-1) this.moveSelection(-1)
}, },
stepIntoForward: function() stepIntoForward: function () {
{
this.moveSelection(1) this.moveSelection(1)
}, },
stepOverBack: function() stepOverBack: function () {
{ if (this.isReturnInstruction(this.state.currentSelected - 1)) {
if (this.isReturnInstruction(this.state.currentSelected - 1)) this.stepOutBack()
this.stepOutBack(); } else {
else this.moveSelection(-1)
this.moveSelection(-1); }
}, },
stepOverForward: function() stepOverForward: function () {
{ if (this.isCallInstruction(this.state.currentSelected)) {
if (this.isCallInstruction(this.state.currentSelected)) this.stepOutForward()
this.stepOutForward(); } else {
else this.moveSelection(1)
this.moveSelection(1); }
}, },
isCallInstruction: function(index) isCallInstruction: function (index) {
{ var state = this.props.vmTrace[index]
var state = this.props.vmTrace[index]; return state.instname === 'CALL' || state.instname === 'CALLCODE' || state.instname === 'CREATE' || state.instname === 'DELEGATECALL'
return state.instname === "CALL" || state.instname === "CALLCODE" || state.instname === "CREATE" || state.instname === "DELEGATECALL"
}, },
isReturnInstruction: function(index) isReturnInstruction: function (index) {
{ var state = this.props.vmTrace[index]
var state = this.props.vmTrace[index]; return state.instname === 'RETURN'
return state.instname === "RETURN"
}, },
stepOutBack: function() stepOutBack: function () {
{ var i = this.state.currentSelected - 1
var i = this.state.currentSelected - 1; var depth = 0
var depth = 0; while (--i >= 0) {
while (--i >= 0) if (this.isCallInstruction(i)) {
{ if (depth === 0) {
if (this.isCallInstruction(i)) break
{ } else {
if (depth == 0) depth--
break; }
else } else if (this.isReturnInstruction(i)) {
depth--; depth++
} }
else if (this.isReturnInstruction(i))
depth++;
} }
this.selectState(i); this.selectState(i)
}, },
stepOutForward: function() stepOutForward: function () {
{
var i = this.state.currentSelected var i = this.state.currentSelected
var depth = 0 var depth = 0
while (++i < this.props.vmTrace.length) while (++i < this.props.vmTrace.length) {
{ if (this.isReturnInstruction(i)) {
if (this.isReturnInstruction(i)) if (depth === 0) {
{
if (depth == 0)
break break
else } else {
depth-- depth--
} }
else if (this.isCallInstruction(i)) } else if (this.isCallInstruction(i)) {
depth++ depth++
} }
this.selectState(i + 1); }
this.selectState(i + 1)
}, },
moveSelection: function(incr) moveSelection: function (incr) {
{
this.selectState(this.state.currentSelected + incr) this.selectState(this.state.currentSelected + incr)
}, },
selectState: function(index) selectState: function (index) {
{
this.updateState(this.props, index) this.updateState(this.props, index)
}, },
formatMemory: function(mem, width) formatMemory: function (mem, width) {
{
var ret = [] var ret = []
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)
ret.push({ ret.push({
address: web3.toHex(k), address: web3.toHex(k),
@ -338,18 +348,17 @@ module.exports = React.createClass({
return ret return ret
}, },
tryAsciiFormat: function(memorySlot) tryAsciiFormat: function (memorySlot) {
{ var ret = { ascii: '', raw: '' }
var ret = { ascii: "", raw: "" } for (var k = 0; k < memorySlot.length; k += 2) {
for (var k = 0; k < memorySlot.length; k += 2)
{
var raw = memorySlot.substr(k, 2) var raw = memorySlot.substr(k, 2)
var ascii = web3.toAscii(raw) var ascii = web3.toAscii(raw)
if (ascii === String.fromCharCode(0)) if (ascii === String.fromCharCode(0)) {
ret.ascii += "?" ret.ascii += '?'
else } else {
ret.ascii += ascii ret.ascii += ascii
ret.raw += " " + raw }
ret.raw += ' ' + raw
} }
return ret return ret
} }

@ -1,22 +1,21 @@
var React = require('react'); var React = require('react')
var style = require('./basicStyles') var style = require('./basicStyles')
module.exports = React.createClass({ module.exports = React.createClass({
getDefaultProps: function () {
getDefaultProps: function()
{
return { return {
data: null, data: null,
name: null, name: null,
renderRow: null renderRow: null
}; }
}, },
render: function() render: function () {
{
return ( return (
<div style={style.panel.container}> <div style={style.panel.container}>
<div style={style.panel.title} >{this.props.name}</div> <div style={style.panel.title}>
{this.props.name}
</div>
<div style={style.panel.tableContainer}> <div style={style.panel.tableContainer}>
<table style={style.panel.table}> <table style={style.panel.table}>
<tbody> <tbody>
@ -25,21 +24,26 @@ module.exports = React.createClass({
</table> </table>
</div> </div>
</div> </div>
); )
}, },
renderItems: function() renderItems: function () {
{ if (!this.props.data) {
if (!this.props.data)
return [] return []
if (!this.props.renderRow) }
{ if (!this.props.renderRow) {
var ret = [] var ret = []
for (var key in this.props.data) for (var key in this.props.data) {
ret.push(<tr key={key} ><td>{this.props.data[key]}</td></tr>) ret.push(
return ret <tr key={key}>
<td>
{this.props.data[key]}
</td>
</tr>)
} }
else return ret
} else {
return this.props.renderRow(this.props.data) return this.props.renderRow(this.props.data)
} }
}
}) })

@ -1,62 +1,48 @@
module.exports = { module.exports = {
wrapper: wrapper: {
{ 'fontFamily': 'arial,sans-serif'
'fontFamily': "arial,sans-serif"
}, },
container: container: {
{
'margin': '10px', 'margin': '10px',
'padding': '5px' 'padding': '5px'
}, },
address: address: {
{
'fontStyle': 'italic' 'fontStyle': 'italic'
}, },
instructionsList: instructionsList: {
{ 'width': '320px'
'width': "320px"
}, },
transactionInfo: transactionInfo: {
{
'marginTop': '5px' 'marginTop': '5px'
}, },
panel: panel: {
{ container: {
container:
{
'border': '1px solid', 'border': '1px solid',
'width': '600px' 'width': '600px'
}, },
tableContainer: tableContainer: {
{
'height': '150px', 'height': '150px',
'overflowY': 'auto' 'overflowY': 'auto'
}, },
table: table: {
{
'padding': '5px' 'padding': '5px'
}, },
title: title: {
{
'padding': '5px', 'padding': '5px',
'fontStyle': 'italic' 'fontStyle': 'italic'
} }
}, },
hidden: hidden: {
{
'display': 'none' 'display': 'none'
}, },
display: display: {
{
'display': 'block' 'display': 'block'
}, },
sticker: sticker: {
{
'verticalAlign': 'top', 'verticalAlign': 'top',
'margin': '5px' 'margin': '5px'
}, },
inline: inline: {
{
'display': 'inline-block' 'display': 'inline-block'
} }
} }

@ -1,21 +1,17 @@
var opcodes = require('./opcodes') var opcodes = require('./opcodes')
module.exports = { module.exports = {
nameOpCodes: function (raw) {
nameOpCodes: function (raw)
{
var pushData = '' var pushData = ''
var codeMap = {} var codeMap = {}
var code = [] var code = []
for (var i = 0; i < raw.length; i++) for (var i = 0; i < raw.length; i++) {
{
var pc = i var pc = i
var curOpCode = opcodes(raw[pc], false).name var curOpCode = opcodes(raw[pc], false).name
codeMap[i] = code.length codeMap[i] = code.length
// no destinations into the middle of PUSH // no destinations into the middle of PUSH
if (curOpCode.slice(0, 4) === 'PUSH') if (curOpCode.slice(0, 4) === 'PUSH') {
{
var jumpNum = raw[pc] - 0x5f var jumpNum = raw[pc] - 0x5f
pushData = raw.slice(pc + 1, pc + jumpNum + 1) pushData = raw.slice(pc + 1, pc + jumpNum + 1)
i += jumpNum i += jumpNum

@ -1,12 +1,12 @@
var React = require('react'); var React = require('react')
var TxBrowser = require('./txBrowser'); var TxBrowser = require('./txBrowser')
var VmTraceManager = require('./vmTraceManager'); var VmTraceManager = require('./vmTraceManager')
var VmTraceBrowser = require('./vmTraceBrowser'); var VmTraceBrowser = require('./vmTraceBrowser')
var style = require('./basicStyles') var style = require('./basicStyles')
module.exports = React.createClass({ module.exports = React.createClass({
getInitialState: function () { getInitialState: function () {
return {vmTrace: null, state: "", currentStep: -1} return {vmTrace: null, state: '', currentStep: -1}
}, },
render: function () { render: function () {
@ -14,19 +14,23 @@ module.exports = React.createClass({
<div style={style.wrapper}> <div style={style.wrapper}>
<h1 style={style.container}>Eth Debugger</h1> <h1 style={style.container}>Eth Debugger</h1>
<TxBrowser onNewTxRequested={this.retrieveVmTrace} /> <TxBrowser onNewTxRequested={this.retrieveVmTrace} />
<div style={style.container} >{this.state.state}</div> <div style={style.container}>
{this.state.state}
</div>
<VmTraceBrowser vmTrace={this.state.vmTrace} /> <VmTraceBrowser vmTrace={this.state.vmTrace} />
</div> </div>
); )
}, },
retrieveVmTrace: function(blockNumber, txNumber) retrieveVmTrace: function (blockNumber, txNumber) {
{ this.setState({state: 'loading...'})
this.setState({state: "loading..."})
var deb = this var deb = this
VmTraceManager.retrieveVmTrace(blockNumber, txNumber, function(error, result) VmTraceManager.retrieveVmTrace(blockNumber, txNumber, function (error, result) {
{ if (error) {
deb.setState({vmTrace: result, state: ""}); console.log(error)
} else {
deb.setState({vmTrace: result, state: ''})
}
}) })
} }
}); })

@ -1,15 +1,15 @@
var ReactDOM = require('react-dom'); var ReactDOM = require('react-dom')
var React = require('react'); var React = require('react')
var Web3 = require('web3'); var Web3 = require('web3')
var Web3Admin = require('./web3Admin') var Web3Admin = require('./web3Admin')
web3 = new Web3(); var web3 = new Web3()
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')); web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'))
Web3Admin.extend(web3); Web3Admin.extend(web3)
var Debugger = require('./debugger'); var Debugger = require('./debugger')
ReactDOM.render( ReactDOM.render(
<Debugger />, <Debugger />,
document.getElementById('app') document.getElementById('app')
); )

@ -1,25 +1,30 @@
var React = require('react'); var React = require('react')
var style = require('./sliderStyles') var style = require('./sliderStyles')
module.exports = React.createClass({ module.exports = React.createClass({
propTypes: { propTypes: {
onChange: React.PropTypes.func.isRequired, onChange: React.PropTypes.func.isRequired
}, },
getDefaultProps: function () { getDefaultProps: function () {
return { return {
min: 0, min: 0,
max: 500 max: 500
}; }
}, },
render: function () { render: function () {
return ( return (
<div> <div>
<input ref="rule" style={style.rule} type="range" min={this.props.min} max={this.props.max} onMouseUp={this.onMouseUp} /> <input
ref='rule'
style={style.rule}
type='range'
min={this.props.min}
max={this.props.max}
onMouseUp={this.onMouseUp} />
</div> </div>
); )
}, },
onMouseUp: function (event) { onMouseUp: function (event) {
@ -28,9 +33,10 @@ module.exports = React.createClass({
setValue: function (value) { setValue: function (value) {
var diff = value - this.refs.rule.value var diff = value - this.refs.rule.value
if (diff > 0) if (diff > 0) {
this.refs.rule.stepUp(diff) this.refs.rule.stepUp(diff)
else } else {
this.refs.rule.stepDown(Math.abs(diff)) this.refs.rule.stepDown(Math.abs(diff))
} }
}
}) })

@ -1,10 +1,8 @@
module.exports = { module.exports = {
rule: rule: {
{ 'width': '600px'
'width': '600px',
}, },
runner: runner: {
{
'position': 'absolute', 'position': 'absolute',
'width': '16px', 'width': '16px',
'height': '16px', 'height': '16px',

@ -1,36 +1,37 @@
var React = require('react'); var React = require('react')
var style = require('./basicStyles')
module.exports = React.createClass({ module.exports = React.createClass({
getDefaultProps: function () {
getDefaultProps: function()
{
return { return {
data: null, data: null
}; }
}, },
render: function() render: function () {
{
return ( return (
<div> <div>
<table><tbody> <table>
<tbody>
{this.renderItems()} {this.renderItems()}
</tbody></table> </tbody>
</table>
</div> </div>
); )
}, },
renderItems: function() renderItems: function () {
{ if (this.props.data) {
if (this.props.data)
{
var ret = [] var ret = []
for (var key in this.props.data) for (var key in this.props.data) {
ret.push(<tr key={key}><td>{this.props.data[key]}</td></tr>) ret.push(
<tr key={key}>
<td>
{this.props.data[key]}
</td>
</tr>)
}
return ret return ret
} }
return null return null
}, }
}) })

@ -1,43 +1,54 @@
var React = require('react'); var React = require('react')
var style = require('./basicStyles') var style = require('./basicStyles')
module.exports = React.createClass({ module.exports = React.createClass({
propTypes: { propTypes: {
onNewTxRequested: React.PropTypes.func.isRequired, onNewTxRequested: React.PropTypes.func.isRequired
}, },
getInitialState: function () { getInitialState: function () {
return {blockNumber: "1382256", txNumber: "1", from: "", to: "", hash: ""} return {blockNumber: '1382256', txNumber: '1', from: '', to: '', hash: ''}
}, },
submit: function() submit: function () {
{
var tx = web3.eth.getTransactionFromBlock(this.state.blockNumber, this.state.txNumber) var tx = web3.eth.getTransactionFromBlock(this.state.blockNumber, this.state.txNumber)
if (tx) if (tx) {
this.setState({from: tx.from, to: tx.to, hash: tx.hash}) this.setState({from: tx.from, to: tx.to, hash: tx.hash})
}
this.props.onNewTxRequested(this.state.blockNumber, parseInt(this.state.txNumber)) this.props.onNewTxRequested(this.state.blockNumber, parseInt(this.state.txNumber))
}, },
updateBlockN: function (ev) { updateBlockN: function (ev) {
this.state.blockNumber = ev.target.value; this.state.blockNumber = ev.target.value
}, },
updateTxN: function (ev) { updateTxN: function (ev) {
this.state.txNumber = ev.target.value; this.state.txNumber = ev.target.value
}, },
render: function () { render: function () {
return ( return (
<div style={style.container}> <div style={style.container}>
<input onChange={this.updateBlockN} type="text" placeholder= {"Block number or hash (default 1382256)" + this.state.blockNumber}></input> <input onChange={this.updateBlockN} type='text' placeholder={'Block number or hash (default 1382256)' + this.state.blockNumber}></input>
<input onChange={this.updateTxN} type="text" placeholder={"Transaction Number (default 1) " + this.state.txNumber}></input> <input onChange={this.updateTxN} type='text' placeholder={'Transaction Number (default 1) ' + this.state.txNumber}></input>
<button onClick={this.submit}>Get</button> <button onClick={this.submit}>
Get
</button>
<div style={style.transactionInfo}> <div style={style.transactionInfo}>
<div>Hash: {this.state.hash}</div> <div>
<div>From: {this.state.from}</div> Hash:
<div>To: {this.state.to}</div> {this.state.hash}
</div>
<div>
From:
{this.state.from}
</div>
<div>
To:
{this.state.to}
</div>
</div> </div>
</div> </div>
); )
} }
}) })

@ -1,13 +1,12 @@
var React = require('react'); var React = require('react')
var AssemblyItemsBrowser = require('./assemblyItemsBrowser'); var AssemblyItemsBrowser = require('./assemblyItemsBrowser')
module.exports = React.createClass({ module.exports = React.createClass({
render: function () { render: function () {
return ( return (
<div> <div>
<AssemblyItemsBrowser vmTrace={this.props.vmTrace} /> <AssemblyItemsBrowser vmTrace={this.props.vmTrace} />
</div> </div>
) )
}, }
}); })

@ -1,30 +1,37 @@
var React = require('react'); var React = require('react')
module.exports = React.createClass({ module.exports = React.createClass({
propTypes: { propTypes: {
stepIntoBack: React.PropTypes.func.isRequired, stepIntoBack: React.PropTypes.func.isRequired,
stepIntoForward: React.PropTypes.func.isRequired, stepIntoForward: React.PropTypes.func.isRequired,
stepOverBack: React.PropTypes.func.isRequired, stepOverBack: React.PropTypes.func.isRequired,
stepOverForward: React.PropTypes.func.isRequired, stepOverForward: React.PropTypes.func.isRequired
}, },
render: function () { render: function () {
return ( return (
<div> <div>
<button onClick={this.props.stepIntoBack} disabled={this.checkButtonState(-1)} >Step Into Back</button> <button onClick={this.props.stepIntoBack} disabled={this.checkButtonState(-1)}>
<button onClick={this.props.stepOverBack} disabled={this.checkButtonState(-1)} >Step Over Back</button> Step Into Back
<button onClick={this.props.stepOverForward} disabled={this.checkButtonState(1)} >Step Over Forward</button> </button>
<button onClick={this.props.stepIntoForward} disabled={this.checkButtonState(1)} >Step Into Forward</button> <button onClick={this.props.stepOverBack} disabled={this.checkButtonState(-1)}>
Step Over Back
</button>
<button onClick={this.props.stepOverForward} disabled={this.checkButtonState(1)}>
Step Over Forward
</button>
<button onClick={this.props.stepIntoForward} disabled={this.checkButtonState(1)}>
Step Into Forward
</button>
</div> </div>
); )
}, },
checkButtonState: function(incr) checkButtonState: function (incr) {
{ if (incr === -1) {
if (incr === -1) return this.props.step === 0 ? 'disabled' : ''
return this.props.step === 0 ? "disabled" : "" } else if (incr === 1) {
else if (incr === 1) return this.props.step >= this.props.vmTraceLength - 1 ? 'disabled' : ''
return this.props.step >= this.props.vmTraceLength - 1 ? "disabled" : "" }
}, }
}) })

@ -1,8 +1,7 @@
module.exports = { module.exports = {
retrieveVmTrace: function (blockNumber, txNumber, callBack) { retrieveVmTrace: function (blockNumber, txNumber, callBack) {
web3.debug.trace(blockNumber, parseInt(txNumber), function(error, result) web3.debug.trace(blockNumber, parseInt(txNumber), function (error, result) {
{
callBack(error, result) callBack(error, result)
}); })
} }
} }

@ -1,11 +1,9 @@
module.exports = { module.exports = {
extend: function (web3) { extend: function (web3) {
// ADMIN // ADMIN
web3._extend({ web3._extend({
property: 'admin', property: 'admin',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'addPeer', name: 'addPeer',
call: 'admin_addPeer', call: 'admin_addPeer',
@ -18,14 +16,14 @@ module.exports = {
call: 'admin_exportChain', call: 'admin_exportChain',
params: 1, params: 1,
inputFormatter: [null], inputFormatter: [null],
outputFormatter: function(obj) { return obj; } outputFormatter: function (obj) { return obj }
}), }),
new web3._extend.Method({ new web3._extend.Method({
name: 'importChain', name: 'importChain',
call: 'admin_importChain', call: 'admin_importChain',
params: 1, params: 1,
inputFormatter: [null], inputFormatter: [null],
outputFormatter: function(obj) { return obj; } outputFormatter: function (obj) { return obj }
}), }),
new web3._extend.Method({ new web3._extend.Method({
name: 'verbosity', name: 'verbosity',
@ -60,10 +58,9 @@ module.exports = {
call: 'admin_eth_vmTrace', call: 'admin_eth_vmTrace',
inputFormatter: [null, null, null], inputFormatter: [null, null, null],
params: 3 params: 3
}), })
], ],
properties: properties: [
[
new web3._extend.Property({ new web3._extend.Property({
name: 'nodeInfo', name: 'nodeInfo',
getter: 'admin_nodeInfo', getter: 'admin_nodeInfo',
@ -72,7 +69,7 @@ module.exports = {
new web3._extend.Property({ new web3._extend.Property({
name: 'peers', name: 'peers',
getter: 'admin_peers', getter: 'admin_peers',
outputFormatter: function(obj) { return obj; } outputFormatter: function (obj) { return obj }
}), }),
new web3._extend.Property({ new web3._extend.Property({
name: 'datadir', name: 'datadir',
@ -82,20 +79,18 @@ module.exports = {
new web3._extend.Property({ new web3._extend.Property({
name: 'chainSyncStatus', name: 'chainSyncStatus',
getter: 'admin_chainSyncStatus', getter: 'admin_chainSyncStatus',
outputFormatter: function(obj) { return obj; } outputFormatter: function (obj) { return obj }
}) })
] ]
}); })
// DEBUG // DEBUG
web3._extend({ web3._extend({
property: 'debug', property: 'debug',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'trace', name: 'trace',
call: 'debug_trace', call: 'debug_trace',
params: 1,
inputFormatter: [null, null], inputFormatter: [null, null],
params: 2 params: 2
}), }),
@ -125,7 +120,7 @@ module.exports = {
call: 'debug_processBlock', call: 'debug_processBlock',
params: 1, params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt], inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: function(obj) { return obj; } outputFormatter: function (obj) { return obj }
}), }),
new web3._extend.Method({ new web3._extend.Method({
name: 'seedHash', name: 'seedHash',
@ -139,19 +134,16 @@ module.exports = {
call: 'debug_dumpBlock', call: 'debug_dumpBlock',
params: 1, params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt], inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: function(obj) { return obj; } outputFormatter: function (obj) { return obj }
}) })
], ],
properties: properties: []
[ })
]
});
// MINER // MINER
web3._extend({ web3._extend({
property: 'miner', property: 'miner',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'start', name: 'start',
call: 'miner_start', call: 'miner_start',
@ -202,21 +194,19 @@ module.exports = {
outputFormatter: web3._extend.formatters.formatOutputBool outputFormatter: web3._extend.formatters.formatOutputBool
}) })
], ],
properties: properties: [
[
new web3._extend.Property({ new web3._extend.Property({
name: 'hashrate', name: 'hashrate',
getter: 'miner_hashrate', getter: 'miner_hashrate',
outputFormatter: web3._extend.utils.toDecimal outputFormatter: web3._extend.utils.toDecimal
}) })
] ]
}); })
// NETWORK // NETWORK
web3._extend({ web3._extend({
property: 'network', property: 'network',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'addPeer', name: 'addPeer',
call: 'net_addPeer', call: 'net_addPeer',
@ -232,8 +222,7 @@ module.exports = {
outputFormatter: web3._extend.formatters.formatOutputString outputFormatter: web3._extend.formatters.formatOutputString
}) })
], ],
properties: properties: [
[
new web3._extend.Property({ new web3._extend.Property({
name: 'listening', name: 'listening',
getter: 'net_listening', getter: 'net_listening',
@ -247,7 +236,7 @@ module.exports = {
new web3._extend.Property({ new web3._extend.Property({
name: 'peers', name: 'peers',
getter: 'net_peers', getter: 'net_peers',
outputFormatter: function(obj) { return obj; } outputFormatter: function (obj) { return obj }
}), }),
new web3._extend.Property({ new web3._extend.Property({
name: 'version', name: 'version',
@ -255,23 +244,19 @@ module.exports = {
outputFormatter: web3._extend.formatters.formatOutputString outputFormatter: web3._extend.formatters.formatOutputString
}) })
] ]
}); })
// TX POOL // TX POOL
web3._extend({ web3._extend({
property: 'txpool', property: 'txpool',
methods: methods: [],
[ properties: [
],
properties:
[
new web3._extend.Property({ new web3._extend.Property({
name: 'status', name: 'status',
getter: 'txpool_status', getter: 'txpool_status',
outputFormatter: function(obj) { return obj; } outputFormatter: function (obj) { return obj }
}) })
] ]
}); })
}
} }
};

Loading…
Cancel
Save