@subql/node-ethereum 0.3.1-0 → 0.3.1-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +0 -2
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/configure/SubqueryProject.js +15 -5
  4. package/dist/configure/SubqueryProject.js.map +1 -1
  5. package/dist/configure/configure.module.js +2 -2
  6. package/dist/configure/configure.module.js.map +1 -1
  7. package/dist/ethereum/api.ethereum.d.ts +1 -0
  8. package/dist/ethereum/api.ethereum.js +28 -0
  9. package/dist/ethereum/api.ethereum.js.map +1 -1
  10. package/dist/ethereum/api.service.ethereum.d.ts +4 -0
  11. package/dist/ethereum/api.service.ethereum.js +16 -1
  12. package/dist/ethereum/api.service.ethereum.js.map +1 -1
  13. package/dist/indexer/blockDispatcher/base-block-dispatcher.d.ts +1 -1
  14. package/dist/indexer/blockDispatcher/base-block-dispatcher.js +3 -1
  15. package/dist/indexer/blockDispatcher/base-block-dispatcher.js.map +1 -1
  16. package/dist/indexer/blockDispatcher/block-dispatcher.service.d.ts +1 -1
  17. package/dist/indexer/blockDispatcher/block-dispatcher.service.js +10 -5
  18. package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -1
  19. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.d.ts +1 -1
  20. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +3 -3
  21. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -1
  22. package/dist/indexer/dictionary.service.js +7 -2
  23. package/dist/indexer/dictionary.service.js.map +1 -1
  24. package/dist/indexer/ds-processor.service.d.ts +1 -1
  25. package/dist/indexer/ds-processor.service.js +4 -0
  26. package/dist/indexer/ds-processor.service.js.map +1 -1
  27. package/dist/indexer/dynamic-ds.service.js +4 -0
  28. package/dist/indexer/dynamic-ds.service.js.map +1 -1
  29. package/dist/indexer/fetch.module.js +12 -5
  30. package/dist/indexer/fetch.module.js.map +1 -1
  31. package/dist/indexer/fetch.service.d.ts +5 -1
  32. package/dist/indexer/fetch.service.js +71 -22
  33. package/dist/indexer/fetch.service.js.map +1 -1
  34. package/dist/indexer/indexer.manager.d.ts +1 -1
  35. package/dist/indexer/indexer.manager.js +4 -0
  36. package/dist/indexer/indexer.manager.js.map +1 -1
  37. package/dist/indexer/indexer.module.js +4 -6
  38. package/dist/indexer/indexer.module.js.map +1 -1
  39. package/dist/indexer/project.service.d.ts +1 -1
  40. package/dist/indexer/project.service.js +22 -6
  41. package/dist/indexer/project.service.js.map +1 -1
  42. package/dist/indexer/sandbox.service.js +4 -0
  43. package/dist/indexer/sandbox.service.js.map +1 -1
  44. package/dist/indexer/worker/worker.js +1 -1
  45. package/dist/indexer/worker/worker.js.map +1 -1
  46. package/dist/subcommands/forceClean.service.d.ts +3 -1
  47. package/dist/subcommands/forceClean.service.js +26 -6
  48. package/dist/subcommands/forceClean.service.js.map +1 -1
  49. package/dist/subcommands/reindex.module.js.map +1 -1
  50. package/dist/subcommands/reindex.service.js +6 -1
  51. package/dist/subcommands/reindex.service.js.map +1 -1
  52. package/dist/utils/project.d.ts +1 -0
  53. package/dist/utils/project.js +5 -1
  54. package/dist/utils/project.js.map +1 -1
  55. package/dist/yargs.d.ts +1 -7
  56. package/dist/yargs.js +1 -6
  57. package/dist/yargs.js.map +1 -1
  58. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;AAEtC,iEAAiE;AACjE,kDAAkD;AAClD,wCAAwC;AACxC,oDAAqD;AACrD,wCAAwC;AACxC,uCAA2C;AAE3C,MAAM,EAAE,IAAI,EAAE,GAAG,oBAAY,CAAC;AAE9B,IAAA,mBAAU,EACR,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;AAEF,o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4D;AAC5D,KAAK,UAAU,gBAAgB;IAC7B,OAAO,aAAa,CAAC,gBAAgB,CAAC;AACxC,CAAC;AAED,4DAA4D;AAC5D,KAAK,UAAU,iBAAiB;IAC9B,OAAO,aAAa,CAAC,iBAAiB,CAAC;AACzC,CAAC;AAED,4DAA4D;AAC5D,KAAK,UAAU,SAAS;IACtB,OAAO;QACL,QAAQ,EAAR,8BAAQ;QACR,aAAa,EAAE,aAAa,CAAC,gBAAgB;QAC7C,aAAa,EAAE,aAAa,CAAC,iBAAiB;QAC9C,UAAU,EAAE,aAAa,CAAC,UAAU;KACrC,CAAC;AACJ,CAAC;AAED,wDAAwD;AACxD,IAAA,0BAAc,EAAC;IACb,UAAU;IACV,UAAU;IACV,YAAY;IACZ,gBAAgB;IAChB,iBAAiB;IACjB,SAAS;CACV,CAAC,CAAC;AAUH,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE,EAAE;IACpC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;IACtC,MAAM,CAAC,CAAC;AACV,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2021 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\n// initlogger and yargs must be imported before all other imports\n// making sure logger is defined before its called\n// eslint-disable-next-line import/order\nimport { initLogger } from '@subql/node-core/logger';\n// eslint-disable-next-line import/order\nimport { yargsOptions } from '../../yargs';\n\nconst { argv } = yargsOptions;\n\ninitLogger(\n argv.debug,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n);\n\nimport assert from 'assert';\nimport { threadId } from 'node:worker_threads';\nimport { INestApplication } from '@nestjs/common';\nimport { NestFactory } from '@nestjs/core';\nimport { registerWorker, getLogger, NestLogger } from '@subql/node-core';\nimport { IndexerManager } from '../indexer.manager';\nimport { WorkerModule } from './worker.module';\nimport {\n FetchBlockResponse,\n ProcessBlockResponse,\n WorkerService,\n WorkerStatusResponse,\n} from './worker.service';\n\nlet app: INestApplication;\nlet workerService: WorkerService;\n\nconst logger = getLogger(`worker #${threadId}`);\n\nasync function initWorker(): Promise<void> {\n try {\n if (app) {\n logger.warn('Worker already initialised');\n return;\n }\n\n app = await NestFactory.create(WorkerModule, {\n logger: new NestLogger(),\n });\n\n await app.init();\n\n const indexerManager = app.get(IndexerManager);\n // Initialise async services, we do this here rather than in factories so we can capture one off events\n await indexerManager.start();\n\n workerService = app.get(WorkerService);\n } catch (e) {\n console.log('Failed to start worker', e);\n logger.error(e, 'Failed to start worker');\n throw e;\n }\n}\n\nasync function fetchBlock(height: number): Promise<FetchBlockResponse> {\n assert(workerService, 'Not initialised');\n\n return workerService.fetchBlock(height);\n}\n\nasync function processBlock(height: number): Promise<ProcessBlockResponse> {\n assert(workerService, 'Not initialised');\n\n return workerService.processBlock(height);\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nasync function numFetchedBlocks(): Promise<number> {\n return workerService.numFetchedBlocks;\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nasync function numFetchingBlocks(): Promise<number> {\n return workerService.numFetchingBlocks;\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nasync function getStatus(): Promise<WorkerStatusResponse> {\n return {\n threadId,\n fetchedBlocks: workerService.numFetchedBlocks,\n toFetchBlocks: workerService.numFetchingBlocks,\n isIndexing: workerService.isIndexing,\n };\n}\n\n// Register these functions to be exposed to worker host\nregisterWorker({\n initWorker,\n fetchBlock,\n processBlock,\n numFetchedBlocks,\n numFetchingBlocks,\n getStatus,\n});\n\n// Export types to be used on the parent\nexport type InitWorker = typeof initWorker;\nexport type FetchBlock = typeof fetchBlock;\nexport type ProcessBlock = typeof processBlock;\nexport type NumFetchedBlocks = typeof numFetchedBlocks;\nexport type NumFetchingBlocks = typeof numFetchingBlocks;\nexport type GetWorkerStatus = typeof getStatus;\n\nprocess.on('uncaughtException', (e) => {\n logger.error(e, 'Uncaught Exception');\n throw e;\n});\n"]}
1
+ {"version":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AM,CAAC,CAAC;KACT;AACH,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,MAAc;IACtC,IAAA,gBAAM,EAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAEzC,OAAO,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,MAAc;IACxC,IAAA,gBAAM,EAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAEzC,OAAO,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC;AAED,4DAA4D;AAC5D,KAAK,UAAU,gBAAgB;IAC7B,OAAO,aAAa,CAAC,gBAAgB,CAAC;AACxC,CAAC;AAED,4DAA4D;AAC5D,KAAK,UAAU,iBAAiB;IAC9B,OAAO,aAAa,CAAC,iBAAiB,CAAC;AACzC,CAAC;AAED,4DAA4D;AAC5D,KAAK,UAAU,SAAS;IACtB,OAAO;QACL,QAAQ,EAAR,8BAAQ;QACR,aAAa,EAAE,aAAa,CAAC,gBAAgB;QAC7C,aAAa,EAAE,aAAa,CAAC,iBAAiB;QAC9C,UAAU,EAAE,aAAa,CAAC,UAAU;KACrC,CAAC;AACJ,CAAC;AAED,wDAAwD;AACxD,IAAA,0BAAc,EAAC;IACb,UAAU;IACV,UAAU;IACV,YAAY;IACZ,gBAAgB;IAChB,iBAAiB;IACjB,SAAS;CACV,CAAC,CAAC;AAUH,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE,EAAE;IACpC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;IACtC,MAAM,CAAC,CAAC;AACV,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2021 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\n// initlogger and yargs must be imported before all other imports\n// making sure logger is defined before its called\n// eslint-disable-next-line import/order\nimport { initLogger } from '@subql/node-core/logger';\n// eslint-disable-next-line import/order\nimport { yargsOptions } from '../../yargs';\n\nconst { argv } = yargsOptions;\n\ninitLogger(\n argv.debug,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n);\n\nimport assert from 'assert';\nimport { threadId } from 'node:worker_threads';\nimport { INestApplication } from '@nestjs/common';\nimport { NestFactory } from '@nestjs/core';\nimport { registerWorker, getLogger, NestLogger } from '@subql/node-core';\nimport { IndexerManager } from '../indexer.manager';\nimport { WorkerModule } from './worker.module';\nimport {\n FetchBlockResponse,\n ProcessBlockResponse,\n WorkerService,\n WorkerStatusResponse,\n} from './worker.service';\n\nlet app: INestApplication;\nlet workerService: WorkerService;\n\nconst logger = getLogger(`worker #${threadId}`);\n\nasync function initWorker(): Promise<void> {\n try {\n if (app) {\n logger.warn('Worker already initialised');\n return;\n }\n\n app = await NestFactory.create(WorkerModule, {\n logger: new NestLogger(), // TIP: If the worker is crashing comment out this line for better logging\n });\n\n await app.init();\n\n const indexerManager = app.get(IndexerManager);\n // Initialise async services, we do this here rather than in factories so we can capture one off events\n await indexerManager.start();\n\n workerService = app.get(WorkerService);\n } catch (e) {\n console.log('Failed to start worker', e);\n logger.error(e, 'Failed to start worker');\n throw e;\n }\n}\n\nasync function fetchBlock(height: number): Promise<FetchBlockResponse> {\n assert(workerService, 'Not initialised');\n\n return workerService.fetchBlock(height);\n}\n\nasync function processBlock(height: number): Promise<ProcessBlockResponse> {\n assert(workerService, 'Not initialised');\n\n return workerService.processBlock(height);\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nasync function numFetchedBlocks(): Promise<number> {\n return workerService.numFetchedBlocks;\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nasync function numFetchingBlocks(): Promise<number> {\n return workerService.numFetchingBlocks;\n}\n\n// eslint-disable-next-line @typescript-eslint/require-await\nasync function getStatus(): Promise<WorkerStatusResponse> {\n return {\n threadId,\n fetchedBlocks: workerService.numFetchedBlocks,\n toFetchBlocks: workerService.numFetchingBlocks,\n isIndexing: workerService.isIndexing,\n };\n}\n\n// Register these functions to be exposed to worker host\nregisterWorker({\n initWorker,\n fetchBlock,\n processBlock,\n numFetchedBlocks,\n numFetchingBlocks,\n getStatus,\n});\n\n// Export types to be used on the parent\nexport type InitWorker = typeof initWorker;\nexport type FetchBlock = typeof fetchBlock;\nexport type ProcessBlock = typeof processBlock;\nexport type NumFetchedBlocks = typeof numFetchedBlocks;\nexport type NumFetchingBlocks = typeof numFetchingBlocks;\nexport type GetWorkerStatus = typeof getStatus;\n\nprocess.on('uncaughtException', (e) => {\n logger.error(e, 'Uncaught Exception');\n throw e;\n});\n"]}
@@ -1,8 +1,10 @@
1
1
  import { NodeConfig } from '@subql/node-core';
2
2
  import { Sequelize } from 'sequelize';
3
+ import { SubqueryProject } from '../configure/SubqueryProject';
3
4
  export declare class ForceCleanService {
4
5
  private readonly sequelize;
5
6
  private readonly nodeConfig;
6
- constructor(sequelize: Sequelize, nodeConfig: NodeConfig);
7
+ protected project: SubqueryProject;
8
+ constructor(sequelize: Sequelize, nodeConfig: NodeConfig, project: SubqueryProject);
7
9
  forceClean(): Promise<void>;
8
10
  }
@@ -10,6 +10,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
10
10
  var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12
12
  };
13
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
14
+ return function (target, key) { decorator(target, key, paramIndex); }
15
+ };
13
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
18
  };
@@ -18,12 +21,15 @@ exports.ForceCleanService = void 0;
18
21
  const fs_1 = __importDefault(require("fs"));
19
22
  const common_1 = require("@nestjs/common");
20
23
  const node_core_1 = require("@subql/node-core");
24
+ const utils_1 = require("@subql/utils");
21
25
  const sequelize_1 = require("sequelize");
26
+ const SubqueryProject_1 = require("../configure/SubqueryProject");
22
27
  const logger = (0, node_core_1.getLogger)('Force-clean');
23
28
  let ForceCleanService = class ForceCleanService {
24
- constructor(sequelize, nodeConfig) {
29
+ constructor(sequelize, nodeConfig, project) {
25
30
  this.sequelize = sequelize;
26
31
  this.nodeConfig = nodeConfig;
32
+ this.project = project;
27
33
  }
28
34
  async forceClean() {
29
35
  const schema = await (0, node_core_1.getExistingProjectSchema)(this.nodeConfig, this.sequelize);
@@ -31,19 +37,31 @@ let ForceCleanService = class ForceCleanService {
31
37
  logger.error('Unable to locate schema');
32
38
  throw new Error('Schema does not exist.');
33
39
  }
40
+ const modelsRelation = (0, utils_1.getAllEntitiesRelations)(this.project.schema);
34
41
  try {
35
42
  // drop existing project schema and metadata table
36
43
  await this.sequelize.dropSchema(`"${schema}"`, {
37
44
  logging: false,
38
45
  benchmark: false,
39
46
  });
47
+ // drop all related enums
48
+ await Promise.all(modelsRelation.enums.map(async (e) => {
49
+ const enumTypeName = `${schema}_enum_${(0, node_core_1.enumNameToHash)(e.name)}`;
50
+ await this.sequelize.query(`
51
+ DROP TYPE "${enumTypeName}";
52
+ `);
53
+ }));
40
54
  // remove schema from subquery table (might not exist)
41
- await this.sequelize.query(` DELETE
55
+ const checker = await this.sequelize.query(`
56
+ SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'public' AND TABLE_NAME = 'subqueries'`);
57
+ if (checker[1].rowCount > 0) {
58
+ await this.sequelize.query(` DELETE
42
59
  FROM public.subqueries
43
60
  WHERE name = :name`, {
44
- replacements: { name: this.nodeConfig.subqueryName },
45
- type: sequelize_1.QueryTypes.DELETE,
46
- });
61
+ replacements: { name: this.nodeConfig.subqueryName },
62
+ type: sequelize_1.QueryTypes.DELETE,
63
+ });
64
+ }
47
65
  logger.info('force cleaned schema and tables');
48
66
  if (fs_1.default.existsSync(this.nodeConfig.mmrPath)) {
49
67
  await fs_1.default.promises.unlink(this.nodeConfig.mmrPath);
@@ -58,8 +76,10 @@ let ForceCleanService = class ForceCleanService {
58
76
  };
59
77
  ForceCleanService = __decorate([
60
78
  (0, common_1.Injectable)(),
79
+ __param(2, (0, common_1.Inject)('ISubqueryProject')),
61
80
  __metadata("design:paramtypes", [sequelize_1.Sequelize,
62
- node_core_1.NodeConfig])
81
+ node_core_1.NodeConfig,
82
+ SubqueryProject_1.SubqueryProject])
63
83
  ], ForceCleanService);
64
84
  exports.ForceCleanService = ForceCleanService;
65
85
  //# sourceMappingURL=forceClean.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"forceClean.service.js","sourceRoot":"","sources":["../../src/subcommands/forceClean.service.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;AAEtC,4CAAoB;AACpB,2CAA4C;AAC5C,gDAI0B;AAC1B,yCAAkD;AAElD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,aAAa,CAAC,CAAC;AAGjC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YACmB,SAAoB,EACpB,UAAsB;QADtB,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAY;IACtC,CAAC;IAEJ,KAAK,CAAC,UAAU;QACd,MAAM,MAAM,GAAG,MAAM,IAAA,oCAAwB,EAC3C,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,CACf,CAAC;QACF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QAED,IAAI;YACF,kDAAkD;YAClD,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,MAAM,GAAG,EAAE;gBAC7C,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,KAAK;aACjB,CAAC,CAAC;YAEH,sDAAsD;YACtD,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CACxB;;qCAE6B,EAC7B;gBACE,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE;gBACpD,IAAI,EAAE,sBAAU,CAAC,MAAM;aACxB,CACF,CAAC;YAEF,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;YAE/C,IAAI,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;gBAC1C,MAAM,YAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAClD,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;aAC7C;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC;YAC3C,MAAM,GAAG,CAAC;SACX;IACH,CAAC;CACF,CAAA;AA7CY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAGmB,qBAAS;QACR,sBAAU;GAH9B,iBAAiB,CA6C7B;AA7CY,8CAAiB","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport fs from 'fs';\nimport { Injectable } from '@nestjs/common';\nimport {\n getLogger,\n NodeConfig,\n getExistingProjectSchema,\n} from '@subql/node-core';\nimport { QueryTypes, Sequelize } from 'sequelize';\n\nconst logger = getLogger('Force-clean');\n\n@Injectable()\nexport class ForceCleanService {\n constructor(\n private readonly sequelize: Sequelize,\n private readonly nodeConfig: NodeConfig,\n ) {}\n\n async forceClean(): Promise<void> {\n const schema = await getExistingProjectSchema(\n this.nodeConfig,\n this.sequelize,\n );\n if (!schema) {\n logger.error('Unable to locate schema');\n throw new Error('Schema does not exist.');\n }\n\n try {\n // drop existing project schema and metadata table\n await this.sequelize.dropSchema(`\"${schema}\"`, {\n logging: false,\n benchmark: false,\n });\n\n // remove schema from subquery table (might not exist)\n await this.sequelize.query(\n ` DELETE\n FROM public.subqueries\n WHERE name = :name`,\n {\n replacements: { name: this.nodeConfig.subqueryName },\n type: QueryTypes.DELETE,\n },\n );\n\n logger.info('force cleaned schema and tables');\n\n if (fs.existsSync(this.nodeConfig.mmrPath)) {\n await fs.promises.unlink(this.nodeConfig.mmrPath);\n logger.info('force cleaned file based mmr');\n }\n } catch (err) {\n logger.error(err, 'failed to force clean');\n throw err;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"forceClean.service.js","sourceRoot":"","sources":["../../src/subcommands/forceClean.service.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;;;;AAEtC,4CAAoB;AACpB,2CAAoD;AACpD,gDAK0B;AAC1B,wCAAuD;AACvD,yCAAkD;AAClD,kEAA+D;AAE/D,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,aAAa,CAAC,CAAC;AAGjC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YACmB,SAAoB,EACpB,UAAsB,EACD,OAAwB;QAF7C,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAY;QACD,YAAO,GAAP,OAAO,CAAiB;IAC7D,CAAC;IAEJ,KAAK,CAAC,UAAU;QACd,MAAM,MAAM,GAAG,MAAM,IAAA,oCAAwB,EAC3C,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,CACf,CAAC;QACF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QACD,MAAM,cAAc,GAAG,IAAA,+BAAuB,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEpE,IAAI;YACF,kDAAkD;YAClD,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,MAAM,GAAG,EAAE;gBAC7C,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,KAAK;aACjB,CAAC,CAAC;YAEH,yBAA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iCAAe;GAJrD,iBAAiB,CAgE7B;AAhEY,8CAAiB","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport fs from 'fs';\nimport { Inject, Injectable } from '@nestjs/common';\nimport {\n getLogger,\n NodeConfig,\n getExistingProjectSchema,\n enumNameToHash,\n} from '@subql/node-core';\nimport { getAllEntitiesRelations } from '@subql/utils';\nimport { QueryTypes, Sequelize } from 'sequelize';\nimport { SubqueryProject } from '../configure/SubqueryProject';\n\nconst logger = getLogger('Force-clean');\n\n@Injectable()\nexport class ForceCleanService {\n constructor(\n private readonly sequelize: Sequelize,\n private readonly nodeConfig: NodeConfig,\n @Inject('ISubqueryProject') protected project: SubqueryProject,\n ) {}\n\n async forceClean(): Promise<void> {\n const schema = await getExistingProjectSchema(\n this.nodeConfig,\n this.sequelize,\n );\n if (!schema) {\n logger.error('Unable to locate schema');\n throw new Error('Schema does not exist.');\n }\n const modelsRelation = getAllEntitiesRelations(this.project.schema);\n\n try {\n // drop existing project schema and metadata table\n await this.sequelize.dropSchema(`\"${schema}\"`, {\n logging: false,\n benchmark: false,\n });\n\n // drop all related enums\n await Promise.all(\n modelsRelation.enums.map(async (e) => {\n const enumTypeName = `${schema}_enum_${enumNameToHash(e.name)}`;\n await this.sequelize.query(`\n DROP TYPE \"${enumTypeName}\";\n `);\n }),\n );\n\n // remove schema from subquery table (might not exist)\n const checker = await this.sequelize.query(\n `\n SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'public' AND TABLE_NAME = 'subqueries'`,\n );\n\n if ((checker[1] as any).rowCount > 0) {\n await this.sequelize.query(\n ` DELETE\n FROM public.subqueries\n WHERE name = :name`,\n {\n replacements: { name: this.nodeConfig.subqueryName },\n type: QueryTypes.DELETE,\n },\n );\n }\n\n logger.info('force cleaned schema and tables');\n\n if (fs.existsSync(this.nodeConfig.mmrPath)) {\n await fs.promises.unlink(this.nodeConfig.mmrPath);\n logger.info('force cleaned file based mmr');\n }\n } catch (err) {\n logger.error(err, 'failed to force clean');\n throw err;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reindex.module.js","sourceRoot":"","sources":["../../src/subcommands/reindex.module.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;AAEtC,2CAAwC;AACxC,gDAAsE;AACtE,oEAAgE;AAChE,0EAAqE;AACrE,sEAAiE;AACjE,6DAAyD;AACzD,uDAAmD;AAa5C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IAXhC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,wBAAY;YACZ,gCAAc;YACd,sBAAU;YACV,sCAAiB;YACjB,qCAAgB;YAChB,yCAAkB;SACnB;QACD,WAAW,EAAE,EAAE;KAChB,CAAC;GACW,oBAAoB,CAAG;AAAvB,oDAAoB;AAU1B,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,aAAa;IARzB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,oBAAQ,CAAC,OAAO,EAAE;YAClB,kCAAe,CAAC,QAAQ,EAAE;YAC1B,oBAAoB;SACrB;QACD,WAAW,EAAE,EAAE;KAChB,CAAC;GACW,aAAa,CAAG;AAAhB,sCAAa","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Module } from '@nestjs/common';\nimport { DbModule, MmrService, StoreService } from '@subql/node-core';\nimport { ConfigureModule } from '../configure/configure.module';\nimport { DsProcessorService } from '../indexer/ds-processor.service';\nimport { DynamicDsService } from '../indexer/dynamic-ds.service';\nimport { ForceCleanService } from './forceClean.service';\nimport { ReindexService } from './reindex.service';\n\n@Module({\n providers: [\n StoreService,\n ReindexService,\n MmrService,\n ForceCleanService,\n DynamicDsService,\n DsProcessorService,\n ],\n controllers: [],\n})\nexport class ReindexFeatureModule {}\n\n@Module({\n imports: [\n DbModule.forRoot(),\n ConfigureModule.register(),\n ReindexFeatureModule,\n ],\n controllers: [],\n})\nexport class ReindexModule {}\n"]}
1
+ {"version":3,"file":"reindex.module.js","sourceRoot":"","sources":["../../src/subcommands/reindex.module.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;AAEtC,2CAAwC;AACxC,gDAK0B;AAC1B,oEAAgE;AAChE,0EAAqE;AACrE,sEAAiE;AACjE,6DAAyD;AACzD,uDAAmD;AAa5C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IAXhC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,wBAAY;YACZ,gCAAc;YACd,sBAAU;YACV,sCAAiB;YACjB,qCAAgB;YAChB,yCAAkB;SACnB;QACD,WAAW,EAAE,EAAE;KAChB,CAAC;GACW,oBAAoB,CAAG;AAAvB,oDAAoB;AAU1B,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,aAAa;IARzB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,oBAAQ,CAAC,OAAO,EAAE;YAClB,kCAAe,CAAC,QAAQ,EAAE;YAC1B,oBAAoB;SACrB;QACD,WAAW,EAAE,EAAE;KAChB,CAAC;GACW,aAAa,CAAG;AAAhB,sCAAa","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Module } from '@nestjs/common';\nimport {\n DbModule,\n MmrService,\n NodeConfig,\n StoreService,\n} from '@subql/node-core';\nimport { ConfigureModule } from '../configure/configure.module';\nimport { DsProcessorService } from '../indexer/ds-processor.service';\nimport { DynamicDsService } from '../indexer/dynamic-ds.service';\nimport { ForceCleanService } from './forceClean.service';\nimport { ReindexService } from './reindex.service';\n\n@Module({\n providers: [\n StoreService,\n ReindexService,\n MmrService,\n ForceCleanService,\n DynamicDsService,\n DsProcessorService,\n ],\n controllers: [],\n})\nexport class ReindexFeatureModule {}\n\n@Module({\n imports: [\n DbModule.forRoot(),\n ConfigureModule.register(),\n ReindexFeatureModule,\n ],\n controllers: [],\n})\nexport class ReindexModule {}\n"]}
@@ -10,6 +10,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
10
10
  var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12
12
  };
13
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
14
+ return function (target, key) { decorator(target, key, paramIndex); }
15
+ };
13
16
  Object.defineProperty(exports, "__esModule", { value: true });
14
17
  exports.ReindexService = void 0;
15
18
  const common_1 = require("@nestjs/common");
@@ -38,7 +41,8 @@ let ReindexService = class ReindexService {
38
41
  throw new Error('Schema does not exist.');
39
42
  }
40
43
  await this.initDbSchema();
41
- this.metadataRepo = (0, node_core_1.MetadataFactory)(this.sequelize, this.schema);
44
+ // Should we use an optional arg for multiChain?
45
+ this.metadataRepo = await (0, node_core_1.MetadataFactory)(this.sequelize, this.schema, this.nodeConfig.multiChain, this.project.network.chainId);
42
46
  this.dynamicDsService.init(this.metadataRepo);
43
47
  }
44
48
  async getExistingProjectSchema() {
@@ -81,6 +85,7 @@ let ReindexService = class ReindexService {
81
85
  };
82
86
  ReindexService = __decorate([
83
87
  (0, common_1.Injectable)(),
88
+ __param(4, (0, common_1.Inject)('ISubqueryProject')),
84
89
  __metadata("design:paramtypes", [sequelize_1.Sequelize,
85
90
  node_core_1.NodeConfig,
86
91
  node_core_1.StoreService,
@@ -1 +1 @@
1
- {"version":3,"file":"reindex.service.js","sourceRoot":"","sources":["../../src/subcommands/reindex.service.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;AAEtC,2CAA4C;AAC5C,gDAS0B;AAC1B,yCAAsC;AACtC,kEAA+D;AAC/D,sEAAiE;AACjE,8CAAgD;AAChD,8CAA2C;AAE3C,6DAAyD;A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Y,EACjB,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,iBAAiB,CACvB,CAAC;IACJ,CAAC;CACF,CAAA;AAlFY,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAMmB,qBAAS;QACR,sBAAU;QACR,wBAAY;QACd,sBAAU;QACb,iCAAe;QACL,sCAAiB;QAClB,qCAAgB;GAX1C,cAAc,CAkF1B;AAlFY,wCAAc","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Injectable } from '@nestjs/common';\nimport {\n getLogger,\n MetadataFactory,\n MetadataRepo,\n MmrService,\n NodeConfig,\n StoreService,\n getExistingProjectSchema,\n getMetaDataInfo,\n} from '@subql/node-core';\nimport { Sequelize } from 'sequelize';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { DynamicDsService } from '../indexer/dynamic-ds.service';\nimport { initDbSchema } from '../utils/project';\nimport { reindex } from '../utils/reindex';\n\nimport { ForceCleanService } from './forceClean.service';\n\nconst logger = getLogger('Reindex');\n\n@Injectable()\nexport class ReindexService {\n private schema: string;\n private metadataRepo: MetadataRepo;\n\n constructor(\n private readonly sequelize: Sequelize,\n private readonly nodeConfig: NodeConfig,\n private readonly storeService: StoreService,\n private readonly mmrService: MmrService,\n private readonly project: SubqueryProject,\n private readonly forceCleanService: ForceCleanService,\n private readonly dynamicDsService: DynamicDsService,\n ) {}\n\n async init(): Promise<void> {\n this.schema = await this.getExistingProjectSchema();\n\n if (!this.schema) {\n logger.error('Unable to locate schema');\n throw new Error('Schema does not exist.');\n }\n await this.initDbSchema();\n this.metadataRepo = MetadataFactory(this.sequelize, this.schema);\n this.dynamicDsService.init(this.metadataRepo);\n }\n\n private async getExistingProjectSchema(): Promise<string> {\n return getExistingProjectSchema(this.nodeConfig, this.sequelize);\n }\n\n private async getLastProcessedHeight(): Promise<number | undefined> {\n return getMetaDataInfo(this.metadataRepo, 'lastProcessedHeight');\n }\n\n private async getMetadataBlockOffset(): Promise<number | undefined> {\n return getMetaDataInfo(this.metadataRepo, 'blockOffset');\n }\n\n private async getMetadataSpecName(): Promise<string | undefined> {\n const res = await this.metadataRepo.findOne({\n where: { key: 'specName' },\n });\n return res?.value as string | undefined;\n }\n\n private async initDbSchema(): Promise<void> {\n await initDbSchema(this.project, this.schema, this.storeService);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n private async getStartBlockFromDataSources() {\n const datasources = this.project.dataSources;\n\n const startBlocksList = datasources.map((item) => item.startBlock ?? 1);\n if (startBlocksList.length === 0) {\n logger.error(\n `Failed to find a valid datasource, Please check your endpoint if specName filter is used.`,\n );\n process.exit(1);\n } else {\n return Math.min(...startBlocksList);\n }\n }\n\n async reindex(targetBlockHeight: number): Promise<void> {\n const [startHeight, lastProcessedHeight] = await Promise.all([\n this.getStartBlockFromDataSources(),\n this.getLastProcessedHeight(),\n ]);\n\n return reindex(\n startHeight,\n await this.getMetadataBlockOffset(),\n targetBlockHeight,\n lastProcessedHeight,\n this.storeService,\n this.dynamicDsService,\n this.mmrService,\n this.sequelize,\n this.forceCleanService,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"reindex.service.js","sourceRoot":"","sources":["../../src/subcommands/reindex.service.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;AAEtC,2CAAoD;AACpD,gDAS0B;AAC1B,yCAAsC;AACtC,kEAA+D;AAC/D,sEAAiE;AACjE,8CAAgD;AAChD,8CAA2C;AAE3C,6DAAyD;AAEzD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,SAAS,CAAC,CAAC;AAG7B,IAAM,cAAc,GAApB,MAAM,cAAc;IAIzB,YACmB,SAAoB,EACpB,UAAsB,EACtB,YAA0B,EAC1B,UAAsB,EACM,OAAwB,EACpD,iBAAoC,EACpC,gBAAkC;QANlC,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU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Y,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAUR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAJC,qBAAS;QACR,sBAAU;QACR,wBAAY;QACd,sBAAU;QACe,iCAAe;QACjC,sCAAiB;QAClB,qCAAgB;GAX1C,cAAc,CAwF1B;AAxFY,wCAAc","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport {\n getLogger,\n MetadataFactory,\n MetadataRepo,\n MmrService,\n NodeConfig,\n StoreService,\n getExistingProjectSchema,\n getMetaDataInfo,\n} from '@subql/node-core';\nimport { Sequelize } from 'sequelize';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { DynamicDsService } from '../indexer/dynamic-ds.service';\nimport { initDbSchema } from '../utils/project';\nimport { reindex } from '../utils/reindex';\n\nimport { ForceCleanService } from './forceClean.service';\n\nconst logger = getLogger('Reindex');\n\n@Injectable()\nexport class ReindexService {\n private schema: string;\n private metadataRepo: MetadataRepo;\n\n constructor(\n private readonly sequelize: Sequelize,\n private readonly nodeConfig: NodeConfig,\n private readonly storeService: StoreService,\n private readonly mmrService: MmrService,\n @Inject('ISubqueryProject') private readonly project: SubqueryProject,\n private readonly forceCleanService: ForceCleanService,\n private readonly dynamicDsService: DynamicDsService,\n ) {}\n\n async init(): Promise<void> {\n this.schema = await this.getExistingProjectSchema();\n\n if (!this.schema) {\n logger.error('Unable to locate schema');\n throw new Error('Schema does not exist.');\n }\n await this.initDbSchema();\n // Should we use an optional arg for multiChain?\n this.metadataRepo = await MetadataFactory(\n this.sequelize,\n this.schema,\n this.nodeConfig.multiChain,\n this.project.network.chainId,\n );\n this.dynamicDsService.init(this.metadataRepo);\n }\n\n private async getExistingProjectSchema(): Promise<string> {\n return getExistingProjectSchema(this.nodeConfig, this.sequelize);\n }\n\n private async getLastProcessedHeight(): Promise<number | undefined> {\n return getMetaDataInfo(this.metadataRepo, 'lastProcessedHeight');\n }\n\n private async getMetadataBlockOffset(): Promise<number | undefined> {\n return getMetaDataInfo(this.metadataRepo, 'blockOffset');\n }\n\n private async getMetadataSpecName(): Promise<string | undefined> {\n const res = await this.metadataRepo.findOne({\n where: { key: 'specName' },\n });\n return res?.value as string | undefined;\n }\n\n private async initDbSchema(): Promise<void> {\n await initDbSchema(this.project, this.schema, this.storeService);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n private async getStartBlockFromDataSources() {\n const datasources = this.project.dataSources;\n\n const startBlocksList = datasources.map((item) => item.startBlock ?? 1);\n if (startBlocksList.length === 0) {\n logger.error(\n `Failed to find a valid datasource, Please check your endpoint if specName filter is used.`,\n );\n process.exit(1);\n } else {\n return Math.min(...startBlocksList);\n }\n }\n\n async reindex(targetBlockHeight: number): Promise<void> {\n const [startHeight, lastProcessedHeight] = await Promise.all([\n this.getStartBlockFromDataSources(),\n this.getLastProcessedHeight(),\n ]);\n\n return reindex(\n startHeight,\n await this.getMetadataBlockOffset(),\n targetBlockHeight,\n lastProcessedHeight,\n this.storeService,\n this.dynamicDsService,\n this.mmrService,\n this.sequelize,\n this.forceCleanService,\n );\n }\n}\n"]}
@@ -11,4 +11,5 @@ export declare function getChainTypes(reader: Reader, root: string, file: string
11
11
  export declare function loadDataSourceScript(reader: Reader, file?: string): Promise<string>;
12
12
  export declare function getProjectRoot(reader: Reader): Promise<string>;
13
13
  export declare function initDbSchema(project: SubqueryProject, schema: string, storeService: StoreService): Promise<void>;
14
+ export declare function initHotSchemaReload(schema: string, storeService: StoreService): Promise<void>;
14
15
  export declare function retryOnFailEth<T>(request: () => Promise<T>, errors?: string[]): Promise<T>;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.retryOnFailEth = exports.initDbSchema = exports.getProjectRoot = exports.loadDataSourceScript = exports.getChainTypes = exports.updateDataSourcesV0_2_0 = exports.isCustomHandler = exports.isBaseHandler = exports.getProjectEntry = exports.prepareProjectDir = void 0;
8
+ exports.retryOnFailEth = exports.initHotSchemaReload = exports.initDbSchema = exports.getProjectRoot = exports.loadDataSourceScript = exports.getChainTypes = exports.updateDataSourcesV0_2_0 = exports.isCustomHandler = exports.isBaseHandler = exports.getProjectEntry = exports.prepareProjectDir = void 0;
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const os_1 = __importDefault(require("os"));
11
11
  const path_1 = __importDefault(require("path"));
@@ -210,6 +210,10 @@ async function initDbSchema(project, schema, storeService) {
210
210
  await storeService.init(modelsRelation, schema);
211
211
  }
212
212
  exports.initDbSchema = initDbSchema;
213
+ async function initHotSchemaReload(schema, storeService) {
214
+ await storeService.initHotSchemaReloadQueries(schema);
215
+ }
216
+ exports.initHotSchemaReload = initHotSchemaReload;
213
217
  const handledErrors = ['timeout'];
214
218
  // eslint-disable-next-line @typescript-eslint/require-await
215
219
  async function retryOnFailEth(request, errors = handledErrors) {
@@ -1 +1 @@
1
- {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;AAEtC,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,0CAA8E;AAC9E,4DAagC;AAChC,gDAA6D;AAC7D,wCAAuD;AACvD,sDAA2B;AAC3B,8CAAsB;AAGf,KAAK,UAAU,iBAAiB,CAAC,WAAmB;IACzD,MAAM,KAAK,GAAG,YAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACvC,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;QAClB,MAAM,GAAG,GAAG,cAAI,CAAC,GAAG,CAAC;QACrB,MAAM,MAAM,GAAG,YAAE,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,YAAE,CAAC,WAAW,CAAC,GAAG,MAAM,GAAG,GAAG,EAA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MAAM,CAAC,CAAC;AAClD,CAAC;AAPD,oCAOC;AAED,MAAM,aAAa,GAAG,CAAC,SAAS,CAAC,CAAC;AAClC,4DAA4D;AACrD,KAAK,UAAU,cAAc,CAClC,OAAyB,EACzB,MAAM,GAAG,aAAa;IAEtB,OAAO,IAAA,uBAAW,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,MAAM,CAAA,CAAC,CAAC,CAAC;AAC5E,CAAC;AALD,wCAKC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport { GithubReader, IPFSReader, LocalReader, Reader } from '@subql/common';\nimport {\n ChainTypes,\n CustomDatasourceV0_2_0,\n isCustomDs,\n loadChainTypes,\n loadChainTypesFromJs,\n parseChainTypes,\n RuntimeDataSourceV0_2_0,\n SubqlRuntimeHandler,\n SubqlCustomHandler,\n SubqlHandler,\n EthereumHandlerKind,\n EthereumDatasourceKind,\n} from '@subql/common-ethereum';\nimport { retryOnFail, StoreService } from '@subql/node-core';\nimport { getAllEntitiesRelations } from '@subql/utils';\nimport yaml from 'js-yaml';\nimport tar from 'tar';\nimport { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject';\n\nexport async function prepareProjectDir(projectPath: string): Promise<string> {\n const stats = fs.statSync(projectPath);\n if (stats.isFile()) {\n const sep = path.sep;\n const tmpDir = os.tmpdir();\n const tempPath = fs.mkdtempSync(`${tmpDir}${sep}`);\n // Will promote errors if incorrect format/extension\n await tar.x({ file: projectPath, cwd: tempPath });\n return tempPath.concat('/package');\n } else if (stats.isDirectory()) {\n return projectPath;\n }\n}\n\n// We cache this to avoid repeated reads from fs\nconst projectEntryCache: Record<string, string> = {};\n\nexport function getProjectEntry(root: string): string {\n const pkgPath = path.join(root, 'package.json');\n try {\n if (!projectEntryCache[pkgPath]) {\n const content = fs.readFileSync(pkgPath).toString();\n const pkg = JSON.parse(content);\n if (!pkg.main) {\n return './dist';\n }\n projectEntryCache[pkgPath] = pkg.main.startsWith('./')\n ? pkg.main\n : `./${pkg.main}`;\n }\n\n return projectEntryCache[pkgPath];\n } catch (err) {\n throw new Error(`can not find package.json within directory ${root}`);\n }\n}\n\nexport function isBaseHandler(\n handler: SubqlHandler,\n): handler is SubqlRuntimeHandler {\n return Object.values<string>(EthereumHandlerKind).includes(handler.kind);\n}\n\nexport function isCustomHandler(\n handler: SubqlHandler,\n): handler is SubqlCustomHandler {\n return !isBaseHandler(handler);\n}\n\nexport async function updateDataSourcesV0_2_0(\n _dataSources: (RuntimeDataSourceV0_2_0 | CustomDatasourceV0_2_0)[],\n reader: Reader,\n root: string,\n): Promise<SubqlProjectDs[]> {\n // force convert to updated ds\n return Promise.all(\n _dataSources.map(async (dataSource) => {\n if (dataSource.kind === 'flare/Runtime') {\n dataSource.kind = EthereumDatasourceKind.Runtime;\n }\n dataSource.mapping.handlers = dataSource.mapping.handlers.map(\n (handler) => {\n switch (handler.kind) {\n case 'flare/BlockHandler': {\n handler.kind = EthereumHandlerKind.Block;\n break;\n }\n case 'flare/TransactionHandler': {\n handler.kind = EthereumHandlerKind.Call;\n break;\n }\n case 'flare/LogHandler': {\n handler.kind = EthereumHandlerKind.Event;\n break;\n }\n default:\n }\n\n return handler;\n },\n );\n\n const entryScript = await loadDataSourceScript(\n reader,\n dataSource.mapping.file,\n );\n const file = await updateDataSourcesEntry(\n reader,\n dataSource.mapping.file,\n root,\n entryScript,\n );\n if (dataSource.assets) {\n for (const [, asset] of Object.entries(dataSource.assets)) {\n if (reader instanceof LocalReader) {\n asset.file = path.resolve(root, asset.file);\n } else {\n const res = await reader.getFile(asset.file);\n const outputPath = path.resolve(\n root,\n asset.file.replace('ipfs://', ''),\n );\n await fs.promises.writeFile(outputPath, res as string);\n asset.file = outputPath;\n }\n }\n }\n if (isCustomDs(dataSource)) {\n if (dataSource.processor) {\n dataSource.processor.file = await updateProcessor(\n reader,\n root,\n dataSource.processor.file,\n );\n }\n if (dataSource.assets) {\n for (const [, asset] of dataSource.assets) {\n if (reader instanceof LocalReader) {\n asset.file = path.resolve(root, asset.file);\n } else {\n const res = await reader.getFile(asset.file);\n const outputPath = path.resolve(\n root,\n asset.file.replace('ipfs://', ''),\n );\n await fs.promises.writeFile(outputPath, res as string);\n asset.file = outputPath;\n }\n }\n }\n return {\n ...dataSource,\n mapping: { ...dataSource.mapping, entryScript, file },\n };\n } else {\n return {\n ...dataSource,\n mapping: { ...dataSource.mapping, entryScript, file },\n };\n }\n }),\n );\n}\n\nasync function updateDataSourcesEntry(\n reader: Reader,\n file: string,\n root: string,\n script: string,\n): Promise<string> {\n if (reader instanceof LocalReader) return file;\n else if (reader instanceof IPFSReader || reader instanceof GithubReader) {\n const outputPath = `${path.resolve(root, file.replace('ipfs://', ''))}.js`;\n await fs.promises.writeFile(outputPath, script);\n return outputPath;\n }\n}\n\nasync function updateProcessor(\n reader: Reader,\n root: string,\n file: string,\n): Promise<string> {\n if (reader instanceof LocalReader) {\n return path.resolve(root, file);\n } else {\n const res = await reader.getFile(file);\n const outputPath = `${path.resolve(root, file.replace('ipfs://', ''))}.js`;\n await fs.promises.writeFile(outputPath, res);\n return outputPath;\n }\n}\n\nexport async function getChainTypes(\n reader: Reader,\n root: string,\n file: string,\n): Promise<ChainTypes> {\n // If the project is load from local, we will direct load them\n if (reader instanceof LocalReader) {\n return loadChainTypes(file, root);\n } else {\n // If it is stored in ipfs or other resources, we will use the corresponding reader to read the file\n // Because ipfs not provide extension of the file, it is difficult to determine its format\n // We will use yaml.load to try to load the script and parse them to supported chain types\n // if it failed, we will give it another another attempt, and assume the script written in js\n // we will download it to a temp folder, and load them within sandbox\n const res = await reader.getFile(file);\n let raw: unknown;\n try {\n raw = yaml.load(res);\n return parseChainTypes(raw);\n } catch (e) {\n const chainTypesPath = `${path.resolve(\n root,\n file.replace('ipfs://', ''),\n )}.js`;\n await fs.promises.writeFile(chainTypesPath, res);\n raw = loadChainTypesFromJs(chainTypesPath); //root not required, as it been packed in single js\n return parseChainTypes(raw);\n }\n }\n}\n\nexport async function loadDataSourceScript(\n reader: Reader,\n file?: string,\n): Promise<string> {\n let entry: string;\n //For RuntimeDataSourceV0_0_1\n if (!file) {\n const pkg = await reader.getPkg();\n if (pkg === undefined) throw new Error('Project package.json is not found');\n if (pkg.main) {\n entry = pkg.main.startsWith('./') ? pkg.main : `./${pkg.main}`;\n } else {\n entry = './dist';\n }\n }\n //Else get file\n const entryScript = await reader.getFile(file ? file : entry);\n if (entryScript === undefined) {\n throw new Error(`Entry file ${entry} for datasource not exist`);\n }\n return entryScript;\n}\n\nasync function makeTempDir(): Promise<string> {\n const sep = path.sep;\n const tmpDir = os.tmpdir();\n return fs.promises.mkdtemp(`${tmpDir}${sep}`);\n}\n\nexport async function getProjectRoot(reader: Reader): Promise<string> {\n if (reader instanceof LocalReader) return reader.root;\n if (reader instanceof IPFSReader || reader instanceof GithubReader) {\n return makeTempDir();\n }\n}\n\nexport async function initDbSchema(\n project: SubqueryProject,\n schema: string,\n storeService: StoreService,\n): Promise<void> {\n const modelsRelation = getAllEntitiesRelations(project.schema);\n await storeService.init(modelsRelation, schema);\n}\n\nconst handledErrors = ['timeout'];\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function retryOnFailEth<T>(\n request: () => Promise<T>,\n errors = handledErrors,\n): Promise<T> {\n return retryOnFail(request, (e) => !!errors.find((t) => t === e?.reason));\n}\n"]}
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;AAEtC,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,0CAA8E;AAC9E,4DAagC;AAChC,gDAA6D;AAC7D,wCAAuD;AACvD,sDAA2B;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;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IACtD,IAAI,MAAM,YAAY,mBAAU,IAAI,MAAM,YAAY,qBAAY,EAAE;QAClE,OAAO,WAAW,EAAE,CAAC;KACtB;AACH,CAAC;AALD,wCAKC;AAEM,KAAK,UAAU,YAAY,CAChC,OAAwB,EACxB,MAAc,EACd,YAA0B;IAE1B,MAAM,cAAc,GAAG,IAAA,+BAAuB,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D,MAAM,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AAPD,oCAOC;AAEM,KAAK,UAAU,mBAAmB,CACvC,MAAc,EACd,YAA0B;IAE1B,MAAM,YAAY,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC;AALD,kDAKC;AAED,MAAM,aAAa,GAAG,CAAC,SAAS,CAAC,CAAC;AAClC,4DAA4D;AACrD,KAAK,UAAU,cAAc,CAClC,OAAyB,EACzB,MAAM,GAAG,aAAa;IAEtB,OAAO,IAAA,uBAAW,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,MAAM,CAAA,CAAC,CAAC,CAAC;AAC5E,CAAC;AALD,wCAKC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport { GithubReader, IPFSReader, LocalReader, Reader } from '@subql/common';\nimport {\n ChainTypes,\n CustomDatasourceV0_2_0,\n isCustomDs,\n loadChainTypes,\n loadChainTypesFromJs,\n parseChainTypes,\n RuntimeDataSourceV0_2_0,\n SubqlRuntimeHandler,\n SubqlCustomHandler,\n SubqlHandler,\n EthereumHandlerKind,\n EthereumDatasourceKind,\n} from '@subql/common-ethereum';\nimport { retryOnFail, StoreService } from '@subql/node-core';\nimport { getAllEntitiesRelations } from '@subql/utils';\nimport yaml from 'js-yaml';\nimport tar from 'tar';\nimport { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject';\n\nexport async function prepareProjectDir(projectPath: string): Promise<string> {\n const stats = fs.statSync(projectPath);\n if (stats.isFile()) {\n const sep = path.sep;\n const tmpDir = os.tmpdir();\n const tempPath = fs.mkdtempSync(`${tmpDir}${sep}`);\n // Will promote errors if incorrect format/extension\n await tar.x({ file: projectPath, cwd: tempPath });\n return tempPath.concat('/package');\n } else if (stats.isDirectory()) {\n return projectPath;\n }\n}\n\n// We cache this to avoid repeated reads from fs\nconst projectEntryCache: Record<string, string> = {};\n\nexport function getProjectEntry(root: string): string {\n const pkgPath = path.join(root, 'package.json');\n try {\n if (!projectEntryCache[pkgPath]) {\n const content = fs.readFileSync(pkgPath).toString();\n const pkg = JSON.parse(content);\n if (!pkg.main) {\n return './dist';\n }\n projectEntryCache[pkgPath] = pkg.main.startsWith('./')\n ? pkg.main\n : `./${pkg.main}`;\n }\n\n return projectEntryCache[pkgPath];\n } catch (err) {\n throw new Error(`can not find package.json within directory ${root}`);\n }\n}\n\nexport function isBaseHandler(\n handler: SubqlHandler,\n): handler is SubqlRuntimeHandler {\n return Object.values<string>(EthereumHandlerKind).includes(handler.kind);\n}\n\nexport function isCustomHandler(\n handler: SubqlHandler,\n): handler is SubqlCustomHandler {\n return !isBaseHandler(handler);\n}\n\nexport async function updateDataSourcesV0_2_0(\n _dataSources: (RuntimeDataSourceV0_2_0 | CustomDatasourceV0_2_0)[],\n reader: Reader,\n root: string,\n): Promise<SubqlProjectDs[]> {\n // force convert to updated ds\n return Promise.all(\n _dataSources.map(async (dataSource) => {\n if (dataSource.kind === 'flare/Runtime') {\n dataSource.kind = EthereumDatasourceKind.Runtime;\n }\n dataSource.mapping.handlers = dataSource.mapping.handlers.map(\n (handler) => {\n switch (handler.kind) {\n case 'flare/BlockHandler': {\n handler.kind = EthereumHandlerKind.Block;\n break;\n }\n case 'flare/TransactionHandler': {\n handler.kind = EthereumHandlerKind.Call;\n break;\n }\n case 'flare/LogHandler': {\n handler.kind = EthereumHandlerKind.Event;\n break;\n }\n default:\n }\n\n return handler;\n },\n );\n\n const entryScript = await loadDataSourceScript(\n reader,\n dataSource.mapping.file,\n );\n const file = await updateDataSourcesEntry(\n reader,\n dataSource.mapping.file,\n root,\n entryScript,\n );\n if (dataSource.assets) {\n for (const [, asset] of Object.entries(dataSource.assets)) {\n if (reader instanceof LocalReader) {\n asset.file = path.resolve(root, asset.file);\n } else {\n const res = await reader.getFile(asset.file);\n const outputPath = path.resolve(\n root,\n asset.file.replace('ipfs://', ''),\n );\n await fs.promises.writeFile(outputPath, res as string);\n asset.file = outputPath;\n }\n }\n }\n if (isCustomDs(dataSource)) {\n if (dataSource.processor) {\n dataSource.processor.file = await updateProcessor(\n reader,\n root,\n dataSource.processor.file,\n );\n }\n if (dataSource.assets) {\n for (const [, asset] of dataSource.assets) {\n if (reader instanceof LocalReader) {\n asset.file = path.resolve(root, asset.file);\n } else {\n const res = await reader.getFile(asset.file);\n const outputPath = path.resolve(\n root,\n asset.file.replace('ipfs://', ''),\n );\n await fs.promises.writeFile(outputPath, res as string);\n asset.file = outputPath;\n }\n }\n }\n return {\n ...dataSource,\n mapping: { ...dataSource.mapping, entryScript, file },\n };\n } else {\n return {\n ...dataSource,\n mapping: { ...dataSource.mapping, entryScript, file },\n };\n }\n }),\n );\n}\n\nasync function updateDataSourcesEntry(\n reader: Reader,\n file: string,\n root: string,\n script: string,\n): Promise<string> {\n if (reader instanceof LocalReader) return file;\n else if (reader instanceof IPFSReader || reader instanceof GithubReader) {\n const outputPath = `${path.resolve(root, file.replace('ipfs://', ''))}.js`;\n await fs.promises.writeFile(outputPath, script);\n return outputPath;\n }\n}\n\nasync function updateProcessor(\n reader: Reader,\n root: string,\n file: string,\n): Promise<string> {\n if (reader instanceof LocalReader) {\n return path.resolve(root, file);\n } else {\n const res = await reader.getFile(file);\n const outputPath = `${path.resolve(root, file.replace('ipfs://', ''))}.js`;\n await fs.promises.writeFile(outputPath, res);\n return outputPath;\n }\n}\n\nexport async function getChainTypes(\n reader: Reader,\n root: string,\n file: string,\n): Promise<ChainTypes> {\n // If the project is load from local, we will direct load them\n if (reader instanceof LocalReader) {\n return loadChainTypes(file, root);\n } else {\n // If it is stored in ipfs or other resources, we will use the corresponding reader to read the file\n // Because ipfs not provide extension of the file, it is difficult to determine its format\n // We will use yaml.load to try to load the script and parse them to supported chain types\n // if it failed, we will give it another another attempt, and assume the script written in js\n // we will download it to a temp folder, and load them within sandbox\n const res = await reader.getFile(file);\n let raw: unknown;\n try {\n raw = yaml.load(res);\n return parseChainTypes(raw);\n } catch (e) {\n const chainTypesPath = `${path.resolve(\n root,\n file.replace('ipfs://', ''),\n )}.js`;\n await fs.promises.writeFile(chainTypesPath, res);\n raw = loadChainTypesFromJs(chainTypesPath); //root not required, as it been packed in single js\n return parseChainTypes(raw);\n }\n }\n}\n\nexport async function loadDataSourceScript(\n reader: Reader,\n file?: string,\n): Promise<string> {\n let entry: string;\n //For RuntimeDataSourceV0_0_1\n if (!file) {\n const pkg = await reader.getPkg();\n if (pkg === undefined) throw new Error('Project package.json is not found');\n if (pkg.main) {\n entry = pkg.main.startsWith('./') ? pkg.main : `./${pkg.main}`;\n } else {\n entry = './dist';\n }\n }\n //Else get file\n const entryScript = await reader.getFile(file ? file : entry);\n if (entryScript === undefined) {\n throw new Error(`Entry file ${entry} for datasource not exist`);\n }\n return entryScript;\n}\n\nasync function makeTempDir(): Promise<string> {\n const sep = path.sep;\n const tmpDir = os.tmpdir();\n return fs.promises.mkdtemp(`${tmpDir}${sep}`);\n}\n\nexport async function getProjectRoot(reader: Reader): Promise<string> {\n if (reader instanceof LocalReader) return reader.root;\n if (reader instanceof IPFSReader || reader instanceof GithubReader) {\n return makeTempDir();\n }\n}\n\nexport async function initDbSchema(\n project: SubqueryProject,\n schema: string,\n storeService: StoreService,\n): Promise<void> {\n const modelsRelation = getAllEntitiesRelations(project.schema);\n await storeService.init(modelsRelation, schema);\n}\n\nexport async function initHotSchemaReload(\n schema: string,\n storeService: StoreService,\n): Promise<void> {\n await storeService.initHotSchemaReloadQueries(schema);\n}\n\nconst handledErrors = ['timeout'];\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function retryOnFailEth<T>(\n request: () => Promise<T>,\n errors = handledErrors,\n): Promise<T> {\n return retryOnFail(request, (e) => !!errors.find((t) => t === e?.reason));\n}\n"]}
package/dist/yargs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare const yargsOptions: import("yargs").Argv<import("yargs").Omit<{
2
2
  targetHeight: number;
3
- }, "subquery" | "subquery-name" | "config" | "local" | "db-schema" | "unsafe" | "subscription" | "batch-size" | "scale-batch-size" | "timeout" | "debug" | "profiler" | "network-endpoint" | "output-fmt" | "log-level" | "migrate" | "timestamp-field" | "network-dictionary" | "dictionary-timeout" | "mmr-path" | "proof-of-index" | "ipfs" | "port" | "disable-historical" | "workers" | "query-limit" | "unfinalized-blocks"> & import("yargs").InferredOptionTypes<{
3
+ }, "subquery" | "subquery-name" | "config" | "local" | "db-schema" | "unsafe" | "subscription" | "batch-size" | "scale-batch-size" | "timeout" | "debug" | "profiler" | "network-endpoint" | "output-fmt" | "log-level" | "timestamp-field" | "network-dictionary" | "dictionary-timeout" | "mmr-path" | "proof-of-index" | "ipfs" | "port" | "disable-historical" | "workers" | "query-limit" | "unfinalized-blocks"> & import("yargs").InferredOptionTypes<{
4
4
  subquery: {
5
5
  alias: string;
6
6
  demandOption: true;
@@ -87,12 +87,6 @@ export declare const yargsOptions: import("yargs").Argv<import("yargs").Omit<{
87
87
  type: "string";
88
88
  choices: string[];
89
89
  };
90
- migrate: {
91
- demandOption: false;
92
- describe: string;
93
- type: "boolean";
94
- default: boolean;
95
- };
96
90
  'timestamp-field': {
97
91
  demandOption: false;
98
92
  describe: string;
package/dist/yargs.js CHANGED
@@ -10,6 +10,7 @@ const logger_1 = require("@subql/node-core/logger");
10
10
  const helpers_1 = require("yargs/helpers");
11
11
  const yargs_1 = __importDefault(require("yargs/yargs"));
12
12
  exports.yargsOptions = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
13
+ .env('SUBQL_NODE')
13
14
  .command({
14
15
  command: 'force-clean',
15
16
  describe: 'Clean the database dropping project schemas and tables. Once the command is executed, the application would exit upon completion.',
@@ -125,12 +126,6 @@ exports.yargsOptions = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)
125
126
  type: 'string',
126
127
  choices: ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent'],
127
128
  },
128
- migrate: {
129
- demandOption: false,
130
- describe: 'Migrate db schema (for management tables only)',
131
- type: 'boolean',
132
- default: false,
133
- },
134
129
  'timestamp-field': {
135
130
  demandOption: false,
136
131
  describe: 'Enable/disable created_at and updated_at in schema',
package/dist/yargs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"yargs.js","sourceRoot":"","sources":["../src/yargs.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;AAEtC,oDAAqD;AACrD,2CAAwC;AACxC,wDAAgC;AAEnB,QAAA,YAAY,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACrD,OAAO,CAAC;IACP,OAAO,EAAE,aAAa;IACtB,QAAQ,EACN,mIAAmI;IACrI,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAChB,IAAA,mBAAU,EACR,IAAI,CAAC,KAAgB,EACrB,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;QAEF,4EAA4E;QAC5E,8DAA8D;QAC9D,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;QACpE,OAAO,cAAc,EAAE,CAAC;IAC1B,CAAC;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ACxE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,GAAG;KACb;IACD,oBAAoB,EAAE;QACpB,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,8CAA8C;QACxD,IAAI,EAAE,SAAS;KAChB;CACF,CAAC,CAAC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { initLogger } from '@subql/node-core/logger';\nimport { hideBin } from 'yargs/helpers';\nimport yargs from 'yargs/yargs';\n\nexport const yargsOptions = yargs(hideBin(process.argv))\n .command({\n command: 'force-clean',\n describe:\n 'Clean the database dropping project schemas and tables. Once the command is executed, the application would exit upon completion.',\n builder: {},\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { forceCleanInit } = require('./subcommands/forceClean.init');\n return forceCleanInit();\n },\n })\n .command({\n command: 'reindex',\n describe:\n 'Reindex to specified block height. Historical must be enabled for the targeted project (--disable-historical=false). Once the command is executed, the application would exit upon completion.',\n builder: (yargs) =>\n yargs.options('targetHeight', {\n type: 'number',\n description: 'set targetHeight',\n require: true,\n }),\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { reindexInit } = require('./subcommands/reindex.init');\n return reindexInit(argv.targetHeight);\n },\n })\n .options({\n subquery: {\n alias: 'f',\n demandOption: true,\n default: process.cwd(),\n describe: 'Local path or IPFS cid of the subquery project',\n type: 'string',\n },\n 'subquery-name': {\n deprecated: true,\n demandOption: false,\n describe: 'Name of the subquery project',\n type: 'string',\n },\n config: {\n alias: 'c',\n demandOption: false,\n describe: 'Specify configuration file',\n type: 'string',\n },\n local: {\n deprecated: true,\n type: 'boolean',\n demandOption: false,\n describe: 'Use local mode',\n },\n 'db-schema': {\n demandOption: false,\n describe: 'Db schema name of the project',\n type: 'string',\n },\n unsafe: {\n type: 'boolean',\n demandOption: false,\n describe: 'Allows usage of any built-in module within the sandbox',\n },\n subscription: {\n demandOption: false,\n describe: 'Enable subscription by create notification triggers',\n type: 'boolean',\n default: false,\n },\n 'batch-size': {\n demandOption: false,\n describe: 'Batch size of blocks to fetch in one round',\n type: 'number',\n },\n 'scale-batch-size': {\n type: 'boolean',\n demandOption: false,\n describe: 'scale batch size based on memory usage',\n default: false,\n },\n timeout: {\n demandOption: false,\n describe: 'Timeout for indexer sandbox to execute the mapping functions',\n type: 'number',\n },\n debug: {\n demandOption: false,\n describe:\n 'Show debug information to console output. will forcefully set log level to debug',\n type: 'boolean',\n default: false,\n },\n profiler: {\n demandOption: false,\n describe: 'Show profiler information to console output',\n type: 'boolean',\n default: false,\n },\n 'network-endpoint': {\n demandOption: false,\n type: 'string',\n describe: 'Blockchain network endpoint to connect',\n },\n 'output-fmt': {\n demandOption: false,\n describe: 'Print log as json or plain text',\n type: 'string',\n choices: ['json', 'colored'],\n },\n 'log-level': {\n demandOption: false,\n describe: 'Specify log level to print. Ignored when --debug is used',\n type: 'string',\n choices: ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent'],\n },\n migrate: {\n demandOption: false,\n describe: 'Migrate db schema (for management tables only)',\n type: 'boolean',\n default: false,\n },\n 'timestamp-field': {\n demandOption: false,\n describe: 'Enable/disable created_at and updated_at in schema',\n type: 'boolean',\n default: false,\n },\n 'network-dictionary': {\n alias: 'd',\n demandOption: false,\n describe: 'Specify the dictionary api for this network',\n type: 'string',\n },\n 'dictionary-timeout': {\n demandOption: false,\n describe: 'Max timeout for dictionary query',\n type: 'number',\n },\n 'mmr-path': {\n alias: 'm',\n demandOption: false,\n describe: 'Local path of the merkle mountain range (.mmr) file',\n type: 'string',\n },\n 'proof-of-index': {\n demandOption: false,\n describe: 'Enable/disable proof of index',\n type: 'boolean',\n default: false,\n },\n ipfs: {\n demandOption: false,\n describe: 'IPFS gateway endpoint',\n type: 'string',\n },\n port: {\n alias: 'p',\n demandOption: false,\n describe: 'The port the service will bind to',\n type: 'number',\n },\n 'disable-historical': {\n demandOption: false,\n default: false,\n describe: 'Disable storing historical state entities',\n type: 'boolean',\n },\n workers: {\n alias: 'w',\n demandOption: false,\n describe:\n 'Number of worker threads to use for fetching and processing blocks. Disabled by default.',\n type: 'number',\n },\n 'query-limit': {\n demandOption: false,\n describe:\n 'The limit of items a project can query with store.getByField at once',\n type: 'number',\n default: 100,\n },\n 'unfinalized-blocks': {\n demandOption: false,\n default: false,\n describe: 'Enable to fetch and index unfinalized blocks',\n type: 'boolean',\n },\n });\n"]}
1
+ {"version":3,"file":"yargs.js","sourceRoot":"","sources":["../src/yargs.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;AAEtC,oDAAqD;AACrD,2CAAwC;AACxC,wDAAgC;AAEnB,QAAA,YAAY,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACrD,GAAG,CAAC,YAAY,CAAC;KACjB,OAAO,CAAC;IACP,OAAO,EAAE,aAAa;IACtB,QAAQ,EACN,mIAAmI;IACrI,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAChB,IAAA,mBAAU,EACR,IAAI,CAAC,KAAgB,EACrB,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;QAEF,4EAA4E;QAC5E,8DAA8D;QAC9D,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;QACpE,OAAO,cAAc,EAAE,CAAC;IAC1B,CAAC;CACF,CAAC;KACD,OAAO,CAAC;IACP,OAAO,EAAE,SAAS;IAClB,QAAQ,EACN,gMAAgM;IAClM,OAAO,E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020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { initLogger } from '@subql/node-core/logger';\nimport { hideBin } from 'yargs/helpers';\nimport yargs from 'yargs/yargs';\n\nexport const yargsOptions = yargs(hideBin(process.argv))\n .env('SUBQL_NODE')\n .command({\n command: 'force-clean',\n describe:\n 'Clean the database dropping project schemas and tables. Once the command is executed, the application would exit upon completion.',\n builder: {},\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { forceCleanInit } = require('./subcommands/forceClean.init');\n return forceCleanInit();\n },\n })\n .command({\n command: 'reindex',\n describe:\n 'Reindex to specified block height. Historical must be enabled for the targeted project (--disable-historical=false). Once the command is executed, the application would exit upon completion.',\n builder: (yargs) =>\n yargs.options('targetHeight', {\n type: 'number',\n description: 'set targetHeight',\n require: true,\n }),\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { reindexInit } = require('./subcommands/reindex.init');\n return reindexInit(argv.targetHeight);\n },\n })\n .options({\n subquery: {\n alias: 'f',\n demandOption: true,\n default: process.cwd(),\n describe: 'Local path or IPFS cid of the subquery project',\n type: 'string',\n },\n 'subquery-name': {\n deprecated: true,\n demandOption: false,\n describe: 'Name of the subquery project',\n type: 'string',\n },\n config: {\n alias: 'c',\n demandOption: false,\n describe: 'Specify configuration file',\n type: 'string',\n },\n local: {\n deprecated: true,\n type: 'boolean',\n demandOption: false,\n describe: 'Use local mode',\n },\n 'db-schema': {\n demandOption: false,\n describe: 'Db schema name of the project',\n type: 'string',\n },\n unsafe: {\n type: 'boolean',\n demandOption: false,\n describe: 'Allows usage of any built-in module within the sandbox',\n },\n subscription: {\n demandOption: false,\n describe: 'Enable subscription by create notification triggers',\n type: 'boolean',\n default: false,\n },\n 'batch-size': {\n demandOption: false,\n describe: 'Batch size of blocks to fetch in one round',\n type: 'number',\n },\n 'scale-batch-size': {\n type: 'boolean',\n demandOption: false,\n describe: 'scale batch size based on memory usage',\n default: false,\n },\n timeout: {\n demandOption: false,\n describe: 'Timeout for indexer sandbox to execute the mapping functions',\n type: 'number',\n },\n debug: {\n demandOption: false,\n describe:\n 'Show debug information to console output. will forcefully set log level to debug',\n type: 'boolean',\n default: false,\n },\n profiler: {\n demandOption: false,\n describe: 'Show profiler information to console output',\n type: 'boolean',\n default: false,\n },\n 'network-endpoint': {\n demandOption: false,\n type: 'string',\n describe: 'Blockchain network endpoint to connect',\n },\n 'output-fmt': {\n demandOption: false,\n describe: 'Print log as json or plain text',\n type: 'string',\n choices: ['json', 'colored'],\n },\n 'log-level': {\n demandOption: false,\n describe: 'Specify log level to print. Ignored when --debug is used',\n type: 'string',\n choices: ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent'],\n },\n 'timestamp-field': {\n demandOption: false,\n describe: 'Enable/disable created_at and updated_at in schema',\n type: 'boolean',\n default: false,\n },\n 'network-dictionary': {\n alias: 'd',\n demandOption: false,\n describe: 'Specify the dictionary api for this network',\n type: 'string',\n },\n 'dictionary-timeout': {\n demandOption: false,\n describe: 'Max timeout for dictionary query',\n type: 'number',\n },\n 'mmr-path': {\n alias: 'm',\n demandOption: false,\n describe: 'Local path of the merkle mountain range (.mmr) file',\n type: 'string',\n },\n 'proof-of-index': {\n demandOption: false,\n describe: 'Enable/disable proof of index',\n type: 'boolean',\n default: false,\n },\n ipfs: {\n demandOption: false,\n describe: 'IPFS gateway endpoint',\n type: 'string',\n },\n port: {\n alias: 'p',\n demandOption: false,\n describe: 'The port the service will bind to',\n type: 'number',\n },\n 'disable-historical': {\n demandOption: false,\n default: false,\n describe: 'Disable storing historical state entities',\n type: 'boolean',\n },\n workers: {\n alias: 'w',\n demandOption: false,\n describe:\n 'Number of worker threads to use for fetching and processing blocks. Disabled by default.',\n type: 'number',\n },\n 'query-limit': {\n demandOption: false,\n describe:\n 'The limit of items a project can query with store.getByField at once',\n type: 'number',\n default: 100,\n },\n 'unfinalized-blocks': {\n demandOption: false,\n default: false,\n describe: 'Enable to fetch and index unfinalized blocks',\n type: 'boolean',\n },\n });\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subql/node-ethereum",
3
- "version": "0.3.1-0",
3
+ "version": "0.3.1-2",
4
4
  "description": "",
5
5
  "author": "Ian He",
6
6
  "license": "Apache-2.0",
@@ -24,11 +24,11 @@
24
24
  "@nestjs/event-emitter": "^1.3.0",
25
25
  "@nestjs/platform-express": "^8.2.6",
26
26
  "@nestjs/schedule": "^1.0.2",
27
- "@subql/common": "latest",
28
- "@subql/common-ethereum": "0.2.2-0",
29
- "@subql/node-core": "1.4.2-0",
30
- "@subql/types-ethereum": "0.2.2-1",
31
- "@subql/utils": "latest",
27
+ "@subql/common": "1.5.0",
28
+ "@subql/common-ethereum": "0.2.2-2",
29
+ "@subql/node-core": "1.7.2-2",
30
+ "@subql/types-ethereum": "0.2.2-2",
31
+ "@subql/utils": "1.3.2-1",
32
32
  "@subql/x-merkle-mountain-range": "2.0.0-0.1.2",
33
33
  "@willsoto/nestjs-prometheus": "^4.4.0",
34
34
  "algosdk": "^1.13.1",
@@ -74,5 +74,5 @@
74
74
  "/dist",
75
75
  "/bin"
76
76
  ],
77
- "stableVersion": "0.3.0"
77
+ "stableVersion": "0.3.1-1"
78
78
  }