mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-31 12:02:07 +00:00
Update codegen indexer template
This commit is contained in:
parent
13addd8241
commit
157975da40
@ -8,13 +8,12 @@ import debug from 'debug';
|
|||||||
{{#if queries}}
|
{{#if queries}}
|
||||||
import JSONbig from 'json-bigint';
|
import JSONbig from 'json-bigint';
|
||||||
{{/if}}
|
{{/if}}
|
||||||
import { ethers, constants } from 'ethers';
|
import { ethers, constants, providers } from 'ethers';
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
import { GraphQLResolveInfo } from 'graphql';
|
import { GraphQLResolveInfo } from 'graphql';
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
import { JsonFragment } from '@ethersproject/abi';
|
import { JsonFragment } from '@ethersproject/abi';
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
|
||||||
import { MappingKey, StorageLayout } from '@cerc-io/solidity-mapper';
|
import { MappingKey, StorageLayout } from '@cerc-io/solidity-mapper';
|
||||||
import {
|
import {
|
||||||
Indexer as BaseIndexer,
|
Indexer as BaseIndexer,
|
||||||
@ -49,6 +48,7 @@ import {
|
|||||||
EthFullTransaction,
|
EthFullTransaction,
|
||||||
ExtraEventData
|
ExtraEventData
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
|
import { initClients } from '@cerc-io/cli';
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
import { GraphWatcher } from '@cerc-io/graph-node';
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@ -91,7 +91,7 @@ const {{capitalize event}}_EVENT = '{{event}}';
|
|||||||
export class Indexer implements IndexerInterface {
|
export class Indexer implements IndexerInterface {
|
||||||
_db: Database;
|
_db: Database;
|
||||||
_ethClient: EthClient;
|
_ethClient: EthClient;
|
||||||
_ethProvider: BaseProvider;
|
_ethProvider: providers.JsonRpcProvider;
|
||||||
_baseIndexer: BaseIndexer;
|
_baseIndexer: BaseIndexer;
|
||||||
_serverConfig: ServerConfig;
|
_serverConfig: ServerConfig;
|
||||||
_upstreamConfig: UpstreamConfig;
|
_upstreamConfig: UpstreamConfig;
|
||||||
@ -118,7 +118,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
},
|
},
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: BaseProvider,
|
ethProvider: providers.JsonRpcProvider,
|
||||||
jobQueue: JobQueue{{#if (subgraphPath)}},{{/if}}
|
jobQueue: JobQueue{{#if (subgraphPath)}},{{/if}}
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
graphWatcher?: GraphWatcherInterface
|
graphWatcher?: GraphWatcherInterface
|
||||||
@ -199,15 +199,19 @@ export class Indexer implements IndexerInterface {
|
|||||||
await this._baseIndexer.fetchStateStatus();
|
await this._baseIndexer.fetchStateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
switchClients ({ ethClient, ethProvider }: { ethClient: EthClient, ethProvider: BaseProvider }): void {
|
async switchClients (): Promise<void> {
|
||||||
|
const { ethClient, ethProvider } = await this._baseIndexer.switchClients(initClients);
|
||||||
this._ethClient = ethClient;
|
this._ethClient = ethClient;
|
||||||
this._ethProvider = ethProvider;
|
this._ethProvider = ethProvider;
|
||||||
this._baseIndexer.switchClients({ ethClient, ethProvider });
|
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
this._graphWatcher.switchClients({ ethClient, ethProvider });
|
this._graphWatcher.switchClients({ ethClient, ethProvider });
|
||||||
{{/if}}
|
{{/if}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async isGetLogsRequestsSlow (): Promise<boolean> {
|
||||||
|
return this._baseIndexer.isGetLogsRequestsSlow();
|
||||||
|
}
|
||||||
|
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
async getMetaData (block: BlockHeight): Promise<ResultMeta | null> {
|
async getMetaData (block: BlockHeight): Promise<ResultMeta | null> {
|
||||||
return this._baseIndexer.getMetaData(block);
|
return this._baseIndexer.getMetaData(block);
|
||||||
|
Loading…
Reference in New Issue
Block a user