Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createTransactionObserver(moduleInstance) {
if (moduleInstance.currentProvider.supportsSubscriptions()) {
return new SocketTransactionObserver(
moduleInstance.currentProvider,
this.getTimeout(moduleInstance),
moduleInstance.transactionConfirmationBlocks,
new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
new NewHeadsSubscription(this.utils, this.formatters, moduleInstance)
);
}
return new HttpTransactionObserver(
moduleInstance.currentProvider,
this.getTimeout(moduleInstance),
moduleInstance.transactionConfirmationBlocks,
new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
new GetBlockByNumberMethod(this.utils, this.formatters, moduleInstance)
);
}
}
createTransactionObserver(moduleInstance) {
if (moduleInstance.currentProvider.supportsSubscriptions()) {
return new SocketTransactionObserver(
moduleInstance.currentProvider,
this.getTimeout(moduleInstance),
moduleInstance.transactionConfirmationBlocks,
new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
new NewHeadsSubscription(this.utils, this.formatters, moduleInstance)
);
}
return new HttpTransactionObserver(
moduleInstance.currentProvider,
this.getTimeout(moduleInstance),
moduleInstance.transactionConfirmationBlocks,
new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
new GetBlockByNumberMethod(this.utils, this.formatters, moduleInstance)
);
}
}
createTransactionObserver(moduleInstance) {
if (moduleInstance.currentProvider.supportsSubscriptions()) {
return new SocketTransactionObserver(
moduleInstance.currentProvider,
this.getTimeout(moduleInstance),
moduleInstance.transactionConfirmationBlocks,
new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
new NewHeadsSubscription(this.utils, this.formatters, moduleInstance)
);
}
return new HttpTransactionObserver(
moduleInstance.currentProvider,
this.getTimeout(moduleInstance),
moduleInstance.transactionConfirmationBlocks,
new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
new GetBlockByNumberMethod(this.utils, this.formatters, moduleInstance)
);
}
}
getSubscription(moduleInstance, type, options) {
switch (type) {
case 'logs':
return new LogSubscription(
options,
this.utils,
this.formatters,
moduleInstance,
new GetPastLogsMethod(this.utils, this.formatters, moduleInstance)
);
case 'newBlockHeaders':
return new NewHeadsSubscription(this.utils, this.formatters, moduleInstance);
case 'pendingTransactions':
return new NewPendingTransactionsSubscription(this.utils, this.formatters, moduleInstance);
case 'syncing':
return new SyncingSubscription(this.utils, this.formatters, moduleInstance);
case 'accountsChanged':
return new AccountsChangedSubscription(this.utils, this.formatters, moduleInstance);
case 'networkChanged':
return new NetworkChangedSubscription(this.utils, this.formatters, moduleInstance);
case 'chainChanged':
return new ChainChangedSubscription(this.utils, this.formatters, moduleInstance);
default:
throw new Error(`Unknown subscription: ${type}`);
}
}
}