remove promise

pull/747/head
yann300 4 years ago
parent 23c8cd0c5b
commit 072c5763a5
  1. 31
      libs/remix-lib/src/execution/txRunnerWeb3.ts

@ -128,29 +128,20 @@ export class TxRunnerWeb3 {
} }
async function tryTillReceiptAvailable (txhash, web3) { async function tryTillReceiptAvailable (txhash, web3) {
return new Promise((resolve, reject) => { try {
web3.eth.getTransactionReceipt(txhash, async (err, receipt) => { const receipt = await web3.eth.getTransactionReceipt(txhash)
if (err || !receipt) { if (receipt) return receipt
// Try again with a bit of delay if error or if result still null } catch (e) {}
await pause() await pause()
return resolve(await tryTillReceiptAvailable(txhash, web3)) return await tryTillReceiptAvailable(txhash, web3)
}
return resolve(receipt)
})
})
} }
async function tryTillTxAvailable (txhash, web3) { async function tryTillTxAvailable (txhash, web3) {
return new Promise((resolve, reject) => { try {
web3.eth.getTransaction(txhash, async (err, tx) => { const tx = await web3.eth.getTransaction(txhash)
if (err || !tx) { if (tx) return tx
// Try again with a bit of delay if error or if result still null } catch (e) {}
await pause() return await tryTillTxAvailable(txhash, web3)
return resolve(await tryTillTxAvailable(txhash, web3))
}
return resolve(tx)
})
})
} }
async function pause () { return new Promise((resolve, reject) => { setTimeout(resolve, 500) }) } async function pause () { return new Promise((resolve, reject) => { setTimeout(resolve, 500) }) }

Loading…
Cancel
Save