|
|
|
@ -69,34 +69,41 @@ Debugger.prototype.updateWeb3 = function (web3) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Debugger.prototype.debug = function (blockNumber, txNumber, tx, loadingCb) { |
|
|
|
|
const self = this |
|
|
|
|
let web3 = this.debugger.web3 |
|
|
|
|
|
|
|
|
|
if (this.debugger.traceManager.isLoading) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
if (this.debugger.traceManager.isLoading) { |
|
|
|
|
return resolve() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (tx) { |
|
|
|
|
if (!tx.to) { |
|
|
|
|
tx.to = traceHelper.contractCreationToken('0') |
|
|
|
|
if (tx) { |
|
|
|
|
if (!tx.to) { |
|
|
|
|
tx.to = traceHelper.contractCreationToken('0') |
|
|
|
|
} |
|
|
|
|
this.debugTx(tx, loadingCb) |
|
|
|
|
return resolve() |
|
|
|
|
} |
|
|
|
|
return self.debugTx(tx, loadingCb) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (txNumber.indexOf('0x') !== -1) { |
|
|
|
|
return web3.eth.getTransaction(txNumber, function (_error, result) { |
|
|
|
|
let tx = result |
|
|
|
|
self.debugTx(tx, loadingCb) |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (txNumber.indexOf('0x') !== -1) { |
|
|
|
|
return web3.eth.getTransaction(txNumber, (_error, tx) => { |
|
|
|
|
if (_error) return reject(_error) |
|
|
|
|
if (!tx) return reject('cannot find transaction ' + txNumber) |
|
|
|
|
this.debugTx(tx, loadingCb) |
|
|
|
|
return resolve() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
web3.eth.getTransactionFromBlock(blockNumber, txNumber, (_error, tx) => { |
|
|
|
|
if (_error) return reject(_error) |
|
|
|
|
if (!tx) return reject('cannot find transaction ' + blockNumber + ' ' + txNumber) |
|
|
|
|
this.debugTx(tx, loadingCb) |
|
|
|
|
return resolve() |
|
|
|
|
}) |
|
|
|
|
} catch (e) { |
|
|
|
|
console.error(e.message) |
|
|
|
|
return reject(e.message) |
|
|
|
|
} |
|
|
|
|
web3.eth.getTransactionFromBlock(blockNumber, txNumber, function (_error, result) { |
|
|
|
|
let tx = result |
|
|
|
|
self.debugTx(tx, loadingCb) |
|
|
|
|
}) |
|
|
|
|
} catch (e) { |
|
|
|
|
console.error(e.message) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Debugger.prototype.debugTx = function (tx, loadingCb) { |
|
|
|
@ -115,7 +122,7 @@ Debugger.prototype.debugTx = function (tx, loadingCb) { |
|
|
|
|
this.vmDebuggerLogic.start() |
|
|
|
|
|
|
|
|
|
this.step_manager.event.register('stepChanged', this, function (stepIndex) { |
|
|
|
|
if (!stepIndex) { |
|
|
|
|
if (typeof stepIndex !== 'number' || stepIndex >= self.step_manager.traceLength) { |
|
|
|
|
return self.event.trigger('endDebug') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|