Commit 505d7436 authored by yann300's avatar yann300

add error param in callback functions

parent 28cb70ee
...@@ -48,8 +48,12 @@ module.exports = React.createClass({ ...@@ -48,8 +48,12 @@ module.exports = React.createClass({
if (nextProps.currentStepIndex < 0) return if (nextProps.currentStepIndex < 0) return
codeResolver.setWeb3(this.context.web3) codeResolver.setWeb3(this.context.web3)
var self = this var self = this
this.context.traceManager.getCurrentCalledAddressAt(nextProps.currentStepIndex, function (address) { this.context.traceManager.getCurrentCalledAddressAt(nextProps.currentStepIndex, function (error, address) {
if (error) {
console.log(error)
} else {
self.ensureCodeLoaded(address, nextProps.currentStepIndex) self.ensureCodeLoaded(address, nextProps.currentStepIndex)
}
}) })
}, },
...@@ -77,10 +81,14 @@ module.exports = React.createClass({ ...@@ -77,10 +81,14 @@ module.exports = React.createClass({
setInstructionIndex: function (address, step) { setInstructionIndex: function (address, step) {
var self = this var self = this
this.context.traceManager.getCurrentPC(step, function (instIndex) { this.context.traceManager.getCurrentPC(step, function (error, instIndex) {
if (error) {
console.log(error)
} else {
self.setState({ self.setState({
selected: codeResolver.getInstructionIndex(address, instIndex) selected: codeResolver.getInstructionIndex(address, instIndex)
}) })
}
}) })
} }
}) })
...@@ -30,8 +30,10 @@ module.exports = React.createClass({ ...@@ -30,8 +30,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this var self = this
this.context.traceManager.getCallDataAt(nextProps.currentStepIndex, function (calldata) { this.context.traceManager.getCallDataAt(nextProps.currentStepIndex, function (error, calldata) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) { if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({ self.setState({
data: calldata data: calldata
}) })
......
...@@ -30,8 +30,10 @@ module.exports = React.createClass({ ...@@ -30,8 +30,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this var self = this
this.context.traceManager.getCallStackAt(nextProps.currentStepIndex, function (callstack) { this.context.traceManager.getCallStackAt(nextProps.currentStepIndex, function (error, callstack) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) { if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({ self.setState({
data: callstack data: callstack
}) })
......
...@@ -31,8 +31,10 @@ module.exports = React.createClass({ ...@@ -31,8 +31,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this var self = this
this.context.traceManager.getMemoryAt(nextProps.currentStepIndex, function (memory) { this.context.traceManager.getMemoryAt(nextProps.currentStepIndex, function (error, memory) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) { if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({ self.setState({
data: self.formatMemory(memory, 16) data: self.formatMemory(memory, 16)
}) })
......
...@@ -30,8 +30,10 @@ module.exports = React.createClass({ ...@@ -30,8 +30,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this var self = this
this.context.traceManager.getStackAt(nextProps.currentStepIndex, function (stack) { this.context.traceManager.getStackAt(nextProps.currentStepIndex, function (error, stack) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) { if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({ self.setState({
data: stack data: stack
}) })
......
...@@ -54,8 +54,12 @@ module.exports = React.createClass({ ...@@ -54,8 +54,12 @@ module.exports = React.createClass({
newTraceAvailable: function () { newTraceAvailable: function () {
this.init() this.init()
var self = this var self = this
this.context.traceManager.getLength(function (length) { this.context.traceManager.getLength(function (error, length) {
if (error) {
console.log(error)
} else {
self.setState({ traceLength: length }) self.setState({ traceLength: length })
}
}) })
}, },
......
...@@ -84,28 +84,44 @@ module.exports = React.createClass({ ...@@ -84,28 +84,44 @@ module.exports = React.createClass({
if (nextProps.currentStepIndex < 0) return if (nextProps.currentStepIndex < 0) return
var self = this var self = this
this.context.traceManager.getCurrentStep(nextProps.currentStepIndex, function (step) { this.context.traceManager.getCurrentStep(nextProps.currentStepIndex, function (error, step) {
if (error) {
console.log(error)
} else {
self.setState({ self.setState({
step: step step: step
}) })
}
}) })
this.context.traceManager.getMemExpand(nextProps.currentStepIndex, function (addmem) { this.context.traceManager.getMemExpand(nextProps.currentStepIndex, function (error, addmem) {
if (error) {
console.log(error)
} else {
self.setState({ self.setState({
addmemory: addmem addmemory: addmem
}) })
}
}) })
this.context.traceManager.getStepCost(nextProps.currentStepIndex, function (gas) { this.context.traceManager.getStepCost(nextProps.currentStepIndex, function (error, gas) {
if (error) {
console.log(error)
} else {
self.setState({ self.setState({
gas: gas gas: gas
}) })
}
}) })
this.context.traceManager.getRemainingGas(nextProps.currentStepIndex, function (remaingas) { this.context.traceManager.getRemainingGas(nextProps.currentStepIndex, function (error, remaingas) {
if (error) {
console.log(error)
} else {
self.setState({ self.setState({
remaininGas: remaingas remaininGas: remaingas
}) })
}
}) })
} }
}) })
...@@ -31,8 +31,10 @@ module.exports = React.createClass({ ...@@ -31,8 +31,10 @@ module.exports = React.createClass({
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this var self = this
this.context.traceManager.getStorageAt(nextProps.currentStepIndex, this.context.tx.blockNumber.toString(), this.context.tx.transactionIndex, function (storage) { this.context.traceManager.getStorageAt(nextProps.currentStepIndex, this.context.tx.blockNumber.toString(), this.context.tx.transactionIndex, function (error, storage) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) { if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({ self.setState({
data: storage data: storage
}) })
......
...@@ -136,14 +136,14 @@ module.exports = { ...@@ -136,14 +136,14 @@ module.exports = {
// API section // API section
getLength: function (callback) { getLength: function (callback) {
if (!this.trace) callback(0) if (!this.trace) callback('no trace available', null)
callback(this.trace.length) callback(null, this.trace.length)
}, },
getStorageAt: function (stepIndex, blockNumber, txIndex, callback) { getStorageAt: function (stepIndex, blockNumber, txIndex, callback) {
var stoChange = this.findLowerBound(stepIndex, this.vmTraceChangesRef) var stoChange = this.findLowerBound(stepIndex, this.vmTraceChangesRef)
if (!stoChange) { if (!stoChange) {
return {} callback('cannot rebuild storage', null)
} }
var changeRefs = this.vmTraceIndexByStorageChange[stoChange] var changeRefs = this.vmTraceIndexByStorageChange[stoChange]
...@@ -160,20 +160,20 @@ module.exports = { ...@@ -160,20 +160,20 @@ module.exports = {
} }
} }
} }
callback(storage) callback(null, storage)
}) })
}, },
getCallDataAt: function (stepIndex, callback) { getCallDataAt: function (stepIndex, callback) {
var callDataChange = this.findLowerBound(stepIndex, this.callDataChanges) var callDataChange = this.findLowerBound(stepIndex, this.callDataChanges)
if (!callDataChange) return [''] if (!callDataChange) return callback('no calldata found', null)
callback([this.trace[callDataChange].calldata]) callback(null, [this.trace[callDataChange].calldata])
}, },
getCallStackAt: function (stepIndex, callback) { getCallStackAt: function (stepIndex, callback) {
var callStackChange = this.findLowerBound(stepIndex, this.depthChanges) var callStackChange = this.findLowerBound(stepIndex, this.depthChanges)
if (!callStackChange) return '' if (!callStackChange) return callback('no callstack found', null)
callback(this.callStack[callStackChange].stack) callback(null, this.callStack[callStackChange].stack)
}, },
getStackAt: function (stepIndex, callback) { getStackAt: function (stepIndex, callback) {
...@@ -181,46 +181,52 @@ module.exports = { ...@@ -181,46 +181,52 @@ module.exports = {
if (this.trace[stepIndex].stack) { // there's always a stack if (this.trace[stepIndex].stack) { // there's always a stack
stack = this.trace[stepIndex].stack.slice(0) stack = this.trace[stepIndex].stack.slice(0)
stack.reverse() stack.reverse()
callback(stack) callback(null, stack)
} else {
callback('no stack found', null)
} }
}, },
getLastDepthIndexChangeSince: function (stepIndex, callback) { getLastDepthIndexChangeSince: function (stepIndex, callback) {
var depthIndex = this.findLowerBound(stepIndex, this.depthChanges) var depthIndex = this.findLowerBound(stepIndex, this.depthChanges)
callback(depthIndex) callback(null, depthIndex)
}, },
getCurrentCalledAddressAt: function (stepIndex, callback) { getCurrentCalledAddressAt: function (stepIndex, callback) {
var self = this var self = this
this.getLastDepthIndexChangeSince(stepIndex, function (addressIndex) { this.getLastDepthIndexChangeSince(stepIndex, function (error, addressIndex) {
callback(self.resolveAddress(addressIndex)) if (error) {
callback(error, null)
} else {
callback(null, self.resolveAddress(addressIndex))
}
}) })
}, },
getMemoryAt: function (stepIndex, callback) { getMemoryAt: function (stepIndex, callback) {
var lastChanges = this.findLowerBound(stepIndex, this.memoryChanges) var lastChanges = this.findLowerBound(stepIndex, this.memoryChanges)
if (!lastChanges) return '' if (!lastChanges) return callback('no memory found', null)
callback(this.trace[lastChanges].memory) callback(null, this.trace[lastChanges].memory)
}, },
getCurrentPC: function (stepIndex, callback) { getCurrentPC: function (stepIndex, callback) {
callback(this.trace[stepIndex].pc) callback(null, this.trace[stepIndex].pc)
}, },
getCurrentStep: function (stepIndex, callback) { getCurrentStep: function (stepIndex, callback) {
callback(this.trace[stepIndex].steps) callback(null, this.trace[stepIndex].steps)
}, },
getMemExpand: function (stepIndex, callback) { getMemExpand: function (stepIndex, callback) {
callback(this.trace[stepIndex].memexpand ? this.trace[stepIndex].memexpand : '') callback(null, this.trace[stepIndex].memexpand ? this.trace[stepIndex].memexpand : '')
}, },
getStepCost: function (stepIndex, callback) { getStepCost: function (stepIndex, callback) {
callback(this.trace[stepIndex].gascost) callback(null, this.trace[stepIndex].gascost)
}, },
getRemainingGas: function (stepIndex, callback) { getRemainingGas: function (stepIndex, callback) {
callback(this.trace[stepIndex].gas) callback(null, this.trace[stepIndex].gas)
}, },
// step section // step section
......
...@@ -73,8 +73,10 @@ module.exports = React.createClass({ ...@@ -73,8 +73,10 @@ module.exports = React.createClass({
if (nextProps.currentStepIndex < 0) return if (nextProps.currentStepIndex < 0) return
if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return if (window.ethDebuggerSelectedItem !== nextProps.currentStepIndex) return
var self = this var self = this
this.context.traceManager.getCurrentCalledAddressAt(nextProps.currentStepIndex, function (address) { this.context.traceManager.getCurrentCalledAddressAt(nextProps.currentStepIndex, function (error, address) {
if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) { if (error) {
console.log(error)
} else if (window.ethDebuggerSelectedItem === nextProps.currentStepIndex) {
self.setState({ self.setState({
currentAddress: address currentAddress: address
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment