@subql/node-ethereum 4.1.1 → 4.1.2-1

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 (50) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/indexer/blockDispatcher/block-dispatcher.service.d.ts +2 -3
  4. package/dist/indexer/blockDispatcher/block-dispatcher.service.js +5 -8
  5. package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -1
  6. package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js.map +1 -1
  7. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.d.ts +2 -2
  8. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +4 -5
  9. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -1
  10. package/dist/indexer/dictionary/ethDictionary.service.js +2 -1
  11. package/dist/indexer/dictionary/ethDictionary.service.js.map +1 -1
  12. package/dist/indexer/dictionary/v1/ethDictionaryV1.js +1 -1
  13. package/dist/indexer/dictionary/v1/ethDictionaryV1.js.map +1 -1
  14. package/dist/indexer/dictionary/v2/ethDictionaryV2.js +15 -9
  15. package/dist/indexer/dictionary/v2/ethDictionaryV2.js.map +1 -1
  16. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js +33 -0
  17. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js.map +1 -1
  18. package/dist/indexer/ds-processor.service.d.ts +2 -6
  19. package/dist/indexer/ds-processor.service.js +1 -22
  20. package/dist/indexer/ds-processor.service.js.map +1 -1
  21. package/dist/indexer/fetch.module.js +4 -20
  22. package/dist/indexer/fetch.module.js.map +1 -1
  23. package/dist/indexer/fetch.service.d.ts +0 -1
  24. package/dist/indexer/fetch.service.js +0 -3
  25. package/dist/indexer/fetch.service.js.map +1 -1
  26. package/dist/indexer/indexer.manager.d.ts +4 -11
  27. package/dist/indexer/indexer.manager.js +1 -3
  28. package/dist/indexer/indexer.manager.js.map +1 -1
  29. package/dist/indexer/project.service.d.ts +0 -1
  30. package/dist/indexer/project.service.js +0 -1
  31. package/dist/indexer/project.service.js.map +1 -1
  32. package/dist/indexer/{worker-fetch.module.js → worker/worker-fetch.module.js} +8 -9
  33. package/dist/indexer/worker/worker-fetch.module.js.map +1 -0
  34. package/dist/indexer/worker/worker.module.js +1 -1
  35. package/dist/indexer/worker/worker.module.js.map +1 -1
  36. package/dist/subcommands/forceClean.init.d.ts +1 -1
  37. package/dist/subcommands/forceClean.init.js +1 -15
  38. package/dist/subcommands/forceClean.init.js.map +1 -1
  39. package/dist/subcommands/reindex.init.d.ts +1 -1
  40. package/dist/subcommands/reindex.init.js +1 -20
  41. package/dist/subcommands/reindex.init.js.map +1 -1
  42. package/dist/subcommands/testing.module.js +1 -2
  43. package/dist/subcommands/testing.module.js.map +1 -1
  44. package/dist/utils/project.js.map +1 -1
  45. package/package.json +8 -7
  46. package/dist/indexer/sandbox.service.d.ts +0 -14
  47. package/dist/indexer/sandbox.service.js +0 -69
  48. package/dist/indexer/sandbox.service.js.map +0 -1
  49. package/dist/indexer/worker-fetch.module.js.map +0 -1
  50. /package/dist/indexer/{worker-fetch.module.d.ts → worker/worker-fetch.module.d.ts} +0 -0
@@ -1,8 +1,7 @@
1
1
  import { OnApplicationShutdown } from '@nestjs/common';
2
2
  import { EventEmitter2 } from '@nestjs/event-emitter';
3
- import { NodeConfig, SmartBatchService, StoreCacheService, StoreService, IProjectService, BlockDispatcher, ProcessBlockResponse, ApiService, IProjectUpgradeService, PoiSyncService, IBlock } from '@subql/node-core';
3
+ import { NodeConfig, StoreCacheService, StoreService, IProjectService, BlockDispatcher, ProcessBlockResponse, ApiService, IProjectUpgradeService, PoiSyncService, IBlock } from '@subql/node-core';
4
4
  import { EthereumProjectDs, SubqueryProject } from '../../configure/SubqueryProject';
5
- import { DynamicDsService } from '../dynamic-ds.service';
6
5
  import { IndexerManager } from '../indexer.manager';
7
6
  import { BlockContent } from '../types';
8
7
  /**
@@ -10,6 +9,6 @@ import { BlockContent } from '../types';
10
9
  */
11
10
  export declare class BlockDispatcherService extends BlockDispatcher<BlockContent, EthereumProjectDs> implements OnApplicationShutdown {
12
11
  private indexerManager;
13
- constructor(apiService: ApiService, nodeConfig: NodeConfig, indexerManager: IndexerManager, eventEmitter: EventEmitter2, projectService: IProjectService<EthereumProjectDs>, projectUpgradeService: IProjectUpgradeService, smartBatchService: SmartBatchService, storeService: StoreService, storeCacheService: StoreCacheService, poiSyncService: PoiSyncService, project: SubqueryProject, dynamicDsService: DynamicDsService);
12
+ constructor(apiService: ApiService, nodeConfig: NodeConfig, indexerManager: IndexerManager, eventEmitter: EventEmitter2, projectService: IProjectService<EthereumProjectDs>, projectUpgradeService: IProjectUpgradeService, storeService: StoreService, storeCacheService: StoreCacheService, poiSyncService: PoiSyncService, project: SubqueryProject);
14
13
  protected indexBlock(block: IBlock<BlockContent>): Promise<ProcessBlockResponse>;
15
14
  }
@@ -19,14 +19,13 @@ const common_1 = require("@nestjs/common");
19
19
  const event_emitter_1 = require("@nestjs/event-emitter");
20
20
  const node_core_1 = require("@subql/node-core");
21
21
  const SubqueryProject_1 = require("../../configure/SubqueryProject");
22
- const dynamic_ds_service_1 = require("../dynamic-ds.service");
23
22
  const indexer_manager_1 = require("../indexer.manager");
24
23
  /**
25
24
  * @description Intended to behave the same as WorkerBlockDispatcherService but doesn't use worker threads or any parallel processing
26
25
  */
27
26
  let BlockDispatcherService = class BlockDispatcherService extends node_core_1.BlockDispatcher {
28
- constructor(apiService, nodeConfig, indexerManager, eventEmitter, projectService, projectUpgradeService, smartBatchService, storeService, storeCacheService, poiSyncService, project, dynamicDsService) {
29
- super(nodeConfig, eventEmitter, projectService, projectUpgradeService, smartBatchService, storeService, storeCacheService, poiSyncService, project, dynamicDsService, apiService.fetchBlocks.bind(apiService));
27
+ constructor(apiService, nodeConfig, indexerManager, eventEmitter, projectService, projectUpgradeService, storeService, storeCacheService, poiSyncService, project) {
28
+ super(nodeConfig, eventEmitter, projectService, projectUpgradeService, storeService, storeCacheService, poiSyncService, project, apiService.fetchBlocks.bind(apiService));
30
29
  this.indexerManager = indexerManager;
31
30
  }
32
31
  async indexBlock(block) {
@@ -37,16 +36,14 @@ BlockDispatcherService = __decorate([
37
36
  (0, common_1.Injectable)(),
38
37
  __param(4, (0, common_1.Inject)('IProjectService')),
39
38
  __param(5, (0, common_1.Inject)('IProjectUpgradeService')),
40
- __param(10, (0, common_1.Inject)('ISubqueryProject')),
39
+ __param(9, (0, common_1.Inject)('ISubqueryProject')),
41
40
  __metadata("design:paramtypes", [node_core_1.ApiService,
42
41
  node_core_1.NodeConfig,
43
42
  indexer_manager_1.IndexerManager,
44
- event_emitter_1.EventEmitter2, Object, Object, node_core_1.SmartBatchService,
45
- node_core_1.StoreService,
43
+ event_emitter_1.EventEmitter2, Object, Object, node_core_1.StoreService,
46
44
  node_core_1.StoreCacheService,
47
45
  node_core_1.PoiSyncService,
48
- SubqueryProject_1.SubqueryProject,
49
- dynamic_ds_service_1.DynamicDsService])
46
+ SubqueryProject_1.SubqueryProject])
50
47
  ], BlockDispatcherService);
51
48
  exports.BlockDispatcherService = BlockDispatcherService;
52
49
  //# sourceMappingURL=block-dispatcher.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"block-dispatcher.service.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/block-dispatcher.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAA2E;AAC3E,yDAAsD;AACtD,gDAY0B;AAC1B,qEAGyC;AACzC,8DAAyD;AACzD,wDAAoD;AAGpD;;GAEG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBACX,SAAQ,2BAAgD;IAGxD,YACE,UAAsB,EACtB,UAAsB,EACd,cAA8B,EACtC,YAA2B,EAE3B,cAAkD,EAElD,qBAA6C,EAC7C,iBAAoC,EACpC,YAA0B,EAC1B,iBAAoC,EACpC,cAA8B,EACF,OAAwB,EACpD,gBAAkC;QAElC,KAAK,CACH,UAAU,EACV,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CACxC,CAAC;QAzBM,mBAAc,GAAd,cAAc,CAAgB;IA0BxC,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,KAA2B;QAE3B,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CACnC,KAAK,EACL,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,WAAW,CAAC,CACxE,CAAC;IACJ,CAAC;CACF,CAAA;AA3CY,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAUR,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;IAEzB,WAAA,IAAA,eAAM,EAAC,wBAAwB,CAAC,CAAA;IAMhC,YAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAZf,sBAAU;QACV,sBAAU;QACE,gCAAc;QACxB,6BAAa,kBAKR,6BAAiB;QACtB,wBAAY;QACP,6BAAiB;QACpB,0BAAc;QACO,iCAAe;QAClC,qCAAgB;GAlBzB,sBAAsB,CA2ClC;AA3CY,wDAAsB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n NodeConfig,\n SmartBatchService,\n StoreCacheService,\n StoreService,\n IProjectService,\n BlockDispatcher,\n ProcessBlockResponse,\n ApiService,\n IProjectUpgradeService,\n PoiSyncService,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumProjectDs,\n SubqueryProject,\n} from '../../configure/SubqueryProject';\nimport { DynamicDsService } from '../dynamic-ds.service';\nimport { IndexerManager } from '../indexer.manager';\nimport { BlockContent } from '../types';\n\n/**\n * @description Intended to behave the same as WorkerBlockDispatcherService but doesn't use worker threads or any parallel processing\n */\n@Injectable()\nexport class BlockDispatcherService\n extends BlockDispatcher<BlockContent, EthereumProjectDs>\n implements OnApplicationShutdown\n{\n constructor(\n apiService: ApiService,\n nodeConfig: NodeConfig,\n private indexerManager: IndexerManager,\n eventEmitter: EventEmitter2,\n @Inject('IProjectService')\n projectService: IProjectService<EthereumProjectDs>,\n @Inject('IProjectUpgradeService')\n projectUpgradeService: IProjectUpgradeService,\n smartBatchService: SmartBatchService,\n storeService: StoreService,\n storeCacheService: StoreCacheService,\n poiSyncService: PoiSyncService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n dynamicDsService: DynamicDsService,\n ) {\n super(\n nodeConfig,\n eventEmitter,\n projectService,\n projectUpgradeService,\n smartBatchService,\n storeService,\n storeCacheService,\n poiSyncService,\n project,\n dynamicDsService,\n apiService.fetchBlocks.bind(apiService),\n );\n }\n\n protected async indexBlock(\n block: IBlock<BlockContent>,\n ): Promise<ProcessBlockResponse> {\n return this.indexerManager.indexBlock(\n block,\n await this.projectService.getDataSources(block.getHeader().blockHeight),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"block-dispatcher.service.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/block-dispatcher.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAA2E;AAC3E,yDAAsD;AACtD,gDAW0B;AAC1B,qEAGyC;AACzC,wDAAoD;AAGpD;;GAEG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBACX,SAAQ,2BAAgD;IAGxD,YACE,UAAsB,EACtB,UAAsB,EACd,cAA8B,EACtC,YAA2B,EAE3B,cAAkD,EAElD,qBAA6C,EAC7C,YAA0B,EAC1B,iBAAoC,EACpC,cAA8B,EACF,OAAwB;QAEpD,KAAK,CACH,UAAU,EACV,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CACxC,CAAC;QArBM,mBAAc,GAAd,cAAc,CAAgB;IAsBxC,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,KAA2B;QAE3B,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CACnC,KAAK,EACL,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,WAAW,CAAC,CACxE,CAAC;IACJ,CAAC;CACF,CAAA;AAvCY,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAUR,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;IAEzB,WAAA,IAAA,eAAM,EAAC,wBAAwB,CAAC,CAAA;IAKhC,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAXf,sBAAU;QACV,sBAAU;QACE,gCAAc;QACxB,6BAAa,kBAKb,wBAAY;QACP,6BAAiB;QACpB,0BAAc;QACO,iCAAe;GAhB3C,sBAAsB,CAuClC;AAvCY,wDAAsB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n NodeConfig,\n StoreCacheService,\n StoreService,\n IProjectService,\n BlockDispatcher,\n ProcessBlockResponse,\n ApiService,\n IProjectUpgradeService,\n PoiSyncService,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumProjectDs,\n SubqueryProject,\n} from '../../configure/SubqueryProject';\nimport { IndexerManager } from '../indexer.manager';\nimport { BlockContent } from '../types';\n\n/**\n * @description Intended to behave the same as WorkerBlockDispatcherService but doesn't use worker threads or any parallel processing\n */\n@Injectable()\nexport class BlockDispatcherService\n extends BlockDispatcher<BlockContent, EthereumProjectDs>\n implements OnApplicationShutdown\n{\n constructor(\n apiService: ApiService,\n nodeConfig: NodeConfig,\n private indexerManager: IndexerManager,\n eventEmitter: EventEmitter2,\n @Inject('IProjectService')\n projectService: IProjectService<EthereumProjectDs>,\n @Inject('IProjectUpgradeService')\n projectUpgradeService: IProjectUpgradeService,\n storeService: StoreService,\n storeCacheService: StoreCacheService,\n poiSyncService: PoiSyncService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n ) {\n super(\n nodeConfig,\n eventEmitter,\n projectService,\n projectUpgradeService,\n storeService,\n storeCacheService,\n poiSyncService,\n project,\n apiService.fetchBlocks.bind(apiService),\n );\n }\n\n protected async indexBlock(\n block: IBlock<BlockContent>,\n ): Promise<ProcessBlockResponse> {\n return this.indexerManager.indexBlock(\n block,\n await this.projectService.getDataSources(block.getHeader().blockHeight),\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ethereum-block-dispatcher.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/ethereum-block-dispatcher.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { IBlockDispatcher, IBlock } from '@subql/node-core';\nimport { EthereumBlock } from '@subql/types-ethereum';\n\nexport interface IEthereumBlockDispatcher\n extends IBlockDispatcher<EthereumBlock> {\n init(onDynamicDsCreated: (height: number) => Promise<void>): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"ethereum-block-dispatcher.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/ethereum-block-dispatcher.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { IBlockDispatcher } from '@subql/node-core';\nimport { EthereumBlock } from '@subql/types-ethereum';\n\nexport interface IEthereumBlockDispatcher\n extends IBlockDispatcher<EthereumBlock> {\n init(onDynamicDsCreated: (height: number) => Promise<void>): Promise<void>;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { OnApplicationShutdown } from '@nestjs/common';
2
2
  import { EventEmitter2 } from '@nestjs/event-emitter';
3
- import { NodeConfig, SmartBatchService, StoreService, StoreCacheService, IProjectService, WorkerBlockDispatcher, ConnectionPoolStateManager, IProjectUpgradeService, PoiSyncService, InMemoryCacheService } from '@subql/node-core';
3
+ import { NodeConfig, StoreService, StoreCacheService, IProjectService, WorkerBlockDispatcher, ConnectionPoolStateManager, IProjectUpgradeService, PoiSyncService, InMemoryCacheService } from '@subql/node-core';
4
4
  import { EthereumBlock } from '@subql/types-ethereum';
5
5
  import { EthereumProjectDs, SubqueryProject } from '../../configure/SubqueryProject';
6
6
  import { EthereumApiConnection } from '../../ethereum/api.connection';
@@ -11,7 +11,7 @@ type IndexerWorker = IIndexerWorker & {
11
11
  terminate: () => Promise<number>;
12
12
  };
13
13
  export declare class WorkerBlockDispatcherService extends WorkerBlockDispatcher<EthereumProjectDs, IndexerWorker, EthereumBlock> implements OnApplicationShutdown {
14
- constructor(nodeConfig: NodeConfig, eventEmitter: EventEmitter2, projectService: IProjectService<EthereumProjectDs>, projectUpgadeService: IProjectUpgradeService, smartBatchService: SmartBatchService, cacheService: InMemoryCacheService, storeService: StoreService, storeCacheService: StoreCacheService, poiSyncService: PoiSyncService, project: SubqueryProject, dynamicDsService: DynamicDsService, unfinalizedBlocksSevice: UnfinalizedBlocksService, connectionPoolState: ConnectionPoolStateManager<EthereumApiConnection>);
14
+ constructor(nodeConfig: NodeConfig, eventEmitter: EventEmitter2, projectService: IProjectService<EthereumProjectDs>, projectUpgadeService: IProjectUpgradeService, cacheService: InMemoryCacheService, storeService: StoreService, storeCacheService: StoreCacheService, poiSyncService: PoiSyncService, project: SubqueryProject, dynamicDsService: DynamicDsService, unfinalizedBlocksSevice: UnfinalizedBlocksService, connectionPoolState: ConnectionPoolStateManager<EthereumApiConnection>);
15
15
  protected fetchBlock(worker: IndexerWorker, height: number): Promise<void>;
16
16
  }
17
17
  export {};
@@ -26,8 +26,8 @@ const SubqueryProject_1 = require("../../configure/SubqueryProject");
26
26
  const dynamic_ds_service_1 = require("../dynamic-ds.service");
27
27
  const unfinalizedBlocks_service_1 = require("../unfinalizedBlocks.service");
28
28
  let WorkerBlockDispatcherService = class WorkerBlockDispatcherService extends node_core_1.WorkerBlockDispatcher {
29
- constructor(nodeConfig, eventEmitter, projectService, projectUpgadeService, smartBatchService, cacheService, storeService, storeCacheService, poiSyncService, project, dynamicDsService, unfinalizedBlocksSevice, connectionPoolState) {
30
- super(nodeConfig, eventEmitter, projectService, projectUpgadeService, smartBatchService, storeService, storeCacheService, poiSyncService, project, dynamicDsService, () => (0, node_core_1.createIndexerWorker)(path_1.default.resolve(__dirname, '../../../dist/indexer/worker/worker.js'), [], storeService.getStore(), cacheService.getCache(), dynamicDsService, unfinalizedBlocksSevice, connectionPoolState, project.root, projectService.startHeight));
29
+ constructor(nodeConfig, eventEmitter, projectService, projectUpgadeService, cacheService, storeService, storeCacheService, poiSyncService, project, dynamicDsService, unfinalizedBlocksSevice, connectionPoolState) {
30
+ super(nodeConfig, eventEmitter, projectService, projectUpgadeService, storeService, storeCacheService, poiSyncService, project, () => (0, node_core_1.createIndexerWorker)(path_1.default.resolve(__dirname, '../../../dist/indexer/worker/worker.js'), [], storeService.getStore(), cacheService.getCache(), dynamicDsService, unfinalizedBlocksSevice, connectionPoolState, project.root, projectService.startHeight));
31
31
  }
32
32
  async fetchBlock(worker, height) {
33
33
  await worker.fetchBlock(height, null);
@@ -37,10 +37,9 @@ WorkerBlockDispatcherService = __decorate([
37
37
  (0, common_1.Injectable)(),
38
38
  __param(2, (0, common_1.Inject)('IProjectService')),
39
39
  __param(3, (0, common_1.Inject)('IProjectUpgradeService')),
40
- __param(9, (0, common_1.Inject)('ISubqueryProject')),
40
+ __param(8, (0, common_1.Inject)('ISubqueryProject')),
41
41
  __metadata("design:paramtypes", [node_core_1.NodeConfig,
42
- event_emitter_1.EventEmitter2, Object, Object, node_core_1.SmartBatchService,
43
- node_core_1.InMemoryCacheService,
42
+ event_emitter_1.EventEmitter2, Object, Object, node_core_1.InMemoryCacheService,
44
43
  node_core_1.StoreService,
45
44
  node_core_1.StoreCacheService,
46
45
  node_core_1.PoiSyncService,
@@ -1 +1 @@
1
- {"version":3,"file":"worker-block-dispatcher.service.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/worker-block-dispatcher.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;;;AAEnC,gDAAwB;AACxB,2CAA2E;AAC3E,yDAAsD;AACtD,gDAY0B;AAE1B,qEAGyC;AAEzC,8DAAyD;AAEzD,4EAAwE;AAQjE,IAAM,4BAA4B,GAAlC,MAAM,4BACX,SAAQ,iCAAsE;IAG9E,YACE,UAAsB,EACtB,YAA2B,EAE3B,cAAkD,EAElD,oBAA4C,EAC5C,iBAAoC,EACpC,YAAkC,EAClC,YAA0B,EAC1B,iBAAoC,EACpC,cAA8B,EACF,OAAwB,EACpD,gBAAkC,EAClC,uBAAiD,EACjD,mBAAsE;QAEtE,KAAK,CACH,UAAU,EACV,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,GAAG,EAAE,CACH,IAAA,+BAAmB,EAMjB,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,wCAAwC,CAAC,EACjE,EAAE,EACF,YAAY,CAAC,QAAQ,EAAE,EACvB,YAAY,CAAC,QAAQ,EAAE,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,OAAO,CAAC,IAAI,EACZ,cAAc,CAAC,WAAW,CAC3B,CACJ,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,MAAqB,EACrB,MAAc;QAEd,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AA1DY,4BAA4B;IADxC,IAAA,mBAAU,GAAE;IAQR,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;IAEzB,WAAA,IAAA,eAAM,EAAC,wBAAwB,CAAC,CAAA;IAOhC,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAXf,sBAAU;QACR,6BAAa,kBAKR,6BAAiB;QACtB,gCAAoB;QACpB,wBAAY;QACP,6BAAiB;QACpB,0BAAc;QACO,iCAAe;QAClC,qCAAgB;QACT,oDAAwB;QAC5B,sCAA0B;GAnBtC,4BAA4B,CA0DxC;AA1DY,oEAA4B","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport path from 'path';\nimport { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n NodeConfig,\n SmartBatchService,\n StoreService,\n StoreCacheService,\n IProjectService,\n WorkerBlockDispatcher,\n ConnectionPoolStateManager,\n IProjectUpgradeService,\n PoiSyncService,\n InMemoryCacheService,\n createIndexerWorker,\n} from '@subql/node-core';\nimport { EthereumBlock } from '@subql/types-ethereum';\nimport {\n EthereumProjectDs,\n SubqueryProject,\n} from '../../configure/SubqueryProject';\nimport { EthereumApiConnection } from '../../ethereum/api.connection';\nimport { DynamicDsService } from '../dynamic-ds.service';\nimport { BlockContent } from '../types';\nimport { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';\nimport { IIndexerWorker } from '../worker/worker';\n\ntype IndexerWorker = IIndexerWorker & {\n terminate: () => Promise<number>;\n};\n\n@Injectable()\nexport class WorkerBlockDispatcherService\n extends WorkerBlockDispatcher<EthereumProjectDs, IndexerWorker, EthereumBlock>\n implements OnApplicationShutdown\n{\n constructor(\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n @Inject('IProjectService')\n projectService: IProjectService<EthereumProjectDs>,\n @Inject('IProjectUpgradeService')\n projectUpgadeService: IProjectUpgradeService,\n smartBatchService: SmartBatchService,\n cacheService: InMemoryCacheService,\n storeService: StoreService,\n storeCacheService: StoreCacheService,\n poiSyncService: PoiSyncService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n dynamicDsService: DynamicDsService,\n unfinalizedBlocksSevice: UnfinalizedBlocksService,\n connectionPoolState: ConnectionPoolStateManager<EthereumApiConnection>,\n ) {\n super(\n nodeConfig,\n eventEmitter,\n projectService,\n projectUpgadeService,\n smartBatchService,\n storeService,\n storeCacheService,\n poiSyncService,\n project,\n dynamicDsService,\n () =>\n createIndexerWorker<\n IIndexerWorker,\n EthereumApiConnection,\n BlockContent,\n EthereumProjectDs\n >(\n path.resolve(__dirname, '../../../dist/indexer/worker/worker.js'),\n [],\n storeService.getStore(),\n cacheService.getCache(),\n dynamicDsService,\n unfinalizedBlocksSevice,\n connectionPoolState,\n project.root,\n projectService.startHeight,\n ),\n );\n }\n\n protected async fetchBlock(\n worker: IndexerWorker,\n height: number,\n ): Promise<void> {\n await worker.fetchBlock(height, null);\n }\n}\n"]}
1
+ {"version":3,"file":"worker-block-dispatcher.service.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/worker-block-dispatcher.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;;;AAEnC,gDAAwB;AACxB,2CAA2E;AAC3E,yDAAsD;AACtD,gDAW0B;AAE1B,qEAGyC;AAEzC,8DAAyD;AAEzD,4EAAwE;AAQjE,IAAM,4BAA4B,GAAlC,MAAM,4BACX,SAAQ,iCAAsE;IAG9E,YACE,UAAsB,EACtB,YAA2B,EAE3B,cAAkD,EAElD,oBAA4C,EAC5C,YAAkC,EAClC,YAA0B,EAC1B,iBAAoC,EACpC,cAA8B,EACF,OAAwB,EACpD,gBAAkC,EAClC,uBAAiD,EACjD,mBAAsE;QAEtE,KAAK,CACH,UAAU,EACV,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,GAAG,EAAE,CACH,IAAA,+BAAmB,EAMjB,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,wCAAwC,CAAC,EACjE,EAAE,EACF,YAAY,CAAC,QAAQ,EAAE,EACvB,YAAY,CAAC,QAAQ,EAAE,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,OAAO,CAAC,IAAI,EACZ,cAAc,CAAC,WAAW,CAC3B,CACJ,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,MAAqB,EACrB,MAAc;QAEd,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AAvDY,4BAA4B;IADxC,IAAA,mBAAU,GAAE;IAQR,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;IAEzB,WAAA,IAAA,eAAM,EAAC,wBAAwB,CAAC,CAAA;IAMhC,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAVf,sBAAU;QACR,6BAAa,kBAKb,gCAAoB;QACpB,wBAAY;QACP,6BAAiB;QACpB,0BAAc;QACO,iCAAe;QAClC,qCAAgB;QACT,oDAAwB;QAC5B,sCAA0B;GAlBtC,4BAA4B,CAuDxC;AAvDY,oEAA4B","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport path from 'path';\nimport { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n NodeConfig,\n StoreService,\n StoreCacheService,\n IProjectService,\n WorkerBlockDispatcher,\n ConnectionPoolStateManager,\n IProjectUpgradeService,\n PoiSyncService,\n InMemoryCacheService,\n createIndexerWorker,\n} from '@subql/node-core';\nimport { EthereumBlock } from '@subql/types-ethereum';\nimport {\n EthereumProjectDs,\n SubqueryProject,\n} from '../../configure/SubqueryProject';\nimport { EthereumApiConnection } from '../../ethereum/api.connection';\nimport { DynamicDsService } from '../dynamic-ds.service';\nimport { BlockContent } from '../types';\nimport { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';\nimport { IIndexerWorker } from '../worker/worker';\n\ntype IndexerWorker = IIndexerWorker & {\n terminate: () => Promise<number>;\n};\n\n@Injectable()\nexport class WorkerBlockDispatcherService\n extends WorkerBlockDispatcher<EthereumProjectDs, IndexerWorker, EthereumBlock>\n implements OnApplicationShutdown\n{\n constructor(\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n @Inject('IProjectService')\n projectService: IProjectService<EthereumProjectDs>,\n @Inject('IProjectUpgradeService')\n projectUpgadeService: IProjectUpgradeService,\n cacheService: InMemoryCacheService,\n storeService: StoreService,\n storeCacheService: StoreCacheService,\n poiSyncService: PoiSyncService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n dynamicDsService: DynamicDsService,\n unfinalizedBlocksSevice: UnfinalizedBlocksService,\n connectionPoolState: ConnectionPoolStateManager<EthereumApiConnection>,\n ) {\n super(\n nodeConfig,\n eventEmitter,\n projectService,\n projectUpgadeService,\n storeService,\n storeCacheService,\n poiSyncService,\n project,\n () =>\n createIndexerWorker<\n IIndexerWorker,\n EthereumApiConnection,\n BlockContent,\n EthereumProjectDs\n >(\n path.resolve(__dirname, '../../../dist/indexer/worker/worker.js'),\n [],\n storeService.getStore(),\n cacheService.getCache(),\n dynamicDsService,\n unfinalizedBlocksSevice,\n connectionPoolState,\n project.root,\n projectService.startHeight,\n ),\n );\n }\n\n protected async fetchBlock(\n worker: IndexerWorker,\n height: number,\n ): Promise<void> {\n await worker.fetchBlock(height, null);\n }\n}\n"]}
@@ -23,7 +23,7 @@ const SubqueryProject_1 = require("../../configure/SubqueryProject");
23
23
  const ethereum_1 = require("../../ethereum");
24
24
  const v1_1 = require("./v1");
25
25
  const v2_1 = require("./v2");
26
- const logger = (0, node_core_1.getLogger)('eth-dictionary');
26
+ const logger = (0, node_core_1.getLogger)('dictionary');
27
27
  let EthDictionaryService = class EthDictionaryService extends node_core_1.DictionaryService {
28
28
  constructor(project, nodeConfig, eventEmitter, apiService) {
29
29
  super(project.network.chainId, nodeConfig, eventEmitter);
@@ -52,6 +52,7 @@ let EthDictionaryService = class EthDictionaryService extends node_core_1.Dictio
52
52
  }
53
53
  }
54
54
  }
55
+ logger.debug(`Dictionary versions, v1: ${dictionariesV1.length}, v2: ${dictionariesV2.length}`);
55
56
  // v2 should be prioritised
56
57
  this.init([...dictionariesV2, ...dictionariesV1]);
57
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ethDictionary.service.js","sourceRoot":"","sources":["../../../src/indexer/dictionary/ethDictionary.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,yDAAsD;AACtD,0CAA+C;AAC/C,gDAK0B;AAE1B,qEAAkE;AAClE,6CAAoD;AACpD,6BAAuC;AACvC,6BAAuC;AAEvC,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,gBAAgB,CAAC,CAAC;AAGpC,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,6BAGzC;IACC,YACwC,OAAwB,EAC9D,UAAsB,EACtB,YAA2B,EACC,UAA8B;QAE1D,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;QALnB,YAAO,GAAP,OAAO,CAAiB;QAGlC,eAAU,GAAV,UAAU,CAAoB;IAG5D,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,cAAc,GAAsB,EAAE,CAAC;QAC7C,MAAM,cAAc,GAAsB,EAAE,CAAC;QAE7C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;SACnE;QAED,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAC3D,uBAAc,CAAC,QAAQ,EACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CACrB,CAAC;QAEF,KAAK,MAAM,QAAQ,IAAI,mBAAmB,EAAE;YAC1C,IAAI;gBACF,MAAM,YAAY,GAAG,MAAM,oBAAe,CAAC,MAAM,CAC/C,QAAQ,EACR,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,UAAU,CAAC,GAAG,CACpB,CAAC;gBACF,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aACnC;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI;oBACF,MAAM,YAAY,GAAG,MAAM,oBAAe,CAAC,MAAM,CAC/C,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,UAAU,EACf,QAAQ,CACT,CAAC;oBACF,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBACnC;gBAAC,OAAO,CAAC,EAAE;oBACV,MAAM,CAAC,IAAI,CACT,wBAAwB,QAAQ,6BAA6B,CAC9D,CAAC;iBACH;aACF;SACF;QACD,2BAA2B;QAC3B,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC;IACpD,CAAC;CACF,CAAA;AArDY,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;IAG1B,WAAA,IAAA,eAAM,EAAC,sBAAU,CAAC,CAAA;qCAH4B,iCAAe;QAClD,sBAAU;QACR,6BAAa;QACa,6BAAkB;GARjD,oBAAoB,CAqDhC;AArDY,oDAAoB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { NETWORK_FAMILY } from '@subql/common';\nimport {\n NodeConfig,\n DictionaryService,\n ApiService,\n getLogger,\n} from '@subql/node-core';\nimport { EthereumBlock, SubqlDatasource } from '@subql/types-ethereum';\nimport { SubqueryProject } from '../../configure/SubqueryProject';\nimport { EthereumApiService } from '../../ethereum';\nimport { EthDictionaryV1 } from './v1';\nimport { EthDictionaryV2 } from './v2';\n\nconst logger = getLogger('eth-dictionary');\n\n@Injectable()\nexport class EthDictionaryService extends DictionaryService<\n SubqlDatasource,\n EthereumBlock\n> {\n constructor(\n @Inject('ISubqueryProject') protected project: SubqueryProject,\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n @Inject(ApiService) private apiService: EthereumApiService,\n ) {\n super(project.network.chainId, nodeConfig, eventEmitter);\n }\n\n async initDictionaries(): Promise<void> {\n const dictionariesV1: EthDictionaryV1[] = [];\n const dictionariesV2: EthDictionaryV2[] = [];\n\n if (!this.project) {\n throw new Error(`Project in Dictionary service not initialized `);\n }\n\n const dictionaryEndpoints = await this.getDictionaryEndpoints(\n NETWORK_FAMILY.ethereum,\n this.project.network,\n );\n\n for (const endpoint of dictionaryEndpoints) {\n try {\n const dictionaryV2 = await EthDictionaryV2.create(\n endpoint,\n this.nodeConfig,\n this.project,\n this.apiService.api,\n );\n dictionariesV2.push(dictionaryV2);\n } catch (e) {\n try {\n const dictionaryV1 = await EthDictionaryV1.create(\n this.project,\n this.nodeConfig,\n endpoint,\n );\n dictionariesV1.push(dictionaryV1);\n } catch (e) {\n logger.warn(\n `Dictionary endpoint \"${endpoint}\" is not a valid dictionary`,\n );\n }\n }\n }\n // v2 should be prioritised\n this.init([...dictionariesV2, ...dictionariesV1]);\n }\n}\n"]}
1
+ {"version":3,"file":"ethDictionary.service.js","sourceRoot":"","sources":["../../../src/indexer/dictionary/ethDictionary.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD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,YAAY,CAAC,CAAC;iBACnC;gBAAC,OAAO,CAAC,EAAE;oBACV,MAAM,CAAC,IAAI,CACT,wBAAwB,QAAQ,6BAA6B,CAC9D,CAAC;iBACH;aACF;SACF;QACD,MAAM,CAAC,KAAK,CACV,4BAA4B,cAAc,CAAC,MAAM,SAAS,cAAc,CAAC,MAAM,EAAE,CAClF,CAAC;QACF,2BAA2B;QAC3B,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC;IACpD,CAAC;CACF,CAAA;AAxDY,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;IAG1B,WAAA,IAAA,eAAM,EAAC,sBAAU,CAAC,CAAA;qCAH4B,iCAAe;QAClD,sBAAU;QACR,6BAAa;QACa,6BAAkB;GARjD,oBAAoB,CAwDhC;AAxDY,oDAAoB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { NETWORK_FAMILY } from '@subql/common';\nimport {\n NodeConfig,\n DictionaryService,\n ApiService,\n getLogger,\n} from '@subql/node-core';\nimport { EthereumBlock, SubqlDatasource } from '@subql/types-ethereum';\nimport { SubqueryProject } from '../../configure/SubqueryProject';\nimport { EthereumApiService } from '../../ethereum';\nimport { EthDictionaryV1 } from './v1';\nimport { EthDictionaryV2 } from './v2';\n\nconst logger = getLogger('dictionary');\n\n@Injectable()\nexport class EthDictionaryService extends DictionaryService<\n SubqlDatasource,\n EthereumBlock\n> {\n constructor(\n @Inject('ISubqueryProject') protected project: SubqueryProject,\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n @Inject(ApiService) private apiService: EthereumApiService,\n ) {\n super(project.network.chainId, nodeConfig, eventEmitter);\n }\n\n async initDictionaries(): Promise<void> {\n const dictionariesV1: EthDictionaryV1[] = [];\n const dictionariesV2: EthDictionaryV2[] = [];\n\n if (!this.project) {\n throw new Error(`Project in Dictionary service not initialized `);\n }\n\n const dictionaryEndpoints = await this.getDictionaryEndpoints(\n NETWORK_FAMILY.ethereum,\n this.project.network,\n );\n\n for (const endpoint of dictionaryEndpoints) {\n try {\n const dictionaryV2 = await EthDictionaryV2.create(\n endpoint,\n this.nodeConfig,\n this.project,\n this.apiService.api,\n );\n dictionariesV2.push(dictionaryV2);\n } catch (e) {\n try {\n const dictionaryV1 = await EthDictionaryV1.create(\n this.project,\n this.nodeConfig,\n endpoint,\n );\n dictionariesV1.push(dictionaryV1);\n } catch (e) {\n logger.warn(\n `Dictionary endpoint \"${endpoint}\" is not a valid dictionary`,\n );\n }\n }\n }\n logger.debug(\n `Dictionary versions, v1: ${dictionariesV1.length}, v2: ${dictionariesV2.length}`,\n );\n // v2 should be prioritised\n this.init([...dictionariesV2, ...dictionariesV1]);\n }\n}\n"]}
@@ -15,7 +15,7 @@ const string_1 = require("../../../utils/string");
15
15
  const yargs_1 = require("../../../yargs");
16
16
  const utils_1 = require("../utils");
17
17
  const CHAIN_ALIASES_URL = 'https://raw.githubusercontent.com/subquery/templates/main/chainAliases.json5';
18
- const logger = (0, node_core_1.getLogger)('eth-dictionary v1');
18
+ const logger = (0, node_core_1.getLogger)('dictionary-v1');
19
19
  function appendDsOptions(dsOptions, conditions) {
20
20
  const queryAddressLimit = yargs_1.yargsOptions.argv['query-address-limit'];
21
21
  if (Array.isArray(dsOptions)) {
@@ -1 +1 @@
1
- {"version":3,"file":"ethDictionaryV1.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/ethDictionaryV1.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;AAEnC,gDAAuE;AAKvE,0DAM+B;AAC/B,kDAA0B;AAC1B,mCAAwC;AACxC,4DAA+B;AAM/B,kDAAwE;AACxE,0CAA8C;AAC9C,oCAAuC;AA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ors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NodeConfig, DictionaryV1, getLogger } from '@subql/node-core';\nimport {\n DictionaryQueryCondition,\n DictionaryQueryEntry as DictionaryV1QueryEntry,\n} from '@subql/types-core';\nimport {\n EthereumHandlerKind,\n EthereumLogFilter,\n EthereumTransactionFilter,\n SubqlDatasource,\n SubqlEthereumProcessorOptions,\n} from '@subql/types-ethereum';\nimport JSON5 from 'json5';\nimport { sortBy, uniqBy } from 'lodash';\nimport fetch from 'node-fetch';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { eventToTopic, functionToSighash } from '../../../utils/string';\nimport { yargsOptions } from '../../../yargs';\nimport { ethFilterDs } from '../utils';\n\nconst CHAIN_ALIASES_URL =\n 'https://raw.githubusercontent.com/subquery/templates/main/chainAliases.json5';\n\nconst logger = getLogger('eth-dictionary v1');\n\nexport function appendDsOptions(\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n conditions: DictionaryQueryCondition[],\n): void {\n const queryAddressLimit = yargsOptions.argv['query-address-limit'];\n if (Array.isArray(dsOptions)) {\n const addresses = dsOptions.map((option) => option.address).filter(Boolean);\n\n if (addresses.length > queryAddressLimit) {\n logger.debug(\n `Addresses length: ${addresses.length} is exceeding limit: ${queryAddressLimit}. Consider increasing this value with the flag --query-address-limit `,\n );\n }\n\n if (addresses.length !== 0 && addresses.length <= queryAddressLimit) {\n conditions.push({\n field: 'address',\n value: addresses,\n matcher: 'in',\n });\n }\n } else {\n if (dsOptions?.address) {\n conditions.push({\n field: 'address',\n value: dsOptions.address.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n }\n}\n\nfunction eventFilterToQueryEntry(\n filter: EthereumLogFilter,\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): DictionaryV1QueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n appendDsOptions(dsOptions, conditions);\n if (filter.topics) {\n for (let i = 0; i < Math.min(filter.topics.length, 4); i++) {\n const topic = filter.topics[i];\n if (!topic) {\n continue;\n }\n const field = `topics${i}`;\n\n if (topic === '!null') {\n conditions.push({\n field,\n value: false as any, // TODO update types to allow boolean\n matcher: 'isNull',\n });\n } else {\n conditions.push({\n field,\n value: eventToTopic(topic),\n matcher: 'equalTo',\n });\n }\n }\n }\n return {\n entity: 'evmLogs',\n conditions,\n };\n}\n\nfunction callFilterToQueryEntry(\n filter: EthereumTransactionFilter,\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): DictionaryV1QueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n appendDsOptions(dsOptions, conditions);\n\n for (const condition of conditions) {\n if (condition.field === 'address') {\n condition.field = 'to';\n }\n }\n if (filter.from) {\n conditions.push({\n field: 'from',\n value: filter.from.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n const optionsAddresses = conditions.find((c) => c.field === 'to');\n if (!optionsAddresses) {\n if (filter.to) {\n conditions.push({\n field: 'to',\n value: filter.to.toLowerCase(),\n matcher: 'equalTo',\n });\n } else if (filter.to === null) {\n conditions.push({\n field: 'to',\n value: true as any, // TODO update types to allow boolean\n matcher: 'isNull',\n });\n }\n } else if (optionsAddresses && (filter.to || filter.to === null)) {\n logger.warn(\n `TransactionFilter 'to' conflict with 'address' in data source options`,\n );\n }\n\n if (filter.function === null || filter.function === '0x') {\n conditions.push({\n field: 'func',\n value: true,\n matcher: 'isNull',\n });\n } else if (filter.function) {\n conditions.push({\n field: 'func',\n value: functionToSighash(filter.function),\n matcher: 'equalTo',\n });\n }\n return {\n entity: 'evmTransactions',\n conditions,\n };\n}\n\nexport type GroupedEthereumProjectDs = SubqlDatasource & {\n groupedOptions?: SubqlEthereumProcessorOptions[];\n};\n\nexport function buildDictionaryV1QueryEntries(\n dataSources: GroupedEthereumProjectDs[],\n): DictionaryV1QueryEntry[] {\n const queryEntries: DictionaryV1QueryEntry[] = [];\n\n for (const ds of dataSources) {\n for (const handler of ds.mapping.handlers) {\n // No filters, cant use dictionary\n if (!handler.filter) return [];\n\n switch (handler.kind) {\n case EthereumHandlerKind.Block:\n return [];\n case EthereumHandlerKind.Call: {\n const filter = handler.filter as EthereumTransactionFilter;\n if (\n filter.from !== undefined ||\n filter.to !== undefined ||\n filter.function !== undefined\n ) {\n queryEntries.push(callFilterToQueryEntry(filter, ds.options));\n } else {\n return [];\n }\n break;\n }\n case EthereumHandlerKind.Event: {\n const filter = handler.filter as EthereumLogFilter;\n if (ds.groupedOptions) {\n queryEntries.push(\n eventFilterToQueryEntry(filter, ds.groupedOptions),\n );\n } else if (ds.options?.address || filter.topics) {\n queryEntries.push(eventFilterToQueryEntry(filter, ds.options));\n } else {\n return [];\n }\n break;\n }\n default:\n }\n }\n }\n\n return uniqBy(\n queryEntries,\n (item) =>\n `${item.entity}|${JSON.stringify(\n sortBy(item.conditions, (c) => c.field),\n )}`,\n );\n}\n\nexport class EthDictionaryV1 extends DictionaryV1<GroupedEthereumProjectDs> {\n private constructor(\n project: SubqueryProject,\n nodeConfig: NodeConfig,\n dictionaryUrl: string,\n chainId?: string,\n ) {\n super(dictionaryUrl, chainId ?? project.network.chainId, nodeConfig);\n }\n\n static async create(\n project: SubqueryProject,\n nodeConfig: NodeConfig,\n dictionaryUrl?: string,\n ): Promise<EthDictionaryV1> {\n /*Some dictionarys for EVM are built with other SDKs as they are chains with an EVM runtime\n * we maintain a list of aliases so we can map the evmChainId to the genesis hash of the other SDKs\n * e.g moonbeam is built with Substrate SDK but can be used as an EVM dictionary\n */\n const chainAliases = await this.getEvmChainId();\n const chainAlias = chainAliases[project.network.chainId];\n\n const dictionary = new EthDictionaryV1(\n project,\n nodeConfig,\n dictionaryUrl,\n chainAlias,\n );\n await dictionary.init();\n return dictionary;\n }\n\n private static async getEvmChainId(): Promise<Record<string, string>> {\n const response = await fetch(CHAIN_ALIASES_URL);\n\n const raw = await response.text();\n // We use JSON5 here because the file has comments in it\n return JSON5.parse(raw);\n }\n\n buildDictionaryQueryEntries(\n // Add name to datasource as templates have this set\n dataSources: (EthereumProjectDs | EthereumProjectDsTemplate)[],\n ): DictionaryV1QueryEntry[] {\n const filteredDs = ethFilterDs(dataSources);\n return buildDictionaryV1QueryEntries(filteredDs);\n }\n}\n"]}
1
+ {"version":3,"file":"ethDictionaryV1.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/ethDictionaryV1.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;AAEnC,gDAAuE;AAKvE,0DAM+B;AAC/B,kDAA0B;AAC1B,mCAAwC;AACxC,4DAA+B;AAM/B,kDAAwE;AACxE,0CAA8C;AAC9C,oCAAuC;AAEvC,MAAM,iBAAiB,GACrB,8EAA8E,CAAC;AAEjF,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,eAAe,CAAC,CAAC;AAE1C,SAAgB,eAAe,CAC7B,SAA0E,EAC1E,UAAsC;IAEtC,MAAM,iBAAiB,GAAG,oBAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnE,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAC5B,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE5E,IAAI,SAAS,CAAC,MAAM,GAAG,iBAAiB,EAAE;YACxC,MAAM,CAAC,KAAK,CACV,qBAAqB,SAAS,CAAC,MAAM,wBAAwB,iBAAiB,wEAAwE,CACvJ,CAAC;SACH;QAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,MAAM,IAAI,iBAAiB,EAAE;YACnE,UAAU,CAAC,IAAI,CAAC;gBACd,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,SAAS;gBAChB,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;SACJ;KAC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Aa;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,iBAAiB,CAAC,CAAC;QAEhD,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAClC,wDAAwD;QACxD,OAAO,eAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,2BAA2B;IACzB,oDAAoD;IACpD,WAA8D;QAE9D,MAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,WAAW,CAAC,CAAC;QAC5C,OAAO,6BAA6B,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;CACF;AA/CD,0CA+CC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NodeConfig, DictionaryV1, getLogger } from '@subql/node-core';\nimport {\n DictionaryQueryCondition,\n DictionaryQueryEntry as DictionaryV1QueryEntry,\n} from '@subql/types-core';\nimport {\n EthereumHandlerKind,\n EthereumLogFilter,\n EthereumTransactionFilter,\n SubqlDatasource,\n SubqlEthereumProcessorOptions,\n} from '@subql/types-ethereum';\nimport JSON5 from 'json5';\nimport { sortBy, uniqBy } from 'lodash';\nimport fetch from 'node-fetch';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { eventToTopic, functionToSighash } from '../../../utils/string';\nimport { yargsOptions } from '../../../yargs';\nimport { ethFilterDs } from '../utils';\n\nconst CHAIN_ALIASES_URL =\n 'https://raw.githubusercontent.com/subquery/templates/main/chainAliases.json5';\n\nconst logger = getLogger('dictionary-v1');\n\nexport function appendDsOptions(\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n conditions: DictionaryQueryCondition[],\n): void {\n const queryAddressLimit = yargsOptions.argv['query-address-limit'];\n if (Array.isArray(dsOptions)) {\n const addresses = dsOptions.map((option) => option.address).filter(Boolean);\n\n if (addresses.length > queryAddressLimit) {\n logger.debug(\n `Addresses length: ${addresses.length} is exceeding limit: ${queryAddressLimit}. Consider increasing this value with the flag --query-address-limit `,\n );\n }\n\n if (addresses.length !== 0 && addresses.length <= queryAddressLimit) {\n conditions.push({\n field: 'address',\n value: addresses,\n matcher: 'in',\n });\n }\n } else {\n if (dsOptions?.address) {\n conditions.push({\n field: 'address',\n value: dsOptions.address.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n }\n}\n\nfunction eventFilterToQueryEntry(\n filter: EthereumLogFilter,\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): DictionaryV1QueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n appendDsOptions(dsOptions, conditions);\n if (filter.topics) {\n for (let i = 0; i < Math.min(filter.topics.length, 4); i++) {\n const topic = filter.topics[i];\n if (!topic) {\n continue;\n }\n const field = `topics${i}`;\n\n if (topic === '!null') {\n conditions.push({\n field,\n value: false as any, // TODO update types to allow boolean\n matcher: 'isNull',\n });\n } else {\n conditions.push({\n field,\n value: eventToTopic(topic),\n matcher: 'equalTo',\n });\n }\n }\n }\n return {\n entity: 'evmLogs',\n conditions,\n };\n}\n\nfunction callFilterToQueryEntry(\n filter: EthereumTransactionFilter,\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): DictionaryV1QueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n appendDsOptions(dsOptions, conditions);\n\n for (const condition of conditions) {\n if (condition.field === 'address') {\n condition.field = 'to';\n }\n }\n if (filter.from) {\n conditions.push({\n field: 'from',\n value: filter.from.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n const optionsAddresses = conditions.find((c) => c.field === 'to');\n if (!optionsAddresses) {\n if (filter.to) {\n conditions.push({\n field: 'to',\n value: filter.to.toLowerCase(),\n matcher: 'equalTo',\n });\n } else if (filter.to === null) {\n conditions.push({\n field: 'to',\n value: true as any, // TODO update types to allow boolean\n matcher: 'isNull',\n });\n }\n } else if (optionsAddresses && (filter.to || filter.to === null)) {\n logger.warn(\n `TransactionFilter 'to' conflict with 'address' in data source options`,\n );\n }\n\n if (filter.function === null || filter.function === '0x') {\n conditions.push({\n field: 'func',\n value: true,\n matcher: 'isNull',\n });\n } else if (filter.function) {\n conditions.push({\n field: 'func',\n value: functionToSighash(filter.function),\n matcher: 'equalTo',\n });\n }\n return {\n entity: 'evmTransactions',\n conditions,\n };\n}\n\nexport type GroupedEthereumProjectDs = SubqlDatasource & {\n groupedOptions?: SubqlEthereumProcessorOptions[];\n};\n\nexport function buildDictionaryV1QueryEntries(\n dataSources: GroupedEthereumProjectDs[],\n): DictionaryV1QueryEntry[] {\n const queryEntries: DictionaryV1QueryEntry[] = [];\n\n for (const ds of dataSources) {\n for (const handler of ds.mapping.handlers) {\n // No filters, cant use dictionary\n if (!handler.filter) return [];\n\n switch (handler.kind) {\n case EthereumHandlerKind.Block:\n return [];\n case EthereumHandlerKind.Call: {\n const filter = handler.filter as EthereumTransactionFilter;\n if (\n filter.from !== undefined ||\n filter.to !== undefined ||\n filter.function !== undefined\n ) {\n queryEntries.push(callFilterToQueryEntry(filter, ds.options));\n } else {\n return [];\n }\n break;\n }\n case EthereumHandlerKind.Event: {\n const filter = handler.filter as EthereumLogFilter;\n if (ds.groupedOptions) {\n queryEntries.push(\n eventFilterToQueryEntry(filter, ds.groupedOptions),\n );\n } else if (ds.options?.address || filter.topics) {\n queryEntries.push(eventFilterToQueryEntry(filter, ds.options));\n } else {\n return [];\n }\n break;\n }\n default:\n }\n }\n }\n\n return uniqBy(\n queryEntries,\n (item) =>\n `${item.entity}|${JSON.stringify(\n sortBy(item.conditions, (c) => c.field),\n )}`,\n );\n}\n\nexport class EthDictionaryV1 extends DictionaryV1<GroupedEthereumProjectDs> {\n private constructor(\n project: SubqueryProject,\n nodeConfig: NodeConfig,\n dictionaryUrl: string,\n chainId?: string,\n ) {\n super(dictionaryUrl, chainId ?? project.network.chainId, nodeConfig);\n }\n\n static async create(\n project: SubqueryProject,\n nodeConfig: NodeConfig,\n dictionaryUrl?: string,\n ): Promise<EthDictionaryV1> {\n /*Some dictionarys for EVM are built with other SDKs as they are chains with an EVM runtime\n * we maintain a list of aliases so we can map the evmChainId to the genesis hash of the other SDKs\n * e.g moonbeam is built with Substrate SDK but can be used as an EVM dictionary\n */\n const chainAliases = await this.getEvmChainId();\n const chainAlias = chainAliases[project.network.chainId];\n\n const dictionary = new EthDictionaryV1(\n project,\n nodeConfig,\n dictionaryUrl,\n chainAlias,\n );\n await dictionary.init();\n return dictionary;\n }\n\n private static async getEvmChainId(): Promise<Record<string, string>> {\n const response = await fetch(CHAIN_ALIASES_URL);\n\n const raw = await response.text();\n // We use JSON5 here because the file has comments in it\n return JSON5.parse(raw);\n }\n\n buildDictionaryQueryEntries(\n // Add name to datasource as templates have this set\n dataSources: (EthereumProjectDs | EthereumProjectDsTemplate)[],\n ): DictionaryV1QueryEntry[] {\n const filteredDs = ethFilterDs(dataSources);\n return buildDictionaryV1QueryEntries(filteredDs);\n }\n}\n"]}
@@ -24,7 +24,7 @@ const yargs_1 = require("../../../yargs");
24
24
  const utils_1 = require("../utils");
25
25
  const utils_2 = require("./utils");
26
26
  const MIN_FETCH_LIMIT = 200;
27
- const logger = (0, node_core_1.getLogger)('eth-dictionary-v2');
27
+ const logger = (0, node_core_1.getLogger)('dictionary-v2');
28
28
  function extractOptionAddresses(dsOptions) {
29
29
  const queryAddressLimit = yargs_1.yargsOptions.argv['query-address-limit'];
30
30
  const addressArray = [];
@@ -52,17 +52,23 @@ function callFilterToDictionaryCondition(filter, dsOptions) {
52
52
  if (filter.from) {
53
53
  fromArray.push(filter.from.toLowerCase());
54
54
  }
55
- const optionsAddresses = extractOptionAddresses(dsOptions);
56
- if (!optionsAddresses.length) {
57
- if (filter.to) {
58
- toArray.push(filter.to.toLowerCase());
55
+ const assignTo = (value) => {
56
+ if (value === null) {
57
+ toArray.push(null);
59
58
  }
60
- else if (filter.to === null) {
61
- toArray.push(null); //TODO, is this correct?
59
+ else if (value !== undefined) {
60
+ toArray.push(value.toLowerCase());
62
61
  }
62
+ };
63
+ const optionsAddresses = extractOptionAddresses(dsOptions);
64
+ if (!optionsAddresses.length) {
65
+ assignTo(filter.to);
63
66
  }
64
- else if (!!optionsAddresses.length && (filter.to || filter.to === null)) {
65
- logger.warn(`TransactionFilter 'to' conflict with 'address' in data source options`);
67
+ else {
68
+ if (filter.to || filter.to === null) {
69
+ logger.warn(`TransactionFilter 'to' conflicts with 'address' in data source options, using data source option`);
70
+ }
71
+ optionsAddresses.forEach(assignTo);
66
72
  }
67
73
  if (filter.function) {
68
74
  funcArray.push((0, string_1.functionToSighash)(filter.function));
@@ -1 +1 @@
1
- {"version":3,"file":"ethDictionaryV2.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,gDAO0B;AAC1B,0DAO+B;AAC/B,mCAAgC;AAChC,8DAAmE;AAOnE,kDAAwE;AACxE,0CAA8C;AAC9C,oCAAuC;AAQvC,mCAA6C;AAE7C,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,mBAAmB,CAAC,CAAC;AAE9C,SAAS,sBAAsB,CAC7B,SAA0E;IAE1E,MAAM,iBAAiB,GAAG,oBAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnE,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAC5B,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE5E,IAAI,SAAS,CAAC,MAAM,GAAG,iBAAiB,EAAE;YACxC,MAAM,CAAC,KAAK,CACV,qBAAqB,SAAS,CAAC,MAA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X-License-Identifier: GPL-3.0\n\nimport {\n NodeConfig,\n DictionaryV2,\n RawDictionaryResponseData,\n DictionaryResponse,\n getLogger,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumHandlerKind,\n EthereumLogFilter,\n EthereumTransactionFilter,\n SubqlDatasource,\n SubqlEthereumProcessorOptions,\n} from '@subql/types-ethereum';\nimport { uniqBy } from 'lodash';\nimport { EthereumNodeConfig } from '../../../configure/NodeConfig';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport { eventToTopic, functionToSighash } from '../../../utils/string';\nimport { yargsOptions } from '../../../yargs';\nimport { ethFilterDs } from '../utils';\nimport { GroupedEthereumProjectDs } from '../v1';\nimport {\n RawEthBlock,\n EthDictionaryV2QueryEntry,\n EthDictionaryTxConditions,\n EthDictionaryLogConditions,\n} from './types';\nimport { rawBlockToEthBlock } from './utils';\n\nconst MIN_FETCH_LIMIT = 200;\n\nconst logger = getLogger('eth-dictionary-v2');\n\nfunction extractOptionAddresses(\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): string[] {\n const queryAddressLimit = yargsOptions.argv['query-address-limit'];\n const addressArray: string[] = [];\n if (Array.isArray(dsOptions)) {\n const addresses = dsOptions.map((option) => option.address).filter(Boolean);\n\n if (addresses.length > queryAddressLimit) {\n logger.debug(\n `Addresses length: ${addresses.length} is exceeding limit: ${queryAddressLimit}. Consider increasing this value with the flag --query-address-limit `,\n );\n }\n if (addresses.length !== 0 && addresses.length <= queryAddressLimit) {\n addressArray.push(...addresses);\n }\n } else {\n if (dsOptions?.address) {\n addressArray.push(dsOptions.address.toLowerCase());\n }\n }\n return addressArray;\n}\n\nfunction callFilterToDictionaryCondition(\n filter: EthereumTransactionFilter,\n dsOptions: SubqlEthereumProcessorOptions,\n): EthDictionaryTxConditions {\n const txConditions: EthDictionaryTxConditions = {};\n const toArray = [];\n const fromArray = [];\n const funcArray = [];\n\n if (filter.from) {\n fromArray.push(filter.from.toLowerCase());\n }\n const optionsAddresses = extractOptionAddresses(dsOptions);\n if (!optionsAddresses.length) {\n if (filter.to) {\n toArray.push(filter.to.toLowerCase());\n } else if (filter.to === null) {\n toArray.push(null); //TODO, is this correct?\n }\n } else if (!!optionsAddresses.length && (filter.to || filter.to === null)) {\n logger.warn(\n `TransactionFilter 'to' conflict with 'address' in data source options`,\n );\n }\n if (filter.function) {\n funcArray.push(functionToSighash(filter.function));\n }\n\n if (toArray.length !== 0) {\n txConditions.to = toArray;\n }\n if (fromArray.length !== 0) {\n txConditions.from = fromArray;\n }\n\n if (funcArray.length !== 0) {\n txConditions.data = funcArray;\n }\n\n return txConditions;\n}\n\nfunction eventFilterToDictionaryCondition(\n filter: EthereumLogFilter,\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): EthDictionaryLogConditions {\n const logConditions: EthDictionaryLogConditions = {};\n logConditions.address = extractOptionAddresses(dsOptions);\n if (filter.topics) {\n for (let i = 0; i < Math.min(filter.topics.length, 4); i++) {\n const topic = filter.topics[i];\n if (!topic) {\n continue;\n }\n const field = `topics${i}`;\n // Initialized\n if (!logConditions[field]) {\n logConditions[field] = [];\n }\n if (topic === '!null') {\n logConditions[field] = []; // TODO, check if !null\n } else {\n logConditions[field].push(eventToTopic(topic));\n }\n }\n }\n return logConditions;\n}\n\nexport function buildDictionaryV2QueryEntry(\n dataSources: GroupedEthereumProjectDs[],\n): EthDictionaryV2QueryEntry {\n const dictionaryConditions: EthDictionaryV2QueryEntry = {\n logs: [],\n transactions: [],\n };\n\n for (const ds of dataSources) {\n for (const handler of ds.mapping.handlers) {\n // No filters, cant use dictionary\n if (!handler.filter) return dictionaryConditions;\n\n switch (handler.kind) {\n case EthereumHandlerKind.Block:\n return dictionaryConditions;\n case EthereumHandlerKind.Call: {\n const filter = handler.filter as EthereumTransactionFilter;\n if (\n filter.from !== undefined ||\n filter.to !== undefined ||\n filter.function !== undefined\n ) {\n dictionaryConditions.transactions.push(\n callFilterToDictionaryCondition(filter, ds.options),\n );\n } else {\n // do nothing;\n }\n break;\n }\n case EthereumHandlerKind.Event: {\n const filter = handler.filter as EthereumLogFilter;\n if (ds.groupedOptions) {\n dictionaryConditions.logs.push(\n eventFilterToDictionaryCondition(filter, ds.groupedOptions),\n );\n } else if (ds.options?.address || filter.topics) {\n dictionaryConditions.logs.push(\n eventFilterToDictionaryCondition(filter, ds.options),\n );\n } else {\n // do nothing;\n }\n break;\n }\n default:\n }\n }\n }\n\n if (!dictionaryConditions.logs.length) {\n delete dictionaryConditions.logs;\n } else {\n dictionaryConditions.logs = uniqBy(dictionaryConditions.logs, (log) =>\n JSON.stringify(log),\n );\n }\n\n if (!dictionaryConditions.transactions.length) {\n delete dictionaryConditions.transactions;\n } else {\n dictionaryConditions.transactions = uniqBy(\n dictionaryConditions.transactions,\n (tx) => JSON.stringify(tx),\n );\n }\n return dictionaryConditions;\n}\n\nexport class EthDictionaryV2 extends DictionaryV2<\n EthereumBlock,\n SubqlDatasource,\n EthDictionaryV2QueryEntry\n> {\n #skipTransactions: boolean;\n\n constructor(\n endpoint: string,\n nodeConfig: NodeConfig,\n project: SubqueryProject,\n private api: EthereumApi,\n ) {\n super(endpoint, project.network.chainId, nodeConfig);\n this.#skipTransactions = !!new EthereumNodeConfig(nodeConfig)\n .skipTransactions;\n }\n\n static async create(\n endpoint: string,\n nodeConfig: NodeConfig,\n project: SubqueryProject,\n api: EthereumApi,\n ): Promise<EthDictionaryV2> {\n const dictionary = new EthDictionaryV2(endpoint, nodeConfig, project, api);\n await dictionary.init();\n return dictionary;\n }\n\n buildDictionaryQueryEntries(\n dataSources: (EthereumProjectDs | EthereumProjectDsTemplate)[],\n ): EthDictionaryV2QueryEntry {\n const filteredDs = ethFilterDs(dataSources);\n return buildDictionaryV2QueryEntry(filteredDs);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getData(\n startBlock: number,\n endBlock: number,\n limit: number = MIN_FETCH_LIMIT,\n ): Promise<DictionaryResponse<IBlock<EthereumBlock> | number> | undefined> {\n return super.getData(startBlock, endBlock, limit, {\n blockHeader: true,\n logs: { transaction: !this.#skipTransactions },\n transactions: { log: true },\n });\n }\n\n convertResponseBlocks<RFB = RawEthBlock>(\n data: RawDictionaryResponseData<RFB>,\n ): DictionaryResponse<IBlock<EthereumBlock>> | undefined {\n try {\n const blocks: IBlock<EthereumBlock>[] = (\n (data.blocks as RawEthBlock[]) || []\n ).map((b) => rawBlockToEthBlock(b, this.api));\n return {\n batchBlocks: blocks,\n lastBufferedHeight: blocks.length\n ? blocks[blocks.length - 1].block.number\n : undefined,\n };\n } catch (e) {\n logger.error(e, `Failed to handle block response}`);\n throw e;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ethDictionaryV2.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,gDAO0B;AAC1B,0DAO+B;AAC/B,mCAAgC;AAChC,8DAAmE;AAOnE,kDAAwE;AACxE,0CAA8C;AAC9C,oCAAuC;AAQvC,mCAA6C;AAE7C,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,eAAe,CAAC,CAAC;AAE1C,SAAS,sBAAsB,CAC7B,SAA0E;IAE1E,MAAM,iBAAiB,GAAG,oBAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnE,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAC5B,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE5E,IAAI,SAAS,CAA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ACV,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,kCAAkC,CAAC,CAAC;YACpD,MAAM,CAAC,CAAC;SACT;IACH,CAAC;CACF;AAnED,0CAmEC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n NodeConfig,\n DictionaryV2,\n RawDictionaryResponseData,\n DictionaryResponse,\n getLogger,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumHandlerKind,\n EthereumLogFilter,\n EthereumTransactionFilter,\n SubqlDatasource,\n SubqlEthereumProcessorOptions,\n} from '@subql/types-ethereum';\nimport { uniqBy } from 'lodash';\nimport { EthereumNodeConfig } from '../../../configure/NodeConfig';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport { eventToTopic, functionToSighash } from '../../../utils/string';\nimport { yargsOptions } from '../../../yargs';\nimport { ethFilterDs } from '../utils';\nimport { GroupedEthereumProjectDs } from '../v1';\nimport {\n RawEthBlock,\n EthDictionaryV2QueryEntry,\n EthDictionaryTxConditions,\n EthDictionaryLogConditions,\n} from './types';\nimport { rawBlockToEthBlock } from './utils';\n\nconst MIN_FETCH_LIMIT = 200;\n\nconst logger = getLogger('dictionary-v2');\n\nfunction extractOptionAddresses(\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): string[] {\n const queryAddressLimit = yargsOptions.argv['query-address-limit'];\n const addressArray: string[] = [];\n if (Array.isArray(dsOptions)) {\n const addresses = dsOptions.map((option) => option.address).filter(Boolean);\n\n if (addresses.length > queryAddressLimit) {\n logger.debug(\n `Addresses length: ${addresses.length} is exceeding limit: ${queryAddressLimit}. Consider increasing this value with the flag --query-address-limit `,\n );\n }\n if (addresses.length !== 0 && addresses.length <= queryAddressLimit) {\n addressArray.push(...addresses);\n }\n } else {\n if (dsOptions?.address) {\n addressArray.push(dsOptions.address.toLowerCase());\n }\n }\n return addressArray;\n}\n\nfunction callFilterToDictionaryCondition(\n filter: EthereumTransactionFilter,\n dsOptions: SubqlEthereumProcessorOptions,\n): EthDictionaryTxConditions {\n const txConditions: EthDictionaryTxConditions = {};\n const toArray = [];\n const fromArray = [];\n const funcArray = [];\n\n if (filter.from) {\n fromArray.push(filter.from.toLowerCase());\n }\n\n const assignTo = (value: string | null | undefined) => {\n if (value === null) {\n toArray.push(null);\n } else if (value !== undefined) {\n toArray.push(value.toLowerCase());\n }\n };\n\n const optionsAddresses = extractOptionAddresses(dsOptions);\n if (!optionsAddresses.length) {\n assignTo(filter.to);\n } else {\n if (filter.to || filter.to === null) {\n logger.warn(\n `TransactionFilter 'to' conflicts with 'address' in data source options, using data source option`,\n );\n }\n optionsAddresses.forEach(assignTo);\n }\n\n if (filter.function) {\n funcArray.push(functionToSighash(filter.function));\n }\n\n if (toArray.length !== 0) {\n txConditions.to = toArray;\n }\n if (fromArray.length !== 0) {\n txConditions.from = fromArray;\n }\n\n if (funcArray.length !== 0) {\n txConditions.data = funcArray;\n }\n\n return txConditions;\n}\n\nfunction eventFilterToDictionaryCondition(\n filter: EthereumLogFilter,\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): EthDictionaryLogConditions {\n const logConditions: EthDictionaryLogConditions = {};\n logConditions.address = extractOptionAddresses(dsOptions);\n if (filter.topics) {\n for (let i = 0; i < Math.min(filter.topics.length, 4); i++) {\n const topic = filter.topics[i];\n if (!topic) {\n continue;\n }\n const field = `topics${i}`;\n // Initialized\n if (!logConditions[field]) {\n logConditions[field] = [];\n }\n if (topic === '!null') {\n logConditions[field] = []; // TODO, check if !null\n } else {\n logConditions[field].push(eventToTopic(topic));\n }\n }\n }\n return logConditions;\n}\n\nexport function buildDictionaryV2QueryEntry(\n dataSources: GroupedEthereumProjectDs[],\n): EthDictionaryV2QueryEntry {\n const dictionaryConditions: EthDictionaryV2QueryEntry = {\n logs: [],\n transactions: [],\n };\n\n for (const ds of dataSources) {\n for (const handler of ds.mapping.handlers) {\n // No filters, cant use dictionary\n if (!handler.filter) return dictionaryConditions;\n\n switch (handler.kind) {\n case EthereumHandlerKind.Block:\n return dictionaryConditions;\n case EthereumHandlerKind.Call: {\n const filter = handler.filter as EthereumTransactionFilter;\n if (\n filter.from !== undefined ||\n filter.to !== undefined ||\n filter.function !== undefined\n ) {\n dictionaryConditions.transactions.push(\n callFilterToDictionaryCondition(filter, ds.options),\n );\n } else {\n // do nothing;\n }\n break;\n }\n case EthereumHandlerKind.Event: {\n const filter = handler.filter as EthereumLogFilter;\n if (ds.groupedOptions) {\n dictionaryConditions.logs.push(\n eventFilterToDictionaryCondition(filter, ds.groupedOptions),\n );\n } else if (ds.options?.address || filter.topics) {\n dictionaryConditions.logs.push(\n eventFilterToDictionaryCondition(filter, ds.options),\n );\n } else {\n // do nothing;\n }\n break;\n }\n default:\n }\n }\n }\n\n if (!dictionaryConditions.logs.length) {\n delete dictionaryConditions.logs;\n } else {\n dictionaryConditions.logs = uniqBy(dictionaryConditions.logs, (log) =>\n JSON.stringify(log),\n );\n }\n\n if (!dictionaryConditions.transactions.length) {\n delete dictionaryConditions.transactions;\n } else {\n dictionaryConditions.transactions = uniqBy(\n dictionaryConditions.transactions,\n (tx) => JSON.stringify(tx),\n );\n }\n return dictionaryConditions;\n}\n\nexport class EthDictionaryV2 extends DictionaryV2<\n EthereumBlock,\n SubqlDatasource,\n EthDictionaryV2QueryEntry\n> {\n #skipTransactions: boolean;\n\n constructor(\n endpoint: string,\n nodeConfig: NodeConfig,\n project: SubqueryProject,\n private api: EthereumApi,\n ) {\n super(endpoint, project.network.chainId, nodeConfig);\n this.#skipTransactions = !!new EthereumNodeConfig(nodeConfig)\n .skipTransactions;\n }\n\n static async create(\n endpoint: string,\n nodeConfig: NodeConfig,\n project: SubqueryProject,\n api: EthereumApi,\n ): Promise<EthDictionaryV2> {\n const dictionary = new EthDictionaryV2(endpoint, nodeConfig, project, api);\n await dictionary.init();\n return dictionary;\n }\n\n buildDictionaryQueryEntries(\n dataSources: (EthereumProjectDs | EthereumProjectDsTemplate)[],\n ): EthDictionaryV2QueryEntry {\n const filteredDs = ethFilterDs(dataSources);\n return buildDictionaryV2QueryEntry(filteredDs);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getData(\n startBlock: number,\n endBlock: number,\n limit: number = MIN_FETCH_LIMIT,\n ): Promise<DictionaryResponse<IBlock<EthereumBlock> | number> | undefined> {\n return super.getData(startBlock, endBlock, limit, {\n blockHeader: true,\n logs: { transaction: !this.#skipTransactions },\n transactions: { log: true },\n });\n }\n\n convertResponseBlocks<RFB = RawEthBlock>(\n data: RawDictionaryResponseData<RFB>,\n ): DictionaryResponse<IBlock<EthereumBlock>> | undefined {\n try {\n const blocks: IBlock<EthereumBlock>[] = (\n (data.blocks as RawEthBlock[]) || []\n ).map((b) => rawBlockToEthBlock(b, this.api));\n return {\n batchBlocks: blocks,\n lastBufferedHeight: blocks.length\n ? blocks[blocks.length - 1].block.number\n : undefined,\n };\n } catch (e) {\n logger.error(e, `Failed to handle block response}`);\n throw e;\n }\n }\n}\n"]}
@@ -236,6 +236,38 @@ describe('buildDictionaryV2QueryEntry', () => {
236
236
  ],
237
237
  });
238
238
  });
239
+ it('Build filter tx filter', () => {
240
+ const ds = {
241
+ kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
242
+ assets: new Map(),
243
+ options: {
244
+ abi: 'erc20',
245
+ address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
246
+ },
247
+ startBlock: 1,
248
+ mapping: {
249
+ file: '',
250
+ handlers: [
251
+ {
252
+ handler: 'handleTx',
253
+ kind: types_ethereum_1.EthereumHandlerKind.Call,
254
+ filter: {
255
+ function: 'setminimumStakingAmount(uint256 amount)',
256
+ },
257
+ },
258
+ ],
259
+ },
260
+ };
261
+ const result = (0, ethDictionaryV2_1.buildDictionaryV2QueryEntry)([ds]);
262
+ expect(result).toEqual({
263
+ transactions: [
264
+ {
265
+ to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],
266
+ data: ['0x7ef9ea98'],
267
+ },
268
+ ],
269
+ });
270
+ });
239
271
  it('build query entries for multiple ds', () => {
240
272
  const ds = [
241
273
  {
@@ -378,6 +410,7 @@ describe('buildDictionaryV2QueryEntry', () => {
378
410
  transactions: [
379
411
  {
380
412
  from: ['mockaddress'],
413
+ to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],
381
414
  data: ['0x7ef9ea98'],
382
415
  },
383
416
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"ethDictionaryV2.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;AAEnC,gDAK0B;AAC1B,0DAM+B;AAC/B,kEAA0C;AAM1C,gDAAgD;AAChD,oCAAuC;AACvC,uDAG2B;AAE3B,MAAM,kBAAkB,GAAG,+CAA+C,CAAC;AAC3E,MAAM,aAAa,GAAG,0BAA0B,CAAC;AACjD,MAAM,MAAM,GAAwB;IAClC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,mBAAmB;oBAC5B,IAAI,EAAE,oCAAmB,CAAC,IAAI;oBAC9B,MAAM,EAAE;wBACN,QAAQ,EAAE,6CAA6C;qBACxD;iBACF;gBACD;oBACE,OAAO,EAAE,WAAW;oBACpB,IAAI,EAAE,oCAAmB,CAAC,KAAK;oBAC/B,MAAM,EAAE;wBACN,MAAM,EAAE;4BACN,oEAAoE;yBACrE;qBACF;iBACF;aACF;SACF;KACF;CACF,CAAC;AAEF,MAAM,UAAU,GAA8B;IAC5C,IAAI,EAAE,UAAU;IAChB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M,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE;gBACJ;oBACE,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE;wBACP,oEAAoE;qBACrE;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n BlockHeightMap,\n DictionaryResponse,\n IBlock,\n NodeConfig,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlDatasource,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport EventEmitter2 from 'eventemitter2';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport { ethFilterDs } from '../utils';\nimport {\n buildDictionaryV2QueryEntry,\n EthDictionaryV2,\n} from './ethDictionaryV2';\n\nconst DEFAULT_DICTIONARY = 'https://ethereum.node.subquery.network/public';\nconst HTTP_ENDPOINT = 'https://eth.llamarpc.com';\nconst mockDs: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address indexed from, address indexed to, uint256 amount)',\n ],\n },\n },\n ],\n },\n },\n];\n\nconst templateTs: EthereumProjectDsTemplate = {\n name: 'template',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n // address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n // startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n};\n\n// tx to is null\nconst mockDs2: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n },\n];\n\nconst nodeConfig = new NodeConfig({\n subquery: 'eth-starter',\n subqueryName: 'eth-starter',\n dictionaryTimeout: 10,\n networkEndpoint: [HTTP_ENDPOINT],\n networkDictionary: [DEFAULT_DICTIONARY],\n});\n\nfunction makeBlockHeightMap(mockDs: SubqlDatasource[]): BlockHeightMap<any> {\n const m = new Map<number, any>();\n mockDs.forEach((ds, index, dataSources) => {\n m.set(ds.startBlock, dataSources.slice(0, index + 1));\n });\n return new BlockHeightMap(m);\n}\n\n// enable this once dictionary v2 is online\ndescribe('eth dictionary v2', () => {\n let ethDictionaryV2: EthDictionaryV2;\n\n const dsMap = makeBlockHeightMap(mockDs);\n\n beforeAll(async () => {\n ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n { network: { chainId: '1' } } as SubqueryProject,\n new EthereumApi(HTTP_ENDPOINT, 1, new EventEmitter2()),\n );\n }, 10000);\n\n beforeEach(() => {\n ethDictionaryV2.updateQueriesMap(dsMap);\n });\n\n it('converts ds to v2 dictionary queries', () => {\n const query = (ethDictionaryV2 as any).queriesMap.get(19217803);\n expect(query.logs.length).toBe(1);\n expect(query.transactions.length).toBe(1);\n });\n\n it('query response match with entries', async () => {\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n expect(ethBlocks.batchBlocks.map((b) => b.block.number)).toStrictEqual([\n 19217803, 19217804,\n ]);\n\n const ethBlock19217803 = ethBlocks.batchBlocks[0].block;\n const ethBlock19217804 = ethBlocks.batchBlocks[1].block;\n\n expect(ethBlock19217803.number).toBe(19217803);\n expect(ethBlock19217804.number).toBe(19217804);\n\n // Sighash of approval tx\n expect(\n ethBlock19217803.transactions.filter(\n (tx) => tx.input.indexOf('0x095ea7b3') === 0,\n ).length,\n ).toBe(4);\n\n expect(ethBlock19217804.logs.length).toBe(233);\n\n // This matches with dictionaryQueryEntries[0].topics\n expect(ethBlock19217804.logs[0].topics).toContain(\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n );\n }, 10000);\n\n // Geth currently throwing errors with this request\n it.skip('is able to get transaction with field to is null', async () => {\n const dsMap = makeBlockHeightMap(mockDs2);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({ transactions: [{ to: [null] }] });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 1,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, transactions } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toBe(\n '0xa9ba70126240a8418739a103527860948a2be32de2eb9a8f590591faa174c08b',\n );\n\n // https://etherscan.io/tx/0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1\n expect(\n transactions.find(\n (tx) =>\n tx.hash ===\n '0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1',\n ),\n ).toBeDefined();\n });\n\n it('is able to query with not null topics', async () => {\n /**\n * Dictionary v1 supported filtering logs where a topic was null or not null.\n * V2 doesn't yet support this but we should still be able to make a dictionary query that gets relevant logs.\n * It will just include events that will be filtered out later.\n * */\n\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 19476187,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, logs } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toEqual(\n '0xa798861151ed58ad67d80d1cf61dc30e65d003bc958e99a7969a05a67e69e0b2',\n );\n\n const log = logs.find((l) => l.logIndex === 184);\n expect(log).toBeDefined();\n expect(log.transactionHash).toEqual(\n '0x5491f3f4b7ca6cc81f992a17e19bc9bafff408518c643c5a254de44b5a7b6d72',\n );\n\n // Uncomment this when not null filter supported\n // expect(logs.filter(l => !l.topics[3]).length).toEqual(6) // There are 6 events with no topic3\n }, 100000);\n});\n\ndescribe('buildDictionaryV2QueryEntry', () => {\n it('Build filter for !null', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n });\n\n it('build query entries for multiple ds', () => {\n const ds: SubqlRuntimeDatasource[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'EnsRegistry',\n address: '0x314159265dd8dbb310642f98f50c066173c1259b',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n // one duplicate one\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleNewOwnerOldRegistry',\n filter: {\n topics: ['NewOwner(bytes32,bytes32,address)'],\n },\n },\n ],\n },\n },\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'Resolver',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleABIChanged',\n filter: {\n topics: ['ABIChanged(bytes32,uint256)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAddrChanged',\n filter: {\n topics: ['AddrChanged(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleMulticoinAddrChanged',\n filter: {\n topics: ['AddressChanged(bytes32,uint256,bytes)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAuthorisationChanged',\n filter: {\n topics: ['AuthorisationChanged(bytes32,address,address,bool)'],\n },\n },\n ],\n },\n },\n ];\n\n const queryEntry = buildDictionaryV2QueryEntry(ds);\n // Total 7 handlers were given, 1 is duplicate\n expect(queryEntry.logs.length).toBe(6);\n });\n\n it('should unique QueryEntry for duplicate dataSources', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleLogSame',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n {\n handler: 'handleTxSame',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n transactions: [\n {\n from: ['mockaddress'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('should group a small number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 10; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ethFilterDs(ds));\n\n expect(result).toEqual({\n logs: [\n {\n address: [\n '0x0',\n '0x1',\n '0x2',\n '0x3',\n '0x4',\n '0x5',\n '0x6',\n '0x7',\n '0x8',\n '0x9',\n ],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('should remove address filter with large number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 200; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ethFilterDs(ds));\n\n expect(result).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n});\n"]}
1
+ {"version":3,"file":"ethDictionaryV2.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;AAEnC,gDAK0B;AAC1B,0DAM+B;AAC/B,kEAA0C;AAM1C,gDAAgD;AAChD,oCAAuC;AACvC,uDAG2B;AAE3B,MAAM,kBAAkB,GAAG,+CAA+C,CAAC;AAC3E,MAAM,aAAa,GAAG,0BAA0B,CAAC;AACjD,MAAM,MAAM,GAAwB;IAClC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,mBAAmB;oBAC5B,IAAI,EAAE,oCAAmB,CAAC,IAAI;oBAC9B,MAAM,EAAE;wBACN,QAAQ,EAAE,6CAA6C;qBACxD;iBACF;gBACD;oBACE,OAAO,EAAE,WAAW;oBACpB,IAAI,EAAE,oCAAmB,CAAC,KAAK;oBAC/B,MAAM,EAAE;wBACN,MAAM,EAAE;4BACN,oEAAoE;yBACrE;qBACF;iBACF;aACF;S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,IAAA,6CAA2B,EAAC,IAAA,mBAAW,EAAC,EAAE,CAAC,CAAC,CAAC;QAE5D,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE;gBACJ;oBACE,OAAO,EAAE;wBACP,KAAK;wBACL,KAAK;wBACL,KAAK;wBACL,KAAK;wBACL,KAAK;wBACL,KAAK;wBACL,KAAK;wBACL,KAAK;wBACL,KAAK;wBACL,KAAK;qBACN;oBACD,OAAO,EAAE;wBACP,oEAAoE;qBACrE;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,EAAE,GAA6B,EAAE,CAAC;QAExC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC5B,mBAAmB;YACnB,MAAM,GAAG,GAAI,MAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YACxD,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAChD;QAED,MAAM,MAAM,GAAG,IAAA,6CAA2B,EAAC,IAAA,mBAAW,EAAC,EAAE,CAAC,CAAC,CAAC;QAE5D,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE;gBACJ;oBACE,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE;wBACP,oEAAoE;qBACrE;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n BlockHeightMap,\n DictionaryResponse,\n IBlock,\n NodeConfig,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlDatasource,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport EventEmitter2 from 'eventemitter2';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport { ethFilterDs } from '../utils';\nimport {\n buildDictionaryV2QueryEntry,\n EthDictionaryV2,\n} from './ethDictionaryV2';\n\nconst DEFAULT_DICTIONARY = 'https://ethereum.node.subquery.network/public';\nconst HTTP_ENDPOINT = 'https://eth.llamarpc.com';\nconst mockDs: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address indexed from, address indexed to, uint256 amount)',\n ],\n },\n },\n ],\n },\n },\n];\n\nconst templateTs: EthereumProjectDsTemplate = {\n name: 'template',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n // address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n // startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n};\n\n// tx to is null\nconst mockDs2: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n },\n];\n\nconst nodeConfig = new NodeConfig({\n subquery: 'eth-starter',\n subqueryName: 'eth-starter',\n dictionaryTimeout: 10,\n networkEndpoint: [HTTP_ENDPOINT],\n networkDictionary: [DEFAULT_DICTIONARY],\n});\n\nfunction makeBlockHeightMap(mockDs: SubqlDatasource[]): BlockHeightMap<any> {\n const m = new Map<number, any>();\n mockDs.forEach((ds, index, dataSources) => {\n m.set(ds.startBlock, dataSources.slice(0, index + 1));\n });\n return new BlockHeightMap(m);\n}\n\n// enable this once dictionary v2 is online\ndescribe('eth dictionary v2', () => {\n let ethDictionaryV2: EthDictionaryV2;\n\n const dsMap = makeBlockHeightMap(mockDs);\n\n beforeAll(async () => {\n ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n { network: { chainId: '1' } } as SubqueryProject,\n new EthereumApi(HTTP_ENDPOINT, 1, new EventEmitter2()),\n );\n }, 10000);\n\n beforeEach(() => {\n ethDictionaryV2.updateQueriesMap(dsMap);\n });\n\n it('converts ds to v2 dictionary queries', () => {\n const query = (ethDictionaryV2 as any).queriesMap.get(19217803);\n expect(query.logs.length).toBe(1);\n expect(query.transactions.length).toBe(1);\n });\n\n it('query response match with entries', async () => {\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n expect(ethBlocks.batchBlocks.map((b) => b.block.number)).toStrictEqual([\n 19217803, 19217804,\n ]);\n\n const ethBlock19217803 = ethBlocks.batchBlocks[0].block;\n const ethBlock19217804 = ethBlocks.batchBlocks[1].block;\n\n expect(ethBlock19217803.number).toBe(19217803);\n expect(ethBlock19217804.number).toBe(19217804);\n\n // Sighash of approval tx\n expect(\n ethBlock19217803.transactions.filter(\n (tx) => tx.input.indexOf('0x095ea7b3') === 0,\n ).length,\n ).toBe(4);\n\n expect(ethBlock19217804.logs.length).toBe(233);\n\n // This matches with dictionaryQueryEntries[0].topics\n expect(ethBlock19217804.logs[0].topics).toContain(\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n );\n }, 10000);\n\n // Geth currently throwing errors with this request\n it.skip('is able to get transaction with field to is null', async () => {\n const dsMap = makeBlockHeightMap(mockDs2);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({ transactions: [{ to: [null] }] });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 1,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, transactions } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toBe(\n '0xa9ba70126240a8418739a103527860948a2be32de2eb9a8f590591faa174c08b',\n );\n\n // https://etherscan.io/tx/0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1\n expect(\n transactions.find(\n (tx) =>\n tx.hash ===\n '0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1',\n ),\n ).toBeDefined();\n });\n\n it('is able to query with not null topics', async () => {\n /**\n * Dictionary v1 supported filtering logs where a topic was null or not null.\n * V2 doesn't yet support this but we should still be able to make a dictionary query that gets relevant logs.\n * It will just include events that will be filtered out later.\n * */\n\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 19476187,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, logs } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toEqual(\n '0xa798861151ed58ad67d80d1cf61dc30e65d003bc958e99a7969a05a67e69e0b2',\n );\n\n const log = logs.find((l) => l.logIndex === 184);\n expect(log).toBeDefined();\n expect(log.transactionHash).toEqual(\n '0x5491f3f4b7ca6cc81f992a17e19bc9bafff408518c643c5a254de44b5a7b6d72',\n );\n\n // Uncomment this when not null filter supported\n // expect(logs.filter(l => !l.topics[3]).length).toEqual(6) // There are 6 events with no topic3\n }, 100000);\n});\n\ndescribe('buildDictionaryV2QueryEntry', () => {\n it('Build filter for !null', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n });\n\n it('Build filter tx filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('build query entries for multiple ds', () => {\n const ds: SubqlRuntimeDatasource[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'EnsRegistry',\n address: '0x314159265dd8dbb310642f98f50c066173c1259b',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n // one duplicate one\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleNewOwnerOldRegistry',\n filter: {\n topics: ['NewOwner(bytes32,bytes32,address)'],\n },\n },\n ],\n },\n },\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'Resolver',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleABIChanged',\n filter: {\n topics: ['ABIChanged(bytes32,uint256)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAddrChanged',\n filter: {\n topics: ['AddrChanged(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleMulticoinAddrChanged',\n filter: {\n topics: ['AddressChanged(bytes32,uint256,bytes)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAuthorisationChanged',\n filter: {\n topics: ['AuthorisationChanged(bytes32,address,address,bool)'],\n },\n },\n ],\n },\n },\n ];\n\n const queryEntry = buildDictionaryV2QueryEntry(ds);\n // Total 7 handlers were given, 1 is duplicate\n expect(queryEntry.logs.length).toBe(6);\n });\n\n it('should unique QueryEntry for duplicate dataSources', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleLogSame',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n {\n handler: 'handleTxSame',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n transactions: [\n {\n from: ['mockaddress'],\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('should group a small number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 10; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ethFilterDs(ds));\n\n expect(result).toEqual({\n logs: [\n {\n address: [\n '0x0',\n '0x1',\n '0x2',\n '0x3',\n '0x4',\n '0x5',\n '0x6',\n '0x7',\n '0x8',\n '0x9',\n ],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('should remove address filter with large number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 200; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ethFilterDs(ds));\n\n expect(result).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n});\n"]}
@@ -1,9 +1,5 @@
1
- import { EthereumHandlerKind, isCustomDs, SubqlEthereumCustomDataSource, SubqlEthereumDataSource, SubqlDatasourceProcessor } from '@subql/common-ethereum';
1
+ import { isCustomDs, SubqlEthereumCustomDataSource, SubqlEthereumDataSource, SubqlDatasourceProcessor } from '@subql/common-ethereum';
2
2
  import { BaseDsProcessorService } from '@subql/node-core';
3
- import { SecondLayerHandlerProcessor_0_0_0, SecondLayerHandlerProcessor_1_0_0, SubqlCustomDatasource } from '@subql/types-ethereum';
4
- export declare function isSecondLayerHandlerProcessor_0_0_0<K extends EthereumHandlerKind, F, E, DS extends SubqlCustomDatasource = SubqlEthereumCustomDataSource>(processor: SecondLayerHandlerProcessor_0_0_0<K, F, E, DS> | SecondLayerHandlerProcessor_1_0_0<K, F, E, DS>): processor is SecondLayerHandlerProcessor_0_0_0<K, F, E, DS>;
5
- export declare function isSecondLayerHandlerProcessor_1_0_0<K extends EthereumHandlerKind, F, E, DS extends SubqlEthereumCustomDataSource = SubqlEthereumCustomDataSource>(processor: SecondLayerHandlerProcessor_0_0_0<K, F, E, DS> | SecondLayerHandlerProcessor_1_0_0<K, F, E, DS>): processor is SecondLayerHandlerProcessor_1_0_0<K, F, E, DS>;
6
- export declare function asSecondLayerHandlerProcessor_1_0_0<K extends EthereumHandlerKind, F, E, DS extends SubqlEthereumCustomDataSource = SubqlEthereumCustomDataSource>(processor: SecondLayerHandlerProcessor_0_0_0<K, F, E, DS> | SecondLayerHandlerProcessor_1_0_0<K, F, E, DS>): SecondLayerHandlerProcessor_1_0_0<K, F, E, DS>;
7
- export declare class DsProcessorService extends BaseDsProcessorService<SubqlEthereumDataSource, SubqlEthereumCustomDataSource<string>, SubqlDatasourceProcessor<string, unknown>> {
3
+ export declare class DsProcessorService extends BaseDsProcessorService<SubqlEthereumDataSource, SubqlEthereumCustomDataSource<string>, SubqlDatasourceProcessor<string, Record<string, unknown>>> {
8
4
  protected isCustomDs: typeof isCustomDs;
9
5
  }