Refactor import-state CLI to cli package (#250)

* Remove unnecessary upstream config arg to event watcher

* Initialize event watcher in CLI package

* Refactor import-state CLI to cli package
This commit is contained in:
prathamesh0
2022-11-22 16:41:15 +05:30
committed by GitHub
parent 6622d0874e
commit 6737ec756c
37 changed files with 369 additions and 513 deletions
@@ -11,8 +11,7 @@ import {
EventWatcher as BaseEventWatcher,
EventWatcherInterface,
QUEUE_BLOCK_PROCESSING,
QUEUE_EVENT_PROCESSING,
UpstreamConfig
QUEUE_EVENT_PROCESSING
} from '@cerc-io/util';
import { Indexer } from './indexer';
@@ -25,7 +24,7 @@ export class EventWatcher implements EventWatcherInterface {
_pubsub: PubSub
_jobQueue: JobQueue
constructor (upstreamConfig: UpstreamConfig, ethClient: EthClient, indexer: Indexer, pubsub: PubSub, jobQueue: JobQueue) {
constructor (ethClient: EthClient, indexer: Indexer, pubsub: PubSub, jobQueue: JobQueue) {
assert(ethClient);
assert(indexer);
@@ -33,7 +32,7 @@ export class EventWatcher implements EventWatcherInterface {
this._indexer = indexer;
this._pubsub = pubsub;
this._jobQueue = jobQueue;
this._baseEventWatcher = new BaseEventWatcher(upstreamConfig, this._ethClient, this._indexer, this._pubsub, this._jobQueue);
this._baseEventWatcher = new BaseEventWatcher(this._ethClient, this._indexer, this._pubsub, this._jobQueue);
}
getEventIterator (): AsyncIterator<any> {
@@ -106,7 +106,7 @@ export const main = async (): Promise<any> => {
// Later: https://www.apollographql.com/docs/apollo-server/data/subscriptions/#production-pubsub-libraries
const pubsub = new PubSub();
const eventWatcher = new EventWatcher(config.upstream, ethClient, indexer, pubsub, jobQueue);
const eventWatcher = new EventWatcher(ethClient, indexer, pubsub, jobQueue);
await fillBlocks(jobQueue, indexer, eventWatcher, jobQueueConfig.blockDelayInMilliSecs, argv);
};
@@ -77,7 +77,7 @@ export const main = async (): Promise<any> => {
await graphWatcher.init();
{{/if}}
const eventWatcher = new EventWatcher(config.upstream, ethClient, indexer, pubsub, jobQueue);
const eventWatcher = new EventWatcher(ethClient, indexer, pubsub, jobQueue);
// Import data.
const importFilePath = path.resolve(argv.importFile);
@@ -71,7 +71,7 @@ export const main = async (): Promise<any> => {
await graphWatcher.init();
{{/if}}
const eventWatcher = new EventWatcher(config.upstream, ethClient, indexer, pubsub, jobQueue);
const eventWatcher = new EventWatcher(ethClient, indexer, pubsub, jobQueue);
if (watcherKind === KIND_ACTIVE) {
await jobQueue.start();