@subql/node-stellar 3.9.2-0 → 3.10.1-0
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.
- package/CHANGELOG.md +11 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/indexer/blockDispatcher/block-dispatcher.service.d.ts +2 -2
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js +1 -1
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -1
- package/dist/indexer/blockDispatcher/stellar-block-dispatcher.d.ts +2 -1
- package/dist/indexer/blockDispatcher/stellar-block-dispatcher.js.map +1 -1
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.d.ts +2 -1
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -1
- package/dist/indexer/dictionary/index.d.ts +1 -0
- package/dist/indexer/dictionary/index.js +20 -0
- package/dist/indexer/dictionary/index.js.map +1 -0
- package/dist/indexer/dictionary/stellarDictionary.service.d.ts +13 -0
- package/dist/indexer/dictionary/stellarDictionary.service.js +69 -0
- package/dist/indexer/dictionary/stellarDictionary.service.js.map +1 -0
- package/dist/indexer/dictionary/v1/index.d.ts +1 -0
- package/dist/indexer/dictionary/v1/index.js +20 -0
- package/dist/indexer/dictionary/v1/index.js.map +1 -0
- package/dist/indexer/dictionary/v1/stellarDictionaryV1.d.ts +16 -0
- package/dist/indexer/dictionary/v1/stellarDictionaryV1.js +210 -0
- package/dist/indexer/dictionary/v1/stellarDictionaryV1.js.map +1 -0
- package/dist/indexer/{fetch.service.spec.js → dictionary/v1/stellarDictionaryV1.spec.js} +51 -6
- package/dist/indexer/dictionary/v1/stellarDictionaryV1.spec.js.map +1 -0
- package/dist/indexer/dynamic-ds.service.js +3 -2
- package/dist/indexer/dynamic-ds.service.js.map +1 -1
- package/dist/indexer/fetch.module.js +3 -10
- package/dist/indexer/fetch.module.js.map +1 -1
- package/dist/indexer/fetch.service.d.ts +4 -14
- package/dist/indexer/fetch.service.js +5 -192
- package/dist/indexer/fetch.service.js.map +1 -1
- package/dist/indexer/indexer.manager.d.ts +2 -2
- package/dist/indexer/indexer.manager.js +1 -1
- package/dist/indexer/indexer.manager.js.map +1 -1
- package/dist/indexer/unfinalizedBlocks.service.d.ts +0 -2
- package/dist/indexer/unfinalizedBlocks.service.js +4 -20
- package/dist/indexer/unfinalizedBlocks.service.js.map +1 -1
- package/dist/indexer/worker/worker.service.d.ts +3 -3
- package/dist/indexer/worker/worker.service.js.map +1 -1
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.d.ts +2 -2
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js +2 -2
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js.map +1 -1
- package/dist/stellar/api.connection.d.ts +4 -4
- package/dist/stellar/api.connection.js.map +1 -1
- package/dist/stellar/api.service.stellar.d.ts +2 -2
- package/dist/stellar/api.service.stellar.js +0 -1
- package/dist/stellar/api.service.stellar.js.map +1 -1
- package/dist/stellar/api.service.stellar.spec.js +2 -3
- package/dist/stellar/api.service.stellar.spec.js.map +1 -1
- package/dist/stellar/api.stellar.d.ts +3 -2
- package/dist/stellar/api.stellar.js +2 -1
- package/dist/stellar/api.stellar.js.map +1 -1
- package/dist/stellar/api.stellar.spec.js +2 -2
- package/dist/stellar/api.stellar.spec.js.map +1 -1
- package/dist/stellar/utils.stellar.d.ts +4 -1
- package/dist/stellar/utils.stellar.js +16 -1
- package/dist/stellar/utils.stellar.js.map +1 -1
- package/package.json +6 -6
- package/dist/indexer/dictionary.service.d.ts +0 -8
- package/dist/indexer/dictionary.service.js +0 -46
- package/dist/indexer/dictionary.service.js.map +0 -1
- package/dist/indexer/fetch.service.spec.js.map +0 -1
- /package/dist/indexer/{fetch.service.spec.d.ts → dictionary/v1/stellarDictionaryV1.spec.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
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 } from '@subql/node-core';
|
|
3
|
+
import { NodeConfig, SmartBatchService, StoreCacheService, StoreService, IProjectService, BlockDispatcher, ProcessBlockResponse, ApiService, IProjectUpgradeService, PoiSyncService, IBlock } from '@subql/node-core';
|
|
4
4
|
import { StellarBlockWrapper } from '@subql/types-stellar';
|
|
5
5
|
import { StellarProjectDs, SubqueryProject } from '../../configure/SubqueryProject';
|
|
6
6
|
import { DynamicDsService } from '../dynamic-ds.service';
|
|
@@ -12,5 +12,5 @@ export declare class BlockDispatcherService extends BlockDispatcher<StellarBlock
|
|
|
12
12
|
private indexerManager;
|
|
13
13
|
constructor(apiService: ApiService, nodeConfig: NodeConfig, indexerManager: IndexerManager, eventEmitter: EventEmitter2, projectService: IProjectService<StellarProjectDs>, projectUpgradeService: IProjectUpgradeService, smartBatchService: SmartBatchService, storeService: StoreService, storeCacheService: StoreCacheService, poiSyncService: PoiSyncService, project: SubqueryProject, dynamicDsService: DynamicDsService);
|
|
14
14
|
protected getBlockHeight(block: StellarBlockWrapper): number;
|
|
15
|
-
protected indexBlock(block: StellarBlockWrapper): Promise<ProcessBlockResponse>;
|
|
15
|
+
protected indexBlock(block: IBlock<StellarBlockWrapper>): Promise<ProcessBlockResponse>;
|
|
16
16
|
}
|
|
@@ -33,7 +33,7 @@ let BlockDispatcherService = class BlockDispatcherService extends node_core_1.Bl
|
|
|
33
33
|
return block.block.sequence;
|
|
34
34
|
}
|
|
35
35
|
async indexBlock(block) {
|
|
36
|
-
return this.indexerManager.indexBlock(block, await this.projectService.getDataSources(
|
|
36
|
+
return this.indexerManager.indexBlock(block, await this.projectService.getDataSources(block.getHeader().blockHeight));
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
BlockDispatcherService = __decorate([
|
|
@@ -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,
|
|
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;AAE1B,qEAGyC;AACzC,8DAAyD;AACzD,wDAAoD;AAEpD;;GAEG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBACX,SAAQ,2BAAsD;IAG9D,YACE,UAAsB,EACtB,UAAsB,EACd,cAA8B,EACtC,YAA2B,EAE3B,cAAiD,EAEjD,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,cAAc,CAAC,KAA0B;QACjD,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,KAAkC;QAElC,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;AA/CY,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,CA+ClC;AA/CY,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 { StellarBlockWrapper } from '@subql/types-stellar';\nimport {\n StellarProjectDs,\n SubqueryProject,\n} from '../../configure/SubqueryProject';\nimport { DynamicDsService } from '../dynamic-ds.service';\nimport { IndexerManager } from '../indexer.manager';\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<StellarBlockWrapper, StellarProjectDs>\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<StellarProjectDs>,\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 getBlockHeight(block: StellarBlockWrapper): number {\n return block.block.sequence;\n }\n\n protected async indexBlock(\n block: IBlock<StellarBlockWrapper>,\n ): Promise<ProcessBlockResponse> {\n return this.indexerManager.indexBlock(\n block,\n await this.projectService.getDataSources(block.getHeader().blockHeight),\n );\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IBlockDispatcher } from '@subql/node-core';
|
|
2
|
-
|
|
2
|
+
import { StellarBlock } from '@subql/types-stellar';
|
|
3
|
+
export interface IStellarBlockDispatcher extends IBlockDispatcher<StellarBlock> {
|
|
3
4
|
init(onDynamicDsCreated: (height: number) => Promise<void>): Promise<void>;
|
|
4
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stellar-block-dispatcher.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/stellar-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';\n\nexport interface IStellarBlockDispatcher
|
|
1
|
+
{"version":3,"file":"stellar-block-dispatcher.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/stellar-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 { StellarBlock } from '@subql/types-stellar';\n\nexport interface IStellarBlockDispatcher\n extends IBlockDispatcher<StellarBlock> {\n init(onDynamicDsCreated: (height: number) => Promise<void>): Promise<void>;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OnApplicationShutdown } from '@nestjs/common';
|
|
2
2
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
3
3
|
import { NodeConfig, SmartBatchService, StoreService, PoiSyncService, StoreCacheService, IProjectService, WorkerBlockDispatcher, IProjectUpgradeService, ConnectionPoolStateManager, InMemoryCacheService } from '@subql/node-core';
|
|
4
|
+
import { StellarBlockWrapper } from '@subql/types-stellar';
|
|
4
5
|
import { StellarProjectDs, SubqueryProject } from '../../configure/SubqueryProject';
|
|
5
6
|
import { StellarApiConnection } from '../../stellar/api.connection';
|
|
6
7
|
import { DynamicDsService } from '../dynamic-ds.service';
|
|
@@ -9,7 +10,7 @@ import { IIndexerWorker } from '../worker/worker';
|
|
|
9
10
|
type IndexerWorker = IIndexerWorker & {
|
|
10
11
|
terminate: () => Promise<number>;
|
|
11
12
|
};
|
|
12
|
-
export declare class WorkerBlockDispatcherService extends WorkerBlockDispatcher<StellarProjectDs, IndexerWorker> implements OnApplicationShutdown {
|
|
13
|
+
export declare class WorkerBlockDispatcherService extends WorkerBlockDispatcher<StellarProjectDs, IndexerWorker, StellarBlockWrapper> implements OnApplicationShutdown {
|
|
13
14
|
constructor(nodeConfig: NodeConfig, eventEmitter: EventEmitter2, projectService: IProjectService<StellarProjectDs>, projectUpgradeService: IProjectUpgradeService, smartBatchService: SmartBatchService, cacheService: InMemoryCacheService, storeService: StoreService, storeCacheService: StoreCacheService, poiSyncService: PoiSyncService, project: SubqueryProject, dynamicDsService: DynamicDsService, unfinalizedBlocksSevice: UnfinalizedBlocksService, connectionPoolState: ConnectionPoolStateManager<StellarApiConnection>);
|
|
14
15
|
protected fetchBlock(worker: IndexerWorker, height: number): Promise<void>;
|
|
15
16
|
}
|
|
@@ -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,gDAa0B;
|
|
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,gDAa0B;AAE1B,qEAGyC;AAGzC,8DAAyD;AACzD,4EAAwE;AAGxE,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,8BAA8B,CAAC,CAAC;AAOlD,IAAM,4BAA4B,GAAlC,MAAM,4BACX,SAAQ,iCAIP;IAGD,YACE,UAAsB,EACtB,YAA2B,EAE3B,cAAiD,EAEjD,qBAA6C,EAC7C,iBAAoC,EACpC,YAAkC,EAClC,YAA0B,EAC1B,iBAAoC,EACpC,cAA8B,EACF,OAAwB,EACpD,gBAAkC,EAClC,uBAAiD,EACjD,mBAAqE;QAErE,KAAK,CACH,UAAU,EACV,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,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,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACtC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACzB,CAAC;CACF,CAAA;AAhEY,4BAA4B;IADxC,IAAA,mBAAU,GAAE;IAYR,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;GAvBtC,4BAA4B,CAgExC;AAhEY,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 getLogger,\n NodeConfig,\n SmartBatchService,\n StoreService,\n PoiSyncService,\n StoreCacheService,\n IProjectService,\n WorkerBlockDispatcher,\n IProjectUpgradeService,\n ConnectionPoolStateManager,\n createIndexerWorker,\n InMemoryCacheService,\n} from '@subql/node-core';\nimport { StellarBlockWrapper } from '@subql/types-stellar';\nimport {\n StellarProjectDs,\n SubqueryProject,\n} from '../../configure/SubqueryProject';\nimport { StellarApiConnection } from '../../stellar/api.connection';\nimport { StellarBlockWrapped } from '../../stellar/block.stellar';\nimport { DynamicDsService } from '../dynamic-ds.service';\nimport { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';\nimport { IIndexerWorker } from '../worker/worker';\n\nconst logger = getLogger('WorkerBlockDispatcherService');\n\ntype IndexerWorker = IIndexerWorker & {\n terminate: () => Promise<number>;\n};\n\n@Injectable()\nexport class WorkerBlockDispatcherService\n extends WorkerBlockDispatcher<\n StellarProjectDs,\n IndexerWorker,\n StellarBlockWrapper\n >\n implements OnApplicationShutdown\n{\n constructor(\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n @Inject('IProjectService')\n projectService: IProjectService<StellarProjectDs>,\n @Inject('IProjectUpgradeService')\n projectUpgradeService: 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<StellarApiConnection>,\n ) {\n super(\n nodeConfig,\n eventEmitter,\n projectService,\n projectUpgradeService,\n smartBatchService,\n storeService,\n storeCacheService,\n poiSyncService,\n project,\n dynamicDsService,\n () =>\n createIndexerWorker<\n IIndexerWorker,\n StellarApiConnection,\n StellarBlockWrapped,\n StellarProjectDs\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 const start = new Date();\n await worker.fetchBlock(height, null);\n const end = new Date();\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stellarDictionary.service';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./stellarDictionary.service"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/indexer/dictionary/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;AAEnC,8DAA4C","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nexport * from './stellarDictionary.service';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
2
|
+
import { SubqlStellarDataSource } from '@subql/common-stellar';
|
|
3
|
+
import { NodeConfig, DictionaryService } from '@subql/node-core';
|
|
4
|
+
import { StellarBlock } from '@subql/types-stellar';
|
|
5
|
+
import { SubqueryProject } from '../../configure/SubqueryProject';
|
|
6
|
+
import { DsProcessorService } from '../ds-processor.service';
|
|
7
|
+
export declare class StellarDictionaryService extends DictionaryService<SubqlStellarDataSource, StellarBlock> {
|
|
8
|
+
protected project: SubqueryProject;
|
|
9
|
+
protected dsProcessorService: DsProcessorService;
|
|
10
|
+
initDictionaries(): Promise<void>;
|
|
11
|
+
constructor(project: SubqueryProject, nodeConfig: NodeConfig, eventEmitter: EventEmitter2, dsProcessorService: DsProcessorService);
|
|
12
|
+
private getV1Dictionary;
|
|
13
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
5
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
+
};
|
|
10
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
12
|
+
};
|
|
13
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
14
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.StellarDictionaryService = void 0;
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
20
|
+
const common_2 = require("@subql/common");
|
|
21
|
+
const node_core_1 = require("@subql/node-core");
|
|
22
|
+
const SubqueryProject_1 = require("../../configure/SubqueryProject");
|
|
23
|
+
const ds_processor_service_1 = require("../ds-processor.service");
|
|
24
|
+
const v1_1 = require("./v1");
|
|
25
|
+
const logger = (0, node_core_1.getLogger)('StellarDictionary');
|
|
26
|
+
let StellarDictionaryService = class StellarDictionaryService extends node_core_1.DictionaryService {
|
|
27
|
+
async initDictionaries() {
|
|
28
|
+
const dictionariesV1 = [];
|
|
29
|
+
if (!this.project) {
|
|
30
|
+
throw new Error(`Project in Dictionary service not initialized `);
|
|
31
|
+
}
|
|
32
|
+
const registryDictionaries = await this.resolveDictionary(common_2.NETWORK_FAMILY.stellar, this.project.network.chainId, this.nodeConfig.dictionaryRegistry);
|
|
33
|
+
logger.debug(`Dictionary registry endpoints: ${registryDictionaries}`);
|
|
34
|
+
const dictionaryEndpoints = (!Array.isArray(this.project.network.dictionary)
|
|
35
|
+
? !this.project.network.dictionary
|
|
36
|
+
? []
|
|
37
|
+
: [this.project.network.dictionary]
|
|
38
|
+
: this.project.network.dictionary).concat(registryDictionaries);
|
|
39
|
+
for (const endpoint of dictionaryEndpoints) {
|
|
40
|
+
try {
|
|
41
|
+
const dictionaryV1 = await v1_1.StellarDictionaryV1.create(this.project, this.nodeConfig, this.dsProcessorService.getDsProcessor.bind(this), endpoint);
|
|
42
|
+
dictionariesV1.push(dictionaryV1);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
logger.warn(`Dictionary endpoint "${endpoint}" is not a valid dictionary`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
this.init(dictionariesV1);
|
|
49
|
+
}
|
|
50
|
+
constructor(project, nodeConfig, eventEmitter, dsProcessorService) {
|
|
51
|
+
super(project.network.chainId, nodeConfig, eventEmitter);
|
|
52
|
+
this.project = project;
|
|
53
|
+
this.dsProcessorService = dsProcessorService;
|
|
54
|
+
}
|
|
55
|
+
getV1Dictionary() {
|
|
56
|
+
// TODO this needs to be removed once Stellar supports V2 dictionaries
|
|
57
|
+
return this._dictionaries[this._currentDictionaryIndex];
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
StellarDictionaryService = __decorate([
|
|
61
|
+
(0, common_1.Injectable)(),
|
|
62
|
+
__param(0, (0, common_1.Inject)('ISubqueryProject')),
|
|
63
|
+
__metadata("design:paramtypes", [SubqueryProject_1.SubqueryProject,
|
|
64
|
+
node_core_1.NodeConfig,
|
|
65
|
+
event_emitter_1.EventEmitter2,
|
|
66
|
+
ds_processor_service_1.DsProcessorService])
|
|
67
|
+
], StellarDictionaryService);
|
|
68
|
+
exports.StellarDictionaryService = StellarDictionaryService;
|
|
69
|
+
//# sourceMappingURL=stellarDictionary.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stellarDictionary.service.js","sourceRoot":"","sources":["../../../src/indexer/dictionary/stellarDictionary.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,yDAAsD;AACtD,0CAA+C;AAE/C,gDAA4E;AAE5E,qEAAkE;AAClE,kEAA6D;AAC7D,6BAA2C;AAE3C,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,mBAAmB,CAAC,CAAC;AAGvC,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,6BAG7C;IACC,KAAK,CAAC,gBAAgB;QACpB,MAAM,cAAc,GAA0B,EAAE,CAAC;QAEjD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;SACnE;QACD,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,iBAAiB,CACvD,uBAAc,CAAC,OAAO,EACtB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAC5B,IAAI,CAAC,UAAU,CAAC,kBAAkB,CACnC,CAAC;QAEF,MAAM,CAAC,KAAK,CAAC,kCAAkC,oBAAoB,EAAE,CAAC,CAAC;QAEvE,MAAM,mBAAmB,GAAa,CACpC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;YAC7C,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU;gBAChC,CAAC,CAAC,EAAE;gBACJ,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: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { NETWORK_FAMILY } from '@subql/common';\nimport { SubqlStellarDataSource } from '@subql/common-stellar';\nimport { NodeConfig, DictionaryService, getLogger } from '@subql/node-core';\nimport { StellarBlock } from '@subql/types-stellar';\nimport { SubqueryProject } from '../../configure/SubqueryProject';\nimport { DsProcessorService } from '../ds-processor.service';\nimport { StellarDictionaryV1 } from './v1';\n\nconst logger = getLogger('StellarDictionary');\n\n@Injectable()\nexport class StellarDictionaryService extends DictionaryService<\n SubqlStellarDataSource,\n StellarBlock\n> {\n async initDictionaries(): Promise<void> {\n const dictionariesV1: StellarDictionaryV1[] = [];\n\n if (!this.project) {\n throw new Error(`Project in Dictionary service not initialized `);\n }\n const registryDictionaries = await this.resolveDictionary(\n NETWORK_FAMILY.stellar,\n this.project.network.chainId,\n this.nodeConfig.dictionaryRegistry,\n );\n\n logger.debug(`Dictionary registry endpoints: ${registryDictionaries}`);\n\n const dictionaryEndpoints: string[] = (\n !Array.isArray(this.project.network.dictionary)\n ? !this.project.network.dictionary\n ? []\n : [this.project.network.dictionary]\n : this.project.network.dictionary\n ).concat(registryDictionaries);\n\n for (const endpoint of dictionaryEndpoints) {\n try {\n const dictionaryV1 = await StellarDictionaryV1.create(\n this.project,\n this.nodeConfig,\n this.dsProcessorService.getDsProcessor.bind(this),\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 this.init(dictionariesV1);\n }\n\n constructor(\n @Inject('ISubqueryProject') protected project: SubqueryProject,\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n protected dsProcessorService: DsProcessorService,\n ) {\n super(project.network.chainId, nodeConfig, eventEmitter);\n }\n\n private getV1Dictionary(): StellarDictionaryV1 | undefined {\n // TODO this needs to be removed once Stellar supports V2 dictionaries\n return this._dictionaries[\n this._currentDictionaryIndex\n ] as StellarDictionaryV1;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stellarDictionaryV1';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./stellarDictionaryV1"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;AAEnC,wDAAsC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nexport * from './stellarDictionaryV1';\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SubqlStellarDataSource, SubqlStellarProcessorOptions } from '@subql/common-stellar';
|
|
2
|
+
import { NodeConfig, DictionaryV1 } from '@subql/node-core';
|
|
3
|
+
import { DictionaryQueryEntry as DictionaryV1QueryEntry, DsProcessor } from '@subql/types-core';
|
|
4
|
+
import { SubqlDatasource } from '@subql/types-stellar';
|
|
5
|
+
import { SubqueryProject } from '../../../configure/SubqueryProject';
|
|
6
|
+
type GroupedSubqlProjectDs = SubqlDatasource & {
|
|
7
|
+
groupedOptions?: SubqlStellarProcessorOptions[];
|
|
8
|
+
};
|
|
9
|
+
export declare function buildDictionaryQueryEntries(dataSources: GroupedSubqlProjectDs[]): DictionaryV1QueryEntry[];
|
|
10
|
+
export declare class StellarDictionaryV1 extends DictionaryV1<SubqlStellarDataSource> {
|
|
11
|
+
protected getDsProcessor: (ds: SubqlStellarDataSource) => DsProcessor<SubqlStellarDataSource>;
|
|
12
|
+
constructor(project: SubqueryProject, nodeConfig: NodeConfig, getDsProcessor: (ds: SubqlStellarDataSource) => DsProcessor<SubqlStellarDataSource>, dictionaryUrl?: string, chainId?: string);
|
|
13
|
+
static create(project: SubqueryProject, nodeConfig: NodeConfig, getDsProcessor: (ds: SubqlStellarDataSource) => DsProcessor<SubqlStellarDataSource>, dictionaryUrl?: string, chainId?: string): Promise<StellarDictionaryV1>;
|
|
14
|
+
buildDictionaryQueryEntries(dataSources: SubqlStellarDataSource[]): DictionaryV1QueryEntry[];
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.StellarDictionaryV1 = exports.buildDictionaryQueryEntries = void 0;
|
|
6
|
+
const common_stellar_1 = require("@subql/common-stellar");
|
|
7
|
+
const node_core_1 = require("@subql/node-core");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const yargs_1 = require("../../../yargs");
|
|
10
|
+
const logger = (0, node_core_1.getLogger)('dictionary v1');
|
|
11
|
+
function transactionFilterToQueryEntry(filter, dsOptions) {
|
|
12
|
+
const conditions = [];
|
|
13
|
+
if (filter.account) {
|
|
14
|
+
conditions.push({
|
|
15
|
+
field: 'account',
|
|
16
|
+
value: filter.account.toLowerCase(),
|
|
17
|
+
matcher: 'equalTo',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
entity: 'transactions',
|
|
22
|
+
conditions,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function operationFilterToQueryEntry(filter, dsOptions) {
|
|
26
|
+
const conditions = [];
|
|
27
|
+
if (filter.type) {
|
|
28
|
+
conditions.push({
|
|
29
|
+
field: 'type',
|
|
30
|
+
value: filter.type.toLowerCase(),
|
|
31
|
+
matcher: 'equalTo',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (filter.sourceAccount) {
|
|
35
|
+
conditions.push({
|
|
36
|
+
field: 'sourceAccount',
|
|
37
|
+
value: filter.sourceAccount.toLowerCase(),
|
|
38
|
+
matcher: 'equalTo',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
entity: 'operations',
|
|
43
|
+
conditions,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function effectFilterToQueryEntry(filter, dsOptions) {
|
|
47
|
+
const conditions = [];
|
|
48
|
+
if (filter.type) {
|
|
49
|
+
conditions.push({
|
|
50
|
+
field: 'type',
|
|
51
|
+
value: filter.type.toLowerCase(),
|
|
52
|
+
matcher: 'equalTo',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (filter.account) {
|
|
56
|
+
conditions.push({
|
|
57
|
+
field: 'account',
|
|
58
|
+
value: filter.account.toLowerCase(),
|
|
59
|
+
matcher: 'equalTo',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
entity: 'effects',
|
|
64
|
+
conditions,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function eventFilterToQueryEntry(filter, dsOptions) {
|
|
68
|
+
const queryAddressLimit = yargs_1.yargsOptions.argv['query-address-limit'];
|
|
69
|
+
const conditions = [];
|
|
70
|
+
if (Array.isArray(dsOptions)) {
|
|
71
|
+
const addresses = dsOptions.map((option) => option.address).filter(Boolean);
|
|
72
|
+
if (addresses.length > queryAddressLimit) {
|
|
73
|
+
logger.warn(`Addresses length: ${addresses.length} is exceeding limit: ${queryAddressLimit}. Consider increasing this value with the flag --query-address-limit `);
|
|
74
|
+
}
|
|
75
|
+
if (addresses.length !== 0 && addresses.length <= queryAddressLimit) {
|
|
76
|
+
conditions.push({
|
|
77
|
+
field: 'address',
|
|
78
|
+
value: addresses,
|
|
79
|
+
matcher: 'in',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if (dsOptions === null || dsOptions === void 0 ? void 0 : dsOptions.address) {
|
|
85
|
+
conditions.push({
|
|
86
|
+
field: 'address',
|
|
87
|
+
value: dsOptions.address.toLowerCase(),
|
|
88
|
+
matcher: 'equalTo',
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (filter.topics) {
|
|
93
|
+
for (let i = 0; i < Math.min(filter.topics.length, 4); i++) {
|
|
94
|
+
const topic = filter.topics[i];
|
|
95
|
+
if (!topic) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const field = `topics${i}`;
|
|
99
|
+
conditions.push({
|
|
100
|
+
field,
|
|
101
|
+
value: topic,
|
|
102
|
+
matcher: 'equalTo',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
entity: 'events',
|
|
108
|
+
conditions,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function buildDictionaryV1QueryEntries(dataSources) {
|
|
112
|
+
const [normalDataSources, templateDataSources] = (0, lodash_1.partition)(dataSources, (ds) => !ds.name);
|
|
113
|
+
// Group templ
|
|
114
|
+
const groupedDataSources = Object.values((0, lodash_1.groupBy)(templateDataSources, (ds) => ds.name)).map((grouped) => {
|
|
115
|
+
if (grouped.length === 1) {
|
|
116
|
+
return grouped[0];
|
|
117
|
+
}
|
|
118
|
+
const options = grouped.map((ds) => ds.options);
|
|
119
|
+
const ref = grouped[0];
|
|
120
|
+
return Object.assign(Object.assign({}, ref), { groupedOptions: options });
|
|
121
|
+
});
|
|
122
|
+
const filteredDs = [...normalDataSources, ...groupedDataSources];
|
|
123
|
+
return buildDictionaryQueryEntries(filteredDs);
|
|
124
|
+
}
|
|
125
|
+
function buildDictionaryQueryEntries(dataSources) {
|
|
126
|
+
var _a;
|
|
127
|
+
const queryEntries = [];
|
|
128
|
+
for (const ds of dataSources) {
|
|
129
|
+
for (const handler of ds.mapping.handlers) {
|
|
130
|
+
// No filters, cant use dictionary
|
|
131
|
+
if (!handler.filter)
|
|
132
|
+
return [];
|
|
133
|
+
switch (handler.kind) {
|
|
134
|
+
case common_stellar_1.StellarHandlerKind.Block:
|
|
135
|
+
return [];
|
|
136
|
+
case common_stellar_1.StellarHandlerKind.Transaction: {
|
|
137
|
+
const filter = handler.filter;
|
|
138
|
+
if (ds.groupedOptions) {
|
|
139
|
+
queryEntries.push(transactionFilterToQueryEntry(filter, ds.groupedOptions));
|
|
140
|
+
}
|
|
141
|
+
else if (filter.account) {
|
|
142
|
+
queryEntries.push(transactionFilterToQueryEntry(filter, ds.options));
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case common_stellar_1.StellarHandlerKind.Operation: {
|
|
150
|
+
const filter = handler.filter;
|
|
151
|
+
if (ds.groupedOptions) {
|
|
152
|
+
queryEntries.push(operationFilterToQueryEntry(filter, ds.groupedOptions));
|
|
153
|
+
}
|
|
154
|
+
else if (filter.sourceAccount || filter.type) {
|
|
155
|
+
queryEntries.push(operationFilterToQueryEntry(filter, ds.options));
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case common_stellar_1.StellarHandlerKind.Effects: {
|
|
163
|
+
const filter = handler.filter;
|
|
164
|
+
if (ds.groupedOptions) {
|
|
165
|
+
queryEntries.push(effectFilterToQueryEntry(filter, ds.groupedOptions));
|
|
166
|
+
}
|
|
167
|
+
else if (filter.account || filter.type) {
|
|
168
|
+
queryEntries.push(effectFilterToQueryEntry(filter, ds.options));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
case common_stellar_1.StellarHandlerKind.Event: {
|
|
176
|
+
const filter = handler.filter;
|
|
177
|
+
if (ds.groupedOptions) {
|
|
178
|
+
queryEntries.push(eventFilterToQueryEntry(filter, ds.groupedOptions));
|
|
179
|
+
}
|
|
180
|
+
else if (((_a = ds.options) === null || _a === void 0 ? void 0 : _a.address) || filter.topics) {
|
|
181
|
+
queryEntries.push(eventFilterToQueryEntry(filter, ds.options));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
default:
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return (0, lodash_1.uniqBy)(queryEntries, (item) => `${item.entity}|${JSON.stringify((0, lodash_1.sortBy)(item.conditions, (c) => c.field))}`);
|
|
193
|
+
}
|
|
194
|
+
exports.buildDictionaryQueryEntries = buildDictionaryQueryEntries;
|
|
195
|
+
class StellarDictionaryV1 extends node_core_1.DictionaryV1 {
|
|
196
|
+
constructor(project, nodeConfig, getDsProcessor, dictionaryUrl, chainId) {
|
|
197
|
+
super(dictionaryUrl, chainId !== null && chainId !== void 0 ? chainId : project.network.chainId, nodeConfig);
|
|
198
|
+
this.getDsProcessor = getDsProcessor;
|
|
199
|
+
}
|
|
200
|
+
static async create(project, nodeConfig, getDsProcessor, dictionaryUrl, chainId) {
|
|
201
|
+
const dictionary = new StellarDictionaryV1(project, nodeConfig, getDsProcessor, dictionaryUrl, chainId);
|
|
202
|
+
await dictionary.init();
|
|
203
|
+
return dictionary;
|
|
204
|
+
}
|
|
205
|
+
buildDictionaryQueryEntries(dataSources) {
|
|
206
|
+
return buildDictionaryV1QueryEntries(dataSources);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.StellarDictionaryV1 = StellarDictionaryV1;
|
|
210
|
+
//# sourceMappingURL=stellarDictionaryV1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stellarDictionaryV1.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/stellarDictionaryV1.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAEnC,0DAO+B;AAC/B,gDAAuE;AASvE,mCAA4D;AAE5D,0CAA8C;AAE9C,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,eAAe,CAAC,CAAC;AAC1C,SAAS,6BAA6B,CACpC,MAAgC,EAChC,SAAwE;IAExE,MAAM,UAAU,GAA+B,EAAE,CAAC;IAElD,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,UAAU,CAAC,IAAI,CAAC;YACd,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE;YACnC,OAAO,EAAE,SAAS;SACnB,CAAC,CAAC;KACJ;IACD,OAAO;QACL,MAAM,EAAE,cAAc;QACtB,UAAU;KACX,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B,CAClC,MAA8B,EAC9B,SAAwE;IAExE,MAAM,UAAU,GAA+B,EAAE,CAAC;IAElD,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,UA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,EACP,UAAU,EACV,cAAc,EACd,aAAa,EACb,OAAO,CACR,CAAC;QACF,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,2BAA2B,CACzB,WAAqC;QAErC,OAAO,6BAA6B,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACF;AAtCD,kDAsCC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n StellarHandlerKind,\n SubqlStellarDataSource,\n StellarTransactionFilter,\n StellarOperationFilter,\n StellarEffectFilter,\n SubqlStellarProcessorOptions,\n} from '@subql/common-stellar';\nimport { NodeConfig, DictionaryV1, getLogger } from '@subql/node-core';\nimport {\n DictionaryQueryCondition,\n DictionaryQueryEntry,\n DictionaryQueryEntry as DictionaryV1QueryEntry,\n DsProcessor,\n} from '@subql/types-core';\n\nimport { SorobanEventFilter, SubqlDatasource } from '@subql/types-stellar';\nimport { groupBy, partition, sortBy, uniqBy } from 'lodash';\nimport { SubqueryProject } from '../../../configure/SubqueryProject';\nimport { yargsOptions } from '../../../yargs';\n\nconst logger = getLogger('dictionary v1');\nfunction transactionFilterToQueryEntry(\n filter: StellarTransactionFilter,\n dsOptions: SubqlStellarProcessorOptions | SubqlStellarProcessorOptions[],\n): DictionaryQueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n\n if (filter.account) {\n conditions.push({\n field: 'account',\n value: filter.account.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n return {\n entity: 'transactions',\n conditions,\n };\n}\n\nfunction operationFilterToQueryEntry(\n filter: StellarOperationFilter,\n dsOptions: SubqlStellarProcessorOptions | SubqlStellarProcessorOptions[],\n): DictionaryQueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n\n if (filter.type) {\n conditions.push({\n field: 'type',\n value: filter.type.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n if (filter.sourceAccount) {\n conditions.push({\n field: 'sourceAccount',\n value: filter.sourceAccount.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n return {\n entity: 'operations',\n conditions,\n };\n}\n\nfunction effectFilterToQueryEntry(\n filter: StellarEffectFilter,\n dsOptions: SubqlStellarProcessorOptions | SubqlStellarProcessorOptions[],\n): DictionaryQueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n\n if (filter.type) {\n conditions.push({\n field: 'type',\n value: filter.type.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n if (filter.account) {\n conditions.push({\n field: 'account',\n value: filter.account.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n return {\n entity: 'effects',\n conditions,\n };\n}\n\nfunction eventFilterToQueryEntry(\n filter: SorobanEventFilter,\n dsOptions: SubqlStellarProcessorOptions | SubqlStellarProcessorOptions[],\n): DictionaryQueryEntry {\n const queryAddressLimit = yargsOptions.argv['query-address-limit'];\n\n const conditions: DictionaryQueryCondition[] = [];\n\n if (Array.isArray(dsOptions)) {\n const addresses = dsOptions.map((option) => option.address).filter(Boolean);\n\n if (addresses.length > queryAddressLimit) {\n logger.warn(\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 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 conditions.push({\n field,\n value: topic,\n matcher: 'equalTo',\n });\n }\n }\n return {\n entity: 'events',\n conditions,\n };\n}\n\ntype GroupedSubqlProjectDs = SubqlDatasource & {\n groupedOptions?: SubqlStellarProcessorOptions[];\n};\n\nfunction buildDictionaryV1QueryEntries(\n dataSources: (SubqlDatasource & { name?: string })[],\n): DictionaryV1QueryEntry[] {\n const [normalDataSources, templateDataSources] = partition(\n dataSources,\n (ds) => !ds.name,\n );\n\n // Group templ\n const groupedDataSources = Object.values(\n groupBy(templateDataSources, (ds) => ds.name),\n ).map((grouped) => {\n if (grouped.length === 1) {\n return grouped[0];\n }\n const options = grouped.map((ds) => ds.options);\n const ref = grouped[0];\n\n return {\n ...ref,\n groupedOptions: options,\n };\n });\n\n const filteredDs = [...normalDataSources, ...groupedDataSources];\n\n return buildDictionaryQueryEntries(filteredDs);\n}\n\nexport function buildDictionaryQueryEntries(\n dataSources: GroupedSubqlProjectDs[],\n): DictionaryV1QueryEntry[] {\n const queryEntries: DictionaryQueryEntry[] = [];\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 StellarHandlerKind.Block:\n return [];\n case StellarHandlerKind.Transaction: {\n const filter = handler.filter as StellarTransactionFilter;\n if (ds.groupedOptions) {\n queryEntries.push(\n transactionFilterToQueryEntry(filter, ds.groupedOptions),\n );\n } else if (filter.account) {\n queryEntries.push(\n transactionFilterToQueryEntry(filter, ds.options),\n );\n } else {\n return [];\n }\n break;\n }\n case StellarHandlerKind.Operation: {\n const filter = handler.filter as StellarOperationFilter;\n if (ds.groupedOptions) {\n queryEntries.push(\n operationFilterToQueryEntry(filter, ds.groupedOptions),\n );\n } else if (filter.sourceAccount || filter.type) {\n queryEntries.push(operationFilterToQueryEntry(filter, ds.options));\n } else {\n return [];\n }\n break;\n }\n case StellarHandlerKind.Effects: {\n const filter = handler.filter as StellarEffectFilter;\n if (ds.groupedOptions) {\n queryEntries.push(\n effectFilterToQueryEntry(filter, ds.groupedOptions),\n );\n } else if (filter.account || filter.type) {\n queryEntries.push(effectFilterToQueryEntry(filter, ds.options));\n } else {\n return [];\n }\n break;\n }\n case StellarHandlerKind.Event: {\n const filter = handler.filter as SorobanEventFilter;\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 StellarDictionaryV1 extends DictionaryV1<SubqlStellarDataSource> {\n constructor(\n project: SubqueryProject,\n nodeConfig: NodeConfig,\n protected getDsProcessor: (\n ds: SubqlStellarDataSource,\n ) => DsProcessor<SubqlStellarDataSource>,\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 getDsProcessor: (\n ds: SubqlStellarDataSource,\n ) => DsProcessor<SubqlStellarDataSource>,\n dictionaryUrl?: string,\n chainId?: string,\n ): Promise<StellarDictionaryV1> {\n const dictionary = new StellarDictionaryV1(\n project,\n nodeConfig,\n getDsProcessor,\n dictionaryUrl,\n chainId,\n );\n await dictionary.init();\n return dictionary;\n }\n\n buildDictionaryQueryEntries(\n dataSources: SubqlStellarDataSource[],\n ): DictionaryV1QueryEntry[] {\n return buildDictionaryV1QueryEntries(dataSources);\n }\n}\n"]}
|
|
@@ -2,8 +2,20 @@
|
|
|
2
2
|
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
|
|
3
3
|
// SPDX-License-Identifier: GPL-3.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
6
|
+
const common_1 = require("@subql/common");
|
|
7
|
+
const node_core_1 = require("@subql/node-core");
|
|
5
8
|
const types_stellar_1 = require("@subql/types-stellar");
|
|
6
|
-
const
|
|
9
|
+
const stellarDictionaryV1_1 = require("./stellarDictionaryV1");
|
|
10
|
+
const nodeConfig = {
|
|
11
|
+
dictionaryTimeout: 10000,
|
|
12
|
+
dictionaryRegistry: 'https://github.com/subquery/templates/raw/main/dist/dictionary.json',
|
|
13
|
+
};
|
|
14
|
+
const project = {
|
|
15
|
+
network: {
|
|
16
|
+
chainId: 'mainnet',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
7
19
|
describe('buildDictionaryQueryEntries', () => {
|
|
8
20
|
it('should correctly build dictionary query entries for transactions', () => {
|
|
9
21
|
const ds = {
|
|
@@ -22,7 +34,7 @@ describe('buildDictionaryQueryEntries', () => {
|
|
|
22
34
|
],
|
|
23
35
|
},
|
|
24
36
|
};
|
|
25
|
-
const result = (0,
|
|
37
|
+
const result = (0, stellarDictionaryV1_1.buildDictionaryQueryEntries)([ds]);
|
|
26
38
|
expect(result).toEqual([
|
|
27
39
|
{
|
|
28
40
|
entity: 'transactions',
|
|
@@ -54,7 +66,7 @@ describe('buildDictionaryQueryEntries', () => {
|
|
|
54
66
|
],
|
|
55
67
|
},
|
|
56
68
|
};
|
|
57
|
-
const result = (0,
|
|
69
|
+
const result = (0, stellarDictionaryV1_1.buildDictionaryQueryEntries)([ds]);
|
|
58
70
|
expect(result).toEqual([
|
|
59
71
|
{
|
|
60
72
|
entity: 'operations',
|
|
@@ -91,7 +103,7 @@ describe('buildDictionaryQueryEntries', () => {
|
|
|
91
103
|
],
|
|
92
104
|
},
|
|
93
105
|
};
|
|
94
|
-
const result = (0,
|
|
106
|
+
const result = (0, stellarDictionaryV1_1.buildDictionaryQueryEntries)([ds]);
|
|
95
107
|
expect(result).toEqual([
|
|
96
108
|
{
|
|
97
109
|
entity: 'effects',
|
|
@@ -125,8 +137,41 @@ describe('buildDictionaryQueryEntries', () => {
|
|
|
125
137
|
],
|
|
126
138
|
},
|
|
127
139
|
};
|
|
128
|
-
const result = (0,
|
|
140
|
+
const result = (0, stellarDictionaryV1_1.buildDictionaryQueryEntries)([ds]);
|
|
129
141
|
expect(result).toEqual([]);
|
|
130
142
|
});
|
|
131
143
|
});
|
|
132
|
-
|
|
144
|
+
class TestDictionaryService extends node_core_1.DictionaryService {
|
|
145
|
+
async initDictionaries() {
|
|
146
|
+
return Promise.resolve(undefined);
|
|
147
|
+
}
|
|
148
|
+
async getRegistryDictionaries(chainId) {
|
|
149
|
+
return this.resolveDictionary(common_1.NETWORK_FAMILY.near, chainId, this.nodeConfig.dictionaryRegistry);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
describe('dictionary v1', () => {
|
|
153
|
+
let dictionary;
|
|
154
|
+
beforeEach(async () => {
|
|
155
|
+
const testDictionaryService = new TestDictionaryService(project.network.chainId, nodeConfig, new event_emitter_1.EventEmitter2());
|
|
156
|
+
const dictionaryEndpoints = await testDictionaryService.getRegistryDictionaries(project.network.chainId);
|
|
157
|
+
dictionary = await stellarDictionaryV1_1.StellarDictionaryV1.create({
|
|
158
|
+
network: {
|
|
159
|
+
chainId: 'mainnet',
|
|
160
|
+
dictionary: dictionaryEndpoints[1],
|
|
161
|
+
},
|
|
162
|
+
}, { dictionaryTimeout: 10000 }, jest.fn(), dictionaryEndpoints[1]);
|
|
163
|
+
});
|
|
164
|
+
it('successfully validates metatada', () => {
|
|
165
|
+
// start height from metadata
|
|
166
|
+
expect(dictionary.startHeight).toBe(1);
|
|
167
|
+
// further validation
|
|
168
|
+
expect(dictionary.dictionaryValidation({
|
|
169
|
+
lastProcessedHeight: 10000,
|
|
170
|
+
targetHeight: 10000,
|
|
171
|
+
chain: 'mainnet',
|
|
172
|
+
genesisHash: 'EPnLgE7iEq9s7yTkos96M3cWymH5avBAPm3qx3NXqR8H=',
|
|
173
|
+
startHeight: 1,
|
|
174
|
+
}, 1)).toBeTruthy();
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=stellarDictionaryV1.spec.js.map
|