From 157975da4055acd0a01ffbd7acbfb7cc8641ea31 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Thu, 20 Jun 2024 16:47:28 +0530 Subject: [PATCH] Update codegen indexer template --- .../src/templates/indexer-template.handlebars | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/codegen/src/templates/indexer-template.handlebars b/packages/codegen/src/templates/indexer-template.handlebars index 47c5cb35..0036e331 100644 --- a/packages/codegen/src/templates/indexer-template.handlebars +++ b/packages/codegen/src/templates/indexer-template.handlebars @@ -8,13 +8,12 @@ import debug from 'debug'; {{#if queries}} import JSONbig from 'json-bigint'; {{/if}} -import { ethers, constants } from 'ethers'; +import { ethers, constants, providers } from 'ethers'; {{#if (subgraphPath)}} import { GraphQLResolveInfo } from 'graphql'; {{/if}} import { JsonFragment } from '@ethersproject/abi'; -import { BaseProvider } from '@ethersproject/providers'; import { MappingKey, StorageLayout } from '@cerc-io/solidity-mapper'; import { Indexer as BaseIndexer, @@ -49,6 +48,7 @@ import { EthFullTransaction, ExtraEventData } from '@cerc-io/util'; +import { initClients } from '@cerc-io/cli'; {{#if (subgraphPath)}} import { GraphWatcher } from '@cerc-io/graph-node'; {{/if}} @@ -91,7 +91,7 @@ const {{capitalize event}}_EVENT = '{{event}}'; export class Indexer implements IndexerInterface { _db: Database; _ethClient: EthClient; - _ethProvider: BaseProvider; + _ethProvider: providers.JsonRpcProvider; _baseIndexer: BaseIndexer; _serverConfig: ServerConfig; _upstreamConfig: UpstreamConfig; @@ -118,7 +118,7 @@ export class Indexer implements IndexerInterface { }, db: DatabaseInterface, clients: Clients, - ethProvider: BaseProvider, + ethProvider: providers.JsonRpcProvider, jobQueue: JobQueue{{#if (subgraphPath)}},{{/if}} {{#if (subgraphPath)}} graphWatcher?: GraphWatcherInterface @@ -199,15 +199,19 @@ export class Indexer implements IndexerInterface { await this._baseIndexer.fetchStateStatus(); } - switchClients ({ ethClient, ethProvider }: { ethClient: EthClient, ethProvider: BaseProvider }): void { + async switchClients (): Promise { + const { ethClient, ethProvider } = await this._baseIndexer.switchClients(initClients); this._ethClient = ethClient; this._ethProvider = ethProvider; - this._baseIndexer.switchClients({ ethClient, ethProvider }); {{#if (subgraphPath)}} this._graphWatcher.switchClients({ ethClient, ethProvider }); {{/if}} } + async isGetLogsRequestsSlow (): Promise { + return this._baseIndexer.isGetLogsRequestsSlow(); + } + {{#if (subgraphPath)}} async getMetaData (block: BlockHeight): Promise { return this._baseIndexer.getMetaData(block);