Merge pull request #12 from embark-framework/bug_fix/ws-only

only poll with a WS provider
This commit is contained in:
Iuri Matias 2018-08-23 14:40:01 -04:00 committed by GitHub
commit 9e3b66822e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 10 deletions

View File

@ -33,17 +33,22 @@ let Utils = {
// This interval is there to compensate for the event that sometimes doesn't get triggered when using WebSocket
// FIXME The issue somehow only happens when the blockchain node is started in the same terminal
const interval = setInterval(() => {
if (!hash) {
return; // Wait until we receive the hash
}
web3.eth.getTransactionReceipt(hash, (err, receipt) => {
if (!err && !receipt) {
return; // Transaction is not yet complete
// Only poll with a Websocket provider
if (web3.currentProvider.constructor.name === 'WebsocketProvider') {
var interval = setInterval(function () {
if (!hash) {
return;
}
callback(err, receipt);
});
}, 100);
web3.eth.getTransactionReceipt(hash, function (err, receipt) {
if (!err && !receipt) {
return;
}
callback(err, receipt);
});
}, 100);
}
toSend.estimateGas()
.then(gasEstimated => {