mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 20:36:19 +00:00
Refactor graph-node database and move to util (#259)
* Move graph-database from graph-node to util * Refactor and remove graph-node dependency from cli package * Modify dependencies using depcheck * Implement CLI refactoring changes in other watchers * Review changes to remove eden comment and fix local import in util * Import GraphDatabase from util instead of graph-node * Move graph-node non assemblyscript code to util package * Implement CLI refactoring changes in codegen * Fix graph-node tests after refactoring * Move fromStateEntityValues to graph state utils
This commit is contained in:
parent
63a2c5804e
commit
b66dcb4af9
@ -10,12 +10,18 @@
|
|||||||
"copy-assets": "copyfiles -u 1 src/**/*.gql dist/"
|
"copy-assets": "copyfiles -u 1 src/**/*.gql dist/"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cerc-io/graph-node": "^0.2.15",
|
"@cerc-io/ipld-eth-client": "^0.2.15",
|
||||||
"@cerc-io/util": "^0.2.15",
|
"@cerc-io/util": "^0.2.15",
|
||||||
"@ethersproject/providers": "^5.4.4",
|
"@ethersproject/providers": "^5.4.4",
|
||||||
|
"@graphql-tools/utils": "^9.1.1",
|
||||||
|
"@ipld/dag-cbor": "^6.0.12",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"typeorm": "^0.2.32",
|
"typeorm": "^0.2.32",
|
||||||
"yargs": "^17.0.1"
|
"yargs": "^17.0.1",
|
||||||
|
"graphql-subscriptions": "^2.0.0",
|
||||||
|
"debug": "^4.3.1",
|
||||||
|
"express": "^4.18.2",
|
||||||
|
"apollo-server-express": "^3.11.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
||||||
@ -24,6 +30,7 @@
|
|||||||
"eslint-config-standard": "^5.0.0",
|
"eslint-config-standard": "^5.0.0",
|
||||||
"eslint-plugin-import": "^2.23.3",
|
"eslint-plugin-import": "^2.23.3",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^5.1.0"
|
"eslint-plugin-promise": "^5.1.0",
|
||||||
|
"eslint-plugin-standard": "^5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import { ConnectionOptions } from 'typeorm';
|
|||||||
import { PubSub } from 'graphql-subscriptions';
|
import { PubSub } from 'graphql-subscriptions';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher, Database as GraphDatabase } from '@cerc-io/graph-node';
|
|
||||||
import {
|
import {
|
||||||
Config,
|
Config,
|
||||||
getConfig,
|
getConfig,
|
||||||
@ -17,9 +16,9 @@ import {
|
|||||||
DatabaseInterface,
|
DatabaseInterface,
|
||||||
IndexerInterface,
|
IndexerInterface,
|
||||||
ServerConfig,
|
ServerConfig,
|
||||||
Database as BaseDatabase,
|
|
||||||
Clients,
|
Clients,
|
||||||
EventWatcherInterface
|
EventWatcherInterface,
|
||||||
|
GraphWatcherInterface
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
import { EthClient } from '@cerc-io/ipld-eth-client';
|
import { EthClient } from '@cerc-io/ipld-eth-client';
|
||||||
|
|
||||||
@ -30,13 +29,20 @@ export class BaseCmd {
|
|||||||
_jobQueue?: JobQueue
|
_jobQueue?: JobQueue
|
||||||
_database?: DatabaseInterface;
|
_database?: DatabaseInterface;
|
||||||
_indexer?: IndexerInterface;
|
_indexer?: IndexerInterface;
|
||||||
_graphDb?: GraphDatabase;
|
|
||||||
_eventWatcher?: EventWatcherInterface;
|
_eventWatcher?: EventWatcherInterface;
|
||||||
|
|
||||||
get config (): Config | undefined {
|
get config (): Config | undefined {
|
||||||
return this._config;
|
return this._config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
get jobQueue (): JobQueue | undefined {
|
get jobQueue (): JobQueue | undefined {
|
||||||
return this._jobQueue;
|
return this._jobQueue;
|
||||||
}
|
}
|
||||||
@ -45,10 +51,6 @@ export class BaseCmd {
|
|||||||
return this._database;
|
return this._database;
|
||||||
}
|
}
|
||||||
|
|
||||||
get graphDb (): GraphDatabase | undefined {
|
|
||||||
return this._graphDb;
|
|
||||||
}
|
|
||||||
|
|
||||||
get indexer (): IndexerInterface | undefined {
|
get indexer (): IndexerInterface | undefined {
|
||||||
return this._indexer;
|
return this._indexer;
|
||||||
}
|
}
|
||||||
@ -70,17 +72,7 @@ export class BaseCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
Indexer: new (
|
clients: { [key: string]: any } = {}
|
||||||
serverConfig: ServerConfig,
|
|
||||||
db: DatabaseInterface,
|
|
||||||
clients: Clients,
|
|
||||||
ethProvider: JsonRpcProvider,
|
|
||||||
jobQueue: JobQueue,
|
|
||||||
graphWatcher?: GraphWatcher
|
|
||||||
) => IndexerInterface,
|
|
||||||
clients: { [key: string]: any } = {},
|
|
||||||
entityQueryTypeMap?: Map<any, any>,
|
|
||||||
entityToLatestEntityMap?: Map<any, any>
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
assert(this._config);
|
assert(this._config);
|
||||||
|
|
||||||
@ -99,18 +91,31 @@ export class BaseCmd {
|
|||||||
const { ethClient, ethProvider } = await initClients(this._config);
|
const { ethClient, ethProvider } = await initClients(this._config);
|
||||||
this._ethProvider = ethProvider;
|
this._ethProvider = ethProvider;
|
||||||
this._clients = { ethClient, ...clients };
|
this._clients = { ethClient, ...clients };
|
||||||
|
}
|
||||||
|
|
||||||
// Check if subgraph watcher.
|
async initIndexer (
|
||||||
if (this._config.server.subgraphPath) {
|
Indexer: new (
|
||||||
const graphWatcher = await this._getGraphWatcher(this._database.baseDatabase, entityQueryTypeMap, entityToLatestEntityMap);
|
serverConfig: ServerConfig,
|
||||||
this._indexer = new Indexer(this._config.server, this._database, this._clients, ethProvider, this._jobQueue, graphWatcher);
|
db: DatabaseInterface,
|
||||||
await this._indexer.init();
|
clients: Clients,
|
||||||
|
ethProvider: JsonRpcProvider,
|
||||||
|
jobQueue: JobQueue,
|
||||||
|
graphWatcher?: GraphWatcherInterface
|
||||||
|
) => IndexerInterface,
|
||||||
|
graphWatcher?: GraphWatcherInterface
|
||||||
|
) {
|
||||||
|
assert(this._config);
|
||||||
|
assert(this._database);
|
||||||
|
assert(this._clients);
|
||||||
|
assert(this._ethProvider);
|
||||||
|
assert(this._jobQueue);
|
||||||
|
|
||||||
|
this._indexer = new Indexer(this._config.server, this._database, this._clients, this._ethProvider, this._jobQueue, graphWatcher);
|
||||||
|
await this._indexer.init();
|
||||||
|
|
||||||
|
if (graphWatcher) {
|
||||||
graphWatcher.setIndexer(this._indexer);
|
graphWatcher.setIndexer(this._indexer);
|
||||||
await graphWatcher.init();
|
await graphWatcher.init();
|
||||||
} else {
|
|
||||||
this._indexer = new Indexer(this._config.server, this._database, this._clients, ethProvider, this._jobQueue);
|
|
||||||
await this._indexer.init();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,19 +136,4 @@ export class BaseCmd {
|
|||||||
const pubsub = new PubSub();
|
const pubsub = new PubSub();
|
||||||
this._eventWatcher = new EventWatcher(this._clients.ethClient, this._indexer, pubsub, this._jobQueue);
|
this._eventWatcher = new EventWatcher(this._clients.ethClient, this._indexer, pubsub, this._jobQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _getGraphWatcher (
|
|
||||||
baseDatabase: BaseDatabase,
|
|
||||||
entityQueryTypeMap?: Map<any, any>,
|
|
||||||
entityToLatestEntityMap?: Map<any, any>
|
|
||||||
): Promise<GraphWatcher> {
|
|
||||||
assert(this._config);
|
|
||||||
assert(this._clients?.ethClient);
|
|
||||||
assert(this._ethProvider);
|
|
||||||
|
|
||||||
this._graphDb = new GraphDatabase(this._config.server, baseDatabase, entityQueryTypeMap, entityToLatestEntityMap);
|
|
||||||
await this._graphDb.init();
|
|
||||||
|
|
||||||
return new GraphWatcher(this._graphDb, this._clients.ethClient, this._ethProvider, this._config.server);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,14 @@ import assert from 'assert';
|
|||||||
import { ConnectionOptions } from 'typeorm';
|
import { ConnectionOptions } from 'typeorm';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
|
||||||
import {
|
import {
|
||||||
JobQueue,
|
JobQueue,
|
||||||
DatabaseInterface,
|
DatabaseInterface,
|
||||||
IndexerInterface,
|
IndexerInterface,
|
||||||
ServerConfig,
|
ServerConfig,
|
||||||
Clients
|
Clients,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
|
|
||||||
import { BaseCmd } from '../base';
|
import { BaseCmd } from '../base';
|
||||||
@ -35,6 +36,22 @@ export class CreateCheckpointCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
async initConfig<ConfigType> (configFile: string): Promise<ConfigType> {
|
async initConfig<ConfigType> (configFile: string): Promise<ConfigType> {
|
||||||
return this._baseCmd.initConfig(configFile);
|
return this._baseCmd.initConfig(configFile);
|
||||||
}
|
}
|
||||||
@ -45,20 +62,26 @@ export class CreateCheckpointCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
this._argv = argv;
|
||||||
|
await this.initConfig(argv.configFile);
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
clients: { [key: string]: any } = {}
|
graphWatcher?: GraphWatcherInterface
|
||||||
): Promise<void> {
|
) {
|
||||||
this._argv = argv;
|
return this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await this.initConfig(argv.configFile);
|
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec (): Promise<void> {
|
async exec (): Promise<void> {
|
||||||
|
@ -8,14 +8,16 @@ import assert from 'assert';
|
|||||||
import { ConnectionOptions } from 'typeorm';
|
import { ConnectionOptions } from 'typeorm';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher, Database as GraphDatabase } from '@cerc-io/graph-node';
|
|
||||||
import {
|
import {
|
||||||
JobQueue,
|
JobQueue,
|
||||||
DatabaseInterface,
|
DatabaseInterface,
|
||||||
IndexerInterface,
|
IndexerInterface,
|
||||||
ServerConfig,
|
ServerConfig,
|
||||||
Clients,
|
Clients,
|
||||||
verifyCheckpointData
|
verifyCheckpointData,
|
||||||
|
GraphDatabase,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
|
|
||||||
import { BaseCmd } from '../base';
|
import { BaseCmd } from '../base';
|
||||||
@ -35,6 +37,22 @@ export class VerifyCheckpointCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
async initConfig<ConfigType> (configFile: string): Promise<ConfigType> {
|
async initConfig<ConfigType> (configFile: string): Promise<ConfigType> {
|
||||||
return this._baseCmd.initConfig(configFile);
|
return this._baseCmd.initConfig(configFile);
|
||||||
}
|
}
|
||||||
@ -45,23 +63,29 @@ export class VerifyCheckpointCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
this._argv = argv;
|
||||||
|
await this.initConfig(argv.configFile);
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
clients: { [key: string]: any } = {}
|
graphWatcher?: GraphWatcherInterface
|
||||||
): Promise<void> {
|
) {
|
||||||
this._argv = argv;
|
return this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await this.initConfig(argv.configFile);
|
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec (): Promise<void> {
|
async exec (graphDb: GraphDatabase): Promise<void> {
|
||||||
assert(this._argv);
|
assert(this._argv);
|
||||||
|
|
||||||
const database = this._baseCmd.database;
|
const database = this._baseCmd.database;
|
||||||
@ -70,9 +94,6 @@ export class VerifyCheckpointCmd {
|
|||||||
assert(database);
|
assert(database);
|
||||||
assert(indexer);
|
assert(indexer);
|
||||||
|
|
||||||
const graphDb: GraphDatabase | undefined = this._baseCmd.graphDb || database.graphDatabase;
|
|
||||||
assert(graphDb);
|
|
||||||
|
|
||||||
const state = await indexer.getStateByCID(this._argv.cid);
|
const state = await indexer.getStateByCID(this._argv.cid);
|
||||||
assert(state, 'State for the provided CID doesn\'t exist.');
|
assert(state, 'State for the provided CID doesn\'t exist.');
|
||||||
const data = indexer.getStateData(state);
|
const data = indexer.getStateData(state);
|
||||||
|
@ -11,7 +11,6 @@ import debug from 'debug';
|
|||||||
import { ConnectionOptions } from 'typeorm';
|
import { ConnectionOptions } from 'typeorm';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
|
||||||
import {
|
import {
|
||||||
DEFAULT_CONFIG_PATH,
|
DEFAULT_CONFIG_PATH,
|
||||||
JobQueue,
|
JobQueue,
|
||||||
@ -19,7 +18,9 @@ import {
|
|||||||
IndexerInterface,
|
IndexerInterface,
|
||||||
ServerConfig,
|
ServerConfig,
|
||||||
StateKind,
|
StateKind,
|
||||||
Clients
|
Clients,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
import * as codec from '@ipld/dag-cbor';
|
import * as codec from '@ipld/dag-cbor';
|
||||||
|
|
||||||
@ -41,6 +42,22 @@ export class ExportStateCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
async initConfig<ConfigType> (): Promise<ConfigType> {
|
async initConfig<ConfigType> (): Promise<ConfigType> {
|
||||||
this._argv = this._getArgv();
|
this._argv = this._getArgv();
|
||||||
assert(this._argv);
|
assert(this._argv);
|
||||||
@ -53,19 +70,25 @@ export class ExportStateCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
await this.initConfig();
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
clients: { [key: string]: any } = {}
|
graphWatcher?: GraphWatcherInterface
|
||||||
): Promise<void> {
|
) {
|
||||||
await this.initConfig();
|
return this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec (): Promise<void> {
|
async exec (): Promise<void> {
|
||||||
|
@ -11,9 +11,8 @@ import { ConnectionOptions } from 'typeorm';
|
|||||||
import { PubSub } from 'graphql-subscriptions';
|
import { PubSub } from 'graphql-subscriptions';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher, fillState } from '@cerc-io/graph-node';
|
|
||||||
import { EthClient } from '@cerc-io/ipld-eth-client';
|
|
||||||
import {
|
import {
|
||||||
|
fillState,
|
||||||
DEFAULT_CONFIG_PATH,
|
DEFAULT_CONFIG_PATH,
|
||||||
JobQueue,
|
JobQueue,
|
||||||
DatabaseInterface,
|
DatabaseInterface,
|
||||||
@ -21,8 +20,11 @@ import {
|
|||||||
ServerConfig,
|
ServerConfig,
|
||||||
Clients,
|
Clients,
|
||||||
EventWatcherInterface,
|
EventWatcherInterface,
|
||||||
fillBlocks
|
fillBlocks,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
|
import { EthClient } from '@cerc-io/ipld-eth-client';
|
||||||
|
|
||||||
import { BaseCmd } from './base';
|
import { BaseCmd } from './base';
|
||||||
|
|
||||||
@ -45,6 +47,22 @@ export class FillCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
get indexer (): IndexerInterface | undefined {
|
get indexer (): IndexerInterface | undefined {
|
||||||
return this._baseCmd.indexer;
|
return this._baseCmd.indexer;
|
||||||
}
|
}
|
||||||
@ -61,13 +79,21 @@ export class FillCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
await this.initConfig();
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
EventWatcher: new(
|
EventWatcher: new(
|
||||||
ethClient: EthClient,
|
ethClient: EthClient,
|
||||||
@ -75,13 +101,9 @@ export class FillCmd {
|
|||||||
pubsub: PubSub,
|
pubsub: PubSub,
|
||||||
jobQueue: JobQueue
|
jobQueue: JobQueue
|
||||||
) => EventWatcherInterface,
|
) => EventWatcherInterface,
|
||||||
clients: { [key: string]: any } = {},
|
graphWatcher?: GraphWatcherInterface
|
||||||
entityQueryTypeMap?: Map<any, any>,
|
) {
|
||||||
entityToLatestEntityMap?: Map<any, any>
|
await this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
): Promise<void> {
|
|
||||||
await this.initConfig();
|
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients, entityQueryTypeMap, entityToLatestEntityMap);
|
|
||||||
await this._baseCmd.initEventWatcher(EventWatcher);
|
await this._baseCmd.initEventWatcher(EventWatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import { ConnectionOptions } from 'typeorm';
|
|||||||
import { PubSub } from 'graphql-subscriptions';
|
import { PubSub } from 'graphql-subscriptions';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher, updateEntitiesFromState } from '@cerc-io/graph-node';
|
|
||||||
import { EthClient } from '@cerc-io/ipld-eth-client';
|
import { EthClient } from '@cerc-io/ipld-eth-client';
|
||||||
import {
|
import {
|
||||||
DEFAULT_CONFIG_PATH,
|
DEFAULT_CONFIG_PATH,
|
||||||
@ -23,7 +22,11 @@ import {
|
|||||||
Clients,
|
Clients,
|
||||||
EventWatcherInterface,
|
EventWatcherInterface,
|
||||||
fillBlocks,
|
fillBlocks,
|
||||||
StateKind
|
StateKind,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
GraphDatabase,
|
||||||
|
updateEntitiesFromState,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
import * as codec from '@ipld/dag-cbor';
|
import * as codec from '@ipld/dag-cbor';
|
||||||
|
|
||||||
@ -44,6 +47,22 @@ export class ImportStateCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
async initConfig<ConfigType> (): Promise<ConfigType> {
|
async initConfig<ConfigType> (): Promise<ConfigType> {
|
||||||
this._argv = this._getArgv();
|
this._argv = this._getArgv();
|
||||||
assert(this._argv);
|
assert(this._argv);
|
||||||
@ -56,13 +75,21 @@ export class ImportStateCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
await this.initConfig();
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
EventWatcher: new(
|
EventWatcher: new(
|
||||||
ethClient: EthClient,
|
ethClient: EthClient,
|
||||||
@ -70,15 +97,13 @@ export class ImportStateCmd {
|
|||||||
pubsub: PubSub,
|
pubsub: PubSub,
|
||||||
jobQueue: JobQueue
|
jobQueue: JobQueue
|
||||||
) => EventWatcherInterface,
|
) => EventWatcherInterface,
|
||||||
clients: { [key: string]: any } = {}
|
graphWatcher?: GraphWatcherInterface
|
||||||
): Promise<void> {
|
) {
|
||||||
await this.initConfig();
|
await this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients);
|
|
||||||
await this._baseCmd.initEventWatcher(EventWatcher);
|
await this._baseCmd.initEventWatcher(EventWatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec (State: new() => any): Promise<void> {
|
async exec (State: new() => any, graphDb?: GraphDatabase): Promise<void> {
|
||||||
assert(this._argv);
|
assert(this._argv);
|
||||||
|
|
||||||
const config = this._baseCmd.config;
|
const config = this._baseCmd.config;
|
||||||
@ -134,12 +159,8 @@ export class ImportStateCmd {
|
|||||||
// relationsMap defined for the watcher,
|
// relationsMap defined for the watcher,
|
||||||
// graphDb instance is avaiable
|
// graphDb instance is avaiable
|
||||||
// TODO: Fill latest entity tables
|
// TODO: Fill latest entity tables
|
||||||
if (indexer.getRelationsMap) {
|
if (indexer.getRelationsMap && graphDb) {
|
||||||
if (this._baseCmd.graphDb) {
|
await updateEntitiesFromState(graphDb, indexer, state);
|
||||||
await updateEntitiesFromState(this._baseCmd.graphDb, indexer, state);
|
|
||||||
} else if (database.graphDatabase) {
|
|
||||||
await updateEntitiesFromState(database.graphDatabase, indexer, state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import assert from 'assert';
|
|||||||
import { ConnectionOptions } from 'typeorm';
|
import { ConnectionOptions } from 'typeorm';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
|
||||||
import {
|
import {
|
||||||
DEFAULT_CONFIG_PATH,
|
DEFAULT_CONFIG_PATH,
|
||||||
JobQueue,
|
JobQueue,
|
||||||
@ -16,7 +15,9 @@ import {
|
|||||||
IndexerInterface,
|
IndexerInterface,
|
||||||
ServerConfig,
|
ServerConfig,
|
||||||
Clients,
|
Clients,
|
||||||
indexBlock
|
indexBlock,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
|
|
||||||
import { BaseCmd } from './base';
|
import { BaseCmd } from './base';
|
||||||
@ -34,6 +35,22 @@ export class IndexBlockCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
async initConfig<ConfigType> (): Promise<ConfigType> {
|
async initConfig<ConfigType> (): Promise<ConfigType> {
|
||||||
this._argv = this._getArgv();
|
this._argv = this._getArgv();
|
||||||
assert(this._argv);
|
assert(this._argv);
|
||||||
@ -46,19 +63,25 @@ export class IndexBlockCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
await this.initConfig();
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
clients: { [key: string]: any } = {}
|
graphWatcher?: GraphWatcherInterface
|
||||||
): Promise<void> {
|
) {
|
||||||
await this.initConfig();
|
return this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec (): Promise<void> {
|
async exec (): Promise<void> {
|
||||||
|
@ -10,14 +10,15 @@ import { ConnectionOptions } from 'typeorm';
|
|||||||
import util from 'util';
|
import util from 'util';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
|
||||||
import {
|
import {
|
||||||
DEFAULT_CONFIG_PATH,
|
DEFAULT_CONFIG_PATH,
|
||||||
JobQueue,
|
JobQueue,
|
||||||
DatabaseInterface,
|
DatabaseInterface,
|
||||||
IndexerInterface,
|
IndexerInterface,
|
||||||
ServerConfig,
|
ServerConfig,
|
||||||
Clients
|
Clients,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
|
|
||||||
import { BaseCmd } from './base';
|
import { BaseCmd } from './base';
|
||||||
@ -37,6 +38,22 @@ export class InspectCIDCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
async initConfig<ConfigType> (): Promise<ConfigType> {
|
async initConfig<ConfigType> (): Promise<ConfigType> {
|
||||||
this._argv = this._getArgv();
|
this._argv = this._getArgv();
|
||||||
assert(this._argv);
|
assert(this._argv);
|
||||||
@ -49,19 +66,25 @@ export class InspectCIDCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
await this.initConfig();
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
clients: { [key: string]: any } = {}
|
graphWatcher?: GraphWatcherInterface
|
||||||
): Promise<void> {
|
) {
|
||||||
await this.initConfig();
|
return this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec (): Promise<void> {
|
async exec (): Promise<void> {
|
||||||
|
@ -9,7 +9,6 @@ import assert from 'assert';
|
|||||||
import { ConnectionOptions } from 'typeorm';
|
import { ConnectionOptions } from 'typeorm';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
|
||||||
import {
|
import {
|
||||||
DEFAULT_CONFIG_PATH,
|
DEFAULT_CONFIG_PATH,
|
||||||
JobQueue,
|
JobQueue,
|
||||||
@ -18,7 +17,9 @@ import {
|
|||||||
ServerConfig,
|
ServerConfig,
|
||||||
Clients,
|
Clients,
|
||||||
JobRunner,
|
JobRunner,
|
||||||
startMetricsServer
|
GraphWatcherInterface,
|
||||||
|
startMetricsServer,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
|
|
||||||
import { BaseCmd } from './base';
|
import { BaseCmd } from './base';
|
||||||
@ -35,6 +36,22 @@ export class JobRunnerCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
get jobQueue (): JobQueue | undefined {
|
get jobQueue (): JobQueue | undefined {
|
||||||
return this._baseCmd.jobQueue;
|
return this._baseCmd.jobQueue;
|
||||||
}
|
}
|
||||||
@ -55,21 +72,25 @@ export class JobRunnerCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
await this.initConfig();
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
clients: { [key: string]: any } = {},
|
graphWatcher?: GraphWatcherInterface
|
||||||
entityQueryTypeMap?: Map<any, any>,
|
) {
|
||||||
entityToLatestEntityMap?: Map<any, any>
|
return this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
): Promise<void> {
|
|
||||||
await this.initConfig();
|
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients, entityQueryTypeMap, entityToLatestEntityMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec (startJobRunner: (jobRunner: JobRunner) => Promise<void>): Promise<void> {
|
async exec (startJobRunner: (jobRunner: JobRunner) => Promise<void>): Promise<void> {
|
||||||
|
@ -8,13 +8,14 @@ import assert from 'assert';
|
|||||||
import { ConnectionOptions } from 'typeorm';
|
import { ConnectionOptions } from 'typeorm';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
|
||||||
import {
|
import {
|
||||||
JobQueue,
|
JobQueue,
|
||||||
DatabaseInterface,
|
DatabaseInterface,
|
||||||
IndexerInterface,
|
IndexerInterface,
|
||||||
ServerConfig,
|
ServerConfig,
|
||||||
Clients
|
Clients,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
|
|
||||||
import { BaseCmd } from '../base';
|
import { BaseCmd } from '../base';
|
||||||
@ -34,6 +35,22 @@ export class ResetWatcherCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
async initConfig<ConfigType> (configFile: string): Promise<ConfigType> {
|
async initConfig<ConfigType> (configFile: string): Promise<ConfigType> {
|
||||||
return this._baseCmd.initConfig(configFile);
|
return this._baseCmd.initConfig(configFile);
|
||||||
}
|
}
|
||||||
@ -44,20 +61,26 @@ export class ResetWatcherCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
this._argv = argv;
|
||||||
|
await this.initConfig(argv.configFile);
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
clients: { [key: string]: any } = {}
|
graphWatcher?: GraphWatcherInterface
|
||||||
): Promise<void> {
|
) {
|
||||||
this._argv = argv;
|
return this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await this.initConfig(argv.configFile);
|
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec (): Promise<void> {
|
async exec (): Promise<void> {
|
||||||
|
@ -12,7 +12,6 @@ import express, { Application } from 'express';
|
|||||||
import { ApolloServer } from 'apollo-server-express';
|
import { ApolloServer } from 'apollo-server-express';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
|
||||||
import { EthClient } from '@cerc-io/ipld-eth-client';
|
import { EthClient } from '@cerc-io/ipld-eth-client';
|
||||||
import {
|
import {
|
||||||
DEFAULT_CONFIG_PATH,
|
DEFAULT_CONFIG_PATH,
|
||||||
@ -24,7 +23,9 @@ import {
|
|||||||
EventWatcherInterface,
|
EventWatcherInterface,
|
||||||
KIND_ACTIVE,
|
KIND_ACTIVE,
|
||||||
createAndStartServer,
|
createAndStartServer,
|
||||||
startGQLMetricsServer
|
startGQLMetricsServer,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
import { TypeSource } from '@graphql-tools/utils';
|
import { TypeSource } from '@graphql-tools/utils';
|
||||||
|
|
||||||
@ -42,6 +43,22 @@ export class ServerCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
async initConfig<ConfigType> (): Promise<ConfigType> {
|
async initConfig<ConfigType> (): Promise<ConfigType> {
|
||||||
this._argv = this._getArgv();
|
this._argv = this._getArgv();
|
||||||
assert(this._argv);
|
assert(this._argv);
|
||||||
@ -54,13 +71,21 @@ export class ServerCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
await this.initConfig();
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
EventWatcher: new(
|
EventWatcher: new(
|
||||||
ethClient: EthClient,
|
ethClient: EthClient,
|
||||||
@ -68,13 +93,9 @@ export class ServerCmd {
|
|||||||
pubsub: PubSub,
|
pubsub: PubSub,
|
||||||
jobQueue: JobQueue
|
jobQueue: JobQueue
|
||||||
) => EventWatcherInterface,
|
) => EventWatcherInterface,
|
||||||
clients: { [key: string]: any } = {},
|
graphWatcher?: GraphWatcherInterface
|
||||||
entityQueryTypeMap?: Map<any, any>,
|
) {
|
||||||
entityToLatestEntityMap?: Map<any, any>
|
await this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
): Promise<void> {
|
|
||||||
await this.initConfig();
|
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients, entityQueryTypeMap, entityToLatestEntityMap);
|
|
||||||
await this._baseCmd.initEventWatcher(EventWatcher);
|
await this._baseCmd.initEventWatcher(EventWatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,15 @@ import assert from 'assert';
|
|||||||
import { ConnectionOptions } from 'typeorm';
|
import { ConnectionOptions } from 'typeorm';
|
||||||
|
|
||||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
|
||||||
import {
|
import {
|
||||||
DEFAULT_CONFIG_PATH,
|
DEFAULT_CONFIG_PATH,
|
||||||
JobQueue,
|
JobQueue,
|
||||||
DatabaseInterface,
|
DatabaseInterface,
|
||||||
IndexerInterface,
|
IndexerInterface,
|
||||||
ServerConfig,
|
ServerConfig,
|
||||||
Clients
|
Clients,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
Config
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
|
|
||||||
import { BaseCmd } from './base';
|
import { BaseCmd } from './base';
|
||||||
@ -36,6 +37,22 @@ export class WatchContractCmd {
|
|||||||
this._baseCmd = new BaseCmd();
|
this._baseCmd = new BaseCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config (): Config | undefined {
|
||||||
|
return this._baseCmd.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clients (): Clients | undefined {
|
||||||
|
return this._baseCmd.clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
get ethProvider (): JsonRpcProvider | undefined {
|
||||||
|
return this._baseCmd.ethProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
get database (): DatabaseInterface | undefined {
|
||||||
|
return this._baseCmd.database;
|
||||||
|
}
|
||||||
|
|
||||||
async initConfig<ConfigType> (): Promise<ConfigType> {
|
async initConfig<ConfigType> (): Promise<ConfigType> {
|
||||||
this._argv = this._getArgv();
|
this._argv = this._getArgv();
|
||||||
assert(this._argv);
|
assert(this._argv);
|
||||||
@ -48,19 +65,25 @@ export class WatchContractCmd {
|
|||||||
config: ConnectionOptions,
|
config: ConnectionOptions,
|
||||||
serverConfig?: ServerConfig
|
serverConfig?: ServerConfig
|
||||||
) => DatabaseInterface,
|
) => DatabaseInterface,
|
||||||
|
clients: { [key: string]: any } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
await this.initConfig();
|
||||||
|
|
||||||
|
await this._baseCmd.init(Database, clients);
|
||||||
|
}
|
||||||
|
|
||||||
|
async initIndexer (
|
||||||
Indexer: new (
|
Indexer: new (
|
||||||
serverConfig: ServerConfig,
|
serverConfig: ServerConfig,
|
||||||
db: DatabaseInterface,
|
db: DatabaseInterface,
|
||||||
clients: Clients,
|
clients: Clients,
|
||||||
ethProvider: JsonRpcProvider,
|
ethProvider: JsonRpcProvider,
|
||||||
jobQueue: JobQueue,
|
jobQueue: JobQueue,
|
||||||
graphWatcher?: GraphWatcher
|
graphWatcher?: GraphWatcherInterface
|
||||||
) => IndexerInterface,
|
) => IndexerInterface,
|
||||||
clients: { [key: string]: any } = {}
|
graphWatcher?: GraphWatcherInterface
|
||||||
): Promise<void> {
|
) {
|
||||||
await this.initConfig();
|
return this._baseCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
|
||||||
await this._baseCmd.init(Database, Indexer, clients);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec (): Promise<void> {
|
async exec (): Promise<void> {
|
||||||
|
@ -3,8 +3,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { CreateCheckpointCmd } from '@cerc-io/cli';
|
import { CreateCheckpointCmd } from '@cerc-io/cli';
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
import { Database } from '../../database';
|
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from '../../database';
|
||||||
import { Indexer } from '../../indexer';
|
import { Indexer } from '../../indexer';
|
||||||
|
|
||||||
export const command = 'create';
|
export const command = 'create';
|
||||||
@ -26,7 +29,19 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const createCheckpointCmd = new CreateCheckpointCmd();
|
const createCheckpointCmd = new CreateCheckpointCmd();
|
||||||
await createCheckpointCmd.init(argv, Database, Indexer);
|
await createCheckpointCmd.init(argv, Database);
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
createCheckpointCmd.config!.server,
|
||||||
|
createCheckpointCmd.clients!.ethClient,
|
||||||
|
createCheckpointCmd.ethProvider!,
|
||||||
|
createCheckpointCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await createCheckpointCmd.initIndexer(Indexer{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
await createCheckpointCmd.exec();
|
await createCheckpointCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { VerifyCheckpointCmd } from '@cerc-io/cli';
|
import { VerifyCheckpointCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../../database';
|
||||||
import { Indexer } from '../../indexer';
|
import { Indexer } from '../../indexer';
|
||||||
|
|
||||||
export const command = 'verify';
|
export const command = 'verify';
|
||||||
@ -22,7 +23,17 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const verifyCheckpointCmd = new VerifyCheckpointCmd();
|
const verifyCheckpointCmd = new VerifyCheckpointCmd();
|
||||||
await verifyCheckpointCmd.init(argv, Database, Indexer);
|
await verifyCheckpointCmd.init(argv, Database);
|
||||||
|
|
||||||
await verifyCheckpointCmd.exec();
|
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
|
||||||
|
verifyCheckpointCmd.config!.server,
|
||||||
|
verifyCheckpointCmd.clients!.ethClient,
|
||||||
|
verifyCheckpointCmd.ethProvider!,
|
||||||
|
verifyCheckpointCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await verifyCheckpointCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
await verifyCheckpointCmd.exec(graphDb);
|
||||||
};
|
};
|
||||||
|
@ -6,10 +6,16 @@ import assert from 'assert';
|
|||||||
import { Connection, ConnectionOptions, DeepPartial, FindConditions, QueryRunner, FindManyOptions, EntityTarget } from 'typeorm';
|
import { Connection, ConnectionOptions, DeepPartial, FindConditions, QueryRunner, FindManyOptions, EntityTarget } from 'typeorm';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { Database as BaseDatabase, DatabaseInterface, QueryOptions, StateKind, Where } from '@cerc-io/util';
|
import {
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
import { ENTITY_QUERY_TYPE } from '@cerc-io/graph-node';
|
ENTITY_QUERY_TYPE,
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Database as BaseDatabase,
|
||||||
|
DatabaseInterface,
|
||||||
|
QueryOptions,
|
||||||
|
StateKind,
|
||||||
|
Where
|
||||||
|
} from '@cerc-io/util';
|
||||||
|
|
||||||
import { Contract } from './entity/Contract';
|
import { Contract } from './entity/Contract';
|
||||||
import { Event } from './entity/Event';
|
import { Event } from './entity/Event';
|
||||||
|
@ -6,16 +6,31 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ExportStateCmd } from '@cerc-io/cli';
|
import { ExportStateCmd } from '@cerc-io/cli';
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:export-state');
|
const log = debug('vulcanize:export-state');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const exportStateCmd = new ExportStateCmd();
|
const exportStateCmd = new ExportStateCmd();
|
||||||
await exportStateCmd.init(Database, Indexer);
|
await exportStateCmd.init(Database);
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
exportStateCmd.config!.server,
|
||||||
|
exportStateCmd.clients!.ethClient,
|
||||||
|
exportStateCmd.ethProvider!,
|
||||||
|
exportStateCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await exportStateCmd.initIndexer(Indexer{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
await exportStateCmd.exec();
|
await exportStateCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,15 +2,14 @@
|
|||||||
// Copyright 2021 Vulcanize, Inc.
|
// Copyright 2021 Vulcanize, Inc.
|
||||||
//
|
//
|
||||||
|
|
||||||
{{#if (subgraphPath)}}
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
{{/if}}
|
|
||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { FillCmd } from '@cerc-io/cli';
|
import { FillCmd } from '@cerc-io/cli';
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
import { getContractEntitiesMap } from '@cerc-io/graph-node';
|
import { getContractEntitiesMap } from '@cerc-io/util';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from './database';
|
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from './database';
|
||||||
@ -21,15 +20,25 @@ const log = debug('vulcanize:fill');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const fillCmd = new FillCmd();
|
const fillCmd = new FillCmd();
|
||||||
await fillCmd.init(Database, Indexer, EventWatcher{{#if (subgraphPath)}}, {}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}});
|
await fillCmd.init(Database);
|
||||||
|
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
const indexer = fillCmd.indexer as Indexer;
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
assert(indexer);
|
fillCmd.config!.server,
|
||||||
|
fillCmd.clients!.ethClient,
|
||||||
|
fillCmd.ethProvider!,
|
||||||
|
fillCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await fillCmd.initIndexer(Indexer, EventWatcher{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
// Get contractEntitiesMap required for fill-state
|
// Get contractEntitiesMap required for fill-state
|
||||||
// NOTE: Assuming each entity type is only mapped to a single contract
|
// NOTE: Assuming each entity type is only mapped to a single contract
|
||||||
const contractEntitiesMap = getContractEntitiesMap(indexer.graphWatcher.dataSources);
|
const contractEntitiesMap = getContractEntitiesMap(graphWatcher.dataSources);
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
await fillCmd.exec({{#if (subgraphPath)}}contractEntitiesMap{{/if}});
|
await fillCmd.exec({{#if (subgraphPath)}}contractEntitiesMap{{/if}});
|
||||||
|
@ -6,8 +6,11 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ImportStateCmd } from '@cerc-io/cli';
|
import { ImportStateCmd } from '@cerc-io/cli';
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
import { EventWatcher } from '../events';
|
import { EventWatcher } from '../events';
|
||||||
import { State } from '../entity/State';
|
import { State } from '../entity/State';
|
||||||
@ -16,9 +19,21 @@ const log = debug('vulcanize:import-state');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const importStateCmd = new ImportStateCmd();
|
const importStateCmd = new ImportStateCmd();
|
||||||
await importStateCmd.init(Database, Indexer, EventWatcher);
|
await importStateCmd.init(Database);
|
||||||
|
|
||||||
await importStateCmd.exec(State);
|
{{#if (subgraphPath)}}
|
||||||
|
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
|
||||||
|
importStateCmd.config!.server,
|
||||||
|
importStateCmd.clients!.ethClient,
|
||||||
|
importStateCmd.ethProvider!,
|
||||||
|
importStateCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await importStateCmd.initIndexer(Indexer, EventWatcher{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
|
await importStateCmd.exec(State{{#if (subgraphPath)}}, graphDb{{/if}});
|
||||||
};
|
};
|
||||||
|
|
||||||
main().catch(err => {
|
main().catch(err => {
|
||||||
|
@ -6,16 +6,31 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { IndexBlockCmd } from '@cerc-io/cli';
|
import { IndexBlockCmd } from '@cerc-io/cli';
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:index-block');
|
const log = debug('vulcanize:index-block');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const indexBlockCmd = new IndexBlockCmd();
|
const indexBlockCmd = new IndexBlockCmd();
|
||||||
await indexBlockCmd.init(Database, Indexer);
|
await indexBlockCmd.init(Database);
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
indexBlockCmd.config!.server,
|
||||||
|
indexBlockCmd.clients!.ethClient,
|
||||||
|
indexBlockCmd.ethProvider!,
|
||||||
|
indexBlockCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await indexBlockCmd.initIndexer(Indexer{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
await indexBlockCmd.exec();
|
await indexBlockCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@ import {
|
|||||||
updateStateForMappingType,
|
updateStateForMappingType,
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
BlockHeight,
|
BlockHeight,
|
||||||
|
updateSubgraphState,
|
||||||
|
dumpSubgraphState,
|
||||||
|
GraphWatcherInterface,
|
||||||
{{/if}}
|
{{/if}}
|
||||||
StateKind,
|
StateKind,
|
||||||
StateStatus,
|
StateStatus,
|
||||||
@ -36,7 +39,7 @@ import {
|
|||||||
Clients
|
Clients
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
import { GraphWatcher, updateSubgraphState, dumpSubgraphState } from '@cerc-io/graph-node';
|
import { GraphWatcher } from '@cerc-io/graph-node';
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#each contracts as | contract |}}
|
{{#each contracts as | contract |}}
|
||||||
@ -89,7 +92,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
_subgraphStateMap: Map<string, any>
|
_subgraphStateMap: Map<string, any>
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
constructor (serverConfig: ServerConfig, db: DatabaseInterface, clients: Clients, ethProvider: BaseProvider, jobQueue: JobQueue{{#if (subgraphPath)}}, graphWatcher?: GraphWatcher{{/if}}) {
|
constructor (serverConfig: ServerConfig, db: DatabaseInterface, clients: Clients, ethProvider: BaseProvider, jobQueue: JobQueue{{#if (subgraphPath)}}, graphWatcher?: GraphWatcherInterface{{/if}}) {
|
||||||
assert(db);
|
assert(db);
|
||||||
assert(clients.ethClient);
|
assert(clients.ethClient);
|
||||||
|
|
||||||
@ -100,7 +103,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
this._baseIndexer = new BaseIndexer(this._serverConfig, this._db, this._ethClient, this._ethProvider, jobQueue);
|
this._baseIndexer = new BaseIndexer(this._serverConfig, this._db, this._ethClient, this._ethProvider, jobQueue);
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
assert(graphWatcher);
|
assert(graphWatcher);
|
||||||
this._graphWatcher = graphWatcher;
|
this._graphWatcher = graphWatcher as GraphWatcher;
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
this._abiMap = new Map();
|
this._abiMap = new Map();
|
||||||
|
@ -6,16 +6,31 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { InspectCIDCmd } from '@cerc-io/cli';
|
import { InspectCIDCmd } from '@cerc-io/cli';
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:inspect-cid');
|
const log = debug('vulcanize:inspect-cid');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const inspectCIDCmd = new InspectCIDCmd();
|
const inspectCIDCmd = new InspectCIDCmd();
|
||||||
await inspectCIDCmd.init(Database, Indexer);
|
await inspectCIDCmd.init(Database);
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
inspectCIDCmd.config!.server,
|
||||||
|
inspectCIDCmd.clients!.ethClient,
|
||||||
|
inspectCIDCmd.ethProvider!,
|
||||||
|
inspectCIDCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await inspectCIDCmd.initIndexer(Indexer{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
await inspectCIDCmd.exec();
|
await inspectCIDCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ import debug from 'debug';
|
|||||||
|
|
||||||
import { JobRunnerCmd } from '@cerc-io/cli';
|
import { JobRunnerCmd } from '@cerc-io/cli';
|
||||||
import { JobRunner } from '@cerc-io/util';
|
import { JobRunner } from '@cerc-io/util';
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
import { Indexer } from './indexer';
|
import { Indexer } from './indexer';
|
||||||
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from './database';
|
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from './database';
|
||||||
@ -14,7 +17,20 @@ const log = debug('vulcanize:job-runner');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const jobRunnerCmd = new JobRunnerCmd();
|
const jobRunnerCmd = new JobRunnerCmd();
|
||||||
await jobRunnerCmd.init(Database, Indexer{{#if (subgraphPath)}}, {}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}});
|
await jobRunnerCmd.init(Database);
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
jobRunnerCmd.config!.server,
|
||||||
|
jobRunnerCmd.clients!.ethClient,
|
||||||
|
jobRunnerCmd.ethProvider!,
|
||||||
|
jobRunnerCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await jobRunnerCmd.initIndexer(Indexer{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
|
|
||||||
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
||||||
await jobRunner.subscribeBlockProcessingQueue();
|
await jobRunner.subscribeBlockProcessingQueue();
|
||||||
|
@ -3,8 +3,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { ResetWatcherCmd } from '@cerc-io/cli';
|
import { ResetWatcherCmd } from '@cerc-io/cli';
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
import { Database } from '../../database';
|
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from '../../database';
|
||||||
import { Indexer } from '../../indexer';
|
import { Indexer } from '../../indexer';
|
||||||
|
|
||||||
export const command = 'watcher';
|
export const command = 'watcher';
|
||||||
@ -19,7 +22,19 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const resetWatcherCmd = new ResetWatcherCmd();
|
const resetWatcherCmd = new ResetWatcherCmd();
|
||||||
await resetWatcherCmd.init(argv, Database, Indexer);
|
await resetWatcherCmd.init(argv, Database);
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
|
||||||
|
resetWatcherCmd.config!.server,
|
||||||
|
resetWatcherCmd.clients!.ethClient,
|
||||||
|
resetWatcherCmd.ethProvider!,
|
||||||
|
resetWatcherCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await resetWatcherCmd.initIndexer(Indexer{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
await resetWatcherCmd.exec();
|
await resetWatcherCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,9 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ServerCmd } from '@cerc-io/cli';
|
import { ServerCmd } from '@cerc-io/cli';
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
import { createResolvers } from './resolvers';
|
import { createResolvers } from './resolvers';
|
||||||
import { Indexer } from './indexer';
|
import { Indexer } from './indexer';
|
||||||
@ -18,10 +21,22 @@ const log = debug('vulcanize:server');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const serverCmd = new ServerCmd();
|
const serverCmd = new ServerCmd();
|
||||||
await serverCmd.init(Database, Indexer, EventWatcher{{#if (subgraphPath)}}, {}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}});
|
await serverCmd.init(Database);
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
serverCmd.config!.server,
|
||||||
|
serverCmd.clients!.ethClient,
|
||||||
|
serverCmd.ethProvider!,
|
||||||
|
serverCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await serverCmd.initIndexer(Indexer, EventWatcher{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
|
|
||||||
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
||||||
|
|
||||||
return serverCmd.exec(createResolvers, typeDefs);
|
return serverCmd.exec(createResolvers, typeDefs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
|
|
||||||
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
||||||
|
|
||||||
|
import { afterEntityInsertOrUpdate } from '@cerc-io/util';
|
||||||
|
|
||||||
import { FrothyEntity } from './FrothyEntity';
|
import { FrothyEntity } from './FrothyEntity';
|
||||||
import { ENTITY_TO_LATEST_ENTITY_MAP, SUBGRAPH_ENTITIES } from '../database';
|
import { ENTITY_TO_LATEST_ENTITY_MAP, SUBGRAPH_ENTITIES } from '../database';
|
||||||
import { afterEntityInsertOrUpdate } from '@cerc-io/graph-node';
|
|
||||||
|
|
||||||
@EventSubscriber()
|
@EventSubscriber()
|
||||||
export class EntitySubscriber implements EntitySubscriberInterface {
|
export class EntitySubscriber implements EntitySubscriberInterface {
|
||||||
|
@ -6,16 +6,31 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { WatchContractCmd } from '@cerc-io/cli';
|
import { WatchContractCmd } from '@cerc-io/cli';
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database{{#if (subgraphPath)}}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP{{/if}} } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:watch-contract');
|
const log = debug('vulcanize:watch-contract');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const watchContractCmd = new WatchContractCmd();
|
const watchContractCmd = new WatchContractCmd();
|
||||||
await watchContractCmd.init(Database, Indexer);
|
await watchContractCmd.init(Database);
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
watchContractCmd.config!.server,
|
||||||
|
watchContractCmd.clients!.ethClient,
|
||||||
|
watchContractCmd.ethProvider!,
|
||||||
|
watchContractCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
await watchContractCmd.initIndexer(Indexer{{#if (subgraphPath)}}, graphWatcher{{/if}});
|
||||||
await watchContractCmd.exec();
|
await watchContractCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { CreateCheckpointCmd } from '@cerc-io/cli';
|
import { CreateCheckpointCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../../database';
|
||||||
import { Indexer } from '../../indexer';
|
import { Indexer } from '../../indexer';
|
||||||
|
|
||||||
export const command = 'create';
|
export const command = 'create';
|
||||||
@ -26,7 +27,17 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const createCheckpointCmd = new CreateCheckpointCmd();
|
const createCheckpointCmd = new CreateCheckpointCmd();
|
||||||
await createCheckpointCmd.init(argv, Database, Indexer);
|
await createCheckpointCmd.init(argv, Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
createCheckpointCmd.config!.server,
|
||||||
|
createCheckpointCmd.clients!.ethClient,
|
||||||
|
createCheckpointCmd.ethProvider!,
|
||||||
|
createCheckpointCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await createCheckpointCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await createCheckpointCmd.exec();
|
await createCheckpointCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { VerifyCheckpointCmd } from '@cerc-io/cli';
|
import { VerifyCheckpointCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../../database';
|
||||||
import { Indexer } from '../../indexer';
|
import { Indexer } from '../../indexer';
|
||||||
|
|
||||||
export const command = 'verify';
|
export const command = 'verify';
|
||||||
@ -22,7 +23,17 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const verifyCheckpointCmd = new VerifyCheckpointCmd();
|
const verifyCheckpointCmd = new VerifyCheckpointCmd();
|
||||||
await verifyCheckpointCmd.init(argv, Database, Indexer);
|
await verifyCheckpointCmd.init(argv, Database);
|
||||||
|
|
||||||
await verifyCheckpointCmd.exec();
|
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
|
||||||
|
verifyCheckpointCmd.config!.server,
|
||||||
|
verifyCheckpointCmd.clients!.ethClient,
|
||||||
|
verifyCheckpointCmd.ethProvider!,
|
||||||
|
verifyCheckpointCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await verifyCheckpointCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
await verifyCheckpointCmd.exec(graphDb);
|
||||||
};
|
};
|
||||||
|
@ -6,16 +6,27 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ExportStateCmd } from '@cerc-io/cli';
|
import { ExportStateCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:export-state');
|
const log = debug('vulcanize:export-state');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const exportStateCmd = new ExportStateCmd();
|
const exportStateCmd = new ExportStateCmd();
|
||||||
await exportStateCmd.init(Database, Indexer);
|
await exportStateCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
exportStateCmd.config!.server,
|
||||||
|
exportStateCmd.clients!.ethClient,
|
||||||
|
exportStateCmd.ethProvider!,
|
||||||
|
exportStateCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await exportStateCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await exportStateCmd.exec();
|
await exportStateCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,8 +6,9 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ImportStateCmd } from '@cerc-io/cli';
|
import { ImportStateCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
import { EventWatcher } from '../events';
|
import { EventWatcher } from '../events';
|
||||||
import { State } from '../entity/State';
|
import { State } from '../entity/State';
|
||||||
@ -16,9 +17,19 @@ const log = debug('vulcanize:import-state');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const importStateCmd = new ImportStateCmd();
|
const importStateCmd = new ImportStateCmd();
|
||||||
await importStateCmd.init(Database, Indexer, EventWatcher);
|
await importStateCmd.init(Database);
|
||||||
|
|
||||||
await importStateCmd.exec(State);
|
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
|
||||||
|
importStateCmd.config!.server,
|
||||||
|
importStateCmd.clients!.ethClient,
|
||||||
|
importStateCmd.ethProvider!,
|
||||||
|
importStateCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await importStateCmd.initIndexer(Indexer, EventWatcher, graphWatcher);
|
||||||
|
await importStateCmd.exec(State, graphDb);
|
||||||
};
|
};
|
||||||
|
|
||||||
main().catch(err => {
|
main().catch(err => {
|
||||||
|
@ -6,16 +6,27 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { IndexBlockCmd } from '@cerc-io/cli';
|
import { IndexBlockCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:index-block');
|
const log = debug('vulcanize:index-block');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const indexBlockCmd = new IndexBlockCmd();
|
const indexBlockCmd = new IndexBlockCmd();
|
||||||
await indexBlockCmd.init(Database, Indexer);
|
await indexBlockCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
indexBlockCmd.config!.server,
|
||||||
|
indexBlockCmd.clients!.ethClient,
|
||||||
|
indexBlockCmd.ethProvider!,
|
||||||
|
indexBlockCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await indexBlockCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await indexBlockCmd.exec();
|
await indexBlockCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,16 +6,27 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { InspectCIDCmd } from '@cerc-io/cli';
|
import { InspectCIDCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:inspect-cid');
|
const log = debug('vulcanize:inspect-cid');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const inspectCIDCmd = new InspectCIDCmd();
|
const inspectCIDCmd = new InspectCIDCmd();
|
||||||
await inspectCIDCmd.init(Database, Indexer);
|
await inspectCIDCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
inspectCIDCmd.config!.server,
|
||||||
|
inspectCIDCmd.clients!.ethClient,
|
||||||
|
inspectCIDCmd.ethProvider!,
|
||||||
|
inspectCIDCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await inspectCIDCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await inspectCIDCmd.exec();
|
await inspectCIDCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { ResetWatcherCmd } from '@cerc-io/cli';
|
import { ResetWatcherCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../../database';
|
||||||
import { Indexer } from '../../indexer';
|
import { Indexer } from '../../indexer';
|
||||||
|
|
||||||
export const command = 'watcher';
|
export const command = 'watcher';
|
||||||
@ -19,7 +20,17 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const resetWatcherCmd = new ResetWatcherCmd();
|
const resetWatcherCmd = new ResetWatcherCmd();
|
||||||
await resetWatcherCmd.init(argv, Database, Indexer);
|
await resetWatcherCmd.init(argv, Database);
|
||||||
|
|
||||||
|
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
|
||||||
|
resetWatcherCmd.config!.server,
|
||||||
|
resetWatcherCmd.clients!.ethClient,
|
||||||
|
resetWatcherCmd.ethProvider!,
|
||||||
|
resetWatcherCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await resetWatcherCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await resetWatcherCmd.exec();
|
await resetWatcherCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -6,16 +6,27 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { WatchContractCmd } from '@cerc-io/cli';
|
import { WatchContractCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:watch-contract');
|
const log = debug('vulcanize:watch-contract');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const watchContractCmd = new WatchContractCmd();
|
const watchContractCmd = new WatchContractCmd();
|
||||||
await watchContractCmd.init(Database, Indexer);
|
await watchContractCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
watchContractCmd.config!.server,
|
||||||
|
watchContractCmd.clients!.ethClient,
|
||||||
|
watchContractCmd.ethProvider!,
|
||||||
|
watchContractCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await watchContractCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await watchContractCmd.exec();
|
await watchContractCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
||||||
|
|
||||||
import { afterEntityInsertOrUpdate } from '@cerc-io/graph-node';
|
import { afterEntityInsertOrUpdate } from '@cerc-io/util';
|
||||||
|
|
||||||
import { FrothyEntity } from './FrothyEntity';
|
import { FrothyEntity } from './FrothyEntity';
|
||||||
import { ENTITY_TO_LATEST_ENTITY_MAP, SUBGRAPH_ENTITIES } from '../database';
|
import { ENTITY_TO_LATEST_ENTITY_MAP, SUBGRAPH_ENTITIES } from '../database';
|
||||||
|
@ -7,7 +7,8 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { FillCmd } from '@cerc-io/cli';
|
import { FillCmd } from '@cerc-io/cli';
|
||||||
import { getContractEntitiesMap } from '@cerc-io/graph-node';
|
import { getContractEntitiesMap } from '@cerc-io/util';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from './database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from './database';
|
||||||
import { Indexer } from './indexer';
|
import { Indexer } from './indexer';
|
||||||
@ -17,15 +18,23 @@ const log = debug('vulcanize:fill');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const fillCmd = new FillCmd();
|
const fillCmd = new FillCmd();
|
||||||
await fillCmd.init(Database, Indexer, EventWatcher, {}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP);
|
await fillCmd.init(Database);
|
||||||
|
|
||||||
const indexer = fillCmd.indexer as Indexer;
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
assert(indexer);
|
fillCmd.config!.server,
|
||||||
|
fillCmd.clients!.ethClient,
|
||||||
|
fillCmd.ethProvider!,
|
||||||
|
fillCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await fillCmd.initIndexer(Indexer, EventWatcher, graphWatcher);
|
||||||
|
|
||||||
// Get contractEntitiesMap required for fill-state
|
// Get contractEntitiesMap required for fill-state
|
||||||
// NOTE: Assuming each entity type is only mapped to a single contract
|
// NOTE: Assuming each entity type is only mapped to a single contract
|
||||||
// This is true for eden subgraph; may not be the case for other subgraphs
|
// This is true for eden subgraph; may not be the case for other subgraphs
|
||||||
const contractEntitiesMap = getContractEntitiesMap(indexer.graphWatcher.dataSources);
|
const contractEntitiesMap = getContractEntitiesMap(graphWatcher.dataSources);
|
||||||
|
|
||||||
await fillCmd.exec(contractEntitiesMap);
|
await fillCmd.exec(contractEntitiesMap);
|
||||||
};
|
};
|
||||||
|
@ -25,9 +25,12 @@ import {
|
|||||||
ResultEvent,
|
ResultEvent,
|
||||||
getResultEvent,
|
getResultEvent,
|
||||||
DatabaseInterface,
|
DatabaseInterface,
|
||||||
Clients
|
Clients,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
updateSubgraphState,
|
||||||
|
dumpSubgraphState
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
import { GraphWatcher, updateSubgraphState, dumpSubgraphState } from '@cerc-io/graph-node';
|
import { GraphWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database, ENTITIES, SUBGRAPH_ENTITIES } from './database';
|
import { Database, ENTITIES, SUBGRAPH_ENTITIES } from './database';
|
||||||
import { Contract } from './entity/Contract';
|
import { Contract } from './entity/Contract';
|
||||||
@ -79,7 +82,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
|
|
||||||
_subgraphStateMap: Map<string, any>
|
_subgraphStateMap: Map<string, any>
|
||||||
|
|
||||||
constructor (serverConfig: ServerConfig, db: DatabaseInterface, clients: Clients, ethProvider: BaseProvider, jobQueue: JobQueue, graphWatcher?: GraphWatcher) {
|
constructor (serverConfig: ServerConfig, db: DatabaseInterface, clients: Clients, ethProvider: BaseProvider, jobQueue: JobQueue, graphWatcher?: GraphWatcherInterface) {
|
||||||
assert(db);
|
assert(db);
|
||||||
assert(clients.ethClient);
|
assert(clients.ethClient);
|
||||||
|
|
||||||
@ -90,7 +93,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
this._baseIndexer = new BaseIndexer(this._serverConfig, this._db, this._ethClient, this._ethProvider, jobQueue);
|
this._baseIndexer = new BaseIndexer(this._serverConfig, this._db, this._ethClient, this._ethProvider, jobQueue);
|
||||||
|
|
||||||
assert(graphWatcher);
|
assert(graphWatcher);
|
||||||
this._graphWatcher = graphWatcher;
|
this._graphWatcher = graphWatcher as GraphWatcher;
|
||||||
|
|
||||||
this._abiMap = new Map();
|
this._abiMap = new Map();
|
||||||
this._storageLayoutMap = new Map();
|
this._storageLayoutMap = new Map();
|
||||||
|
@ -6,6 +6,7 @@ import debug from 'debug';
|
|||||||
|
|
||||||
import { JobRunnerCmd } from '@cerc-io/cli';
|
import { JobRunnerCmd } from '@cerc-io/cli';
|
||||||
import { JobRunner } from '@cerc-io/util';
|
import { JobRunner } from '@cerc-io/util';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Indexer } from './indexer';
|
import { Indexer } from './indexer';
|
||||||
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from './database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from './database';
|
||||||
@ -14,7 +15,18 @@ const log = debug('vulcanize:job-runner');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const jobRunnerCmd = new JobRunnerCmd();
|
const jobRunnerCmd = new JobRunnerCmd();
|
||||||
await jobRunnerCmd.init(Database, Indexer, {}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP);
|
await jobRunnerCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
jobRunnerCmd.config!.server,
|
||||||
|
jobRunnerCmd.clients!.ethClient,
|
||||||
|
jobRunnerCmd.ethProvider!,
|
||||||
|
jobRunnerCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await jobRunnerCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
|
||||||
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
||||||
await jobRunner.subscribeBlockProcessingQueue();
|
await jobRunner.subscribeBlockProcessingQueue();
|
||||||
|
@ -8,6 +8,7 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ServerCmd } from '@cerc-io/cli';
|
import { ServerCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { createResolvers } from './resolvers';
|
import { createResolvers } from './resolvers';
|
||||||
import { Indexer } from './indexer';
|
import { Indexer } from './indexer';
|
||||||
@ -18,10 +19,20 @@ const log = debug('vulcanize:server');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const serverCmd = new ServerCmd();
|
const serverCmd = new ServerCmd();
|
||||||
await serverCmd.init(Database, Indexer, EventWatcher, {}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP);
|
await serverCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
serverCmd.config!.server,
|
||||||
|
serverCmd.clients!.ethClient,
|
||||||
|
serverCmd.ethProvider!,
|
||||||
|
serverCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await serverCmd.initIndexer(Indexer, EventWatcher, graphWatcher);
|
||||||
|
|
||||||
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
||||||
|
|
||||||
return serverCmd.exec(createResolvers, typeDefs);
|
return serverCmd.exec(createResolvers, typeDefs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const resetWatcherCmd = new ResetWatcherCmd();
|
const resetWatcherCmd = new ResetWatcherCmd();
|
||||||
await resetWatcherCmd.init(argv, Database, Indexer);
|
await resetWatcherCmd.init(argv, Database);
|
||||||
|
await resetWatcherCmd.initIndexer(Indexer);
|
||||||
await resetWatcherCmd.exec();
|
await resetWatcherCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -14,8 +14,8 @@ const log = debug('vulcanize:watch-contract');
|
|||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const watchContractCmd = new WatchContractCmd();
|
const watchContractCmd = new WatchContractCmd();
|
||||||
await watchContractCmd.init(Database, Indexer);
|
await watchContractCmd.init(Database);
|
||||||
|
await watchContractCmd.initIndexer(Indexer);
|
||||||
await watchContractCmd.exec();
|
await watchContractCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ const log = debug('vulcanize:fill');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const fillCmd = new FillCmd();
|
const fillCmd = new FillCmd();
|
||||||
await fillCmd.init(Database, Indexer, EventWatcher);
|
await fillCmd.init(Database);
|
||||||
|
await fillCmd.initIndexer(Indexer, EventWatcher);
|
||||||
await fillCmd.exec();
|
await fillCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ const log = debug('vulcanize:job-runner');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const jobRunnerCmd = new JobRunnerCmd();
|
const jobRunnerCmd = new JobRunnerCmd();
|
||||||
await jobRunnerCmd.init(Database, Indexer);
|
await jobRunnerCmd.init(Database);
|
||||||
|
await jobRunnerCmd.initIndexer(Indexer);
|
||||||
|
|
||||||
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
||||||
await jobRunner.subscribeBlockProcessingQueue();
|
await jobRunner.subscribeBlockProcessingQueue();
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
// Copyright 2021 Vulcanize, Inc.
|
// Copyright 2021 Vulcanize, Inc.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import 'reflect-metadata';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ServerCmd } from '@cerc-io/cli';
|
import { ServerCmd } from '@cerc-io/cli';
|
||||||
@ -16,7 +19,8 @@ const log = debug('vulcanize:server');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const serverCmd = new ServerCmd();
|
const serverCmd = new ServerCmd();
|
||||||
await serverCmd.init(Database, Indexer, EventWatcher);
|
await serverCmd.init(Database);
|
||||||
|
await serverCmd.initIndexer(Indexer, EventWatcher);
|
||||||
|
|
||||||
return serverCmd.exec(createResolvers, typeDefs);
|
return serverCmd.exec(createResolvers, typeDefs);
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,7 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const createCheckpointCmd = new CreateCheckpointCmd();
|
const createCheckpointCmd = new CreateCheckpointCmd();
|
||||||
await createCheckpointCmd.init(argv, Database, Indexer);
|
await createCheckpointCmd.init(argv, Database);
|
||||||
|
await createCheckpointCmd.initIndexer(Indexer);
|
||||||
await createCheckpointCmd.exec();
|
await createCheckpointCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -14,8 +14,8 @@ const log = debug('vulcanize:export-state');
|
|||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const exportStateCmd = new ExportStateCmd();
|
const exportStateCmd = new ExportStateCmd();
|
||||||
await exportStateCmd.init(Database, Indexer);
|
await exportStateCmd.init(Database);
|
||||||
|
await exportStateCmd.initIndexer(Indexer);
|
||||||
await exportStateCmd.exec();
|
await exportStateCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ const log = debug('vulcanize:import-state');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const importStateCmd = new ImportStateCmd();
|
const importStateCmd = new ImportStateCmd();
|
||||||
await importStateCmd.init(Database, Indexer, EventWatcher);
|
await importStateCmd.init(Database);
|
||||||
|
await importStateCmd.initIndexer(Indexer, EventWatcher);
|
||||||
await importStateCmd.exec(State);
|
await importStateCmd.exec(State);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ const log = debug('vulcanize:index-block');
|
|||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const indexBlockCmd = new IndexBlockCmd();
|
const indexBlockCmd = new IndexBlockCmd();
|
||||||
await indexBlockCmd.init(Database, Indexer);
|
await indexBlockCmd.init(Database);
|
||||||
|
await indexBlockCmd.initIndexer(Indexer);
|
||||||
await indexBlockCmd.exec();
|
await indexBlockCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ const log = debug('vulcanize:inspect-cid');
|
|||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const inspectCIDCmd = new InspectCIDCmd();
|
const inspectCIDCmd = new InspectCIDCmd();
|
||||||
await inspectCIDCmd.init(Database, Indexer);
|
await inspectCIDCmd.init(Database);
|
||||||
|
await inspectCIDCmd.initIndexer(Indexer);
|
||||||
await inspectCIDCmd.exec();
|
await inspectCIDCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const resetWatcherCmd = new ResetWatcherCmd();
|
const resetWatcherCmd = new ResetWatcherCmd();
|
||||||
await resetWatcherCmd.init(argv, Database, Indexer);
|
await resetWatcherCmd.init(argv, Database);
|
||||||
|
await resetWatcherCmd.initIndexer(Indexer);
|
||||||
await resetWatcherCmd.exec();
|
await resetWatcherCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -14,8 +14,8 @@ const log = debug('vulcanize:watch-contract');
|
|||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const watchContractCmd = new WatchContractCmd();
|
const watchContractCmd = new WatchContractCmd();
|
||||||
await watchContractCmd.init(Database, Indexer);
|
await watchContractCmd.init(Database);
|
||||||
|
await watchContractCmd.initIndexer(Indexer);
|
||||||
await watchContractCmd.exec();
|
await watchContractCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,8 +15,9 @@ const log = debug('vulcanize:fill');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const fillCmd = new FillCmd();
|
const fillCmd = new FillCmd();
|
||||||
await fillCmd.init(Database, Indexer, EventWatcher);
|
await fillCmd.init(Database);
|
||||||
|
|
||||||
|
await fillCmd.initIndexer(Indexer, EventWatcher);
|
||||||
await fillCmd.exec();
|
await fillCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ const log = debug('vulcanize:job-runner');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const jobRunnerCmd = new JobRunnerCmd();
|
const jobRunnerCmd = new JobRunnerCmd();
|
||||||
await jobRunnerCmd.init(Database, Indexer);
|
await jobRunnerCmd.init(Database);
|
||||||
|
await jobRunnerCmd.initIndexer(Indexer);
|
||||||
|
|
||||||
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
||||||
await jobRunner.subscribeBlockProcessingQueue();
|
await jobRunner.subscribeBlockProcessingQueue();
|
||||||
|
@ -18,10 +18,10 @@ const log = debug('vulcanize:server');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const serverCmd = new ServerCmd();
|
const serverCmd = new ServerCmd();
|
||||||
await serverCmd.init(Database, Indexer, EventWatcher);
|
await serverCmd.init(Database);
|
||||||
|
await serverCmd.initIndexer(Indexer, EventWatcher);
|
||||||
|
|
||||||
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
||||||
|
|
||||||
return serverCmd.exec(createResolvers, typeDefs);
|
return serverCmd.exec(createResolvers, typeDefs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,12 +8,11 @@ import spies from 'chai-spies';
|
|||||||
import { utils } from 'ethers';
|
import { utils } from 'ethers';
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
import { GraphDatabase, createEvent, createBlock, Block, EventData } from '@cerc-io/util';
|
||||||
|
|
||||||
import { getDummyEventData, getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
import { getDummyEventData, getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||||
import abi from '../test/subgraph/example1/build/Example1/abis/Example1.json';
|
import abi from '../test/subgraph/example1/build/Example1/abis/Example1.json';
|
||||||
import { instantiate } from './loader';
|
import { instantiate } from './loader';
|
||||||
import { createEvent, createBlock, Block, EventData } from './utils';
|
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
import { Indexer } from '../test/utils/indexer';
|
||||||
|
|
||||||
chai.use(spies);
|
chai.use(spies);
|
||||||
@ -22,7 +21,7 @@ const sandbox = chai.spy.sandbox();
|
|||||||
|
|
||||||
xdescribe('call handler in mapping code', () => {
|
xdescribe('call handler in mapping code', () => {
|
||||||
let exports: any;
|
let exports: any;
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
|
|
||||||
|
@ -8,7 +8,15 @@ import debug from 'debug';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
|
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
|
||||||
import { getConfig as getWatcherConfig, wait, Database as BaseDatabase, Config as WatcherConfig } from '@cerc-io/util';
|
|
||||||
|
import {
|
||||||
|
getConfig as getWatcherConfig,
|
||||||
|
wait,
|
||||||
|
Database as BaseDatabase,
|
||||||
|
Config as WatcherConfig,
|
||||||
|
GraphDatabase,
|
||||||
|
getSubgraphConfig
|
||||||
|
} from '@cerc-io/util';
|
||||||
import { GraphQLClient } from '@cerc-io/ipld-eth-client';
|
import { GraphQLClient } from '@cerc-io/ipld-eth-client';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -22,8 +30,6 @@ import {
|
|||||||
getConfig,
|
getConfig,
|
||||||
checkGQLEntitiesInState
|
checkGQLEntitiesInState
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import { Database } from '../../database';
|
|
||||||
import { getSubgraphConfig } from '../../utils';
|
|
||||||
|
|
||||||
const DEFAULT_ENTITIES_LIMIT = 100;
|
const DEFAULT_ENTITIES_LIMIT = 100;
|
||||||
|
|
||||||
@ -116,7 +122,7 @@ export const main = async (): Promise<void> => {
|
|||||||
let blockDelay = wait(0);
|
let blockDelay = wait(0);
|
||||||
let subgraphContracts: string[] = [];
|
let subgraphContracts: string[] = [];
|
||||||
const contractLatestStateCIDMap: Map<string, { diff: string, checkpoint: string }> = new Map();
|
const contractLatestStateCIDMap: Map<string, { diff: string, checkpoint: string }> = new Map();
|
||||||
let db: Database | undefined, subgraphGQLClient: GraphQLClient | undefined;
|
let db: GraphDatabase | undefined, subgraphGQLClient: GraphQLClient | undefined;
|
||||||
|
|
||||||
if (config.watcher) {
|
if (config.watcher) {
|
||||||
const watcherConfigPath = path.resolve(path.dirname(configFile), config.watcher.configPath);
|
const watcherConfigPath = path.resolve(path.dirname(configFile), config.watcher.configPath);
|
||||||
@ -126,7 +132,7 @@ export const main = async (): Promise<void> => {
|
|||||||
const baseDatabase = new BaseDatabase({ ...watcherConfig.database, entities: [entitiesDir] });
|
const baseDatabase = new BaseDatabase({ ...watcherConfig.database, entities: [entitiesDir] });
|
||||||
await baseDatabase.init();
|
await baseDatabase.init();
|
||||||
|
|
||||||
db = new Database(watcherConfig.server, baseDatabase);
|
db = new GraphDatabase(watcherConfig.server, baseDatabase);
|
||||||
await db.init();
|
await db.init();
|
||||||
|
|
||||||
if (config.watcher.verifyState) {
|
if (config.watcher.verifyState) {
|
||||||
|
@ -15,9 +15,9 @@ import debug from 'debug';
|
|||||||
import { Config as CacheConfig, getCache } from '@cerc-io/cache';
|
import { Config as CacheConfig, getCache } from '@cerc-io/cache';
|
||||||
import { GraphQLClient } from '@cerc-io/ipld-eth-client';
|
import { GraphQLClient } from '@cerc-io/ipld-eth-client';
|
||||||
import { gql } from '@apollo/client/core';
|
import { gql } from '@apollo/client/core';
|
||||||
|
import { DEFAULT_LIMIT } from '@cerc-io/util';
|
||||||
|
|
||||||
import { Client } from './client';
|
import { Client } from './client';
|
||||||
import { DEFAULT_LIMIT } from '../../database';
|
|
||||||
|
|
||||||
const log = debug('vulcanize:compare-utils');
|
const log = debug('vulcanize:compare-utils');
|
||||||
|
|
||||||
|
@ -7,15 +7,15 @@ import { expect } from 'chai';
|
|||||||
import { utils } from 'ethers';
|
import { utils } from 'ethers';
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
import { GraphDatabase } from '@cerc-io/util';
|
||||||
|
|
||||||
import { instantiate } from './loader';
|
import { instantiate } from './loader';
|
||||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
import { Indexer } from '../test/utils/indexer';
|
||||||
|
|
||||||
describe('crypto host api', () => {
|
describe('crypto host api', () => {
|
||||||
let exports: any;
|
let exports: any;
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
|
|
||||||
|
@ -9,14 +9,13 @@ import chai from 'chai';
|
|||||||
import spies from 'chai-spies';
|
import spies from 'chai-spies';
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
import { GraphDatabase, createEvent, Block, createBlock, EventData } from '@cerc-io/util';
|
||||||
|
|
||||||
import { instantiate } from './loader';
|
import { instantiate } from './loader';
|
||||||
import { createEvent, Block, createBlock, EventData } from './utils';
|
|
||||||
import edenNetworkAbi from '../test/subgraph/eden/EdenNetwork/abis/EdenNetwork.json';
|
import edenNetworkAbi from '../test/subgraph/eden/EdenNetwork/abis/EdenNetwork.json';
|
||||||
import merkleDistributorAbi from '../test/subgraph/eden/EdenNetworkDistribution/abis/MerkleDistributor.json';
|
import merkleDistributorAbi from '../test/subgraph/eden/EdenNetworkDistribution/abis/MerkleDistributor.json';
|
||||||
import distributorGovernanceAbi from '../test/subgraph/eden/EdenNetworkGovernance/abis/DistributorGovernance.json';
|
import distributorGovernanceAbi from '../test/subgraph/eden/EdenNetworkGovernance/abis/DistributorGovernance.json';
|
||||||
import { getDummyEventData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
import { getDummyEventData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
import { Indexer } from '../test/utils/indexer';
|
||||||
|
|
||||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||||
@ -26,7 +25,7 @@ chai.use(spies);
|
|||||||
const sandbox = chai.spy.sandbox();
|
const sandbox = chai.spy.sandbox();
|
||||||
|
|
||||||
xdescribe('eden wasm loader tests', async () => {
|
xdescribe('eden wasm loader tests', async () => {
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
|
|
||||||
|
@ -6,15 +6,15 @@ import path from 'path';
|
|||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
import { GraphDatabase } from '@cerc-io/util';
|
||||||
|
|
||||||
import { instantiate } from './loader';
|
import { instantiate } from './loader';
|
||||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
import { Indexer } from '../test/utils/indexer';
|
||||||
|
|
||||||
describe('ethereum ABI encode decode', () => {
|
describe('ethereum ABI encode decode', () => {
|
||||||
let exports: any;
|
let exports: any;
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
let encoded: string;
|
let encoded: string;
|
||||||
|
@ -6,17 +6,16 @@ import assert from 'assert';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
import { GraphDatabase, EventData } from '@cerc-io/util';
|
||||||
|
|
||||||
import { instantiate } from './loader';
|
import { instantiate } from './loader';
|
||||||
import exampleAbi from '../test/subgraph/example1/build/Example1/abis/Example1.json';
|
import exampleAbi from '../test/subgraph/example1/build/Example1/abis/Example1.json';
|
||||||
import { getTestDatabase, getTestIndexer, getTestProvider, getDummyEventData } from '../test/utils';
|
import { getTestDatabase, getTestIndexer, getTestProvider, getDummyEventData } from '../test/utils';
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
import { Indexer } from '../test/utils/indexer';
|
||||||
import { EventData } from './utils';
|
|
||||||
|
|
||||||
xdescribe('eth-call wasm tests', () => {
|
xdescribe('eth-call wasm tests', () => {
|
||||||
let exports: any;
|
let exports: any;
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
|
|
||||||
|
@ -1,7 +1 @@
|
|||||||
export * from './watcher';
|
export * from './watcher';
|
||||||
export * from './database';
|
|
||||||
export {
|
|
||||||
resolveEntityFieldConflicts,
|
|
||||||
afterEntityInsertOrUpdate
|
|
||||||
} from './utils';
|
|
||||||
export * from './state-utils';
|
|
||||||
|
@ -5,15 +5,15 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
import { GraphDatabase } from '@cerc-io/util';
|
||||||
|
|
||||||
import { instantiate } from './loader';
|
import { instantiate } from './loader';
|
||||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
import { Indexer } from '../test/utils/indexer';
|
||||||
|
|
||||||
describe('json host api', () => {
|
describe('json host api', () => {
|
||||||
let exports: any;
|
let exports: any;
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
|
|
||||||
|
@ -7,17 +7,17 @@ import { expect } from 'chai';
|
|||||||
import { utils } from 'ethers';
|
import { utils } from 'ethers';
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
import { GraphDatabase } from '@cerc-io/util';
|
||||||
|
|
||||||
import { instantiate } from './loader';
|
import { instantiate } from './loader';
|
||||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
import { Indexer } from '../test/utils/indexer';
|
||||||
|
|
||||||
const WASM_FILE_PATH = '../build/debug.wasm';
|
const WASM_FILE_PATH = '../build/debug.wasm';
|
||||||
|
|
||||||
describe('wasm loader tests', () => {
|
describe('wasm loader tests', () => {
|
||||||
let exports: any;
|
let exports: any;
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
let module: WebAssembly.Module;
|
let module: WebAssembly.Module;
|
||||||
|
@ -15,19 +15,21 @@ import debug from 'debug';
|
|||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
import loader from '@vulcanize/assemblyscript/lib/loader';
|
import loader from '@vulcanize/assemblyscript/lib/loader';
|
||||||
import { IndexerInterface, GraphDecimal, getGraphDigitsAndExp } from '@cerc-io/util';
|
|
||||||
|
|
||||||
import { TypeId, Level } from './types';
|
|
||||||
import {
|
import {
|
||||||
|
IndexerInterface,
|
||||||
|
GraphDecimal,
|
||||||
|
getGraphDigitsAndExp,
|
||||||
|
prepareEntityState,
|
||||||
|
TypeId,
|
||||||
|
Level,
|
||||||
|
GraphDatabase,
|
||||||
Block,
|
Block,
|
||||||
fromEthereumValue,
|
fromEthereumValue,
|
||||||
toEthereumValue,
|
toEthereumValue,
|
||||||
getEthereumTypes,
|
getEthereumTypes,
|
||||||
jsonFromBytes,
|
jsonFromBytes,
|
||||||
getStorageValueType
|
getStorageValueType
|
||||||
} from './utils';
|
} from '@cerc-io/util';
|
||||||
import { prepareEntityState } from './state-utils';
|
|
||||||
import { Database } from './database';
|
|
||||||
|
|
||||||
// Endianness of BN used in bigInt store host API.
|
// Endianness of BN used in bigInt store host API.
|
||||||
// Negative bigInt is being stored in wasm in 2's compliment, 'le' representation.
|
// Negative bigInt is being stored in wasm in 2's compliment, 'le' representation.
|
||||||
@ -52,7 +54,7 @@ export interface Context {
|
|||||||
const log = debug('vulcanize:graph-node');
|
const log = debug('vulcanize:graph-node');
|
||||||
|
|
||||||
export const instantiate = async (
|
export const instantiate = async (
|
||||||
database: Database,
|
database: GraphDatabase,
|
||||||
indexer: IndexerInterface,
|
indexer: IndexerInterface,
|
||||||
provider: BaseProvider,
|
provider: BaseProvider,
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -6,14 +6,9 @@ import path from 'path';
|
|||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import BN from 'bn.js';
|
import BN from 'bn.js';
|
||||||
|
|
||||||
import { GraphDecimal } from '@cerc-io/util';
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
|
||||||
|
|
||||||
import { instantiate } from './loader';
|
|
||||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
|
||||||
import {
|
import {
|
||||||
|
GraphDecimal,
|
||||||
|
GraphDatabase,
|
||||||
UINT128_MAX,
|
UINT128_MAX,
|
||||||
UINT256_MAX,
|
UINT256_MAX,
|
||||||
INT256_MIN,
|
INT256_MIN,
|
||||||
@ -22,13 +17,18 @@ import {
|
|||||||
DECIMAL128_MAX,
|
DECIMAL128_MAX,
|
||||||
DECIMAL128_PMIN,
|
DECIMAL128_PMIN,
|
||||||
DECIMAL128_NMAX
|
DECIMAL128_NMAX
|
||||||
} from './utils';
|
} from '@cerc-io/util';
|
||||||
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
|
||||||
|
import { instantiate } from './loader';
|
||||||
|
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||||
|
import { Indexer } from '../test/utils/indexer';
|
||||||
|
|
||||||
const EXAMPLE_WASM_FILE_PATH = '../test/subgraph/example1/build/Example1/Example1.wasm';
|
const EXAMPLE_WASM_FILE_PATH = '../test/subgraph/example1/build/Example1/Example1.wasm';
|
||||||
|
|
||||||
describe('numbers wasm tests', () => {
|
describe('numbers wasm tests', () => {
|
||||||
let exports: any;
|
let exports: any;
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
|
|
||||||
|
@ -6,18 +6,17 @@ import assert from 'assert';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
import { GraphDatabase, EventData } from '@cerc-io/util';
|
||||||
|
|
||||||
import { instantiate } from './loader';
|
import { instantiate } from './loader';
|
||||||
import exampleAbi from '../test/subgraph/example1/build/Example1/abis/Example1.json';
|
import exampleAbi from '../test/subgraph/example1/build/Example1/abis/Example1.json';
|
||||||
import { storageLayout } from '../test/artifacts/Example1.json';
|
import { storageLayout } from '../test/artifacts/Example1.json';
|
||||||
import { getTestDatabase, getTestIndexer, getTestProvider, getDummyEventData } from '../test/utils';
|
import { getTestDatabase, getTestIndexer, getTestProvider, getDummyEventData } from '../test/utils';
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
import { Indexer } from '../test/utils/indexer';
|
||||||
import { EventData } from './utils';
|
|
||||||
|
|
||||||
xdescribe('storage-call wasm tests', () => {
|
xdescribe('storage-call wasm tests', () => {
|
||||||
let exports: any;
|
let exports: any;
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
|
|
||||||
|
@ -7,17 +7,17 @@ import { expect } from 'chai';
|
|||||||
import { utils, BigNumber } from 'ethers';
|
import { utils, BigNumber } from 'ethers';
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
|
import { GraphDatabase } from '@cerc-io/util';
|
||||||
|
|
||||||
import { instantiate } from './loader';
|
import { instantiate } from './loader';
|
||||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||||
import { Database } from './database';
|
|
||||||
import { Indexer } from '../test/utils/indexer';
|
import { Indexer } from '../test/utils/indexer';
|
||||||
|
|
||||||
const EXAMPLE_WASM_FILE_PATH = '../test/subgraph/example1/build/Example1/Example1.wasm';
|
const EXAMPLE_WASM_FILE_PATH = '../test/subgraph/example1/build/Example1/Example1.wasm';
|
||||||
|
|
||||||
describe('typeConversion wasm tests', () => {
|
describe('typeConversion wasm tests', () => {
|
||||||
let exports: any;
|
let exports: any;
|
||||||
let db: Database;
|
let db: GraphDatabase;
|
||||||
let indexer: Indexer;
|
let indexer: Indexer;
|
||||||
let provider: BaseProvider;
|
let provider: BaseProvider;
|
||||||
|
|
||||||
|
@ -12,11 +12,25 @@ import { SelectionNode } from 'graphql';
|
|||||||
|
|
||||||
import { ResultObject } from '@vulcanize/assemblyscript/lib/loader';
|
import { ResultObject } from '@vulcanize/assemblyscript/lib/loader';
|
||||||
import { EthClient } from '@cerc-io/ipld-eth-client';
|
import { EthClient } from '@cerc-io/ipld-eth-client';
|
||||||
import { getFullBlock, BlockHeight, ServerConfig, getFullTransaction, QueryOptions, IndexerInterface, BlockProgressInterface } from '@cerc-io/util';
|
import {
|
||||||
|
getFullBlock,
|
||||||
|
BlockHeight,
|
||||||
|
ServerConfig,
|
||||||
|
getFullTransaction,
|
||||||
|
QueryOptions,
|
||||||
|
IndexerInterface,
|
||||||
|
BlockProgressInterface,
|
||||||
|
Database as BaseDatabase,
|
||||||
|
GraphDatabase,
|
||||||
|
resolveEntityFieldConflicts,
|
||||||
|
createBlock,
|
||||||
|
createEvent,
|
||||||
|
getSubgraphConfig,
|
||||||
|
Transaction,
|
||||||
|
DEFAULT_LIMIT
|
||||||
|
} from '@cerc-io/util';
|
||||||
|
|
||||||
import { createBlock, createEvent, getSubgraphConfig, resolveEntityFieldConflicts, Transaction } from './utils';
|
|
||||||
import { Context, GraphData, instantiate } from './loader';
|
import { Context, GraphData, instantiate } from './loader';
|
||||||
import { Database, DEFAULT_LIMIT } from './database';
|
|
||||||
|
|
||||||
const log = debug('vulcanize:graph-watcher');
|
const log = debug('vulcanize:graph-watcher');
|
||||||
|
|
||||||
@ -27,7 +41,7 @@ interface DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class GraphWatcher {
|
export class GraphWatcher {
|
||||||
_database: Database;
|
_database: GraphDatabase;
|
||||||
_indexer?: IndexerInterface;
|
_indexer?: IndexerInterface;
|
||||||
_ethClient: EthClient;
|
_ethClient: EthClient;
|
||||||
_ethProvider: providers.BaseProvider;
|
_ethProvider: providers.BaseProvider;
|
||||||
@ -39,7 +53,7 @@ export class GraphWatcher {
|
|||||||
|
|
||||||
_context: Context = {};
|
_context: Context = {};
|
||||||
|
|
||||||
constructor (database: Database, ethClient: EthClient, ethProvider: providers.BaseProvider, serverConfig: ServerConfig) {
|
constructor (database: GraphDatabase, ethClient: EthClient, ethProvider: providers.BaseProvider, serverConfig: ServerConfig) {
|
||||||
this._database = database;
|
this._database = database;
|
||||||
this._ethClient = ethClient;
|
this._ethClient = ethClient;
|
||||||
this._ethProvider = ethProvider;
|
this._ethProvider = ethProvider;
|
||||||
@ -462,3 +476,22 @@ export class GraphWatcher {
|
|||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getGraphDbAndWatcher = async (
|
||||||
|
serverConfig: ServerConfig,
|
||||||
|
ethClient: EthClient,
|
||||||
|
ethProvider: providers.BaseProvider,
|
||||||
|
baseDatabase: BaseDatabase,
|
||||||
|
entityQueryTypeMap?: Map<any, any>,
|
||||||
|
entityToLatestEntityMap?: Map<any, any>
|
||||||
|
): Promise<{ graphDb: GraphDatabase, graphWatcher: GraphWatcher }> => {
|
||||||
|
const graphDb = new GraphDatabase(serverConfig, baseDatabase, entityQueryTypeMap, entityToLatestEntityMap);
|
||||||
|
await graphDb.init();
|
||||||
|
|
||||||
|
const graphWatcher = new GraphWatcher(graphDb, ethClient, ethProvider, serverConfig);
|
||||||
|
|
||||||
|
return {
|
||||||
|
graphDb,
|
||||||
|
graphWatcher
|
||||||
|
};
|
||||||
|
};
|
||||||
|
@ -3,12 +3,10 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { BaseProvider } from '@ethersproject/providers';
|
import { BaseProvider } from '@ethersproject/providers';
|
||||||
import { getCustomProvider, Database as BaseDatabase, ServerConfig } from '@cerc-io/util';
|
import { getCustomProvider, Database as BaseDatabase, ServerConfig, GraphDatabase, EventData } from '@cerc-io/util';
|
||||||
import { EthClient } from '@cerc-io/ipld-eth-client';
|
import { EthClient } from '@cerc-io/ipld-eth-client';
|
||||||
import { StorageLayout } from '@cerc-io/solidity-mapper';
|
import { StorageLayout } from '@cerc-io/solidity-mapper';
|
||||||
|
|
||||||
import { EventData } from '../../src/utils';
|
|
||||||
import { Database } from '../../src/database';
|
|
||||||
import { Indexer } from './indexer';
|
import { Indexer } from './indexer';
|
||||||
|
|
||||||
const NETWORK_URL = 'http://127.0.0.1:8081';
|
const NETWORK_URL = 'http://127.0.0.1:8081';
|
||||||
@ -70,10 +68,10 @@ export const getDummyGraphData = (): any => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTestDatabase = (): Database => {
|
export const getTestDatabase = (): GraphDatabase => {
|
||||||
const baseDatabase = new BaseDatabase({ type: 'postgres' });
|
const baseDatabase = new BaseDatabase({ type: 'postgres' });
|
||||||
const serverConfig = {} as ServerConfig;
|
const serverConfig = {} as ServerConfig;
|
||||||
return new Database(serverConfig, baseDatabase);
|
return new GraphDatabase(serverConfig, baseDatabase);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTestIndexer = (storageLayout?: Map<string, StorageLayout>): Indexer => {
|
export const getTestIndexer = (storageLayout?: Map<string, StorageLayout>): Indexer => {
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { CreateCheckpointCmd } from '@cerc-io/cli';
|
import { CreateCheckpointCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../../database';
|
||||||
import { Indexer } from '../../indexer';
|
import { Indexer } from '../../indexer';
|
||||||
|
|
||||||
export const command = 'create';
|
export const command = 'create';
|
||||||
@ -26,7 +27,17 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const createCheckpointCmd = new CreateCheckpointCmd();
|
const createCheckpointCmd = new CreateCheckpointCmd();
|
||||||
await createCheckpointCmd.init(argv, Database, Indexer);
|
await createCheckpointCmd.init(argv, Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
createCheckpointCmd.config!.server,
|
||||||
|
createCheckpointCmd.clients!.ethClient,
|
||||||
|
createCheckpointCmd.ethProvider!,
|
||||||
|
createCheckpointCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await createCheckpointCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await createCheckpointCmd.exec();
|
await createCheckpointCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { VerifyCheckpointCmd } from '@cerc-io/cli';
|
import { VerifyCheckpointCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../../database';
|
||||||
import { Indexer } from '../../indexer';
|
import { Indexer } from '../../indexer';
|
||||||
|
|
||||||
export const command = 'verify';
|
export const command = 'verify';
|
||||||
@ -22,7 +23,17 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const verifyCheckpointCmd = new VerifyCheckpointCmd();
|
const verifyCheckpointCmd = new VerifyCheckpointCmd();
|
||||||
await verifyCheckpointCmd.init(argv, Database, Indexer);
|
await verifyCheckpointCmd.init(argv, Database);
|
||||||
|
|
||||||
await verifyCheckpointCmd.exec();
|
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
|
||||||
|
verifyCheckpointCmd.config!.server,
|
||||||
|
verifyCheckpointCmd.clients!.ethClient,
|
||||||
|
verifyCheckpointCmd.ethProvider!,
|
||||||
|
verifyCheckpointCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await verifyCheckpointCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
await verifyCheckpointCmd.exec(graphDb);
|
||||||
};
|
};
|
||||||
|
@ -6,16 +6,27 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ExportStateCmd } from '@cerc-io/cli';
|
import { ExportStateCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:export-state');
|
const log = debug('vulcanize:export-state');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const exportStateCmd = new ExportStateCmd();
|
const exportStateCmd = new ExportStateCmd();
|
||||||
await exportStateCmd.init(Database, Indexer);
|
await exportStateCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
exportStateCmd.config!.server,
|
||||||
|
exportStateCmd.clients!.ethClient,
|
||||||
|
exportStateCmd.ethProvider!,
|
||||||
|
exportStateCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await exportStateCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await exportStateCmd.exec();
|
await exportStateCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,8 +6,9 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ImportStateCmd } from '@cerc-io/cli';
|
import { ImportStateCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
import { EventWatcher } from '../events';
|
import { EventWatcher } from '../events';
|
||||||
import { State } from '../entity/State';
|
import { State } from '../entity/State';
|
||||||
@ -16,9 +17,19 @@ const log = debug('vulcanize:import-state');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const importStateCmd = new ImportStateCmd();
|
const importStateCmd = new ImportStateCmd();
|
||||||
await importStateCmd.init(Database, Indexer, EventWatcher);
|
await importStateCmd.init(Database);
|
||||||
|
|
||||||
await importStateCmd.exec(State);
|
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
|
||||||
|
importStateCmd.config!.server,
|
||||||
|
importStateCmd.clients!.ethClient,
|
||||||
|
importStateCmd.ethProvider!,
|
||||||
|
importStateCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await importStateCmd.initIndexer(Indexer, EventWatcher, graphWatcher);
|
||||||
|
await importStateCmd.exec(State, graphDb);
|
||||||
};
|
};
|
||||||
|
|
||||||
main().catch(err => {
|
main().catch(err => {
|
||||||
|
@ -6,16 +6,27 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { IndexBlockCmd } from '@cerc-io/cli';
|
import { IndexBlockCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:index-block');
|
const log = debug('vulcanize:index-block');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const indexBlockCmd = new IndexBlockCmd();
|
const indexBlockCmd = new IndexBlockCmd();
|
||||||
await indexBlockCmd.init(Database, Indexer);
|
await indexBlockCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
indexBlockCmd.config!.server,
|
||||||
|
indexBlockCmd.clients!.ethClient,
|
||||||
|
indexBlockCmd.ethProvider!,
|
||||||
|
indexBlockCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await indexBlockCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await indexBlockCmd.exec();
|
await indexBlockCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,16 +6,27 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { InspectCIDCmd } from '@cerc-io/cli';
|
import { InspectCIDCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:inspect-cid');
|
const log = debug('vulcanize:inspect-cid');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const inspectCIDCmd = new InspectCIDCmd();
|
const inspectCIDCmd = new InspectCIDCmd();
|
||||||
await inspectCIDCmd.init(Database, Indexer);
|
await inspectCIDCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
inspectCIDCmd.config!.server,
|
||||||
|
inspectCIDCmd.clients!.ethClient,
|
||||||
|
inspectCIDCmd.ethProvider!,
|
||||||
|
inspectCIDCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await inspectCIDCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await inspectCIDCmd.exec();
|
await inspectCIDCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { ResetWatcherCmd } from '@cerc-io/cli';
|
import { ResetWatcherCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../../database';
|
||||||
import { Indexer } from '../../indexer';
|
import { Indexer } from '../../indexer';
|
||||||
|
|
||||||
export const command = 'watcher';
|
export const command = 'watcher';
|
||||||
@ -19,7 +20,17 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const resetWatcherCmd = new ResetWatcherCmd();
|
const resetWatcherCmd = new ResetWatcherCmd();
|
||||||
await resetWatcherCmd.init(argv, Database, Indexer);
|
await resetWatcherCmd.init(argv, Database);
|
||||||
|
|
||||||
|
const { graphWatcher, graphDb } = await getGraphDbAndWatcher(
|
||||||
|
resetWatcherCmd.config!.server,
|
||||||
|
resetWatcherCmd.clients!.ethClient,
|
||||||
|
resetWatcherCmd.ethProvider!,
|
||||||
|
resetWatcherCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await resetWatcherCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await resetWatcherCmd.exec();
|
await resetWatcherCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -6,16 +6,27 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { WatchContractCmd } from '@cerc-io/cli';
|
import { WatchContractCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database } from '../database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from '../database';
|
||||||
import { Indexer } from '../indexer';
|
import { Indexer } from '../indexer';
|
||||||
|
|
||||||
const log = debug('vulcanize:watch-contract');
|
const log = debug('vulcanize:watch-contract');
|
||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const watchContractCmd = new WatchContractCmd();
|
const watchContractCmd = new WatchContractCmd();
|
||||||
await watchContractCmd.init(Database, Indexer);
|
await watchContractCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
watchContractCmd.config!.server,
|
||||||
|
watchContractCmd.clients!.ethClient,
|
||||||
|
watchContractCmd.ethProvider!,
|
||||||
|
watchContractCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await watchContractCmd.initIndexer(Indexer, graphWatcher);
|
||||||
await watchContractCmd.exec();
|
await watchContractCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
||||||
|
|
||||||
import { afterEntityInsertOrUpdate } from '@cerc-io/graph-node';
|
import { afterEntityInsertOrUpdate } from '@cerc-io/util';
|
||||||
|
|
||||||
import { FrothyEntity } from './FrothyEntity';
|
import { FrothyEntity } from './FrothyEntity';
|
||||||
import { ENTITY_TO_LATEST_ENTITY_MAP, SUBGRAPH_ENTITIES } from '../database';
|
import { ENTITY_TO_LATEST_ENTITY_MAP, SUBGRAPH_ENTITIES } from '../database';
|
||||||
|
@ -7,7 +7,8 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { FillCmd } from '@cerc-io/cli';
|
import { FillCmd } from '@cerc-io/cli';
|
||||||
import { getContractEntitiesMap } from '@cerc-io/graph-node';
|
import { getContractEntitiesMap } from '@cerc-io/util';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from './database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from './database';
|
||||||
import { Indexer } from './indexer';
|
import { Indexer } from './indexer';
|
||||||
@ -17,13 +18,22 @@ const log = debug('vulcanize:fill');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const fillCmd = new FillCmd();
|
const fillCmd = new FillCmd();
|
||||||
await fillCmd.init(Database, Indexer, EventWatcher, {}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP);
|
await fillCmd.init(Database);
|
||||||
|
|
||||||
const indexer = fillCmd.indexer as Indexer;
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
assert(indexer);
|
fillCmd.config!.server,
|
||||||
|
fillCmd.clients!.ethClient,
|
||||||
|
fillCmd.ethProvider!,
|
||||||
|
fillCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await fillCmd.initIndexer(Indexer, EventWatcher, graphWatcher);
|
||||||
|
|
||||||
// Get contractEntitiesMap required for fill-state
|
// Get contractEntitiesMap required for fill-state
|
||||||
const contractEntitiesMap = getContractEntitiesMap(indexer.graphWatcher.dataSources);
|
// NOTE: Assuming each entity type is only mapped to a single contract
|
||||||
|
const contractEntitiesMap = getContractEntitiesMap(graphWatcher.dataSources);
|
||||||
|
|
||||||
await fillCmd.exec(contractEntitiesMap);
|
await fillCmd.exec(contractEntitiesMap);
|
||||||
};
|
};
|
||||||
|
@ -28,9 +28,12 @@ import {
|
|||||||
ResultEvent,
|
ResultEvent,
|
||||||
getResultEvent,
|
getResultEvent,
|
||||||
DatabaseInterface,
|
DatabaseInterface,
|
||||||
Clients
|
Clients,
|
||||||
|
GraphWatcherInterface,
|
||||||
|
updateSubgraphState,
|
||||||
|
dumpSubgraphState
|
||||||
} from '@cerc-io/util';
|
} from '@cerc-io/util';
|
||||||
import { GraphWatcher, updateSubgraphState, dumpSubgraphState } from '@cerc-io/graph-node';
|
import { GraphWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Database, ENTITIES, SUBGRAPH_ENTITIES } from './database';
|
import { Database, ENTITIES, SUBGRAPH_ENTITIES } from './database';
|
||||||
import { Contract } from './entity/Contract';
|
import { Contract } from './entity/Contract';
|
||||||
@ -68,7 +71,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
|
|
||||||
_subgraphStateMap: Map<string, any>
|
_subgraphStateMap: Map<string, any>
|
||||||
|
|
||||||
constructor (serverConfig: ServerConfig, db: DatabaseInterface, clients: Clients, ethProvider: BaseProvider, jobQueue: JobQueue, graphWatcher?: GraphWatcher) {
|
constructor (serverConfig: ServerConfig, db: DatabaseInterface, clients: Clients, ethProvider: BaseProvider, jobQueue: JobQueue, graphWatcher?: GraphWatcherInterface) {
|
||||||
assert(db);
|
assert(db);
|
||||||
assert(clients.ethClient);
|
assert(clients.ethClient);
|
||||||
|
|
||||||
@ -79,7 +82,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
this._baseIndexer = new BaseIndexer(this._serverConfig, this._db, this._ethClient, this._ethProvider, jobQueue);
|
this._baseIndexer = new BaseIndexer(this._serverConfig, this._db, this._ethClient, this._ethProvider, jobQueue);
|
||||||
|
|
||||||
assert(graphWatcher);
|
assert(graphWatcher);
|
||||||
this._graphWatcher = graphWatcher;
|
this._graphWatcher = graphWatcher as GraphWatcher;
|
||||||
|
|
||||||
this._abiMap = new Map();
|
this._abiMap = new Map();
|
||||||
this._storageLayoutMap = new Map();
|
this._storageLayoutMap = new Map();
|
||||||
|
@ -6,15 +6,27 @@ import debug from 'debug';
|
|||||||
|
|
||||||
import { JobRunnerCmd } from '@cerc-io/cli';
|
import { JobRunnerCmd } from '@cerc-io/cli';
|
||||||
import { JobRunner } from '@cerc-io/util';
|
import { JobRunner } from '@cerc-io/util';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { Indexer } from './indexer';
|
import { Indexer } from './indexer';
|
||||||
import { Database } from './database';
|
import { Database, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP } from './database';
|
||||||
|
|
||||||
const log = debug('vulcanize:job-runner');
|
const log = debug('vulcanize:job-runner');
|
||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const jobRunnerCmd = new JobRunnerCmd();
|
const jobRunnerCmd = new JobRunnerCmd();
|
||||||
await jobRunnerCmd.init(Database, Indexer);
|
await jobRunnerCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
jobRunnerCmd.config!.server,
|
||||||
|
jobRunnerCmd.clients!.ethClient,
|
||||||
|
jobRunnerCmd.ethProvider!,
|
||||||
|
jobRunnerCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await jobRunnerCmd.initIndexer(Indexer, graphWatcher);
|
||||||
|
|
||||||
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
||||||
await jobRunner.subscribeBlockProcessingQueue();
|
await jobRunner.subscribeBlockProcessingQueue();
|
||||||
|
@ -8,6 +8,7 @@ import 'reflect-metadata';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import { ServerCmd } from '@cerc-io/cli';
|
import { ServerCmd } from '@cerc-io/cli';
|
||||||
|
import { getGraphDbAndWatcher } from '@cerc-io/graph-node';
|
||||||
|
|
||||||
import { createResolvers } from './resolvers';
|
import { createResolvers } from './resolvers';
|
||||||
import { Indexer } from './indexer';
|
import { Indexer } from './indexer';
|
||||||
@ -18,10 +19,20 @@ const log = debug('vulcanize:server');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const serverCmd = new ServerCmd();
|
const serverCmd = new ServerCmd();
|
||||||
await serverCmd.init(Database, Indexer, EventWatcher, {}, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP);
|
await serverCmd.init(Database);
|
||||||
|
|
||||||
|
const { graphWatcher } = await getGraphDbAndWatcher(
|
||||||
|
serverCmd.config!.server,
|
||||||
|
serverCmd.clients!.ethClient,
|
||||||
|
serverCmd.ethProvider!,
|
||||||
|
serverCmd.database!.baseDatabase,
|
||||||
|
ENTITY_QUERY_TYPE_MAP,
|
||||||
|
ENTITY_TO_LATEST_ENTITY_MAP
|
||||||
|
);
|
||||||
|
|
||||||
|
await serverCmd.initIndexer(Indexer, EventWatcher, graphWatcher);
|
||||||
|
|
||||||
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
||||||
|
|
||||||
return serverCmd.exec(createResolvers, typeDefs);
|
return serverCmd.exec(createResolvers, typeDefs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
"graphql": "^15.5.0",
|
"graphql": "^15.5.0",
|
||||||
"graphql-ws": "^5.11.2",
|
"graphql-ws": "^5.11.2",
|
||||||
"left-pad": "^1.3.0",
|
"left-pad": "^1.3.0",
|
||||||
"lodash": "^4.17.21",
|
|
||||||
"ws": "^8.11.0",
|
"ws": "^8.11.0",
|
||||||
"zen-observable-ts": "^1.1.0"
|
"zen-observable-ts": "^1.1.0"
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,7 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const createCheckpointCmd = new CreateCheckpointCmd();
|
const createCheckpointCmd = new CreateCheckpointCmd();
|
||||||
await createCheckpointCmd.init(argv, Database, Indexer);
|
await createCheckpointCmd.init(argv, Database);
|
||||||
|
await createCheckpointCmd.initIndexer(Indexer);
|
||||||
await createCheckpointCmd.exec();
|
await createCheckpointCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -14,8 +14,8 @@ const log = debug('vulcanize:export-state');
|
|||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const exportStateCmd = new ExportStateCmd();
|
const exportStateCmd = new ExportStateCmd();
|
||||||
await exportStateCmd.init(Database, Indexer);
|
await exportStateCmd.init(Database);
|
||||||
|
await exportStateCmd.initIndexer(Indexer);
|
||||||
await exportStateCmd.exec();
|
await exportStateCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ const log = debug('vulcanize:import-state');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const importStateCmd = new ImportStateCmd();
|
const importStateCmd = new ImportStateCmd();
|
||||||
await importStateCmd.init(Database, Indexer, EventWatcher);
|
await importStateCmd.init(Database);
|
||||||
|
await importStateCmd.initIndexer(Indexer, EventWatcher);
|
||||||
await importStateCmd.exec(State);
|
await importStateCmd.exec(State);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ const log = debug('vulcanize:index-block');
|
|||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const indexBlockCmd = new IndexBlockCmd();
|
const indexBlockCmd = new IndexBlockCmd();
|
||||||
await indexBlockCmd.init(Database, Indexer);
|
await indexBlockCmd.init(Database);
|
||||||
|
await indexBlockCmd.initIndexer(Indexer);
|
||||||
await indexBlockCmd.exec();
|
await indexBlockCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ const log = debug('vulcanize:inspect-cid');
|
|||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const inspectCIDCmd = new InspectCIDCmd();
|
const inspectCIDCmd = new InspectCIDCmd();
|
||||||
await inspectCIDCmd.init(Database, Indexer);
|
await inspectCIDCmd.init(Database);
|
||||||
|
await inspectCIDCmd.initIndexer(Indexer);
|
||||||
await inspectCIDCmd.exec();
|
await inspectCIDCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: any): Promise<void> => {
|
export const handler = async (argv: any): Promise<void> => {
|
||||||
const resetWatcherCmd = new ResetWatcherCmd();
|
const resetWatcherCmd = new ResetWatcherCmd();
|
||||||
await resetWatcherCmd.init(argv, Database, Indexer);
|
await resetWatcherCmd.init(argv, Database);
|
||||||
|
await resetWatcherCmd.initIndexer(Indexer);
|
||||||
await resetWatcherCmd.exec();
|
await resetWatcherCmd.exec();
|
||||||
};
|
};
|
||||||
|
@ -14,8 +14,8 @@ const log = debug('vulcanize:watch-contract');
|
|||||||
|
|
||||||
const main = async (): Promise<void> => {
|
const main = async (): Promise<void> => {
|
||||||
const watchContractCmd = new WatchContractCmd();
|
const watchContractCmd = new WatchContractCmd();
|
||||||
await watchContractCmd.init(Database, Indexer);
|
await watchContractCmd.init(Database);
|
||||||
|
await watchContractCmd.initIndexer(Indexer);
|
||||||
await watchContractCmd.exec();
|
await watchContractCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,8 +15,9 @@ const log = debug('vulcanize:fill');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const fillCmd = new FillCmd();
|
const fillCmd = new FillCmd();
|
||||||
await fillCmd.init(Database, Indexer, EventWatcher);
|
await fillCmd.init(Database);
|
||||||
|
|
||||||
|
await fillCmd.initIndexer(Indexer, EventWatcher);
|
||||||
await fillCmd.exec();
|
await fillCmd.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ const log = debug('vulcanize:job-runner');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const jobRunnerCmd = new JobRunnerCmd();
|
const jobRunnerCmd = new JobRunnerCmd();
|
||||||
await jobRunnerCmd.init(Database, Indexer);
|
await jobRunnerCmd.init(Database);
|
||||||
|
await jobRunnerCmd.initIndexer(Indexer);
|
||||||
|
|
||||||
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
await jobRunnerCmd.exec(async (jobRunner: JobRunner): Promise<void> => {
|
||||||
await jobRunner.subscribeBlockProcessingQueue();
|
await jobRunner.subscribeBlockProcessingQueue();
|
||||||
|
@ -18,10 +18,10 @@ const log = debug('vulcanize:server');
|
|||||||
|
|
||||||
export const main = async (): Promise<any> => {
|
export const main = async (): Promise<any> => {
|
||||||
const serverCmd = new ServerCmd();
|
const serverCmd = new ServerCmd();
|
||||||
await serverCmd.init(Database, Indexer, EventWatcher);
|
await serverCmd.init(Database);
|
||||||
|
await serverCmd.initIndexer(Indexer, EventWatcher);
|
||||||
|
|
||||||
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
||||||
|
|
||||||
return serverCmd.exec(createResolvers, typeDefs);
|
return serverCmd.exec(createResolvers, typeDefs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
||||||
"@nomiclabs/hardhat-waffle": "^2.0.1",
|
"@nomiclabs/hardhat-waffle": "^2.0.1",
|
||||||
"@types/chai": "^4.2.18",
|
"@types/chai": "^4.2.18",
|
||||||
"@types/mocha": "^8.2.2",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
||||||
"@typescript-eslint/parser": "^4.25.0",
|
"@typescript-eslint/parser": "^4.25.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
|
@ -6,8 +6,10 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/utils.keyvaluecache": "^1.0.1",
|
"@apollo/utils.keyvaluecache": "^1.0.1",
|
||||||
"@cerc-io/solidity-mapper": "^0.2.15",
|
"@cerc-io/solidity-mapper": "^0.2.15",
|
||||||
|
"@ethersproject/providers": "^5.4.4",
|
||||||
"@graphql-tools/schema": "^9.0.10",
|
"@graphql-tools/schema": "^9.0.10",
|
||||||
"@graphql-tools/utils": "^9.1.1",
|
"@graphql-tools/utils": "^9.1.1",
|
||||||
|
"@ipld/dag-cbor": "^6.0.12",
|
||||||
"apollo-server-core": "^3.11.1",
|
"apollo-server-core": "^3.11.1",
|
||||||
"apollo-server-express": "^3.11.1",
|
"apollo-server-express": "^3.11.1",
|
||||||
"apollo-server-plugin-response-cache": "^3.8.1",
|
"apollo-server-plugin-response-cache": "^3.8.1",
|
||||||
@ -26,11 +28,16 @@
|
|||||||
"pg-boss": "^6.1.0",
|
"pg-boss": "^6.1.0",
|
||||||
"prom-client": "^14.0.1",
|
"prom-client": "^14.0.1",
|
||||||
"toml": "^3.0.0",
|
"toml": "^3.0.0",
|
||||||
"ws": "^8.11.0"
|
"ws": "^8.11.0",
|
||||||
|
"typeorm": "^0.2.32",
|
||||||
|
"typeorm-naming-strategies": "^2.0.0",
|
||||||
|
"graphql-subscriptions": "^2.0.0",
|
||||||
|
"json-bigint": "^1.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cerc-io/cache": "^0.2.15",
|
"@cerc-io/cache": "^0.2.15",
|
||||||
"@cerc-io/ipld-eth-client": "^0.2.15",
|
"@cerc-io/ipld-eth-client": "^0.2.15",
|
||||||
|
"@nomiclabs/hardhat-waffle": "^2.0.1",
|
||||||
"@types/express": "^4.17.14",
|
"@types/express": "^4.17.14",
|
||||||
"@types/fs-extra": "^9.0.11",
|
"@types/fs-extra": "^9.0.11",
|
||||||
"@types/pg": "^8.6.5",
|
"@types/pg": "^8.6.5",
|
||||||
@ -46,9 +53,7 @@
|
|||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^5.1.0",
|
"eslint-plugin-promise": "^5.1.0",
|
||||||
"eslint-plugin-standard": "^5.0.0",
|
"eslint-plugin-standard": "^5.0.0",
|
||||||
"hardhat": "^2.3.0",
|
"hardhat": "^2.3.0"
|
||||||
"typeorm": "^0.2.32",
|
|
||||||
"typeorm-naming-strategies": "^2.0.0"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
|
@ -21,20 +21,12 @@ import { SelectionNode } from 'graphql';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
|
||||||
import {
|
import { BlockHeight, Database as BaseDatabase, QueryOptions, Where } from '../database';
|
||||||
BlockHeight,
|
import { BlockProgressInterface } from '../types';
|
||||||
BlockProgressInterface,
|
import { cachePrunedEntitiesCount, eventProcessingLoadEntityCacheHitCount, eventProcessingLoadEntityCount, eventProcessingLoadEntityDBQueryDuration } from '../metrics';
|
||||||
cachePrunedEntitiesCount,
|
import { ServerConfig } from '../config';
|
||||||
Database as BaseDatabase,
|
import { Block, fromEntityValue, getLatestEntityFromEntity, resolveEntityFieldConflicts, toEntityValue } from './utils';
|
||||||
eventProcessingLoadEntityCacheHitCount,
|
import { fromStateEntityValues } from './state-utils';
|
||||||
eventProcessingLoadEntityCount,
|
|
||||||
eventProcessingLoadEntityDBQueryDuration,
|
|
||||||
QueryOptions,
|
|
||||||
ServerConfig,
|
|
||||||
Where
|
|
||||||
} from '@cerc-io/util';
|
|
||||||
|
|
||||||
import { Block, fromEntityValue, fromStateEntityValues, getLatestEntityFromEntity, resolveEntityFieldConflicts, toEntityValue } from './utils';
|
|
||||||
|
|
||||||
const log = debug('vulcanize:graph-database');
|
const log = debug('vulcanize:graph-database');
|
||||||
|
|
||||||
@ -60,7 +52,7 @@ interface CachedEntities {
|
|||||||
latestPrunedEntities: Map<string, Map<string, { [key: string]: any }>>;
|
latestPrunedEntities: Map<string, Map<string, { [key: string]: any }>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Database {
|
export class GraphDatabase {
|
||||||
_serverConfig: ServerConfig
|
_serverConfig: ServerConfig
|
||||||
_conn!: Connection
|
_conn!: Connection
|
||||||
_baseDatabase: BaseDatabase
|
_baseDatabase: BaseDatabase
|
@ -5,11 +5,11 @@
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { Between, ValueTransformer } from 'typeorm';
|
||||||
|
|
||||||
import { Between } from 'typeorm';
|
import { jsonBigIntStringReplacer } from '../misc';
|
||||||
import { IndexerInterface, jsonBigIntStringReplacer, StateInterface } from '@cerc-io/util';
|
import { IndexerInterface, StateInterface } from '../types';
|
||||||
|
import { GraphDatabase } from './database';
|
||||||
import { Database } from './database';
|
|
||||||
import { resolveEntityFieldConflicts } from './utils';
|
import { resolveEntityFieldConflicts } from './utils';
|
||||||
|
|
||||||
const log = debug('vulcanize:state-utils');
|
const log = debug('vulcanize:state-utils');
|
||||||
@ -55,7 +55,7 @@ export const prepareEntityState = (updatedEntity: any, entityName: string, relat
|
|||||||
return diffData;
|
return diffData;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateEntitiesFromState = async (database: Database, indexer: IndexerInterface, state: StateInterface) => {
|
export const updateEntitiesFromState = async (database: GraphDatabase, indexer: IndexerInterface, state: StateInterface) => {
|
||||||
const data = indexer.getStateData(state);
|
const data = indexer.getStateData(state);
|
||||||
|
|
||||||
// Get relations for subgraph entity
|
// Get relations for subgraph entity
|
||||||
@ -206,3 +206,36 @@ export const fillState = async (
|
|||||||
|
|
||||||
console.timeEnd('time:fill-state');
|
console.timeEnd('time:fill-state');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const fromStateEntityValues = (
|
||||||
|
stateEntity: any,
|
||||||
|
propertyName: string,
|
||||||
|
relations: { [key: string]: any } = {},
|
||||||
|
transformer?: ValueTransformer | ValueTransformer[]
|
||||||
|
): any => {
|
||||||
|
// Parse DB data value from state entity data.
|
||||||
|
if (relations) {
|
||||||
|
const relation = relations[propertyName];
|
||||||
|
|
||||||
|
if (relation) {
|
||||||
|
if (relation.isArray) {
|
||||||
|
return stateEntity[propertyName].map((relatedEntity: { id: string }) => relatedEntity.id);
|
||||||
|
} else {
|
||||||
|
return stateEntity[propertyName]?.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transformer) {
|
||||||
|
if (Array.isArray(transformer)) {
|
||||||
|
// Apply transformer in reverse order similar to when reading from DB.
|
||||||
|
return transformer.reduceRight((acc, elTransformer) => {
|
||||||
|
return elTransformer.from(acc);
|
||||||
|
}, stateEntity[propertyName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return transformer.from(stateEntity[propertyName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stateEntity[propertyName];
|
||||||
|
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user