parent
b4d7d8c4ad
commit
592cddcf85
@ -0,0 +1,2 @@ |
|||||||
|
node_modules |
||||||
|
npm-debug.log |
@ -1,356 +1,365 @@ |
|||||||
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 { |
||||||
{ |
currentSelected: -1, // current selected item in the vmTrace
|
||||||
return { |
selectedInst: -1, // current selected item in the contract assembly code
|
||||||
currentSelected: -1, // current selected item in the vmTrace
|
currentAddress: null, |
||||||
selectedInst: -1, // current selected item in the contract assembly code
|
currentStack: null, |
||||||
currentAddress: null, |
currentLevels: null, |
||||||
currentStack: null, |
currentStorage: null, |
||||||
currentLevels: null, |
currentMemory: null, |
||||||
currentStorage: null, |
currentCallData: null, |
||||||
currentMemory: null, |
currentStepInfo: null, |
||||||
currentCallData: null, |
codes: {}, // assembly items instructions list by contract addesses
|
||||||
currentStepInfo: null, |
instructionsIndexByBytesOffset: {}, // mapping between bytes offset and instructions index.
|
||||||
codes: {}, // assembly items instructions list by contract addesses
|
callStack: {} |
||||||
instructionsIndexByBytesOffset: {}, // mapping between bytes offset and instructions index.
|
} |
||||||
callStack: {} |
}, |
||||||
}; |
|
||||||
}, |
getDefaultProps: function () { |
||||||
|
return { |
||||||
getDefaultProps: function()
|
vmTrace: null |
||||||
{ |
} |
||||||
return { |
}, |
||||||
vmTrace: null |
|
||||||
}; |
render: function () { |
||||||
},
|
return ( |
||||||
|
<div style={this.props.vmTrace === null ? style.hidden : style.display}> |
||||||
render: function()
|
<div style={style.container}> |
||||||
{
|
<span style={style.address}>Current code: {this.state.currentAddress}</span> |
||||||
return ( |
</div> |
||||||
<div style={this.props.vmTrace === null ? style.hidden : style.display} > |
<div style={style.container}> |
||||||
<div style={style.container}><span style={style.address}>Current code: {this.state.currentAddress}</span></div> |
<Slider |
||||||
<div style={style.container}> |
ref='slider' |
||||||
<Slider ref="slider" onChange={this.selectState} min="0" max={this.props.vmTrace ? this.props.vmTrace.length : 0}/> |
onChange={this.selectState} |
||||||
<ButtonNavigator |
min='0' |
||||||
vmTraceLength={this.props.vmTrace ? this.props.vmTrace.length : 0} step={this.state.currentSelected} stepIntoBack={this.stepIntoBack}
|
max={this.props.vmTrace ? this.props.vmTrace.length : 0} /> |
||||||
stepIntoForward={this.stepIntoForward} stepOverBack={this.stepOverBack} stepOverForward={this.stepOverForward} /> |
<ButtonNavigator |
||||||
</div> |
vmTraceLength={this.props.vmTrace ? this.props.vmTrace.length : 0} |
||||||
<div style={style.container}> |
step={this.state.currentSelected} |
||||||
<table> |
stepIntoBack={this.stepIntoBack} |
||||||
<tbody> |
stepIntoForward={this.stepIntoForward} |
||||||
<tr> |
stepOverBack={this.stepOverBack} |
||||||
<td> |
stepOverForward={this.stepOverForward} /> |
||||||
<select size="10" ref='itemsList' style={style.instructionsList} value={this.state.selectedInst}> |
</div> |
||||||
{ this.renderAssemblyItems() } |
<div style={style.container}> |
||||||
</select> |
<table> |
||||||
<div style={Object.assign(style.inline, style.sticker)}> |
<tbody> |
||||||
<Sticker data={this.state.currentStepInfo} /> |
<tr> |
||||||
</div> |
<td> |
||||||
</td> |
<select |
||||||
<td> |
size='10' |
||||||
<BasicPanel name="CallData" data={this.state.currentCallData} /> |
ref='itemsList' |
||||||
</td> |
style={style.instructionsList} |
||||||
</tr> |
value={this.state.selectedInst}> |
||||||
<tr> |
{this.renderAssemblyItems()} |
||||||
<td> |
</select> |
||||||
<BasicPanel name="Stack" data={this.state.currentStack} /> |
<div style={Object.assign(style.inline, style.sticker)}> |
||||||
</td> |
<Sticker data={this.state.currentStepInfo} /> |
||||||
<td> |
</div> |
||||||
<BasicPanel name="CallStack" data={this.state.currentCallStack} />
|
</td> |
||||||
</td> |
<td> |
||||||
</tr> |
<BasicPanel name='CallData' data={this.state.currentCallData} /> |
||||||
<tr> |
</td> |
||||||
<td> |
</tr> |
||||||
<BasicPanel name="Storage" data={this.state.currentStorage} renderRow={this.renderStorageRow} /> |
<tr> |
||||||
</td> |
<td> |
||||||
<td> |
<BasicPanel name='Stack' data={this.state.currentStack} /> |
||||||
<BasicPanel name="Memory" data={this.state.currentMemory} renderRow={this.renderMemoryRow} /> |
</td> |
||||||
</td> |
<td> |
||||||
</tr> |
<BasicPanel name='CallStack' data={this.state.currentCallStack} /> |
||||||
</tbody> |
</td> |
||||||
</table> |
</tr> |
||||||
</div> |
<tr> |
||||||
</div> |
<td> |
||||||
); |
<BasicPanel name='Storage' data={this.state.currentStorage} renderRow={this.renderStorageRow} /> |
||||||
}, |
</td> |
||||||
|
<td> |
||||||
renderStorageRow: function(data) |
<BasicPanel name='Memory' data={this.state.currentMemory} renderRow={this.renderMemoryRow} /> |
||||||
{ |
</td> |
||||||
var ret = [] |
</tr> |
||||||
if (data) |
</tbody> |
||||||
{ |
</table> |
||||||
for (var key in data) |
</div> |
||||||
ret.push(<tr key={key} ><td>{key}</td><td>{data[key]}</td></tr>) |
</div> |
||||||
} |
) |
||||||
return ret |
}, |
||||||
}, |
|
||||||
|
renderStorageRow: function (data) { |
||||||
renderMemoryRow: function(data) |
var ret = [] |
||||||
{ |
if (data) { |
||||||
var ret = [] |
for (var key in data) { |
||||||
if (data) |
ret.push( |
||||||
{ |
<tr key={key}> |
||||||
for (var key in data) |
<td> |
||||||
{ |
{key} |
||||||
var memSlot = data[key] |
</td> |
||||||
ret.push(<tr key={key} ><td>{memSlot.address}</td><td>{memSlot.content.raw}</td><td>{memSlot.content.ascii}</td></tr>) |
<td> |
||||||
} |
{data[key]} |
||||||
} |
</td> |
||||||
return ret |
</tr>) |
||||||
}, |
} |
||||||
|
} |
||||||
resolveAddress: function(address) |
return ret |
||||||
{ |
}, |
||||||
if (!this.state.codes[address]) |
|
||||||
{ |
renderMemoryRow: function (data) { |
||||||
var hexCode = web3.eth.getCode(address)
|
var ret = [] |
||||||
var code = codeUtils.nameOpCodes(new Buffer(hexCode.substring(2), 'hex')) |
if (data) { |
||||||
this.state.codes[address] = code[0] |
for (var key in data) { |
||||||
this.state.instructionsIndexByBytesOffset[address] = code[1] |
var memSlot = data[key] |
||||||
} |
ret.push( |
||||||
},
|
<tr key={key}> |
||||||
|
<td> |
||||||
renderAssemblyItems: function() |
{memSlot.address} |
||||||
{ |
</td> |
||||||
if (this.props.vmTrace) |
<td> |
||||||
{ |
{memSlot.content.raw} |
||||||
return this.state.codes[this.state.currentAddress].map(function(item, i)
|
</td> |
||||||
{ |
<td> |
||||||
return <option key={i} value={i} >{item}</option>; |
{memSlot.content.ascii} |
||||||
});
|
</td> |
||||||
} |
</tr>) |
||||||
}, |
} |
||||||
|
} |
||||||
componentWillReceiveProps: function (nextProps)
|
return ret |
||||||
{
|
}, |
||||||
if (!nextProps.vmTrace) |
|
||||||
return |
resolveAddress: function (address) { |
||||||
this.buildCallStack(nextProps.vmTrace) |
if (!this.state.codes[address]) { |
||||||
this.setState({"currentSelected": -1}) |
var hexCode = web3.eth.getCode(address) |
||||||
this.updateState(nextProps, 0) |
var code = codeUtils.nameOpCodes(new Buffer(hexCode.substring(2), 'hex')) |
||||||
}, |
this.state.codes[address] = code[0] |
||||||
|
this.state.instructionsIndexByBytesOffset[address] = code[1] |
||||||
buildCallStack: function(vmTrace) |
} |
||||||
{ |
}, |
||||||
if (!vmTrace) |
|
||||||
return |
renderAssemblyItems: function () { |
||||||
var callStack = [] |
if (this.props.vmTrace) { |
||||||
var depth = -1 |
return this.state.codes[this.state.currentAddress].map(function (item, i) { |
||||||
for (var k = 0; k < vmTrace.length; k++) |
return <option key={i} value={i}>{item}</option> |
||||||
{ |
}) |
||||||
var trace = vmTrace[k] |
} |
||||||
if (trace.depth === undefined || trace.depth === depth) |
}, |
||||||
continue |
|
||||||
if (trace.depth > depth) |
componentWillReceiveProps: function (nextProps) { |
||||||
callStack.push(trace.address) // new context
|
if (!nextProps.vmTrace) { |
||||||
else if (trace.depth < depth) |
return |
||||||
callStack.pop() // returning from context
|
} |
||||||
depth = trace.depth |
this.buildCallStack(nextProps.vmTrace) |
||||||
this.state.callStack[k] = callStack.slice(0) |
this.setState({'currentSelected': -1}) |
||||||
} |
this.updateState(nextProps, 0) |
||||||
}, |
}, |
||||||
|
|
||||||
updateState: function(props, vmTraceIndex) |
buildCallStack: function (vmTrace) { |
||||||
{ |
if (!vmTrace) { |
||||||
if (!props.vmTrace || !props.vmTrace[vmTraceIndex]) |
return |
||||||
return |
} |
||||||
var previousIndex = this.state.currentSelected |
var callStack = [] |
||||||
var stateChanges = {} |
var depth = -1 |
||||||
|
for (var k = 0; k < vmTrace.length; k++) { |
||||||
if (props.vmTrace[vmTraceIndex].stack) // there's always a stack
|
var trace = vmTrace[k] |
||||||
{ |
if (trace.depth === undefined || trace.depth === depth) { |
||||||
var stack = props.vmTrace[vmTraceIndex].stack |
continue |
||||||
stack.reverse() |
} |
||||||
stateChanges["currentStack"] = stack |
if (trace.depth > depth) { |
||||||
} |
callStack.push(trace.address) // new context
|
||||||
|
} else if (trace.depth < depth) { |
||||||
var currentAddress = this.state.currentAddress |
callStack.pop() // returning from context
|
||||||
var addressIndex = this.shouldUpdateStateProperty("address", vmTraceIndex, previousIndex, props.vmTrace) |
} |
||||||
if (addressIndex > -1) |
depth = trace.depth |
||||||
{ |
this.state.callStack[k] = callStack.slice(0) |
||||||
currentAddress = props.vmTrace[addressIndex].address |
} |
||||||
this.resolveAddress(currentAddress) |
}, |
||||||
Object.assign(stateChanges, { "currentAddress": currentAddress }) |
|
||||||
} |
updateState: function (props, vmTraceIndex) { |
||||||
|
if (!props.vmTrace || !props.vmTrace[vmTraceIndex]) { |
||||||
var depthIndex = this.shouldUpdateStateProperty("depth", vmTraceIndex, previousIndex, props.vmTrace) |
return |
||||||
if (depthIndex > -1) |
} |
||||||
Object.assign(stateChanges, { "currentCallStack": this.state.callStack[depthIndex] }) |
var previousIndex = this.state.currentSelected |
||||||
|
var stateChanges = {} |
||||||
var storageIndex = this.shouldUpdateStateProperty("storage", vmTraceIndex, previousIndex, props.vmTrace) |
|
||||||
if (storageIndex > -1) |
if (props.vmTrace[vmTraceIndex].stack) { // there's always a stack
|
||||||
Object.assign(stateChanges, { "currentStorage": props.vmTrace[storageIndex].storage }) |
var stack = props.vmTrace[vmTraceIndex].stack |
||||||
|
stack.reverse() |
||||||
var memoryIndex = this.shouldUpdateStateProperty("memory", vmTraceIndex, previousIndex, props.vmTrace) |
stateChanges['currentStack'] = stack |
||||||
if (memoryIndex > -1) |
} |
||||||
Object.assign(stateChanges, { "currentMemory": this.formatMemory(props.vmTrace[memoryIndex].memory, 16) }) |
|
||||||
|
var currentAddress = this.state.currentAddress |
||||||
var callDataIndex = this.shouldUpdateStateProperty("calldata", vmTraceIndex, previousIndex, props.vmTrace) |
var addressIndex = this.shouldUpdateStateProperty('address', vmTraceIndex, previousIndex, props.vmTrace) |
||||||
if (callDataIndex > -1) |
if (addressIndex > -1) { |
||||||
Object.assign(stateChanges, { "currentCallData": [props.vmTrace[callDataIndex].calldata] }) |
currentAddress = props.vmTrace[addressIndex].address |
||||||
|
this.resolveAddress(currentAddress) |
||||||
stateChanges["selectedInst"] = this.state.instructionsIndexByBytesOffset[currentAddress][props.vmTrace[vmTraceIndex].pc] |
Object.assign(stateChanges, { 'currentAddress': currentAddress }) |
||||||
stateChanges["currentSelected"] = vmTraceIndex |
} |
||||||
|
|
||||||
stateChanges["currentStepInfo"] = [ |
var depthIndex = this.shouldUpdateStateProperty('depth', vmTraceIndex, previousIndex, props.vmTrace) |
||||||
"Current Step: " + props.vmTrace[vmTraceIndex].steps, |
if (depthIndex > -1) { |
||||||
"Adding Memory: " + (props.vmTrace[vmTraceIndex].memexpand ? props.vmTrace[vmTraceIndex].memexpand : ""), |
Object.assign(stateChanges, { 'currentCallStack': this.state.callStack[depthIndex] }) |
||||||
"Step Cost: " + props.vmTrace[vmTraceIndex].gascost, |
} |
||||||
"Remaining Gas: " + props.vmTrace[vmTraceIndex].gas |
|
||||||
] |
var storageIndex = this.shouldUpdateStateProperty('storage', vmTraceIndex, previousIndex, props.vmTrace) |
||||||
this.refs.slider.setValue(vmTraceIndex) |
if (storageIndex > -1) { |
||||||
this.setState(stateChanges) |
Object.assign(stateChanges, { 'currentStorage': props.vmTrace[storageIndex].storage }) |
||||||
}, |
} |
||||||
|
|
||||||
shouldUpdateStateProperty: function(vmTraceName, nextIndex, previousIndex, vmTrace) |
var memoryIndex = this.shouldUpdateStateProperty('memory', vmTraceIndex, previousIndex, props.vmTrace) |
||||||
{ |
if (memoryIndex > -1) { |
||||||
var propIndex = -1 |
Object.assign(stateChanges, { 'currentMemory': this.formatMemory(props.vmTrace[memoryIndex].memory, 16) }) |
||||||
if (previousIndex + 1 === nextIndex) |
} |
||||||
propIndex = nextIndex |
|
||||||
else |
var callDataIndex = this.shouldUpdateStateProperty('calldata', vmTraceIndex, previousIndex, props.vmTrace) |
||||||
propIndex = this.retrieveLastSeenProperty(nextIndex, vmTraceName, vmTrace) |
if (callDataIndex > -1) { |
||||||
|
Object.assign(stateChanges, { 'currentCallData': [props.vmTrace[callDataIndex].calldata] }) |
||||||
if (propIndex > -1 && vmTrace[propIndex][vmTraceName] !== undefined) |
} |
||||||
return propIndex |
|
||||||
else |
stateChanges['selectedInst'] = this.state.instructionsIndexByBytesOffset[currentAddress][props.vmTrace[vmTraceIndex].pc] |
||||||
return -1 |
stateChanges['currentSelected'] = vmTraceIndex |
||||||
}, |
|
||||||
|
stateChanges['currentStepInfo'] = [ |
||||||
retrieveLastSeenProperty: function(currentIndex, propertyName, vmTrace) |
'Current Step: ' + props.vmTrace[vmTraceIndex].steps, |
||||||
{ |
'Adding Memory: ' + (props.vmTrace[vmTraceIndex].memexpand ? props.vmTrace[vmTraceIndex].memexpand : ''), |
||||||
var index = currentIndex |
'Step Cost: ' + props.vmTrace[vmTraceIndex].gascost, |
||||||
while (index > 0) |
'Remaining Gas: ' + props.vmTrace[vmTraceIndex].gas |
||||||
{ |
] |
||||||
if (vmTrace[index][propertyName]) |
this.refs.slider.setValue(vmTraceIndex) |
||||||
break |
this.setState(stateChanges) |
||||||
index-- |
}, |
||||||
} |
|
||||||
return index
|
shouldUpdateStateProperty: function (vmTraceName, nextIndex, previousIndex, vmTrace) { |
||||||
}, |
var propIndex = -1 |
||||||
|
if (previousIndex + 1 === nextIndex) { |
||||||
stepIntoBack: function() |
propIndex = nextIndex |
||||||
{ |
} else { |
||||||
this.moveSelection(-1) |
propIndex = this.retrieveLastSeenProperty(nextIndex, vmTraceName, vmTrace) |
||||||
}, |
} |
||||||
|
|
||||||
stepIntoForward: function() |
if (propIndex > -1 && vmTrace[propIndex][vmTraceName] !== undefined) { |
||||||
{ |
return propIndex |
||||||
this.moveSelection(1) |
} else { |
||||||
}, |
return -1 |
||||||
|
} |
||||||
stepOverBack: function() |
}, |
||||||
{ |
|
||||||
if (this.isReturnInstruction(this.state.currentSelected - 1)) |
retrieveLastSeenProperty: function (currentIndex, propertyName, vmTrace) { |
||||||
this.stepOutBack(); |
var index = currentIndex |
||||||
else |
while (index > 0) { |
||||||
this.moveSelection(-1); |
if (vmTrace[index][propertyName]) { |
||||||
}, |
break |
||||||
|
} |
||||||
stepOverForward: function() |
index-- |
||||||
{ |
} |
||||||
if (this.isCallInstruction(this.state.currentSelected)) |
return index |
||||||
this.stepOutForward(); |
}, |
||||||
else |
|
||||||
this.moveSelection(1); |
stepIntoBack: function () { |
||||||
}, |
this.moveSelection(-1) |
||||||
|
}, |
||||||
isCallInstruction: function(index) |
|
||||||
{ |
stepIntoForward: function () { |
||||||
var state = this.props.vmTrace[index]; |
this.moveSelection(1) |
||||||
return state.instname === "CALL" || state.instname === "CALLCODE" || state.instname === "CREATE" || state.instname === "DELEGATECALL" |
}, |
||||||
}, |
|
||||||
|
stepOverBack: function () { |
||||||
isReturnInstruction: function(index) |
if (this.isReturnInstruction(this.state.currentSelected - 1)) { |
||||||
{ |
this.stepOutBack() |
||||||
var state = this.props.vmTrace[index]; |
} else { |
||||||
return state.instname === "RETURN" |
this.moveSelection(-1) |
||||||
}, |
} |
||||||
|
}, |
||||||
stepOutBack: function() |
|
||||||
{ |
stepOverForward: function () { |
||||||
var i = this.state.currentSelected - 1; |
if (this.isCallInstruction(this.state.currentSelected)) { |
||||||
var depth = 0; |
this.stepOutForward() |
||||||
while (--i >= 0)
|
} else { |
||||||
{ |
this.moveSelection(1) |
||||||
if (this.isCallInstruction(i)) |
} |
||||||
{ |
}, |
||||||
if (depth == 0) |
|
||||||
break; |
isCallInstruction: function (index) { |
||||||
else |
var state = this.props.vmTrace[index] |
||||||
depth--; |
return state.instname === 'CALL' || state.instname === 'CALLCODE' || state.instname === 'CREATE' || state.instname === 'DELEGATECALL' |
||||||
} |
}, |
||||||
else if (this.isReturnInstruction(i)) |
|
||||||
depth++; |
isReturnInstruction: function (index) { |
||||||
|
var state = this.props.vmTrace[index] |
||||||
} |
return state.instname === 'RETURN' |
||||||
this.selectState(i); |
}, |
||||||
}, |
|
||||||
|
stepOutBack: function () { |
||||||
stepOutForward: function() |
var i = this.state.currentSelected - 1 |
||||||
{ |
var depth = 0 |
||||||
var i = this.state.currentSelected |
while (--i >= 0) { |
||||||
var depth = 0 |
if (this.isCallInstruction(i)) { |
||||||
while (++i < this.props.vmTrace.length)
|
if (depth === 0) { |
||||||
{ |
break |
||||||
if (this.isReturnInstruction(i)) |
} else { |
||||||
{ |
depth-- |
||||||
if (depth == 0) |
} |
||||||
break |
} else if (this.isReturnInstruction(i)) { |
||||||
else |
depth++ |
||||||
depth-- |
} |
||||||
} |
} |
||||||
else if (this.isCallInstruction(i)) |
this.selectState(i) |
||||||
depth++ |
}, |
||||||
} |
|
||||||
this.selectState(i + 1); |
stepOutForward: function () { |
||||||
}, |
var i = this.state.currentSelected |
||||||
|
var depth = 0 |
||||||
moveSelection: function(incr) |
while (++i < this.props.vmTrace.length) { |
||||||
{ |
if (this.isReturnInstruction(i)) { |
||||||
this.selectState(this.state.currentSelected + incr) |
if (depth === 0) { |
||||||
}, |
break |
||||||
|
} else { |
||||||
selectState: function(index) |
depth-- |
||||||
{ |
} |
||||||
this.updateState(this.props, index) |
} else if (this.isCallInstruction(i)) { |
||||||
}, |
depth++ |
||||||
|
} |
||||||
formatMemory: function(mem, width) |
} |
||||||
{ |
this.selectState(i + 1) |
||||||
var ret = [] |
}, |
||||||
for (var k = 0; k < mem.length; k += (width * 2)) |
|
||||||
{ |
moveSelection: function (incr) { |
||||||
var memory = mem.substr(k, width * 2) |
this.selectState(this.state.currentSelected + incr) |
||||||
ret.push({ |
}, |
||||||
address: web3.toHex(k), |
|
||||||
content: this.tryAsciiFormat(memory) |
selectState: function (index) { |
||||||
}) |
this.updateState(this.props, index) |
||||||
} |
}, |
||||||
return ret |
|
||||||
}, |
formatMemory: function (mem, width) { |
||||||
|
var ret = [] |
||||||
tryAsciiFormat: function(memorySlot) |
for (var k = 0; k < mem.length; k += (width * 2)) { |
||||||
{ |
var memory = mem.substr(k, width * 2) |
||||||
var ret = { ascii: "", raw: "" } |
ret.push({ |
||||||
for (var k = 0; k < memorySlot.length; k += 2) |
address: web3.toHex(k), |
||||||
{ |
content: this.tryAsciiFormat(memory) |
||||||
var raw = memorySlot.substr(k, 2) |
}) |
||||||
var ascii = web3.toAscii(raw) |
} |
||||||
if (ascii === String.fromCharCode(0)) |
return ret |
||||||
ret.ascii += "?" |
}, |
||||||
else |
|
||||||
ret.ascii += ascii |
tryAsciiFormat: function (memorySlot) { |
||||||
ret.raw += " " + raw |
var ret = { ascii: '', raw: '' } |
||||||
} |
for (var k = 0; k < memorySlot.length; k += 2) { |
||||||
return ret |
var raw = memorySlot.substr(k, 2) |
||||||
} |
var ascii = web3.toAscii(raw) |
||||||
|
if (ascii === String.fromCharCode(0)) { |
||||||
|
ret.ascii += '?' |
||||||
|
} else { |
||||||
|
ret.ascii += ascii |
||||||
|
} |
||||||
|
ret.raw += ' ' + raw |
||||||
|
} |
||||||
|
return ret |
||||||
|
} |
||||||
}) |
}) |
||||||
|
@ -1,45 +1,49 @@ |
|||||||
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 () { |
||||||
|
return { |
||||||
|
data: null, |
||||||
|
name: null, |
||||||
|
renderRow: null |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
getDefaultProps: function()
|
render: function () { |
||||||
{ |
return ( |
||||||
return { |
<div style={style.panel.container}> |
||||||
data: null, |
<div style={style.panel.title}> |
||||||
name: null, |
{this.props.name} |
||||||
renderRow: null |
</div> |
||||||
}; |
<div style={style.panel.tableContainer}> |
||||||
}, |
<table style={style.panel.table}> |
||||||
|
<tbody> |
||||||
|
{this.renderItems()} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
) |
||||||
|
}, |
||||||
|
|
||||||
render: function()
|
renderItems: function () { |
||||||
{
|
if (!this.props.data) { |
||||||
return ( |
return [] |
||||||
<div style={style.panel.container}> |
} |
||||||
<div style={style.panel.title} >{this.props.name}</div> |
if (!this.props.renderRow) { |
||||||
<div style={style.panel.tableContainer} > |
var ret = [] |
||||||
<table style={style.panel.table}> |
for (var key in this.props.data) { |
||||||
<tbody> |
ret.push( |
||||||
{this.renderItems()} |
<tr key={key}> |
||||||
</tbody> |
<td> |
||||||
</table> |
{this.props.data[key]} |
||||||
</div> |
</td> |
||||||
</div> |
</tr>) |
||||||
); |
} |
||||||
}, |
return ret |
||||||
|
} else { |
||||||
renderItems: function() |
return this.props.renderRow(this.props.data) |
||||||
{ |
} |
||||||
if (!this.props.data) |
} |
||||||
return [] |
|
||||||
if (!this.props.renderRow) |
|
||||||
{ |
|
||||||
var ret = []
|
|
||||||
for (var key in this.props.data) |
|
||||||
ret.push(<tr key={key} ><td>{this.props.data[key]}</td></tr>) |
|
||||||
return ret |
|
||||||
} |
|
||||||
else |
|
||||||
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', |
||||||
{ |
'padding': '5px' |
||||||
'margin': '10px', |
}, |
||||||
'padding': '5px' |
address: { |
||||||
}, |
'fontStyle': 'italic' |
||||||
address: |
}, |
||||||
{ |
instructionsList: { |
||||||
'fontStyle': 'italic' |
'width': '320px' |
||||||
}, |
}, |
||||||
instructionsList: |
transactionInfo: { |
||||||
{ |
'marginTop': '5px' |
||||||
'width': "320px" |
}, |
||||||
}, |
panel: { |
||||||
transactionInfo: |
container: { |
||||||
{ |
'border': '1px solid', |
||||||
'marginTop': '5px' |
'width': '600px' |
||||||
}, |
}, |
||||||
panel: |
tableContainer: { |
||||||
{ |
'height': '150px', |
||||||
container: |
'overflowY': 'auto' |
||||||
{ |
}, |
||||||
'border': '1px solid', |
table: { |
||||||
'width': '600px' |
'padding': '5px' |
||||||
}, |
}, |
||||||
tableContainer: |
title: { |
||||||
{ |
'padding': '5px', |
||||||
'height': '150px', |
'fontStyle': 'italic' |
||||||
'overflowY': 'auto' |
} |
||||||
}, |
}, |
||||||
table: |
hidden: { |
||||||
{ |
'display': 'none' |
||||||
'padding': '5px' |
}, |
||||||
}, |
display: { |
||||||
title: |
'display': 'block' |
||||||
{ |
}, |
||||||
'padding': '5px', |
sticker: { |
||||||
'fontStyle': 'italic' |
'verticalAlign': 'top', |
||||||
} |
'margin': '5px' |
||||||
}, |
}, |
||||||
hidden: |
inline: { |
||||||
{ |
'display': 'inline-block' |
||||||
'display': 'none' |
} |
||||||
}, |
|
||||||
display: |
|
||||||
{ |
|
||||||
'display': 'block' |
|
||||||
}, |
|
||||||
sticker: |
|
||||||
{ |
|
||||||
'verticalAlign': 'top', |
|
||||||
'margin': '5px' |
|
||||||
}, |
|
||||||
inline: |
|
||||||
{ |
|
||||||
'display': 'inline-block' |
|
||||||
} |
|
||||||
} |
} |
@ -1,43 +1,39 @@ |
|||||||
var opcodes = require('./opcodes') |
var opcodes = require('./opcodes') |
||||||
|
|
||||||
module.exports = { |
module.exports = { |
||||||
|
nameOpCodes: function (raw) { |
||||||
|
var pushData = '' |
||||||
|
var codeMap = {} |
||||||
|
var code = [] |
||||||
|
|
||||||
nameOpCodes: function (raw)
|
for (var i = 0; i < raw.length; i++) { |
||||||
{ |
var pc = i |
||||||
var pushData = '' |
var curOpCode = opcodes(raw[pc], false).name |
||||||
var codeMap = {} |
codeMap[i] = code.length |
||||||
var code = [] |
// no destinations into the middle of PUSH
|
||||||
|
if (curOpCode.slice(0, 4) === 'PUSH') { |
||||||
|
var jumpNum = raw[pc] - 0x5f |
||||||
|
pushData = raw.slice(pc + 1, pc + jumpNum + 1) |
||||||
|
i += jumpNum |
||||||
|
} |
||||||
|
|
||||||
for (var i = 0; i < raw.length; i++) |
code.push(this.pad(pc, this.roundLog(raw.length, 10)) + ' ' + curOpCode + ' ' + pushData.toString('hex')) |
||||||
{ |
pushData = '' |
||||||
var pc = i |
} |
||||||
var curOpCode = opcodes(raw[pc], false).name |
return [ code, codeMap ] |
||||||
codeMap[i] = code.length |
}, |
||||||
// no destinations into the middle of PUSH
|
|
||||||
if (curOpCode.slice(0, 4) === 'PUSH')
|
|
||||||
{ |
|
||||||
var jumpNum = raw[pc] - 0x5f |
|
||||||
pushData = raw.slice(pc + 1, pc + jumpNum + 1) |
|
||||||
i += jumpNum |
|
||||||
} |
|
||||||
|
|
||||||
code.push(this.pad(pc, this.roundLog(raw.length, 10)) + ' ' + curOpCode + ' ' + pushData.toString('hex')) |
pad: function (num, size) { |
||||||
pushData = '' |
var s = num + '' |
||||||
} |
while (s.length < size) s = '0' + s |
||||||
return [ code, codeMap ] |
return s |
||||||
}, |
}, |
||||||
|
|
||||||
pad: function (num, size) { |
log: function (num, base) { |
||||||
var s = num + '' |
return Math.log(num) / Math.log(base) |
||||||
while (s.length < size) s = '0' + s |
}, |
||||||
return s |
|
||||||
}, |
|
||||||
|
|
||||||
log: function (num, base) { |
roundLog: function (num, base) { |
||||||
return Math.log(num) / Math.log(base) |
return Math.ceil(this.log(num, base)) |
||||||
}, |
} |
||||||
|
|
||||||
roundLog: function (num, base) { |
|
||||||
return Math.ceil(this.log(num, base)) |
|
||||||
} |
|
||||||
} |
} |
@ -1,32 +1,36 @@ |
|||||||
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 () { |
||||||
return ( |
return ( |
||||||
<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}> |
||||||
<VmTraceBrowser vmTrace={this.state.vmTrace} /> |
{this.state.state} |
||||||
</div> |
</div> |
||||||
); |
<VmTraceBrowser vmTrace={this.state.vmTrace} /> |
||||||
}, |
</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) { |
||||||
{ |
console.log(error) |
||||||
deb.setState({vmTrace: result, state: ""}); |
} 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,36 +1,42 @@ |
|||||||
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: { |
||||||
|
onChange: React.PropTypes.func.isRequired |
||||||
|
}, |
||||||
|
|
||||||
propTypes: { |
getDefaultProps: function () { |
||||||
onChange: React.PropTypes.func.isRequired, |
return { |
||||||
}, |
min: 0, |
||||||
|
max: 500 |
||||||
getDefaultProps: function () { |
} |
||||||
return { |
}, |
||||||
min: 0, |
|
||||||
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 |
||||||
</div> |
ref='rule' |
||||||
); |
style={style.rule} |
||||||
}, |
type='range' |
||||||
|
min={this.props.min} |
||||||
|
max={this.props.max} |
||||||
|
onMouseUp={this.onMouseUp} /> |
||||||
|
</div> |
||||||
|
) |
||||||
|
}, |
||||||
|
|
||||||
onMouseUp: function (event) { |
onMouseUp: function (event) { |
||||||
this.props.onChange(parseInt(this.refs.rule.value)) |
this.props.onChange(parseInt(this.refs.rule.value)) |
||||||
}, |
}, |
||||||
|
|
||||||
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,17 +1,15 @@ |
|||||||
module.exports = { |
module.exports = { |
||||||
rule: |
rule: { |
||||||
{ |
'width': '600px' |
||||||
'width': '600px', |
}, |
||||||
},
|
runner: { |
||||||
runner: |
'position': 'absolute', |
||||||
{ |
'width': '16px', |
||||||
'position': 'absolute', |
'height': '16px', |
||||||
'width': '16px', |
'margin': '0', |
||||||
'height': '16px', |
'padding': '0', |
||||||
'margin': '0', |
'overflow': 'hidden', |
||||||
'padding': '0', |
'border': '1px solid #a4bed4', |
||||||
'overflow': 'hidden', |
'background-color': '#f1f7ff' |
||||||
'border': '1px solid #a4bed4', |
} |
||||||
'background-color': '#f1f7ff' |
|
||||||
} |
|
||||||
} |
} |
@ -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 () { |
||||||
|
return { |
||||||
|
data: null |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
getDefaultProps: function()
|
render: function () { |
||||||
{ |
return ( |
||||||
return { |
<div> |
||||||
data: null, |
<table> |
||||||
}; |
<tbody> |
||||||
}, |
{this.renderItems()} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
) |
||||||
|
}, |
||||||
|
|
||||||
render: function()
|
renderItems: function () { |
||||||
{
|
if (this.props.data) { |
||||||
return ( |
var ret = [] |
||||||
<div> |
for (var key in this.props.data) { |
||||||
<table><tbody> |
ret.push( |
||||||
{this.renderItems()} |
<tr key={key}> |
||||||
</tbody></table> |
<td> |
||||||
</div> |
{this.props.data[key]} |
||||||
); |
</td> |
||||||
}, |
</tr>) |
||||||
|
} |
||||||
renderItems: function() |
return ret |
||||||
{ |
} |
||||||
|
return null |
||||||
if (this.props.data) |
} |
||||||
{ |
|
||||||
var ret = []
|
|
||||||
for (var key in this.props.data) |
|
||||||
ret.push(<tr key={key}><td>{this.props.data[key]}</td></tr>) |
|
||||||
return ret
|
|
||||||
} |
|
||||||
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}> |
||||||
<div style={style.transactionInfo}> |
Get |
||||||
<div>Hash: {this.state.hash}</div> |
</button> |
||||||
<div>From: {this.state.from}</div> |
<div style={style.transactionInfo}> |
||||||
<div>To: {this.state.to}</div> |
<div> |
||||||
</div> |
Hash: |
||||||
</div> |
{this.state.hash} |
||||||
); |
</div> |
||||||
} |
<div> |
||||||
|
From: |
||||||
|
{this.state.from} |
||||||
|
</div> |
||||||
|
<div> |
||||||
|
To: |
||||||
|
{this.state.to} |
||||||
|
</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: { |
||||||
|
stepIntoBack: React.PropTypes.func.isRequired, |
||||||
|
stepIntoForward: React.PropTypes.func.isRequired, |
||||||
|
stepOverBack: React.PropTypes.func.isRequired, |
||||||
|
stepOverForward: React.PropTypes.func.isRequired |
||||||
|
}, |
||||||
|
|
||||||
propTypes: { |
render: function () { |
||||||
stepIntoBack: React.PropTypes.func.isRequired, |
return ( |
||||||
stepIntoForward: React.PropTypes.func.isRequired, |
<div> |
||||||
stepOverBack: React.PropTypes.func.isRequired, |
<button onClick={this.props.stepIntoBack} disabled={this.checkButtonState(-1)}> |
||||||
stepOverForward: React.PropTypes.func.isRequired, |
Step Into Back |
||||||
}, |
</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> |
||||||
|
) |
||||||
|
}, |
||||||
|
|
||||||
render: function() {
|
checkButtonState: function (incr) { |
||||||
return ( |
if (incr === -1) { |
||||||
<div> |
return this.props.step === 0 ? 'disabled' : '' |
||||||
<button onClick={this.props.stepIntoBack} disabled={this.checkButtonState(-1)} >Step Into Back</button> |
} else if (incr === 1) { |
||||||
<button onClick={this.props.stepOverBack} disabled={this.checkButtonState(-1)} >Step Over Back</button> |
return this.props.step >= this.props.vmTraceLength - 1 ? 'disabled' : '' |
||||||
<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> |
|
||||||
); |
|
||||||
}, |
|
||||||
|
|
||||||
checkButtonState: function(incr) |
|
||||||
{ |
|
||||||
if (incr === -1) |
|
||||||
return this.props.step === 0 ? "disabled" : "" |
|
||||||
else if (incr === 1) |
|
||||||
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,277 +1,262 @@ |
|||||||
module.exports = { |
module.exports = { |
||||||
extend: function(web3) { |
extend: function (web3) { |
||||||
|
// ADMIN
|
||||||
|
web3._extend({ |
||||||
|
property: 'admin', |
||||||
|
methods: [ |
||||||
|
new web3._extend.Method({ |
||||||
|
name: 'addPeer', |
||||||
|
call: 'admin_addPeer', |
||||||
|
params: 1, |
||||||
|
inputFormatter: [web3._extend.utils.fromDecimal], |
||||||
|
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
|
}), |
||||||
|
new web3._extend.Method({ |
||||||
|
name: 'exportChain', |
||||||
|
call: 'admin_exportChain', |
||||||
|
params: 1, |
||||||
|
inputFormatter: [null], |
||||||
|
outputFormatter: function (obj) { return obj } |
||||||
|
}), |
||||||
|
new web3._extend.Method({ |
||||||
|
name: 'importChain', |
||||||
|
call: 'admin_importChain', |
||||||
|
params: 1, |
||||||
|
inputFormatter: [null], |
||||||
|
outputFormatter: function (obj) { return obj } |
||||||
|
}), |
||||||
|
new web3._extend.Method({ |
||||||
|
name: 'verbosity', |
||||||
|
call: 'admin_verbosity', |
||||||
|
params: 1, |
||||||
|
inputFormatter: [web3._extend.utils.formatInputInt], |
||||||
|
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
|
}), |
||||||
|
new web3._extend.Method({ |
||||||
|
name: 'setSolc', |
||||||
|
call: 'admin_setSolc', |
||||||
|
params: 1, |
||||||
|
inputFormatter: [null], |
||||||
|
outputFormatter: web3._extend.formatters.formatOutputString |
||||||
|
}), |
||||||
|
new web3._extend.Method({ |
||||||
|
name: 'startRPC', |
||||||
|
call: 'admin_startRPC', |
||||||
|
params: 4, |
||||||
|
inputFormatter: [null, web3._extend.utils.formatInputInteger, null, null], |
||||||
|
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
|
}), |
||||||
|
new web3._extend.Method({ |
||||||
|
name: 'stopRPC', |
||||||
|
call: 'admin_stopRPC', |
||||||
|
params: 0, |
||||||
|
inputFormatter: [], |
||||||
|
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
|
}), |
||||||
|
new web3._extend.Method({ |
||||||
|
name: 'vmTrace', |
||||||
|
call: 'admin_eth_vmTrace', |
||||||
|
inputFormatter: [null, null, null], |
||||||
|
params: 3 |
||||||
|
}) |
||||||
|
], |
||||||
|
properties: [ |
||||||
|
new web3._extend.Property({ |
||||||
|
name: 'nodeInfo', |
||||||
|
getter: 'admin_nodeInfo', |
||||||
|
outputFormatter: web3._extend.formatters.formatOutputString |
||||||
|
}), |
||||||
|
new web3._extend.Property({ |
||||||
|
name: 'peers', |
||||||
|
getter: 'admin_peers', |
||||||
|
outputFormatter: function (obj) { return obj } |
||||||
|
}), |
||||||
|
new web3._extend.Property({ |
||||||
|
name: 'datadir', |
||||||
|
getter: 'admin_datadir', |
||||||
|
outputFormatter: web3._extend.formatters.formatOutputString |
||||||
|
}), |
||||||
|
new web3._extend.Property({ |
||||||
|
name: 'chainSyncStatus', |
||||||
|
getter: 'admin_chainSyncStatus', |
||||||
|
outputFormatter: function (obj) { return obj } |
||||||
|
}) |
||||||
|
] |
||||||
|
}) |
||||||
|
|
||||||
// ADMIN
|
// DEBUG
|
||||||
web3._extend({ |
web3._extend({ |
||||||
property: 'admin', |
property: 'debug', |
||||||
methods: |
methods: [ |
||||||
[ |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'trace', |
||||||
name: 'addPeer', |
call: 'debug_trace', |
||||||
call: 'admin_addPeer', |
inputFormatter: [null, null], |
||||||
params: 1, |
params: 2 |
||||||
inputFormatter: [web3._extend.utils.fromDecimal], |
}), |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
new web3._extend.Method({ |
||||||
}), |
name: 'printBlock', |
||||||
new web3._extend.Method({ |
call: 'debug_printBlock', |
||||||
name: 'exportChain', |
params: 1, |
||||||
call: 'admin_exportChain', |
inputFormatter: [web3._extend.formatters.formatInputInt], |
||||||
params: 1, |
outputFormatter: web3._extend.formatters.formatOutputString |
||||||
inputFormatter: [null], |
}), |
||||||
outputFormatter: function(obj) { return obj; } |
new web3._extend.Method({ |
||||||
}), |
name: 'getBlockRlp', |
||||||
new web3._extend.Method({ |
call: 'debug_getBlockRlp', |
||||||
name: 'importChain', |
params: 1, |
||||||
call: 'admin_importChain', |
inputFormatter: [web3._extend.formatters.formatInputInt], |
||||||
params: 1, |
outputFormatter: web3._extend.formatters.formatOutputString |
||||||
inputFormatter: [null], |
}), |
||||||
outputFormatter: function(obj) { return obj; } |
new web3._extend.Method({ |
||||||
}), |
name: 'setHead', |
||||||
new web3._extend.Method({ |
call: 'debug_setHead', |
||||||
name: 'verbosity', |
params: 1, |
||||||
call: 'admin_verbosity', |
inputFormatter: [web3._extend.formatters.formatInputInt], |
||||||
params: 1, |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
inputFormatter: [web3._extend.utils.formatInputInt], |
}), |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
new web3._extend.Method({ |
||||||
}), |
name: 'processBlock', |
||||||
new web3._extend.Method({ |
call: 'debug_processBlock', |
||||||
name: 'setSolc', |
params: 1, |
||||||
call: 'admin_setSolc', |
inputFormatter: [web3._extend.formatters.formatInputInt], |
||||||
params: 1, |
outputFormatter: function (obj) { return obj } |
||||||
inputFormatter: [null], |
}), |
||||||
outputFormatter: web3._extend.formatters.formatOutputString |
new web3._extend.Method({ |
||||||
}), |
name: 'seedHash', |
||||||
new web3._extend.Method({ |
call: 'debug_seedHash', |
||||||
name: 'startRPC', |
params: 1, |
||||||
call: 'admin_startRPC', |
inputFormatter: [web3._extend.formatters.formatInputInt], |
||||||
params: 4, |
outputFormatter: web3._extend.formatters.formatOutputString |
||||||
inputFormatter: [null,web3._extend.utils.formatInputInteger,null,null], |
}), |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
new web3._extend.Method({ |
||||||
}), |
name: 'dumpBlock', |
||||||
new web3._extend.Method({ |
call: 'debug_dumpBlock', |
||||||
name: 'stopRPC', |
params: 1, |
||||||
call: 'admin_stopRPC', |
inputFormatter: [web3._extend.formatters.formatInputInt], |
||||||
params: 0, |
outputFormatter: function (obj) { return obj } |
||||||
inputFormatter: [], |
}) |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
], |
||||||
}), |
properties: [] |
||||||
new web3._extend.Method({ |
}) |
||||||
name: 'vmTrace', |
|
||||||
call: 'admin_eth_vmTrace', |
|
||||||
inputFormatter: [null, null, null], |
|
||||||
params: 3 |
|
||||||
}),
|
|
||||||
], |
|
||||||
properties: |
|
||||||
[ |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'nodeInfo', |
|
||||||
getter: 'admin_nodeInfo', |
|
||||||
outputFormatter: web3._extend.formatters.formatOutputString |
|
||||||
}), |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'peers', |
|
||||||
getter: 'admin_peers', |
|
||||||
outputFormatter: function(obj) { return obj; } |
|
||||||
}), |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'datadir', |
|
||||||
getter: 'admin_datadir', |
|
||||||
outputFormatter: web3._extend.formatters.formatOutputString |
|
||||||
}), |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'chainSyncStatus', |
|
||||||
getter: 'admin_chainSyncStatus', |
|
||||||
outputFormatter: function(obj) { return obj; } |
|
||||||
}) |
|
||||||
] |
|
||||||
}); |
|
||||||
|
|
||||||
// DEBUG
|
// MINER
|
||||||
web3._extend({ |
web3._extend({ |
||||||
property: 'debug', |
property: 'miner', |
||||||
methods: |
methods: [ |
||||||
[ |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'start', |
||||||
name: 'trace', |
call: 'miner_start', |
||||||
call: 'debug_trace', |
params: 1, |
||||||
params: 1, |
inputFormatter: [web3._extend.formatters.formatInputInt], |
||||||
inputFormatter: [null, null], |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
params: 2 |
}), |
||||||
}), |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'stop', |
||||||
name: 'printBlock', |
call: 'miner_stop', |
||||||
call: 'debug_printBlock', |
params: 1, |
||||||
params: 1, |
inputFormatter: [web3._extend.formatters.formatInputInt], |
||||||
inputFormatter: [web3._extend.formatters.formatInputInt], |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
outputFormatter: web3._extend.formatters.formatOutputString |
}), |
||||||
}), |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'setExtra', |
||||||
name: 'getBlockRlp', |
call: 'miner_setExtra', |
||||||
call: 'debug_getBlockRlp', |
params: 1, |
||||||
params: 1, |
inputFormatter: [web3._extend.utils.formatInputString], |
||||||
inputFormatter: [web3._extend.formatters.formatInputInt], |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
outputFormatter: web3._extend.formatters.formatOutputString |
}), |
||||||
}), |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'setGasPrice', |
||||||
name: 'setHead', |
call: 'miner_setGasPrice', |
||||||
call: 'debug_setHead', |
params: 1, |
||||||
params: 1, |
inputFormatter: [web3._extend.utils.formatInputString], |
||||||
inputFormatter: [web3._extend.formatters.formatInputInt], |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
}), |
||||||
}), |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'startAutoDAG', |
||||||
name: 'processBlock', |
call: 'miner_startAutoDAG', |
||||||
call: 'debug_processBlock', |
params: 0, |
||||||
params: 1, |
inputFormatter: [], |
||||||
inputFormatter: [web3._extend.formatters.formatInputInt], |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
outputFormatter: function(obj) { return obj; } |
}), |
||||||
}), |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'stopAutoDAG', |
||||||
name: 'seedHash', |
call: 'miner_stopAutoDAG', |
||||||
call: 'debug_seedHash', |
params: 0, |
||||||
params: 1, |
inputFormatter: [], |
||||||
inputFormatter: [web3._extend.formatters.formatInputInt], |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
outputFormatter: web3._extend.formatters.formatOutputString |
}), |
||||||
}) , |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'makeDAG', |
||||||
name: 'dumpBlock', |
call: 'miner_makeDAG', |
||||||
call: 'debug_dumpBlock', |
params: 1, |
||||||
params: 1, |
inputFormatter: [web3._extend.formatters.inputDefaultBlockNumberFormatter], |
||||||
inputFormatter: [web3._extend.formatters.formatInputInt], |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
outputFormatter: function(obj) { return obj; } |
}) |
||||||
}) |
], |
||||||
], |
properties: [ |
||||||
properties: |
new web3._extend.Property({ |
||||||
[ |
name: 'hashrate', |
||||||
] |
getter: 'miner_hashrate', |
||||||
}); |
outputFormatter: web3._extend.utils.toDecimal |
||||||
|
}) |
||||||
|
] |
||||||
|
}) |
||||||
|
|
||||||
// MINER
|
// NETWORK
|
||||||
web3._extend({ |
web3._extend({ |
||||||
property: 'miner', |
property: 'network', |
||||||
methods: |
methods: [ |
||||||
[ |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'addPeer', |
||||||
name: 'start', |
call: 'net_addPeer', |
||||||
call: 'miner_start', |
params: 1, |
||||||
params: 1, |
inputFormatter: [web3._extend.utils.formatInputString], |
||||||
inputFormatter: [web3._extend.formatters.formatInputInt], |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
}), |
||||||
}), |
new web3._extend.Method({ |
||||||
new web3._extend.Method({ |
name: 'getPeerCount', |
||||||
name: 'stop', |
call: 'net_peerCount', |
||||||
call: 'miner_stop', |
params: 0, |
||||||
params: 1, |
inputFormatter: [], |
||||||
inputFormatter: [web3._extend.formatters.formatInputInt], |
outputFormatter: web3._extend.formatters.formatOutputString |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
}) |
||||||
}), |
], |
||||||
new web3._extend.Method({ |
properties: [ |
||||||
name: 'setExtra', |
new web3._extend.Property({ |
||||||
call: 'miner_setExtra', |
name: 'listening', |
||||||
params: 1, |
getter: 'net_listening', |
||||||
inputFormatter: [web3._extend.utils.formatInputString], |
outputFormatter: web3._extend.formatters.formatOutputBool |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
}), |
||||||
}), |
new web3._extend.Property({ |
||||||
new web3._extend.Method({ |
name: 'peerCount', |
||||||
name: 'setGasPrice', |
getter: 'net_peerCount', |
||||||
call: 'miner_setGasPrice', |
outputFormatter: web3._extend.utils.toDecimal |
||||||
params: 1, |
}), |
||||||
inputFormatter: [web3._extend.utils.formatInputString], |
new web3._extend.Property({ |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
name: 'peers', |
||||||
}), |
getter: 'net_peers', |
||||||
new web3._extend.Method({ |
outputFormatter: function (obj) { return obj } |
||||||
name: 'startAutoDAG', |
}), |
||||||
call: 'miner_startAutoDAG', |
new web3._extend.Property({ |
||||||
params: 0, |
name: 'version', |
||||||
inputFormatter: [], |
getter: 'net_version', |
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
outputFormatter: web3._extend.formatters.formatOutputString |
||||||
}), |
}) |
||||||
new web3._extend.Method({ |
] |
||||||
name: 'stopAutoDAG', |
}) |
||||||
call: 'miner_stopAutoDAG', |
|
||||||
params: 0, |
|
||||||
inputFormatter: [], |
|
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
|
||||||
}), |
|
||||||
new web3._extend.Method({ |
|
||||||
name: 'makeDAG', |
|
||||||
call: 'miner_makeDAG', |
|
||||||
params: 1, |
|
||||||
inputFormatter: [web3._extend.formatters.inputDefaultBlockNumberFormatter], |
|
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
|
||||||
}) |
|
||||||
], |
|
||||||
properties: |
|
||||||
[ |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'hashrate', |
|
||||||
getter: 'miner_hashrate', |
|
||||||
outputFormatter: web3._extend.utils.toDecimal |
|
||||||
}) |
|
||||||
] |
|
||||||
}); |
|
||||||
|
|
||||||
// NETWORK
|
|
||||||
web3._extend({ |
|
||||||
property: 'network', |
|
||||||
methods: |
|
||||||
[ |
|
||||||
new web3._extend.Method({ |
|
||||||
name: 'addPeer', |
|
||||||
call: 'net_addPeer', |
|
||||||
params: 1, |
|
||||||
inputFormatter: [web3._extend.utils.formatInputString], |
|
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
|
||||||
}), |
|
||||||
new web3._extend.Method({ |
|
||||||
name: 'getPeerCount', |
|
||||||
call: 'net_peerCount', |
|
||||||
params: 0, |
|
||||||
inputFormatter: [], |
|
||||||
outputFormatter: web3._extend.formatters.formatOutputString |
|
||||||
}) |
|
||||||
], |
|
||||||
properties: |
|
||||||
[ |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'listening', |
|
||||||
getter: 'net_listening', |
|
||||||
outputFormatter: web3._extend.formatters.formatOutputBool |
|
||||||
}), |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'peerCount', |
|
||||||
getter: 'net_peerCount', |
|
||||||
outputFormatter: web3._extend.utils.toDecimal |
|
||||||
}), |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'peers', |
|
||||||
getter: 'net_peers', |
|
||||||
outputFormatter: function(obj) { return obj; } |
|
||||||
}), |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'version', |
|
||||||
getter: 'net_version', |
|
||||||
outputFormatter: web3._extend.formatters.formatOutputString |
|
||||||
}) |
|
||||||
] |
|
||||||
}); |
|
||||||
|
|
||||||
// TX POOL
|
|
||||||
web3._extend({ |
|
||||||
property: 'txpool', |
|
||||||
methods: |
|
||||||
[ |
|
||||||
], |
|
||||||
properties: |
|
||||||
[ |
|
||||||
new web3._extend.Property({ |
|
||||||
name: 'status', |
|
||||||
getter: 'txpool_status', |
|
||||||
outputFormatter: function(obj) { return obj; } |
|
||||||
}) |
|
||||||
] |
|
||||||
}); |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
|
// TX POOL
|
||||||
|
web3._extend({ |
||||||
|
property: 'txpool', |
||||||
|
methods: [], |
||||||
|
properties: [ |
||||||
|
new web3._extend.Property({ |
||||||
|
name: 'status', |
||||||
|
getter: 'txpool_status', |
||||||
|
outputFormatter: function (obj) { return obj } |
||||||
|
}) |
||||||
|
] |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
Loading…
Reference in new issue