From d76268e5064398b2dded62e241e353e220a304d5 Mon Sep 17 00:00:00 2001 From: nikugogoi <95nikass@gmail.com> Date: Wed, 17 Nov 2021 20:50:35 +0530 Subject: [PATCH] Call subgraph block handlers and fix eden-watcher dependency (#52) * Call subgraph block handler in watchers * Fix eden-watcher dependency for build Co-authored-by: prathamesh0 --- packages/eden-watcher/package.json | 1 + packages/eden-watcher/src/indexer.ts | 5 +++++ packages/eden-watcher/src/job-runner.ts | 9 ++++++++- packages/graph-test-watcher/src/indexer.ts | 5 +++++ packages/graph-test-watcher/src/job-runner.ts | 9 ++++++++- 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/eden-watcher/package.json b/packages/eden-watcher/package.json index 569517a7..1b35576a 100644 --- a/packages/eden-watcher/package.json +++ b/packages/eden-watcher/package.json @@ -35,6 +35,7 @@ "@vulcanize/ipld-eth-client": "^0.1.0", "@vulcanize/solidity-mapper": "^0.1.0", "@vulcanize/util": "^0.1.0", + "@vulcanize/graph-node": "^0.1.0", "apollo-server-express": "^2.25.0", "apollo-type-bigint": "^0.1.3", "debug": "^4.3.1", diff --git a/packages/eden-watcher/src/indexer.ts b/packages/eden-watcher/src/indexer.ts index 4a69b912..c6b88b44 100644 --- a/packages/eden-watcher/src/indexer.ts +++ b/packages/eden-watcher/src/indexer.ts @@ -543,6 +543,11 @@ export class Indexer implements IndexerInterface { await this.triggerIndexingOnEvent(event); } + async processBlock (blockHash: string): Promise { + // Call subgraph handler for block. + await this._graphWatcher.handleBlock(blockHash); + } + parseEventNameAndArgs (kind: string, logObj: any): any { let eventName = UNKNOWN_EVENT_NAME; let eventInfo = {}; diff --git a/packages/eden-watcher/src/job-runner.ts b/packages/eden-watcher/src/job-runner.ts index 9f7cbea3..60087c69 100644 --- a/packages/eden-watcher/src/job-runner.ts +++ b/packages/eden-watcher/src/job-runner.ts @@ -21,7 +21,8 @@ import { QUEUE_IPFS, JobQueueConfig, DEFAULT_CONFIG_PATH, - initClients + initClients, + JOB_KIND_INDEX } from '@vulcanize/util'; import { GraphWatcher, Database as GraphDatabase } from '@vulcanize/graph-node'; @@ -57,6 +58,12 @@ export class JobRunner { await this._baseJobRunner.processBlock(job); + const { data: { kind, blockHash } } = job; + + if (kind === JOB_KIND_INDEX) { + await this._indexer.processBlock(blockHash); + } + await this._jobQueue.markComplete(job); }); } diff --git a/packages/graph-test-watcher/src/indexer.ts b/packages/graph-test-watcher/src/indexer.ts index a960c04e..40acfc31 100644 --- a/packages/graph-test-watcher/src/indexer.ts +++ b/packages/graph-test-watcher/src/indexer.ts @@ -553,6 +553,11 @@ export class Indexer implements IndexerInterface { await this.triggerIndexingOnEvent(event); } + async processBlock (blockHash: string): Promise { + // Call subgraph handler for block. + await this._graphWatcher.handleBlock(blockHash); + } + parseEventNameAndArgs (kind: string, logObj: any): any { let eventName = UNKNOWN_EVENT_NAME; let eventInfo = {}; diff --git a/packages/graph-test-watcher/src/job-runner.ts b/packages/graph-test-watcher/src/job-runner.ts index 9f7cbea3..60087c69 100644 --- a/packages/graph-test-watcher/src/job-runner.ts +++ b/packages/graph-test-watcher/src/job-runner.ts @@ -21,7 +21,8 @@ import { QUEUE_IPFS, JobQueueConfig, DEFAULT_CONFIG_PATH, - initClients + initClients, + JOB_KIND_INDEX } from '@vulcanize/util'; import { GraphWatcher, Database as GraphDatabase } from '@vulcanize/graph-node'; @@ -57,6 +58,12 @@ export class JobRunner { await this._baseJobRunner.processBlock(job); + const { data: { kind, blockHash } } = job; + + if (kind === JOB_KIND_INDEX) { + await this._indexer.processBlock(blockHash); + } + await this._jobQueue.markComplete(job); }); }