Commit 072c5763 authored by yann300's avatar yann300

remove promise

parent 23c8cd0c
...@@ -128,29 +128,20 @@ export class TxRunnerWeb3 { ...@@ -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) }) }
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