|
|
|
@ -99,38 +99,28 @@ export class Debugger { |
|
|
|
|
this.debugger.web3 = web3 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
debug (blockNumber, txNumber, tx, loadingCb): Promise<void> { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
const web3 = this.debugger.web3 |
|
|
|
|
async debug (blockNumber, txNumber, tx, loadingCb) { |
|
|
|
|
const web3 = this.debugger.web3 |
|
|
|
|
|
|
|
|
|
if (this.debugger.traceManager.isLoading) { |
|
|
|
|
return resolve() |
|
|
|
|
} |
|
|
|
|
if (this.debugger.traceManager.isLoading) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (tx) { |
|
|
|
|
if (!tx.to) { |
|
|
|
|
tx.to = contractCreationToken('0') |
|
|
|
|
} |
|
|
|
|
return this.debugTx(tx, loadingCb).then(resolve).catch(reject) |
|
|
|
|
if (tx) { |
|
|
|
|
if (!tx.to) { |
|
|
|
|
tx.to = contractCreationToken('0') |
|
|
|
|
} |
|
|
|
|
return await this.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(new Error('cannot find transaction ' + txNumber)) |
|
|
|
|
return this.debugTx(tx, loadingCb).then(resolve).catch(reject) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
web3.eth.getTransactionFromBlock(blockNumber, txNumber, (_error, tx) => { |
|
|
|
|
if (_error) return reject(_error) |
|
|
|
|
if (!tx) return reject(new Error('cannot find transaction ' + blockNumber + ' ' + txNumber)) |
|
|
|
|
return this.debugTx(tx, loadingCb).then(resolve).catch(reject) |
|
|
|
|
}) |
|
|
|
|
} catch (e) { |
|
|
|
|
return reject(e) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if (txNumber.indexOf('0x') !== -1) { |
|
|
|
|
tx = await web3.eth.getTransaction(txNumber) |
|
|
|
|
if (!tx) throw new Error('cannot find transaction ' + txNumber)
|
|
|
|
|
} else { |
|
|
|
|
tx = await web3.eth.getTransactionFromBlock(blockNumber, txNumber) |
|
|
|
|
if (!tx) throw new Error('cannot find transaction ' + blockNumber + ' ' + txNumber) |
|
|
|
|
} |
|
|
|
|
return await this.debugTx(tx, loadingCb) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async debugTx (tx, loadingCb) { |
|
|
|
|