make it async

pull/5370/head
yann300 4 years ago
parent fe52493e50
commit c43aac2d7c
  1. 46
      libs/remix-debug/src/debugger/debugger.ts

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

Loading…
Cancel
Save