Refactor watch-contract CLI to cli package (#245)

* Refactor watch-contract CLI to cli package

* Use watch-contract from cli in eden and erc721 watchers

* Use watch-contract from cli in all watchers

* Pass an object containing clients to refactored CLI

Co-authored-by: nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
prathamesh0
2022-11-21 11:47:23 +04:00
committed by GitHub
co-authored by nabarun
parent a0ba657d17
commit 7520e9012c
74 changed files with 481 additions and 404 deletions
-21
View File
@@ -1,21 +0,0 @@
//
// Copyright 2021 Vulcanize, Inc.
//
export * from './src/config';
export * from './src/database';
export * from './src/job-queue';
export * from './src/constants';
export * from './src/misc';
export * from './src/fill';
export * from './src/events';
export * from './src/types';
export * from './src/indexer';
export * from './src/job-runner';
export * from './src/state-helper';
export * from './src/graph-decimal';
export * from './src/index-block';
export * from './src/metrics';
export * from './src/gql-metrics';
export * from './src/common';
export * from './src/server';
+21
View File
@@ -0,0 +1,21 @@
//
// Copyright 2022 Vulcanize, Inc.
//
export * from './config';
export * from './database';
export * from './job-queue';
export * from './constants';
export * from './misc';
export * from './fill';
export * from './events';
export * from './types';
export * from './indexer';
export * from './job-runner';
export * from './state-helper';
export * from './graph-decimal';
export * from './index-block';
export * from './metrics';
export * from './gql-metrics';
export * from './common';
export * from './server';
+3 -2
View File
@@ -3,7 +3,7 @@ import { ApolloServer } from 'apollo-server-express';
import { createServer } from 'http';
import { WebSocketServer } from 'ws';
import { useServer } from 'graphql-ws/lib/use/ws';
import { ApolloServerPluginDrainHttpServer } from 'apollo-server-core';
import { ApolloServerPluginDrainHttpServer, ApolloServerPluginLandingPageLocalDefault } from 'apollo-server-core';
import debug from 'debug';
import responseCachePlugin from 'apollo-server-plugin-response-cache';
import { InMemoryLRUCache } from '@apollo/utils.keyvaluecache';
@@ -65,7 +65,8 @@ export const createAndStartServer = async (
}
},
// GQL response cache plugin
responseCachePlugin()
responseCachePlugin(),
ApolloServerPluginLandingPageLocalDefault({ embed: true })
]
});
await server.start();
+11 -1
View File
@@ -3,10 +3,12 @@
//
import { Connection, DeepPartial, EntityTarget, FindConditions, FindManyOptions, QueryRunner } from 'typeorm';
import { MappingKey, StorageLayout } from '@cerc-io/solidity-mapper';
import { EthClient } from '@cerc-io/ipld-eth-client';
import { ServerConfig } from './config';
import { Where, QueryOptions } from './database';
import { Where, QueryOptions, Database } from './database';
import { ValueResult, StateStatus } from './indexer';
export enum StateKind {
@@ -81,6 +83,7 @@ export interface StateInterface {
export interface IndexerInterface {
readonly serverConfig: ServerConfig
readonly storageLayoutMap: Map<string, StorageLayout>
init (): Promise<void>
getBlockProgress (blockHash: string): Promise<BlockProgressInterface | undefined>
getBlockProgressEntities (where: FindConditions<BlockProgressInterface>, options: FindManyOptions<BlockProgressInterface>): Promise<BlockProgressInterface[]>
getEvent (id: string): Promise<EventInterface | undefined>
@@ -132,6 +135,8 @@ export interface EventWatcherInterface {
export interface DatabaseInterface {
_conn: Connection;
readonly baseDatabase: Database
init (): Promise<void>;
close (): Promise<void>;
createTransactionRunner (): Promise<QueryRunner>;
getBlocksAtHeight (height: number, isPruned: boolean): Promise<BlockProgressInterface[]>;
@@ -170,3 +175,8 @@ export interface DatabaseInterface {
export interface GraphDatabaseInterface {
getEntity<Entity> (entity: (new () => Entity) | string, id: string, blockHash?: string): Promise<Entity | undefined>;
}
export type Clients = {
ethClient: EthClient;
[key: string]: any;
}
+1
View File
@@ -72,5 +72,6 @@
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"resolveJsonModule": true /* Enabling the option allows importing JSON, and validating the types in that JSON file. */
},
"include": ["src"],
"exclude": ["test", "dist", "artifacts", "cache"]
}