Skip to content

Commit 58e3719

Browse files
Aniket-Enggyann300
authored andcommitted
wait to get tx receipt
1 parent b444717 commit 58e3719

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

apps/remix-ide/src/app/tabs/web3-provider.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Web3ProviderModule extends Plugin {
2828
if (error) return reject(error)
2929
if (payload.method === 'eth_sendTransaction') {
3030
if (payload.params.length && !payload.params[0].to && message.result) {
31-
const receipt = await this.call('blockchain', 'getTransactionReceipt', message.result)
31+
const receipt = await this.tryTillReceiptAvailable(message.result)
3232
const contractData = await this.call('compilerArtefacts', 'getContractDataFromAddress', receipt.contractAddress)
3333
if (contractData) this.call('udapp', 'addInstance', receipt.contractAddress, contractData.contract.abi, contractData.name)
3434
}
@@ -37,4 +37,19 @@ export class Web3ProviderModule extends Plugin {
3737
})
3838
})
3939
}
40+
41+
async tryTillReceiptAvailable (txhash) {
42+
try {
43+
const receipt = await this.call('blockchain', 'getTransactionReceipt', txhash)
44+
if (receipt) return receipt
45+
} catch (e) {}
46+
await this.pause()
47+
return await this.tryTillReceiptAvailable(txhash)
48+
}
49+
50+
async pause () {
51+
return new Promise((resolve, reject) => {
52+
setTimeout(resolve, 500)
53+
})
54+
}
4055
}

0 commit comments

Comments
 (0)