wait to get tx receipt

pull/5370/head
Aniket-Engg 3 years ago committed by yann300
parent 515f9c502d
commit 0adbe1774d
  1. 17
      apps/remix-ide/src/app/tabs/web3-provider.js

@ -28,7 +28,7 @@ export class Web3ProviderModule extends Plugin {
if (error) return reject(error)
if (payload.method === 'eth_sendTransaction') {
if (payload.params.length && !payload.params[0].to && message.result) {
const receipt = await this.call('blockchain', 'getTransactionReceipt', message.result)
const receipt = await this.tryTillReceiptAvailable(message.result)
const contractData = await this.call('compilerArtefacts', 'getContractDataFromAddress', receipt.contractAddress)
if (contractData) this.call('udapp', 'addInstance', receipt.contractAddress, contractData.contract.abi, contractData.name)
}
@ -37,4 +37,19 @@ export class Web3ProviderModule extends Plugin {
})
})
}
async tryTillReceiptAvailable (txhash) {
try {
const receipt = await this.call('blockchain', 'getTransactionReceipt', txhash)
if (receipt) return receipt
} catch (e) {}
await this.pause()
return await this.tryTillReceiptAvailable(txhash)
}
async pause () {
return new Promise((resolve, reject) => {
setTimeout(resolve, 500)
})
}
}

Loading…
Cancel
Save