From 181b533a8a93af5296845f53bdea2758a360678e Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 15 Aug 2018 16:43:51 -0400 Subject: [PATCH] only poll with a WS provider --- src/utils.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/utils.js b/src/utils.js index 831dc4d..0a66102 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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 => {