Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var checkConfirmation = function (existingReceipt, isPolling, err, blockHeader, sub) {
if (!err) {
// create fake unsubscribe
if (!sub) {
sub = {
unsubscribe: function () {
clearInterval(intervalId);
}
};
}
// if we have a valid receipt we don't need to send a request
return (existingReceipt ? promiEvent.resolve(existingReceipt) : _ethereumCall.getTransactionReceipt(result))
// catch error from requesting receipt
.catch(function (err) {
sub.unsubscribe();
promiseResolved = true;
utils._fireError({message: 'Failed to check for transaction receipt:', data: err}, defer.eventEmitter, defer.reject);
})
// if CONFIRMATION listener exists check for confirmations, by setting canUnsubscribe = false
.then(function(receipt) {
if (!receipt || !receipt.blockHash) {
throw new Error('Receipt missing or blockHash null');
}
// apply extra formatters
if (method.extraFormatters && method.extraFormatters.receiptFormatter) {
receipt = method.extraFormatters.receiptFormatter(receipt);
}