mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-09 01:04:07 +00:00
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:
@@ -12,7 +12,6 @@ import { JobQueue } from './job-queue';
|
||||
import { BlockProgressInterface, EventInterface, IndexerInterface } from './types';
|
||||
import { MAX_REORG_DEPTH, JOB_KIND_PRUNE, JOB_KIND_INDEX, UNKNOWN_EVENT_NAME, JOB_KIND_EVENTS, QUEUE_BLOCK_PROCESSING, QUEUE_EVENT_PROCESSING } from './constants';
|
||||
import { createPruningJob, processBlockByNumber } from './common';
|
||||
import { UpstreamConfig } from './config';
|
||||
import { OrderDirection } from './database';
|
||||
|
||||
const EVENT = 'event';
|
||||
@@ -27,10 +26,8 @@ export class EventWatcher {
|
||||
_subscription?: ZenObservable.Subscription
|
||||
_pubsub: PubSub
|
||||
_jobQueue: JobQueue
|
||||
_upstreamConfig: UpstreamConfig
|
||||
|
||||
constructor (upstreamConfig: UpstreamConfig, ethClient: EthClient, indexer: IndexerInterface, pubsub: PubSub, jobQueue: JobQueue) {
|
||||
this._upstreamConfig = upstreamConfig;
|
||||
constructor (ethClient: EthClient, indexer: IndexerInterface, pubsub: PubSub, jobQueue: JobQueue) {
|
||||
this._ethClient = ethClient;
|
||||
this._indexer = indexer;
|
||||
this._pubsub = pubsub;
|
||||
|
||||
@@ -109,7 +109,7 @@ export interface IndexerInterface {
|
||||
isWatchedContract: (address: string) => ContractInterface | undefined;
|
||||
getContractsByKind?: (kind: string) => ContractInterface[]
|
||||
cacheContract?: (contract: ContractInterface) => void;
|
||||
watchContract?: (address: string, kind: string, checkpoint: boolean, startingBlock: number) => Promise<void>
|
||||
watchContract: (address: string, kind: string, checkpoint: boolean, startingBlock: number) => Promise<void>
|
||||
getEntityTypesMap?: () => Map<string, { [key: string]: string }>
|
||||
getRelationsMap?: () => Map<any, { [key: string]: any }>
|
||||
createDiffStaged?: (contractAddress: string, blockHash: string, data: any) => Promise<void>
|
||||
@@ -125,6 +125,8 @@ export interface IndexerInterface {
|
||||
updateStateStatusMap (address: string, stateStatus: StateStatus): void
|
||||
getStateData (state: StateInterface): any
|
||||
getStateByCID (cid: string): Promise<StateInterface | undefined>
|
||||
saveOrUpdateState (state: StateInterface): Promise<StateInterface>
|
||||
removeStates (blockNumber: number, kind: StateKind): Promise<void>
|
||||
resetWatcherToBlock (blockNumber: number): Promise<void>
|
||||
getResultEvent (event: EventInterface): any
|
||||
}
|
||||
@@ -138,6 +140,7 @@ export interface EventWatcherInterface {
|
||||
export interface DatabaseInterface {
|
||||
_conn: Connection;
|
||||
readonly baseDatabase: Database
|
||||
readonly graphDatabase?: any
|
||||
init (): Promise<void>;
|
||||
close (): Promise<void>;
|
||||
createTransactionRunner (): Promise<QueryRunner>;
|
||||
|
||||
Reference in New Issue
Block a user