web3-core-method
Advanced tools
Comparing version 1.0.0-beta.30 to 1.0.0-beta.31
{ | ||
"name": "web3-core-method", | ||
"namespace": "ethereum", | ||
"version": "1.0.0-beta.30", | ||
"version": "1.0.0-beta.31", | ||
"description": "Creates the methods on the web3 modules. This is an internal package.", | ||
@@ -11,7 +11,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.30", | ||
"web3-core-promievent": "1.0.0-beta.30", | ||
"web3-core-subscriptions": "1.0.0-beta.30", | ||
"web3-utils": "1.0.0-beta.30" | ||
"web3-core-helpers": "1.0.0-beta.31", | ||
"web3-core-promievent": "1.0.0-beta.31", | ||
"web3-core-subscriptions": "1.0.0-beta.31", | ||
"web3-utils": "1.0.0-beta.31" | ||
} | ||
} |
@@ -34,2 +34,3 @@ /* | ||
var TIMEOUTBLOCK = 50; | ||
var POLLINGTIMEOUT = 15 * TIMEOUTBLOCK; // ~average block time (seconds) * TIMEOUTBLOCK | ||
var CONFIRMATIONBLOCKS = 24; | ||
@@ -244,3 +245,3 @@ | ||
// fire "receipt" and confirmation events and resolve after | ||
var checkConfirmation = function (err, blockHeader, sub, existingReceipt) { | ||
var checkConfirmation = function (existingReceipt, isPolling, err, blockHeader, sub) { | ||
if (!err) { | ||
@@ -265,3 +266,2 @@ // create fake unsubscribe | ||
.then(function(receipt) { | ||
if (!receipt || !receipt.blockHash) { | ||
@@ -279,3 +279,8 @@ throw new Error('Receipt missing or blockHash null'); | ||
defer.eventEmitter.emit('confirmation', confirmationCount, receipt); | ||
// If there was an immediately retrieved receipt, it's already | ||
// been confirmed by the direct call to checkConfirmation needed | ||
// for parity instant-seal | ||
if (existingReceipt === undefined || confirmationCount !== 0){ | ||
defer.eventEmitter.emit('confirmation', confirmationCount, receipt); | ||
} | ||
@@ -305,3 +310,4 @@ canUnsubscribe = false; | ||
return utils._fireError(new Error('The transaction receipt didn\'t contain a contract address.'), defer.eventEmitter, defer.reject); | ||
utils._fireError(new Error('The transaction receipt didn\'t contain a contract address.'), defer.eventEmitter, defer.reject); | ||
return; | ||
} | ||
@@ -377,6 +383,16 @@ | ||
if (timeoutCount - 1 >= TIMEOUTBLOCK) { | ||
sub.unsubscribe(); | ||
promiseResolved = true; | ||
return utils._fireError(new Error('Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!'), defer.eventEmitter, defer.reject); | ||
// check to see if we are http polling | ||
if(!!isPolling) { | ||
// polling timeout is different than TIMEOUTBLOCK blocks since we are triggering every second | ||
if (timeoutCount - 1 >= POLLINGTIMEOUT) { | ||
sub.unsubscribe(); | ||
promiseResolved = true; | ||
utils._fireError(new Error('Transaction was not mined within' + POLLINGTIMEOUT + ' seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!'), defer.eventEmitter, defer.reject); | ||
} | ||
} else { | ||
if (timeoutCount - 1 >= TIMEOUTBLOCK) { | ||
sub.unsubscribe(); | ||
promiseResolved = true; | ||
utils._fireError(new Error('Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!'), defer.eventEmitter, defer.reject); | ||
} | ||
} | ||
@@ -389,3 +405,3 @@ }); | ||
promiseResolved = true; | ||
return utils._fireError({message: 'Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.', data: err}, defer.eventEmitter, defer.reject); | ||
utils._fireError({message: 'Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.', data: err}, defer.eventEmitter, defer.reject); | ||
} | ||
@@ -395,8 +411,8 @@ }; | ||
// start watching for confirmation depending on the support features of the provider | ||
var startWatching = function() { | ||
var startWatching = function(existingReceipt) { | ||
// if provider allows PUB/SUB | ||
if (_.isFunction(this.requestManager.provider.on)) { | ||
_ethereumCall.subscribe('newBlockHeaders', checkConfirmation); | ||
_ethereumCall.subscribe('newBlockHeaders', checkConfirmation.bind(null, existingReceipt, false)); | ||
} else { | ||
intervalId = setInterval(checkConfirmation, 1000); | ||
intervalId = setInterval(checkConfirmation.bind(null, existingReceipt, true), 1000); | ||
} | ||
@@ -411,9 +427,7 @@ }.bind(this); | ||
if (defer.eventEmitter.listeners('confirmation').length > 0) { | ||
// if the promise has not been resolved we must keep on watching for new Blocks, if a confrimation listener is present | ||
setTimeout(function(){ | ||
if (!promiseResolved) startWatching(); | ||
}, 1000); | ||
// We must keep on watching for new Blocks, if a confirmation listener is present | ||
startWatching(receipt); | ||
} | ||
checkConfirmation(receipt, false); | ||
return checkConfirmation(null, null, null, receipt); | ||
} else if (!promiseResolved) { | ||
@@ -420,0 +434,0 @@ startWatching(); |
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
21862
497
+ Addedany-promise@1.3.0(transitive)
+ Addedweb3-core-helpers@1.0.0-beta.31(transitive)
+ Addedweb3-core-promievent@1.0.0-beta.31(transitive)
+ Addedweb3-core-subscriptions@1.0.0-beta.31(transitive)
+ Addedweb3-eth-iban@1.0.0-beta.31(transitive)
+ Addedweb3-utils@1.0.0-beta.31(transitive)
- Removedbluebird@3.3.1(transitive)
- Removedweb3-core-helpers@1.0.0-beta.30(transitive)
- Removedweb3-core-promievent@1.0.0-beta.30(transitive)
- Removedweb3-core-subscriptions@1.0.0-beta.30(transitive)
- Removedweb3-eth-iban@1.0.0-beta.30(transitive)
- Removedweb3-utils@1.0.0-beta.30(transitive)
Updatedweb3-utils@1.0.0-beta.31