diff --git a/packages/address-watcher/src/tx-watcher.ts b/packages/address-watcher/src/tx-watcher.ts index e902fa0b..3e087dab 100644 --- a/packages/address-watcher/src/tx-watcher.ts +++ b/packages/address-watcher/src/tx-watcher.ts @@ -4,7 +4,6 @@ import assert from 'assert'; import debug from 'debug'; -import _ from 'lodash'; import { PubSub } from 'graphql-subscriptions'; import { EthClient } from '@cerc-io/ipld-eth-client'; diff --git a/packages/cli/src/base.ts b/packages/cli/src/base.ts index 706e4b6f..00b85359 100644 --- a/packages/cli/src/base.ts +++ b/packages/cli/src/base.ts @@ -30,31 +30,38 @@ export class BaseCmd { _indexer?: IndexerInterface; _eventWatcher?: EventWatcher; - get config (): Config | undefined { + get config (): Config { + assert(this._config); return this._config; } - get clients (): Clients | undefined { + get clients (): Clients { + assert(this._clients); return this._clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { + assert(this._ethProvider); return this._ethProvider; } - get jobQueue (): JobQueue | undefined { + get jobQueue (): JobQueue { + assert(this._jobQueue); return this._jobQueue; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { + assert(this._database); return this._database; } - get indexer (): IndexerInterface | undefined { + get indexer (): IndexerInterface { + assert(this._indexer); return this._indexer; } - get eventWatcher (): EventWatcher | undefined { + get eventWatcher (): EventWatcher { + assert(this._eventWatcher); return this._eventWatcher; } diff --git a/packages/cli/src/checkpoint/create.ts b/packages/cli/src/checkpoint/create.ts index dc76ccaa..289c5ff2 100644 --- a/packages/cli/src/checkpoint/create.ts +++ b/packages/cli/src/checkpoint/create.ts @@ -36,19 +36,19 @@ export class CreateCheckpointCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/cli/src/checkpoint/verify.ts b/packages/cli/src/checkpoint/verify.ts index 0a8dd1b2..c4adf0ed 100644 --- a/packages/cli/src/checkpoint/verify.ts +++ b/packages/cli/src/checkpoint/verify.ts @@ -37,19 +37,19 @@ export class VerifyCheckpointCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/cli/src/export-state.ts b/packages/cli/src/export-state.ts index 66ac9a0e..28cc96fa 100644 --- a/packages/cli/src/export-state.ts +++ b/packages/cli/src/export-state.ts @@ -42,19 +42,19 @@ export class ExportStateCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/cli/src/fill.ts b/packages/cli/src/fill.ts index afcf180b..4fe06709 100644 --- a/packages/cli/src/fill.ts +++ b/packages/cli/src/fill.ts @@ -44,19 +44,19 @@ export class FillCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/cli/src/import-state.ts b/packages/cli/src/import-state.ts index 7102faa1..a86e89b6 100644 --- a/packages/cli/src/import-state.ts +++ b/packages/cli/src/import-state.ts @@ -44,19 +44,19 @@ export class ImportStateCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/cli/src/index-block.ts b/packages/cli/src/index-block.ts index 1c252d83..c5d08314 100644 --- a/packages/cli/src/index-block.ts +++ b/packages/cli/src/index-block.ts @@ -35,19 +35,19 @@ export class IndexBlockCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/cli/src/inspect-cid.ts b/packages/cli/src/inspect-cid.ts index bf50daab..4b5c5afe 100644 --- a/packages/cli/src/inspect-cid.ts +++ b/packages/cli/src/inspect-cid.ts @@ -38,19 +38,19 @@ export class InspectCIDCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/cli/src/job-runner.ts b/packages/cli/src/job-runner.ts index 99ac9cb4..5e953c7a 100644 --- a/packages/cli/src/job-runner.ts +++ b/packages/cli/src/job-runner.ts @@ -36,27 +36,27 @@ export class JobRunnerCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } - get jobQueue (): JobQueue | undefined { + get jobQueue (): JobQueue { return this._baseCmd.jobQueue; } - get indexer (): IndexerInterface | undefined { + get indexer (): IndexerInterface { return this._baseCmd.indexer; } diff --git a/packages/cli/src/reset/watcher.ts b/packages/cli/src/reset/watcher.ts index 194f090c..d0a58ba8 100644 --- a/packages/cli/src/reset/watcher.ts +++ b/packages/cli/src/reset/watcher.ts @@ -35,19 +35,19 @@ export class ResetWatcherCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/cli/src/server.ts b/packages/cli/src/server.ts index 45742d58..c161c548 100644 --- a/packages/cli/src/server.ts +++ b/packages/cli/src/server.ts @@ -41,19 +41,19 @@ export class ServerCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/cli/src/watch-contract.ts b/packages/cli/src/watch-contract.ts index bc566629..6f443690 100644 --- a/packages/cli/src/watch-contract.ts +++ b/packages/cli/src/watch-contract.ts @@ -37,19 +37,19 @@ export class WatchContractCmd { this._baseCmd = new BaseCmd(); } - get config (): Config | undefined { + get config (): Config { return this._baseCmd.config; } - get clients (): Clients | undefined { + get clients (): Clients { return this._baseCmd.clients; } - get ethProvider (): JsonRpcProvider | undefined { + get ethProvider (): JsonRpcProvider { return this._baseCmd.ethProvider; } - get database (): DatabaseInterface | undefined { + get database (): DatabaseInterface { return this._baseCmd.database; } diff --git a/packages/codegen/package.json b/packages/codegen/package.json index ecfb82e7..2a4adf33 100644 --- a/packages/codegen/package.json +++ b/packages/codegen/package.json @@ -23,6 +23,7 @@ "@graphql-tools/load-files": "^6.5.2", "@poanet/solidity-flattener": "https://github.com/vulcanize/solidity-flattener.git", "@solidity-parser/parser": "^0.13.2", + "ethers": "^5.4.4", "gql-generator": "https://github.com/vulcanize/gql-generator.git", "graphql": "^15.5.0", "graphql-compose": "^9.0.3", @@ -36,7 +37,6 @@ "yargs": "^17.1.1" }, "devDependencies": { - "@openzeppelin/contracts": "^4.3.2", "@types/js-yaml": "^4.0.3", "@types/node": "^16.9.0", "@typescript-eslint/eslint-plugin": "^4.25.0", diff --git a/packages/codegen/src/templates/checkpoint-create-template.handlebars b/packages/codegen/src/templates/checkpoint-create-template.handlebars index beb64803..01af1617 100644 --- a/packages/codegen/src/templates/checkpoint-create-template.handlebars +++ b/packages/codegen/src/templates/checkpoint-create-template.handlebars @@ -33,10 +33,10 @@ export const handler = async (argv: any): Promise => { {{#if (subgraphPath)}} const { graphWatcher } = await getGraphDbAndWatcher( - createCheckpointCmd.config!.server, - createCheckpointCmd.clients!.ethClient, - createCheckpointCmd.ethProvider!, - createCheckpointCmd.database!.baseDatabase, + createCheckpointCmd.config.server, + createCheckpointCmd.clients.ethClient, + createCheckpointCmd.ethProvider, + createCheckpointCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/checkpoint-verify-template.handlebars b/packages/codegen/src/templates/checkpoint-verify-template.handlebars index c3861260..3709f543 100644 --- a/packages/codegen/src/templates/checkpoint-verify-template.handlebars +++ b/packages/codegen/src/templates/checkpoint-verify-template.handlebars @@ -26,10 +26,10 @@ export const handler = async (argv: any): Promise => { await verifyCheckpointCmd.init(argv, Database); const { graphWatcher, graphDb } = await getGraphDbAndWatcher( - verifyCheckpointCmd.config!.server, - verifyCheckpointCmd.clients!.ethClient, - verifyCheckpointCmd.ethProvider!, - verifyCheckpointCmd.database!.baseDatabase, + verifyCheckpointCmd.config.server, + verifyCheckpointCmd.clients.ethClient, + verifyCheckpointCmd.ethProvider, + verifyCheckpointCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/database-template.handlebars b/packages/codegen/src/templates/database-template.handlebars index f137e9a7..ba6a4351 100644 --- a/packages/codegen/src/templates/database-template.handlebars +++ b/packages/codegen/src/templates/database-template.handlebars @@ -37,10 +37,8 @@ export const SUBGRAPH_ENTITIES = new Set([ {{~/each}}]); {{/if}} export const ENTITIES = [ - {{~#if (subgraphPath)}}...SUBGRAPH_ENTITIES, {{/if}} - {{~#each queries as | query |}}{{query.entityName}} - {{~#unless @last}}, {{/unless}} - {{~/each}}]; + {{~#each queries as | query |}}{{query.entityName}}, {{/each}} + {{~#if (subgraphPath)}}...SUBGRAPH_ENTITIES{{/if}}]; {{#if (subgraphPath)}} // Map: Entity to suitable query type. export const ENTITY_QUERY_TYPE_MAP = new Map any, ENTITY_QUERY_TYPE>([]); diff --git a/packages/codegen/src/templates/export-state-template.handlebars b/packages/codegen/src/templates/export-state-template.handlebars index 344cb897..b165cc40 100644 --- a/packages/codegen/src/templates/export-state-template.handlebars +++ b/packages/codegen/src/templates/export-state-template.handlebars @@ -21,10 +21,10 @@ const main = async (): Promise => { {{#if (subgraphPath)}} const { graphWatcher } = await getGraphDbAndWatcher( - exportStateCmd.config!.server, - exportStateCmd.clients!.ethClient, - exportStateCmd.ethProvider!, - exportStateCmd.database!.baseDatabase, + exportStateCmd.config.server, + exportStateCmd.clients.ethClient, + exportStateCmd.ethProvider, + exportStateCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/fill-template.handlebars b/packages/codegen/src/templates/fill-template.handlebars index f24cdf20..d20ca83b 100644 --- a/packages/codegen/src/templates/fill-template.handlebars +++ b/packages/codegen/src/templates/fill-template.handlebars @@ -22,10 +22,10 @@ export const main = async (): Promise => { {{#if (subgraphPath)}} const { graphWatcher } = await getGraphDbAndWatcher( - fillCmd.config!.server, - fillCmd.clients!.ethClient, - fillCmd.ethProvider!, - fillCmd.database!.baseDatabase, + fillCmd.config.server, + fillCmd.clients.ethClient, + fillCmd.ethProvider, + fillCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/import-state-template.handlebars b/packages/codegen/src/templates/import-state-template.handlebars index 5b674af8..eaf08e42 100644 --- a/packages/codegen/src/templates/import-state-template.handlebars +++ b/packages/codegen/src/templates/import-state-template.handlebars @@ -22,10 +22,10 @@ export const main = async (): Promise => { {{#if (subgraphPath)}} const { graphWatcher, graphDb } = await getGraphDbAndWatcher( - importStateCmd.config!.server, - importStateCmd.clients!.ethClient, - importStateCmd.ethProvider!, - importStateCmd.database!.baseDatabase, + importStateCmd.config.server, + importStateCmd.clients.ethClient, + importStateCmd.ethProvider, + importStateCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/index-block-template.handlebars b/packages/codegen/src/templates/index-block-template.handlebars index ec0d82d0..4bed0140 100644 --- a/packages/codegen/src/templates/index-block-template.handlebars +++ b/packages/codegen/src/templates/index-block-template.handlebars @@ -21,10 +21,10 @@ const main = async (): Promise => { {{#if (subgraphPath)}} const { graphWatcher } = await getGraphDbAndWatcher( - indexBlockCmd.config!.server, - indexBlockCmd.clients!.ethClient, - indexBlockCmd.ethProvider!, - indexBlockCmd.database!.baseDatabase, + indexBlockCmd.config.server, + indexBlockCmd.clients.ethClient, + indexBlockCmd.ethProvider, + indexBlockCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/inspect-cid-template.handlebars b/packages/codegen/src/templates/inspect-cid-template.handlebars index 4ad8c2df..e06c3c24 100644 --- a/packages/codegen/src/templates/inspect-cid-template.handlebars +++ b/packages/codegen/src/templates/inspect-cid-template.handlebars @@ -21,10 +21,10 @@ const main = async (): Promise => { {{#if (subgraphPath)}} const { graphWatcher } = await getGraphDbAndWatcher( - inspectCIDCmd.config!.server, - inspectCIDCmd.clients!.ethClient, - inspectCIDCmd.ethProvider!, - inspectCIDCmd.database!.baseDatabase, + inspectCIDCmd.config.server, + inspectCIDCmd.clients.ethClient, + inspectCIDCmd.ethProvider, + inspectCIDCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/job-runner-template.handlebars b/packages/codegen/src/templates/job-runner-template.handlebars index dbc69bfb..41756141 100644 --- a/packages/codegen/src/templates/job-runner-template.handlebars +++ b/packages/codegen/src/templates/job-runner-template.handlebars @@ -21,10 +21,10 @@ export const main = async (): Promise => { {{#if (subgraphPath)}} const { graphWatcher } = await getGraphDbAndWatcher( - jobRunnerCmd.config!.server, - jobRunnerCmd.clients!.ethClient, - jobRunnerCmd.ethProvider!, - jobRunnerCmd.database!.baseDatabase, + jobRunnerCmd.config.server, + jobRunnerCmd.clients.ethClient, + jobRunnerCmd.ethProvider, + jobRunnerCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/package-template.handlebars b/packages/codegen/src/templates/package-template.handlebars index c8000441..dc35361d 100644 --- a/packages/codegen/src/templates/package-template.handlebars +++ b/packages/codegen/src/templates/package-template.handlebars @@ -41,7 +41,6 @@ "dependencies": { "@apollo/client": "^3.3.19", "@ethersproject/providers": "^5.4.4", - "@ipld/dag-cbor": "^6.0.12", "@cerc-io/cli": "^0.2.15", "@cerc-io/ipld-eth-client": "^0.2.15", "@cerc-io/solidity-mapper": "^0.2.15", @@ -52,7 +51,6 @@ "apollo-type-bigint": "^0.1.3", "debug": "^4.3.1", "ethers": "^5.4.4", - "express": "^4.18.2", "graphql": "^15.5.0", "json-bigint": "^1.0.0", "reflect-metadata": "^0.1.13", @@ -62,7 +60,6 @@ }, "devDependencies": { "@ethersproject/abi": "^5.3.0", - "@types/express": "^4.17.14", "@types/yargs": "^17.0.0", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", diff --git a/packages/codegen/src/templates/reset-watcher-template.handlebars b/packages/codegen/src/templates/reset-watcher-template.handlebars index 7b6bd5dc..4ed8e053 100644 --- a/packages/codegen/src/templates/reset-watcher-template.handlebars +++ b/packages/codegen/src/templates/reset-watcher-template.handlebars @@ -25,11 +25,11 @@ export const handler = async (argv: any): Promise => { await resetWatcherCmd.init(argv, Database); {{#if (subgraphPath)}} - const { graphWatcher, graphDb } = await getGraphDbAndWatcher( - resetWatcherCmd.config!.server, - resetWatcherCmd.clients!.ethClient, - resetWatcherCmd.ethProvider!, - resetWatcherCmd.database!.baseDatabase, + const { graphWatcher } = await getGraphDbAndWatcher( + resetWatcherCmd.config.server, + resetWatcherCmd.clients.ethClient, + resetWatcherCmd.ethProvider, + resetWatcherCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/resolvers-template.handlebars b/packages/codegen/src/templates/resolvers-template.handlebars index b7e1f71c..be6cf771 100644 --- a/packages/codegen/src/templates/resolvers-template.handlebars +++ b/packages/codegen/src/templates/resolvers-template.handlebars @@ -21,7 +21,6 @@ import { } from '@cerc-io/util'; import { Indexer } from './indexer'; -import { EventWatcher } from './events'; {{#if (subgraphPath)}} {{#each subgraphQueries as | query |}} diff --git a/packages/codegen/src/templates/server-template.handlebars b/packages/codegen/src/templates/server-template.handlebars index 171cf4d5..0988f4ca 100644 --- a/packages/codegen/src/templates/server-template.handlebars +++ b/packages/codegen/src/templates/server-template.handlebars @@ -24,10 +24,10 @@ export const main = async (): Promise => { {{#if (subgraphPath)}} const { graphWatcher } = await getGraphDbAndWatcher( - serverCmd.config!.server, - serverCmd.clients!.ethClient, - serverCmd.ethProvider!, - serverCmd.database!.baseDatabase, + serverCmd.config.server, + serverCmd.clients.ethClient, + serverCmd.ethProvider, + serverCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/codegen/src/templates/watch-contract-template.handlebars b/packages/codegen/src/templates/watch-contract-template.handlebars index d32d4e13..2c4d77b1 100644 --- a/packages/codegen/src/templates/watch-contract-template.handlebars +++ b/packages/codegen/src/templates/watch-contract-template.handlebars @@ -21,10 +21,10 @@ const main = async (): Promise => { {{#if (subgraphPath)}} const { graphWatcher } = await getGraphDbAndWatcher( - watchContractCmd.config!.server, - watchContractCmd.clients!.ethClient, - watchContractCmd.ethProvider!, - watchContractCmd.database!.baseDatabase, + watchContractCmd.config.server, + watchContractCmd.clients.ethClient, + watchContractCmd.ethProvider, + watchContractCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/package.json b/packages/eden-watcher/package.json index 74fd498c..4b1a6263 100644 --- a/packages/eden-watcher/package.json +++ b/packages/eden-watcher/package.json @@ -44,21 +44,17 @@ "@cerc-io/solidity-mapper": "^0.2.16", "@cerc-io/util": "^0.2.16", "@ethersproject/providers": "^5.4.4", - "@ipld/dag-cbor": "^6.0.12", "apollo-type-bigint": "^0.1.3", "debug": "^4.3.1", "decimal.js": "^10.3.1", "ethers": "^5.4.4", - "express": "^4.18.2", "graphql": "^15.5.0", - "json-bigint": "^1.0.0", "reflect-metadata": "^0.1.13", "typeorm": "^0.2.32", "yargs": "^17.0.1" }, "devDependencies": { "@ethersproject/abi": "^5.3.0", - "@types/express": "^4.17.14", "@types/yargs": "^17.0.0", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", diff --git a/packages/eden-watcher/src/cli/checkpoint-cmds/create.ts b/packages/eden-watcher/src/cli/checkpoint-cmds/create.ts index f4b91aa0..e771c702 100644 --- a/packages/eden-watcher/src/cli/checkpoint-cmds/create.ts +++ b/packages/eden-watcher/src/cli/checkpoint-cmds/create.ts @@ -30,10 +30,10 @@ export const handler = async (argv: any): Promise => { await createCheckpointCmd.init(argv, Database); const { graphWatcher } = await getGraphDbAndWatcher( - createCheckpointCmd.config!.server, - createCheckpointCmd.clients!.ethClient, - createCheckpointCmd.ethProvider!, - createCheckpointCmd.database!.baseDatabase, + createCheckpointCmd.config.server, + createCheckpointCmd.clients.ethClient, + createCheckpointCmd.ethProvider, + createCheckpointCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/cli/checkpoint-cmds/verify.ts b/packages/eden-watcher/src/cli/checkpoint-cmds/verify.ts index c3861260..3709f543 100644 --- a/packages/eden-watcher/src/cli/checkpoint-cmds/verify.ts +++ b/packages/eden-watcher/src/cli/checkpoint-cmds/verify.ts @@ -26,10 +26,10 @@ export const handler = async (argv: any): Promise => { await verifyCheckpointCmd.init(argv, Database); const { graphWatcher, graphDb } = await getGraphDbAndWatcher( - verifyCheckpointCmd.config!.server, - verifyCheckpointCmd.clients!.ethClient, - verifyCheckpointCmd.ethProvider!, - verifyCheckpointCmd.database!.baseDatabase, + verifyCheckpointCmd.config.server, + verifyCheckpointCmd.clients.ethClient, + verifyCheckpointCmd.ethProvider, + verifyCheckpointCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/cli/export-state.ts b/packages/eden-watcher/src/cli/export-state.ts index e8e1fc2e..bcd1c8ab 100644 --- a/packages/eden-watcher/src/cli/export-state.ts +++ b/packages/eden-watcher/src/cli/export-state.ts @@ -18,10 +18,10 @@ const main = async (): Promise => { await exportStateCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - exportStateCmd.config!.server, - exportStateCmd.clients!.ethClient, - exportStateCmd.ethProvider!, - exportStateCmd.database!.baseDatabase, + exportStateCmd.config.server, + exportStateCmd.clients.ethClient, + exportStateCmd.ethProvider, + exportStateCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/cli/import-state.ts b/packages/eden-watcher/src/cli/import-state.ts index 0ab2593c..04ce0e8c 100644 --- a/packages/eden-watcher/src/cli/import-state.ts +++ b/packages/eden-watcher/src/cli/import-state.ts @@ -19,10 +19,10 @@ export const main = async (): Promise => { await importStateCmd.init(Database); const { graphWatcher, graphDb } = await getGraphDbAndWatcher( - importStateCmd.config!.server, - importStateCmd.clients!.ethClient, - importStateCmd.ethProvider!, - importStateCmd.database!.baseDatabase, + importStateCmd.config.server, + importStateCmd.clients.ethClient, + importStateCmd.ethProvider, + importStateCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/cli/index-block.ts b/packages/eden-watcher/src/cli/index-block.ts index 32998111..19a302af 100644 --- a/packages/eden-watcher/src/cli/index-block.ts +++ b/packages/eden-watcher/src/cli/index-block.ts @@ -18,10 +18,10 @@ const main = async (): Promise => { await indexBlockCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - indexBlockCmd.config!.server, - indexBlockCmd.clients!.ethClient, - indexBlockCmd.ethProvider!, - indexBlockCmd.database!.baseDatabase, + indexBlockCmd.config.server, + indexBlockCmd.clients.ethClient, + indexBlockCmd.ethProvider, + indexBlockCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/cli/inspect-cid.ts b/packages/eden-watcher/src/cli/inspect-cid.ts index 4453e4d0..4f5955ef 100644 --- a/packages/eden-watcher/src/cli/inspect-cid.ts +++ b/packages/eden-watcher/src/cli/inspect-cid.ts @@ -18,10 +18,10 @@ const main = async (): Promise => { await inspectCIDCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - inspectCIDCmd.config!.server, - inspectCIDCmd.clients!.ethClient, - inspectCIDCmd.ethProvider!, - inspectCIDCmd.database!.baseDatabase, + inspectCIDCmd.config.server, + inspectCIDCmd.clients.ethClient, + inspectCIDCmd.ethProvider, + inspectCIDCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/cli/reset-cmds/watcher.ts b/packages/eden-watcher/src/cli/reset-cmds/watcher.ts index cdbe328f..827fd28d 100644 --- a/packages/eden-watcher/src/cli/reset-cmds/watcher.ts +++ b/packages/eden-watcher/src/cli/reset-cmds/watcher.ts @@ -22,11 +22,11 @@ export const handler = async (argv: any): Promise => { const resetWatcherCmd = new ResetWatcherCmd(); await resetWatcherCmd.init(argv, Database); - const { graphWatcher, graphDb } = await getGraphDbAndWatcher( - resetWatcherCmd.config!.server, - resetWatcherCmd.clients!.ethClient, - resetWatcherCmd.ethProvider!, - resetWatcherCmd.database!.baseDatabase, + const { graphWatcher } = await getGraphDbAndWatcher( + resetWatcherCmd.config.server, + resetWatcherCmd.clients.ethClient, + resetWatcherCmd.ethProvider, + resetWatcherCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/cli/watch-contract.ts b/packages/eden-watcher/src/cli/watch-contract.ts index 687c4921..7d6ce1a5 100644 --- a/packages/eden-watcher/src/cli/watch-contract.ts +++ b/packages/eden-watcher/src/cli/watch-contract.ts @@ -18,10 +18,10 @@ const main = async (): Promise => { await watchContractCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - watchContractCmd.config!.server, - watchContractCmd.clients!.ethClient, - watchContractCmd.ethProvider!, - watchContractCmd.database!.baseDatabase, + watchContractCmd.config.server, + watchContractCmd.clients.ethClient, + watchContractCmd.ethProvider, + watchContractCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/fill.ts b/packages/eden-watcher/src/fill.ts index c3f41aee..a8906f85 100644 --- a/packages/eden-watcher/src/fill.ts +++ b/packages/eden-watcher/src/fill.ts @@ -19,10 +19,10 @@ export const main = async (): Promise => { await fillCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - fillCmd.config!.server, - fillCmd.clients!.ethClient, - fillCmd.ethProvider!, - fillCmd.database!.baseDatabase, + fillCmd.config.server, + fillCmd.clients.ethClient, + fillCmd.ethProvider, + fillCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/job-runner.ts b/packages/eden-watcher/src/job-runner.ts index 9abbe64f..84b0065e 100644 --- a/packages/eden-watcher/src/job-runner.ts +++ b/packages/eden-watcher/src/job-runner.ts @@ -18,10 +18,10 @@ export const main = async (): Promise => { await jobRunnerCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - jobRunnerCmd.config!.server, - jobRunnerCmd.clients!.ethClient, - jobRunnerCmd.ethProvider!, - jobRunnerCmd.database!.baseDatabase, + jobRunnerCmd.config.server, + jobRunnerCmd.clients.ethClient, + jobRunnerCmd.ethProvider, + jobRunnerCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/eden-watcher/src/server.ts b/packages/eden-watcher/src/server.ts index 12899c82..d55266d9 100644 --- a/packages/eden-watcher/src/server.ts +++ b/packages/eden-watcher/src/server.ts @@ -21,10 +21,10 @@ export const main = async (): Promise => { await serverCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - serverCmd.config!.server, - serverCmd.clients!.ethClient, - serverCmd.ethProvider!, - serverCmd.database!.baseDatabase, + serverCmd.config.server, + serverCmd.clients.ethClient, + serverCmd.ethProvider, + serverCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/erc20-watcher/package.json b/packages/erc20-watcher/package.json index 4e60ad68..c1efe926 100644 --- a/packages/erc20-watcher/package.json +++ b/packages/erc20-watcher/package.json @@ -45,30 +45,22 @@ "@cerc-io/solidity-mapper": "^0.2.16", "@cerc-io/util": "^0.2.16", "@ethersproject/providers": "^5.4.4", - "@types/express": "^4.17.14", - "@types/lodash": "^4.14.168", "apollo-type-bigint": "^0.1.3", "debug": "^4.3.1", "ethers": "^5.4.4", - "express": "^4.18.2", "graphql": "^15.5.0", "graphql-request": "^3.4.0", "json-bigint": "^1.0.0", - "lodash": "^4.17.21", "reflect-metadata": "^0.1.13", - "typeorm": "^0.2.32", - "yargs": "^17.0.1" + "typeorm": "^0.2.32" }, "devDependencies": { "@ethersproject/abi": "^5.3.0", "@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-waffle": "^2.0.1", - "@types/express": "^4.17.14", "@types/json-bigint": "^1.0.0", - "@types/yargs": "^17.0.0", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", - "chai": "^4.3.4", "eslint": "^7.27.0", "eslint-config-semistandard": "^15.0.1", "eslint-config-standard": "^16.0.3", @@ -77,7 +69,6 @@ "eslint-plugin-promise": "^5.1.0", "eslint-plugin-standard": "^5.0.0", "hardhat": "^2.3.0", - "mocha": "^8.4.0", "nodemon": "^2.0.7" } } diff --git a/packages/erc20-watcher/src/indexer.ts b/packages/erc20-watcher/src/indexer.ts index 3c9f7365..e76d8179 100644 --- a/packages/erc20-watcher/src/indexer.ts +++ b/packages/erc20-watcher/src/indexer.ts @@ -2,6 +2,8 @@ // Copyright 2021 Vulcanize, Inc. // +/* eslint-disable @typescript-eslint/no-unused-vars */ + import assert from 'assert'; import debug from 'debug'; import { JsonFragment } from '@ethersproject/abi'; diff --git a/packages/erc20-watcher/src/server.ts b/packages/erc20-watcher/src/server.ts index b4a677b6..4ae6de5e 100644 --- a/packages/erc20-watcher/src/server.ts +++ b/packages/erc20-watcher/src/server.ts @@ -2,8 +2,6 @@ // Copyright 2021 Vulcanize, Inc. // -import fs from 'fs'; -import path from 'path'; import 'reflect-metadata'; import debug from 'debug'; diff --git a/packages/erc721-watcher/package.json b/packages/erc721-watcher/package.json index e3098940..0e15502d 100644 --- a/packages/erc721-watcher/package.json +++ b/packages/erc721-watcher/package.json @@ -51,12 +51,10 @@ "@cerc-io/solidity-mapper": "^0.2.16", "@cerc-io/util": "^0.2.16", "@ethersproject/providers": "^5.4.4", - "@ipld/dag-cbor": "^6.0.12", "apollo-type-bigint": "^0.1.3", "debug": "^4.3.1", "decimal.js": "^10.3.1", "ethers": "^5.4.4", - "express": "^4.18.2", "graphql": "^15.5.0", "json-bigint": "^1.0.0", "reflect-metadata": "^0.1.13", @@ -67,7 +65,6 @@ "@ethersproject/abi": "^5.3.0", "@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-waffle": "^2.0.1", - "@types/express": "^4.17.14", "@types/yargs": "^17.0.0", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", diff --git a/packages/graph-node/package.json b/packages/graph-node/package.json index 09409b53..5ceaa294 100644 --- a/packages/graph-node/package.json +++ b/packages/graph-node/package.json @@ -4,12 +4,13 @@ "main": "dist/index.js", "license": "AGPL-3.0", "devDependencies": { + "@cerc-io/solidity-mapper": "^0.2.16", + "@ethersproject/providers": "^5.4.4", "@graphprotocol/graph-ts": "^0.22.0", "@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-waffle": "^2.0.1", "@types/chai": "^4.2.18", "@types/chai-spies": "^1.0.3", - "@types/js-yaml": "^4.0.4", "@types/pluralize": "^0.0.29", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", @@ -48,21 +49,23 @@ }, "dependencies": { "@apollo/client": "^3.3.19", + "@cerc-io/cache": "^0.2.16", "@cerc-io/ipld-eth-client": "^0.2.16", "@cerc-io/util": "^0.2.16", "@types/json-diff": "^0.5.2", "@vulcanize/assemblyscript": "0.0.1", "bn.js": "^4.11.9", "debug": "^4.3.1", + "graphql": "^15.5.0", "fs-extra": "^10.0.0", - "js-yaml": "^4.1.0", - "json-bigint": "^1.0.0", + "lodash": "^4.17.21", "json-diff": "^0.5.4", "omit-deep": "^0.3.0", "pluralize": "^8.0.0", "reflect-metadata": "^0.1.13", "toml": "^3.0.0", "typeorm": "^0.2.32", + "typeorm-naming-strategies": "^2.0.0", "yargs": "^17.0.1" } } diff --git a/packages/graph-node/src/watcher.ts b/packages/graph-node/src/watcher.ts index 835f3538..cc700c90 100644 --- a/packages/graph-node/src/watcher.ts +++ b/packages/graph-node/src/watcher.ts @@ -443,6 +443,7 @@ export class GraphWatcher { // Important to call _start for built subgraphs on instantiation! // TODO: Check api version https://github.com/graphprotocol/graph-node/blob/6098daa8955bdfac597cec87080af5449807e874/runtime/wasm/src/module/mod.rs#L533 + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this._dataSourceMap[dataSourceName].instance!.exports._start(); } diff --git a/packages/graph-node/test/subgraph/example1/src/mapping.ts b/packages/graph-node/test/subgraph/example1/src/mapping.ts index 69a2859a..cfd01d39 100644 --- a/packages/graph-node/test/subgraph/example1/src/mapping.ts +++ b/packages/graph-node/test/subgraph/example1/src/mapping.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + import { Address, log, BigInt, BigDecimal, ByteArray, dataSource, ethereum, Bytes, crypto, json, JSONValueKind } from '@graphprotocol/graph-ts'; import { @@ -164,7 +166,7 @@ export function testGetStorageValue (): void { // Bind the contract to the address. const contractAddress = dataSource.address(); - const contract = Example1.bind(contractAddress); + Example1.bind(contractAddress); const res = ethereum.getStorageValue('_test', []); log.debug('Storage call result: {}', [res!.toBigInt().toString()]); } @@ -174,7 +176,7 @@ export function testMapStorageValue (): void { // Bind the contract to the address. const contractAddress = dataSource.address(); - const contract = Example1.bind(contractAddress); + Example1.bind(contractAddress); const addressValue = ethereum.Value.fromAddress(Address.zero()); const res = ethereum.getStorageValue('addressUintMap', [addressValue]); log.debug('Storage call result: {}', [res!.toBigInt().toString()]); diff --git a/packages/graph-node/test/utils/indexer.ts b/packages/graph-node/test/utils/indexer.ts index 993602c2..394c0613 100644 --- a/packages/graph-node/test/utils/indexer.ts +++ b/packages/graph-node/test/utils/indexer.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ + import assert from 'assert'; import { DeepPartial, FindConditions, FindManyOptions } from 'typeorm'; diff --git a/packages/graph-test-watcher/package.json b/packages/graph-test-watcher/package.json index 21683479..3a580d53 100644 --- a/packages/graph-test-watcher/package.json +++ b/packages/graph-test-watcher/package.json @@ -44,22 +44,18 @@ "@cerc-io/solidity-mapper": "^0.2.16", "@cerc-io/util": "^0.2.16", "@ethersproject/providers": "^5.4.4", - "@ipld/dag-cbor": "^6.0.12", "apollo-type-bigint": "^0.1.3", "debug": "^4.3.1", "decimal.js": "^10.3.1", "ethers": "^5.4.4", - "express": "^4.18.2", "graphql": "^15.5.0", "json-bigint": "^1.0.0", - "lodash": "^4.17.21", "reflect-metadata": "^0.1.13", "typeorm": "^0.2.32", "yargs": "^17.0.1" }, "devDependencies": { "@ethersproject/abi": "^5.3.0", - "@types/express": "^4.17.14", "@types/yargs": "^17.0.0", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", diff --git a/packages/graph-test-watcher/src/cli/checkpoint-cmds/create.ts b/packages/graph-test-watcher/src/cli/checkpoint-cmds/create.ts index f4b91aa0..e771c702 100644 --- a/packages/graph-test-watcher/src/cli/checkpoint-cmds/create.ts +++ b/packages/graph-test-watcher/src/cli/checkpoint-cmds/create.ts @@ -30,10 +30,10 @@ export const handler = async (argv: any): Promise => { await createCheckpointCmd.init(argv, Database); const { graphWatcher } = await getGraphDbAndWatcher( - createCheckpointCmd.config!.server, - createCheckpointCmd.clients!.ethClient, - createCheckpointCmd.ethProvider!, - createCheckpointCmd.database!.baseDatabase, + createCheckpointCmd.config.server, + createCheckpointCmd.clients.ethClient, + createCheckpointCmd.ethProvider, + createCheckpointCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/cli/checkpoint-cmds/verify.ts b/packages/graph-test-watcher/src/cli/checkpoint-cmds/verify.ts index c3861260..3709f543 100644 --- a/packages/graph-test-watcher/src/cli/checkpoint-cmds/verify.ts +++ b/packages/graph-test-watcher/src/cli/checkpoint-cmds/verify.ts @@ -26,10 +26,10 @@ export const handler = async (argv: any): Promise => { await verifyCheckpointCmd.init(argv, Database); const { graphWatcher, graphDb } = await getGraphDbAndWatcher( - verifyCheckpointCmd.config!.server, - verifyCheckpointCmd.clients!.ethClient, - verifyCheckpointCmd.ethProvider!, - verifyCheckpointCmd.database!.baseDatabase, + verifyCheckpointCmd.config.server, + verifyCheckpointCmd.clients.ethClient, + verifyCheckpointCmd.ethProvider, + verifyCheckpointCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/cli/export-state.ts b/packages/graph-test-watcher/src/cli/export-state.ts index e8e1fc2e..bcd1c8ab 100644 --- a/packages/graph-test-watcher/src/cli/export-state.ts +++ b/packages/graph-test-watcher/src/cli/export-state.ts @@ -18,10 +18,10 @@ const main = async (): Promise => { await exportStateCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - exportStateCmd.config!.server, - exportStateCmd.clients!.ethClient, - exportStateCmd.ethProvider!, - exportStateCmd.database!.baseDatabase, + exportStateCmd.config.server, + exportStateCmd.clients.ethClient, + exportStateCmd.ethProvider, + exportStateCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/cli/import-state.ts b/packages/graph-test-watcher/src/cli/import-state.ts index 0ab2593c..04ce0e8c 100644 --- a/packages/graph-test-watcher/src/cli/import-state.ts +++ b/packages/graph-test-watcher/src/cli/import-state.ts @@ -19,10 +19,10 @@ export const main = async (): Promise => { await importStateCmd.init(Database); const { graphWatcher, graphDb } = await getGraphDbAndWatcher( - importStateCmd.config!.server, - importStateCmd.clients!.ethClient, - importStateCmd.ethProvider!, - importStateCmd.database!.baseDatabase, + importStateCmd.config.server, + importStateCmd.clients.ethClient, + importStateCmd.ethProvider, + importStateCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/cli/index-block.ts b/packages/graph-test-watcher/src/cli/index-block.ts index 32998111..19a302af 100644 --- a/packages/graph-test-watcher/src/cli/index-block.ts +++ b/packages/graph-test-watcher/src/cli/index-block.ts @@ -18,10 +18,10 @@ const main = async (): Promise => { await indexBlockCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - indexBlockCmd.config!.server, - indexBlockCmd.clients!.ethClient, - indexBlockCmd.ethProvider!, - indexBlockCmd.database!.baseDatabase, + indexBlockCmd.config.server, + indexBlockCmd.clients.ethClient, + indexBlockCmd.ethProvider, + indexBlockCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/cli/inspect-cid.ts b/packages/graph-test-watcher/src/cli/inspect-cid.ts index 4453e4d0..4f5955ef 100644 --- a/packages/graph-test-watcher/src/cli/inspect-cid.ts +++ b/packages/graph-test-watcher/src/cli/inspect-cid.ts @@ -18,10 +18,10 @@ const main = async (): Promise => { await inspectCIDCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - inspectCIDCmd.config!.server, - inspectCIDCmd.clients!.ethClient, - inspectCIDCmd.ethProvider!, - inspectCIDCmd.database!.baseDatabase, + inspectCIDCmd.config.server, + inspectCIDCmd.clients.ethClient, + inspectCIDCmd.ethProvider, + inspectCIDCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/cli/reset-cmds/watcher.ts b/packages/graph-test-watcher/src/cli/reset-cmds/watcher.ts index cdbe328f..827fd28d 100644 --- a/packages/graph-test-watcher/src/cli/reset-cmds/watcher.ts +++ b/packages/graph-test-watcher/src/cli/reset-cmds/watcher.ts @@ -22,11 +22,11 @@ export const handler = async (argv: any): Promise => { const resetWatcherCmd = new ResetWatcherCmd(); await resetWatcherCmd.init(argv, Database); - const { graphWatcher, graphDb } = await getGraphDbAndWatcher( - resetWatcherCmd.config!.server, - resetWatcherCmd.clients!.ethClient, - resetWatcherCmd.ethProvider!, - resetWatcherCmd.database!.baseDatabase, + const { graphWatcher } = await getGraphDbAndWatcher( + resetWatcherCmd.config.server, + resetWatcherCmd.clients.ethClient, + resetWatcherCmd.ethProvider, + resetWatcherCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/cli/watch-contract.ts b/packages/graph-test-watcher/src/cli/watch-contract.ts index 687c4921..7d6ce1a5 100644 --- a/packages/graph-test-watcher/src/cli/watch-contract.ts +++ b/packages/graph-test-watcher/src/cli/watch-contract.ts @@ -18,10 +18,10 @@ const main = async (): Promise => { await watchContractCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - watchContractCmd.config!.server, - watchContractCmd.clients!.ethClient, - watchContractCmd.ethProvider!, - watchContractCmd.database!.baseDatabase, + watchContractCmd.config.server, + watchContractCmd.clients.ethClient, + watchContractCmd.ethProvider, + watchContractCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/fill.ts b/packages/graph-test-watcher/src/fill.ts index a15c9f43..a09ea2b4 100644 --- a/packages/graph-test-watcher/src/fill.ts +++ b/packages/graph-test-watcher/src/fill.ts @@ -19,10 +19,10 @@ export const main = async (): Promise => { await fillCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - fillCmd.config!.server, - fillCmd.clients!.ethClient, - fillCmd.ethProvider!, - fillCmd.database!.baseDatabase, + fillCmd.config.server, + fillCmd.clients.ethClient, + fillCmd.ethProvider, + fillCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/job-runner.ts b/packages/graph-test-watcher/src/job-runner.ts index 9abbe64f..84b0065e 100644 --- a/packages/graph-test-watcher/src/job-runner.ts +++ b/packages/graph-test-watcher/src/job-runner.ts @@ -18,10 +18,10 @@ export const main = async (): Promise => { await jobRunnerCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - jobRunnerCmd.config!.server, - jobRunnerCmd.clients!.ethClient, - jobRunnerCmd.ethProvider!, - jobRunnerCmd.database!.baseDatabase, + jobRunnerCmd.config.server, + jobRunnerCmd.clients.ethClient, + jobRunnerCmd.ethProvider, + jobRunnerCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/graph-test-watcher/src/server.ts b/packages/graph-test-watcher/src/server.ts index 12899c82..d55266d9 100644 --- a/packages/graph-test-watcher/src/server.ts +++ b/packages/graph-test-watcher/src/server.ts @@ -21,10 +21,10 @@ export const main = async (): Promise => { await serverCmd.init(Database); const { graphWatcher } = await getGraphDbAndWatcher( - serverCmd.config!.server, - serverCmd.clients!.ethClient, - serverCmd.ethProvider!, - serverCmd.database!.baseDatabase, + serverCmd.config.server, + serverCmd.clients.ethClient, + serverCmd.ethProvider, + serverCmd.database.baseDatabase, ENTITY_QUERY_TYPE_MAP, ENTITY_TO_LATEST_ENTITY_MAP ); diff --git a/packages/mobymask-watcher/package.json b/packages/mobymask-watcher/package.json index f0ce83be..723f1437 100644 --- a/packages/mobymask-watcher/package.json +++ b/packages/mobymask-watcher/package.json @@ -42,12 +42,10 @@ "@cerc-io/solidity-mapper": "^0.2.16", "@cerc-io/util": "^0.2.16", "@ethersproject/providers": "^5.4.4", - "@ipld/dag-cbor": "^6.0.12", "apollo-type-bigint": "^0.1.3", "debug": "^4.3.1", "decimal.js": "^10.3.1", "ethers": "^5.4.4", - "express": "^4.18.2", "graphql": "^15.5.0", "json-bigint": "^1.0.0", "reflect-metadata": "^0.1.13", @@ -56,7 +54,6 @@ }, "devDependencies": { "@ethersproject/abi": "^5.3.0", - "@types/express": "^4.17.14", "@types/yargs": "^17.0.0", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", diff --git a/packages/test/package.json b/packages/test/package.json index d7f77b8e..8df2ecb1 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -16,7 +16,6 @@ "debug": "^4.3.1", "ethers": "^5.4.4", "fs-extra": "^10.0.0", - "lodash": "^4.17.21", "mocha": "^8.4.0", "toml": "^3.0.0", "yargs": "^17.0.1" diff --git a/packages/util/package.json b/packages/util/package.json index af3342cb..b4c4c115 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -19,6 +19,7 @@ "express": "^4.18.2", "express-queue": "^0.0.13", "fs-extra": "^10.0.0", + "js-yaml": "^4.1.0", "graphql": "^15.5.0", "graphql-subscriptions": "^2.0.0", "graphql-ws": "^5.11.2", @@ -32,6 +33,7 @@ "toml": "^3.0.0", "typeorm": "^0.2.32", "typeorm-naming-strategies": "^2.0.0", + "yargs": "^17.0.1", "ws": "^8.11.0" }, "devDependencies": { @@ -44,6 +46,7 @@ "@types/ws": "^8.5.3", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", + "@types/js-yaml": "^4.0.4", "decimal.js": "^10.3.1", "eslint": "^7.27.0", "eslint-config-semistandard": "^15.0.1", diff --git a/packages/util/src/block-size-cache.ts b/packages/util/src/block-size-cache.ts index 28148f65..d27b466c 100644 --- a/packages/util/src/block-size-cache.ts +++ b/packages/util/src/block-size-cache.ts @@ -61,7 +61,7 @@ const cacheBlockSizesAsync = async (provider: providers.JsonRpcProvider, blockNu if (blockNumber % BLOCK_SIZE_MAP_CLEAR_HEIGHT_INTERVAL === 0) { log(`cacheBlockSizesAsync-clear-map-below-${blockNumber}`); const previousBlockHashes = Array.from(blockSizeMap.entries()) - .filter(([_, value]) => value.blockNumber <= blockNumber) + .filter(([, value]) => value.blockNumber <= blockNumber) .map(([blockHash]) => blockHash); previousBlockHashes.forEach(blockHash => blockSizeMap.delete(blockHash)); diff --git a/packages/util/src/database.ts b/packages/util/src/database.ts index 5552600b..6be8673b 100644 --- a/packages/util/src/database.ts +++ b/packages/util/src/database.ts @@ -13,7 +13,6 @@ import { FindConditions, FindManyOptions, In, - Not, QueryRunner, Repository, SelectQueryBuilder diff --git a/packages/util/src/graph/database.ts b/packages/util/src/graph/database.ts index 92386078..76ca554b 100644 --- a/packages/util/src/graph/database.ts +++ b/packages/util/src/graph/database.ts @@ -76,7 +76,7 @@ export class GraphDatabase { this._entityToLatestEntityMap = entityToLatestEntityMap; } - get cachedEntities () { + get cachedEntities (): CachedEntities { return this._cachedEntities; } @@ -154,8 +154,9 @@ export class GraphDatabase { } } + assert(repo.queryRunner); const endTimer = eventProcessingLoadEntityDBQueryDuration.startTimer(); - const dbEntity = await this._baseDatabase.getPrevEntityVersion(repo.queryRunner!, repo, findOptions); + const dbEntity = await this._baseDatabase.getPrevEntityVersion(repo.queryRunner, repo, findOptions); endTimer(); return dbEntity; @@ -1074,7 +1075,7 @@ export class GraphDatabase { } } - async getBlocksAtHeight (height: number, isPruned: boolean) { + async getBlocksAtHeight (height: number, isPruned: boolean): Promise { const repo: Repository = this._conn.getRepository('block_progress'); return this._baseDatabase.getBlocksAtHeight(repo, height, isPruned); @@ -1105,7 +1106,7 @@ export class GraphDatabase { } } - pruneEntityCacheFrothyBlocks (canonicalBlockHash: string, canonicalBlockNumber: number) { + pruneEntityCacheFrothyBlocks (canonicalBlockHash: string, canonicalBlockNumber: number): void { const canonicalBlock = this.cachedEntities.frothyBlocks.get(canonicalBlockHash); if (canonicalBlock) { @@ -1153,7 +1154,7 @@ export class GraphDatabase { .execute(); } - async pruneEntities (frothyEntityType: new () => any, queryRunner: QueryRunner, blocks: BlockProgressInterface[], entityTypes: Set any>) { + async pruneEntities (frothyEntityType: new () => any, queryRunner: QueryRunner, blocks: BlockProgressInterface[], entityTypes: Set any>): Promise { // Assumption: all blocks are at same height assert(blocks.length); const blockNumber = blocks[0].blockNumber; @@ -1249,7 +1250,7 @@ export class GraphDatabase { ); } - _measureCachedPrunedEntities () { + _measureCachedPrunedEntities (): void { const totalEntities = Array.from(this.cachedEntities.latestPrunedEntities.values()) .reduce((acc, idEntitiesMap) => acc + idEntitiesMap.size, 0); diff --git a/packages/util/src/graph/state-utils.ts b/packages/util/src/graph/state-utils.ts index 5f69996a..cdde0dd8 100644 --- a/packages/util/src/graph/state-utils.ts +++ b/packages/util/src/graph/state-utils.ts @@ -26,7 +26,7 @@ export const prepareEntityState = (updatedEntity: any, entityName: string, relat if (result) { // Update entity data if relations exist. - const [_, relations] = result; + const [, relations] = result; // Update relation fields for diff data to be similar to GQL query entities. Object.entries(relations).forEach(([relation, { isArray, isDerived }]) => { @@ -55,7 +55,7 @@ export const prepareEntityState = (updatedEntity: any, entityName: string, relat return diffData; }; -export const updateEntitiesFromState = async (database: GraphDatabase, indexer: IndexerInterface, state: StateInterface) => { +export const updateEntitiesFromState = async (database: GraphDatabase, indexer: IndexerInterface, state: StateInterface): Promise => { const data = indexer.getStateData(state); // Get relations for subgraph entity @@ -70,7 +70,7 @@ export const updateEntitiesFromState = async (database: GraphDatabase, indexer: log(`Updating entities from State for entity ${entityName}`); console.time(`time:watcher#GraphWatcher-updateEntitiesFromState-update-entity-${entityName}`); - for (const [id, entityData] of Object.entries(entities as any)) { + for (const [, entityData] of Object.entries(entities as any)) { const dbData = database.fromState(state.block, entityName, entityData, relations); await database.saveEntity(entityName, dbData); } diff --git a/packages/util/src/graph/utils.ts b/packages/util/src/graph/utils.ts index a6051097..f8dce17b 100644 --- a/packages/util/src/graph/utils.ts +++ b/packages/util/src/graph/utils.ts @@ -534,7 +534,7 @@ export const getSubgraphConfig = async (subgraphPath: string): Promise => { return config; }; -export const toEntityValue = async (instanceExports: any, entityInstance: any, data: any, field: ColumnMetadata, type: string) => { +export const toEntityValue = async (instanceExports: any, entityInstance: any, data: any, field: ColumnMetadata, type: string): Promise => { const { __newString, Value } = instanceExports; const { isArray, propertyName, isNullable } = field; diff --git a/yarn.lock b/yarn.lock index bfc592cb..e1e010fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2322,11 +2322,6 @@ dependencies: "@octokit/openapi-types" "^7.2.3" -"@openzeppelin/contracts@^4.3.2": - version "4.3.2" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.3.2.tgz#ff80affd6d352dbe1bbc5b4e1833c41afd6283b6" - integrity sha512-AybF1cesONZStg5kWf6ao9OlqTZuPqddvprc0ky7lrUVOjXeKpmQ2Y9FK+6ygxasb+4aic4O5pneFBfwVsRRRg== - "@poanet/solidity-flattener@https://github.com/vulcanize/solidity-flattener.git": version "3.0.6" resolved "https://github.com/vulcanize/solidity-flattener.git#144ef6cda8823f4a5e48cb4f615be87a32e2dcbc"