web3-core-method
Advanced tools
Comparing version 1.0.0-beta.12 to 1.0.0-beta.13
{ | ||
"name": "web3-core-method", | ||
"version": "1.0.0-beta.12", | ||
"version": "1.0.0-beta.13", | ||
"description": "Creates the methods on the web3 modules. This is an internal package.", | ||
@@ -10,7 +10,7 @@ "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-core-method", | ||
"underscore": "1.8.3", | ||
"web3-core-helpers": "^1.0.0-beta.12", | ||
"web3-core-promievent": "^1.0.0-beta.12", | ||
"web3-core-subscriptions": "^1.0.0-beta.12", | ||
"web3-utils": "^1.0.0-beta.12" | ||
"web3-core-helpers": "^1.0.0-beta.13", | ||
"web3-core-promievent": "^1.0.0-beta.13", | ||
"web3-core-subscriptions": "^1.0.0-beta.13", | ||
"web3-utils": "^1.0.0-beta.13" | ||
} | ||
} |
@@ -230,3 +230,3 @@ /* | ||
// fire "receipt" and confirmation events and resolve after | ||
var checkConfirmation = function (err, block, sub) { | ||
var checkConfirmation = function (err, blockHeader, sub, existingReceipt) { | ||
if (!err) { | ||
@@ -241,4 +241,4 @@ // create fake unsubscribe | ||
} | ||
method._ethereumCall.getTransactionReceipt(result) | ||
// if we have a valid receipt we don't need to send a request | ||
(existingReceipt ? promiEvent.resolve(existingReceipt) : method._ethereumCall.getTransactionReceipt(result)) | ||
// catch error from requesting receipt | ||
@@ -376,8 +376,30 @@ .catch(function (err) { | ||
// if provider allows PUB/SUB | ||
if (_.isFunction(this.requestManager.provider.on)) { | ||
method._ethereumCall.subscribe('newBlockHeaders', checkConfirmation); | ||
} else { | ||
intervalId = setInterval(checkConfirmation, 1000); | ||
} | ||
// start watching for confirmation depending on the support features of the provider | ||
var startWatching = function() { | ||
// if provider allows PUB/SUB | ||
if (_.isFunction(this.requestManager.provider.on)) { | ||
method._ethereumCall.subscribe('newBlockHeaders', checkConfirmation); | ||
} else { | ||
intervalId = setInterval(checkConfirmation, 1000); | ||
} | ||
}.bind(this); | ||
// first check if we already have a confirmed transaction | ||
method._ethereumCall.getTransactionReceipt(result) | ||
.then(function(receipt) { | ||
if (receipt && receipt.blockNumber) { | ||
checkConfirmation(null, null, null, receipt); | ||
if (defer.eventEmitter.listeners('confirmation').length > 0) { | ||
setTimeout(function(){ | ||
// if the promised has not been resolved we must keep on watching for new Blocks | ||
if (!promiseResolved) startWatching(); | ||
} ,1000); | ||
} | ||
} | ||
else { | ||
startWatching(); | ||
} | ||
}) | ||
.catch(startWatching); | ||
}; | ||
@@ -442,3 +464,2 @@ | ||
} else { | ||
defer.eventEmitter.emit('transactionHash', result); | ||
@@ -445,0 +466,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19828
454