@subql/node-stellar 5.0.2 → 6.0.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.
@@ -54,7 +54,7 @@ let BlockchainService = class BlockchainService {
54
54
  }
55
55
  // eslint-disable-next-line @typescript-eslint/require-await
56
56
  async getChainInterval() {
57
- const CHAIN_INTERVAL = (0, utils_stellar_1.calcInterval)(this.apiService.api) * INTERVAL_PERCENT;
57
+ const CHAIN_INTERVAL = (0, utils_stellar_1.calcInterval)() * INTERVAL_PERCENT;
58
58
  return Math.min(BLOCK_TIME_VARIANCE, CHAIN_INTERVAL);
59
59
  }
60
60
  // Stellar has instant finalizaition and no way to get blocks by hash so the headers should use the block height as the hash and parent hash
@@ -1 +1 @@
1
- {"version":3,"file":"blockchain.service.js","sourceRoot":"","sources":["../src/blockchain.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AAEpD,0DAI+B;AAO/B,wDAO8B;AAC9B,yDAAiD;AACjD,qDAA+C;AAE/C,2CAA+C;AAE/C,uCAA8C;AAE9C,2DAA6E;AAE7E,8DAA8D;AAC9D,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE/D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAGtB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAiBc;IAL1C,gBAAgB,GAAG,kCAAkB,CAAC,KAAK,CAAC;IAC5C,UAAU,GAAG,2BAAU,CAAC;IACxB,WAAW,GAAG,4BAAW,CAAC;IAC1B,cAAc,GAAG,cAAc,CAAC;IAEhC,YAA0C,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAE3E,KAAK,CAAC,WAAW,CACf,SAAmB;QAEnB,OAAO,IAAI,CAAC,UAAU,CAAC,W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,CAAC,CAAC,IAAI,EAAE,CAAC;QAE5E,OAAO,IAAI,IAAI,CACZ,KAAmD,CAAC,SAAS,CAC/D,CAAC;IACJ,CAAC;CACF,CAAA;AAjHY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAkBE,WAAA,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;qCAAqB,2BAAiB;GAjB5D,iBAAiB,CAiH7B","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { Horizon } from '@stellar/stellar-sdk';\nimport {\n isCustomDs,\n isRuntimeDs,\n StellarRuntimeDataSourceImpl,\n} from '@subql/common-stellar';\nimport {\n DatasourceParams,\n Header,\n IBlock,\n IBlockchainService,\n} from '@subql/node-core';\nimport {\n StellarBlockWrapper,\n StellarHandlerKind,\n SubqlCustomDatasource,\n SubqlCustomHandler,\n SubqlDatasource,\n SubqlMapping,\n} from '@subql/types-stellar';\nimport { plainToClass } from 'class-transformer';\nimport { validateSync } from 'class-validator';\nimport { SubqueryProject } from './configure/SubqueryProject';\nimport { getBlockSize } from './indexer/types';\nimport { IIndexerWorker } from './indexer/worker/worker';\nimport { StellarApiService } from './stellar';\nimport SafeStellarProvider from './stellar/safe-api';\nimport { calcInterval, stellarBlockToHeader } from './stellar/utils.stellar';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { version: packageVersion } = require('../package.json');\n\nconst BLOCK_TIME_VARIANCE = 5000;\nconst INTERVAL_PERCENT = 0.9;\n\n@Injectable()\nexport class BlockchainService\n implements\n IBlockchainService<\n SubqlDatasource,\n SubqlCustomDatasource,\n SubqueryProject,\n SafeStellarProvider,\n StellarBlockWrapper, // Update to light block if thats ever supported\n StellarBlockWrapper,\n IIndexerWorker\n >\n{\n blockHandlerKind = StellarHandlerKind.Block;\n isCustomDs = isCustomDs;\n isRuntimeDs = isRuntimeDs;\n packageVersion = packageVersion;\n\n constructor(@Inject('APIService') private apiService: StellarApiService) {}\n\n async fetchBlocks(\n blockNums: number[],\n ): Promise<IBlock<StellarBlockWrapper>[]> {\n return this.apiService.fetchBlocks(blockNums);\n }\n\n async fetchBlockWorker(\n worker: IIndexerWorker,\n blockNum: number,\n context: { workers: IIndexerWorker[] },\n ): Promise<Header> {\n return worker.fetchBlock(blockNum, 0 /* Not used by stellar*/);\n }\n\n getBlockSize(block: IBlock<StellarBlockWrapper>): number {\n return getBlockSize(block.block);\n }\n\n async getFinalizedHeader(): Promise<Header> {\n const block = await this.apiService.api.getFinalizedBlock();\n return stellarBlockToHeader(block);\n }\n\n async getBestHeight(): Promise<number> {\n return this.apiService.api.getBestBlockHeight();\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getChainInterval(): Promise<number> {\n const CHAIN_INTERVAL = calcInterval(this.apiService.api) * INTERVAL_PERCENT;\n\n return Math.min(BLOCK_TIME_VARIANCE, CHAIN_INTERVAL);\n }\n\n // Stellar has instant finalizaition and no way to get blocks by hash so the headers should use the block height as the hash and parent hash\n async getHeaderForHash(hash: string): Promise<Header> {\n return this.getHeaderForHeight(parseInt(hash, 10));\n }\n\n async getHeaderForHeight(height: number): Promise<Header> {\n const res = await this.apiService.api.api.ledgers().ledger(height).call();\n return stellarBlockToHeader(res as any);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async updateDynamicDs(\n params: DatasourceParams,\n dsObj: SubqlDatasource | SubqlCustomDatasource,\n ): Promise<void> {\n if (isCustomDs(dsObj)) {\n dsObj.processor.options = {\n ...dsObj.processor.options,\n ...params.args,\n };\n // await this.dsProcessorService.validateCustomDs([dsObj]);\n } else if (isRuntimeDs(dsObj)) {\n dsObj.options = {\n ...dsObj.options,\n ...params.args,\n };\n\n const parsedDs = plainToClass(StellarRuntimeDataSourceImpl, dsObj);\n\n const errors = validateSync(parsedDs, {\n whitelist: true,\n forbidNonWhitelisted: false,\n });\n if (errors.length) {\n throw new Error(\n `Dynamic ds is invalid\\n${errors\n .map((e) => e.toString())\n .join('\\n')}`,\n );\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getSafeApi(block: StellarBlockWrapper): Promise<SafeStellarProvider> {\n return this.apiService.safeApi(block.block.sequence);\n }\n\n onProjectChange(project: SubqueryProject): void | Promise<void> {\n // TODO update this when implementing skipBlock feature for Stellar\n // this.apiService.updateBlockFetching();\n }\n\n async getBlockTimestamp(height: number): Promise<Date> {\n const block = await this.apiService.api.api.ledgers().ledger(height).call();\n\n return new Date(\n (block as unknown as Horizon.ServerApi.LedgerRecord).closed_at,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"blockchain.service.js","sourceRoot":"","sources":["../src/blockchain.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AAEpD,0DAI+B;AAO/B,wDAO8B;AAC9B,yDAAiD;AACjD,qDAA+C;AAE/C,2CAA+C;AAE/C,uCAA8C;AAE9C,2DAA6E;AAE7E,8DAA8D;AAC9D,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE/D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAGtB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAiBc;IAL1C,gBAAgB,GAAG,kCAAkB,CAAC,KAAK,CAAC;IAC5C,UAAU,GAAG,2BAAU,CAAC;IACxB,WAAW,GAAG,4BAAW,CAAC;IAC1B,cAAc,GAAG,cAAc,CAAC;IAEhC,YAA0C,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAE3E,KAAK,CAAC,WAAW,CACf,SAAmB;QAEnB,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,M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F,CAAA;AAjHY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAkBE,WAAA,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;qCAAqB,2BAAiB;GAjB5D,iBAAiB,CAiH7B","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { Horizon } from '@stellar/stellar-sdk';\nimport {\n isCustomDs,\n isRuntimeDs,\n StellarRuntimeDataSourceImpl,\n} from '@subql/common-stellar';\nimport {\n DatasourceParams,\n Header,\n IBlock,\n IBlockchainService,\n} from '@subql/node-core';\nimport {\n StellarBlockWrapper,\n StellarHandlerKind,\n SubqlCustomDatasource,\n SubqlCustomHandler,\n SubqlDatasource,\n SubqlMapping,\n} from '@subql/types-stellar';\nimport { plainToClass } from 'class-transformer';\nimport { validateSync } from 'class-validator';\nimport { SubqueryProject } from './configure/SubqueryProject';\nimport { getBlockSize } from './indexer/types';\nimport { IIndexerWorker } from './indexer/worker/worker';\nimport { StellarApiService } from './stellar';\nimport SafeStellarProvider from './stellar/safe-api';\nimport { calcInterval, stellarBlockToHeader } from './stellar/utils.stellar';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { version: packageVersion } = require('../package.json');\n\nconst BLOCK_TIME_VARIANCE = 5000;\nconst INTERVAL_PERCENT = 0.9;\n\n@Injectable()\nexport class BlockchainService\n implements\n IBlockchainService<\n SubqlDatasource,\n SubqlCustomDatasource,\n SubqueryProject,\n SafeStellarProvider,\n StellarBlockWrapper, // Update to light block if thats ever supported\n StellarBlockWrapper,\n IIndexerWorker\n >\n{\n blockHandlerKind = StellarHandlerKind.Block;\n isCustomDs = isCustomDs;\n isRuntimeDs = isRuntimeDs;\n packageVersion = packageVersion;\n\n constructor(@Inject('APIService') private apiService: StellarApiService) {}\n\n async fetchBlocks(\n blockNums: number[],\n ): Promise<IBlock<StellarBlockWrapper>[]> {\n return this.apiService.fetchBlocks(blockNums);\n }\n\n async fetchBlockWorker(\n worker: IIndexerWorker,\n blockNum: number,\n context: { workers: IIndexerWorker[] },\n ): Promise<Header> {\n return worker.fetchBlock(blockNum, 0 /* Not used by stellar*/);\n }\n\n getBlockSize(block: IBlock<StellarBlockWrapper>): number {\n return getBlockSize(block.block);\n }\n\n async getFinalizedHeader(): Promise<Header> {\n const block = await this.apiService.api.getFinalizedBlock();\n return stellarBlockToHeader(block);\n }\n\n async getBestHeight(): Promise<number> {\n return this.apiService.api.getBestBlockHeight();\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getChainInterval(): Promise<number> {\n const CHAIN_INTERVAL = calcInterval() * INTERVAL_PERCENT;\n\n return Math.min(BLOCK_TIME_VARIANCE, CHAIN_INTERVAL);\n }\n\n // Stellar has instant finalizaition and no way to get blocks by hash so the headers should use the block height as the hash and parent hash\n async getHeaderForHash(hash: string): Promise<Header> {\n return this.getHeaderForHeight(parseInt(hash, 10));\n }\n\n async getHeaderForHeight(height: number): Promise<Header> {\n const res = await this.apiService.api.api.ledgers().ledger(height).call();\n return stellarBlockToHeader(res as any);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async updateDynamicDs(\n params: DatasourceParams,\n dsObj: SubqlDatasource | SubqlCustomDatasource,\n ): Promise<void> {\n if (isCustomDs(dsObj)) {\n dsObj.processor.options = {\n ...dsObj.processor.options,\n ...params.args,\n };\n // await this.dsProcessorService.validateCustomDs([dsObj]);\n } else if (isRuntimeDs(dsObj)) {\n dsObj.options = {\n ...dsObj.options,\n ...params.args,\n };\n\n const parsedDs = plainToClass(StellarRuntimeDataSourceImpl, dsObj);\n\n const errors = validateSync(parsedDs, {\n whitelist: true,\n forbidNonWhitelisted: false,\n });\n if (errors.length) {\n throw new Error(\n `Dynamic ds is invalid\\n${errors\n .map((e) => e.toString())\n .join('\\n')}`,\n );\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getSafeApi(block: StellarBlockWrapper): Promise<SafeStellarProvider> {\n return this.apiService.safeApi(block.block.sequence);\n }\n\n onProjectChange(project: SubqueryProject): void | Promise<void> {\n // TODO update this when implementing skipBlock feature for Stellar\n // this.apiService.updateBlockFetching();\n }\n\n async getBlockTimestamp(height: number): Promise<Date> {\n const block = await this.apiService.api.api.ledgers().ledger(height).call();\n\n return new Date(\n (block as unknown as Horizon.ServerApi.LedgerRecord).closed_at,\n );\n }\n}\n"]}
@@ -1,14 +1,15 @@
1
1
  import { isCustomDs, isRuntimeDs, SubqlStellarCustomDataSource, StellarHandlerKind, StellarRuntimeHandlerInputMap, SubqlStellarDataSource, isBlockHandlerProcessor, isTransactionHandlerProcessor, isOperationHandlerProcessor, isEffectHandlerProcessor, isEventHandlerProcessor, isSorobanTransactionHandlerProcessor } from '@subql/common-stellar';
2
- import { NodeConfig, IndexerSandbox, ProcessBlockResponse, BaseIndexerManager, ApiService, IBlock, SandboxService, DsProcessorService, DynamicDsService, UnfinalizedBlocksService } from '@subql/node-core';
2
+ import { NodeConfig, IndexerSandbox, ProcessBlockResponse, BaseIndexerManager, IBlock, SandboxService, DsProcessorService, DynamicDsService, UnfinalizedBlocksService } from '@subql/node-core';
3
3
  import { StellarBlockWrapper, SubqlDatasource, StellarTransaction, StellarOperation, StellarEffect, StellarBlock, StellarBlockFilter, StellarTransactionFilter, StellarOperationFilter, StellarEffectFilter, SorobanEvent, SorobanEventFilter } from '@subql/types-stellar';
4
4
  import { BlockchainService } from '../blockchain.service';
5
- import { StellarApi } from '../stellar';
5
+ import { StellarApi, StellarApiService } from '../stellar';
6
6
  import SafeStellarProvider from '../stellar/safe-api';
7
- export declare class IndexerManager extends BaseIndexerManager<StellarApi, SafeStellarProvider | null, StellarBlockWrapper, ApiService, SubqlStellarDataSource, SubqlStellarCustomDataSource, typeof FilterTypeMap, typeof ProcessorTypeMap, StellarRuntimeHandlerInputMap> {
7
+ export declare class IndexerManager extends BaseIndexerManager<StellarApi, SafeStellarProvider | null, StellarBlockWrapper, StellarApiService, SubqlStellarDataSource, SubqlStellarCustomDataSource, typeof FilterTypeMap, typeof ProcessorTypeMap, StellarRuntimeHandlerInputMap> {
8
8
  protected isRuntimeDs: typeof isRuntimeDs;
9
9
  protected isCustomDs: typeof isCustomDs;
10
- constructor(apiService: ApiService, nodeConfig: NodeConfig, sandboxService: SandboxService<SafeStellarProvider | null, StellarApi>, dsProcessorService: DsProcessorService, dynamicDsService: DynamicDsService<SubqlStellarDataSource>, unfinalizedBlocksService: UnfinalizedBlocksService, blockchainService: BlockchainService);
10
+ constructor(apiService: StellarApiService, nodeConfig: NodeConfig, sandboxService: SandboxService<SafeStellarProvider | null, StellarApi>, dsProcessorService: DsProcessorService, dynamicDsService: DynamicDsService<SubqlStellarDataSource>, unfinalizedBlocksService: UnfinalizedBlocksService, blockchainService: BlockchainService);
11
11
  indexBlock(block: IBlock<StellarBlockWrapper>, dataSources: SubqlStellarDataSource[]): Promise<ProcessBlockResponse>;
12
+ protected getDsProcessor(ds: SubqlStellarDataSource, safeApi: SafeStellarProvider): IndexerSandbox;
12
13
  private getApi;
13
14
  protected indexBlockData({ block, transactions }: StellarBlockWrapper, dataSources: SubqlDatasource[], getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>): Promise<void>;
14
15
  private indexBlockContent;
@@ -19,6 +19,7 @@ const common_1 = require("@nestjs/common");
19
19
  const common_stellar_1 = require("@subql/common-stellar");
20
20
  const node_core_1 = require("@subql/node-core");
21
21
  const blockchain_service_1 = require("../blockchain.service");
22
+ const stellar_1 = require("../stellar");
22
23
  const block_stellar_1 = require("../stellar/block.stellar");
23
24
  const logger = (0, node_core_1.getLogger)('indexer');
24
25
  let IndexerManager = class IndexerManager extends node_core_1.BaseIndexerManager {
@@ -30,6 +31,15 @@ let IndexerManager = class IndexerManager extends node_core_1.BaseIndexerManager
30
31
  async indexBlock(block, dataSources) {
31
32
  return super.internalIndexBlock(block, dataSources, () => this.getApi(block.block));
32
33
  }
34
+ getDsProcessor(ds, safeApi) {
35
+ // Expand on the type here to allow for extra injections, we also change the unsafeApi type
36
+ const sandbox = this.sandboxService;
37
+ return sandbox.getDsProcessor(ds, safeApi, this.apiService.unsafeApi.api, {
38
+ unsafeSorobanApi: this.nodeConfig.unsafe
39
+ ? this.apiService.unsafeApi.sorobanClient
40
+ : undefined,
41
+ });
42
+ }
33
43
  // eslint-disable-next-line @typescript-eslint/require-await
34
44
  async getApi(block) {
35
45
  // return this.apiService.safeApi(block.block.sequence);
@@ -94,7 +104,7 @@ exports.IndexerManager = IndexerManager = __decorate([
94
104
  __param(0, (0, common_1.Inject)('APIService')),
95
105
  __param(5, (0, common_1.Inject)('IUnfinalizedBlocksService')),
96
106
  __param(6, (0, common_1.Inject)('IBlockchainService')),
97
- __metadata("design:paramtypes", [node_core_1.ApiService,
107
+ __metadata("design:paramtypes", [stellar_1.StellarApiService,
98
108
  node_core_1.NodeConfig,
99
109
  node_core_1.SandboxService,
100
110
  node_core_1.DsProcessorService,
@@ -1 +1 @@
1
- {"version":3,"file":"indexer.manager.js","sourceRoot":"","sources":["../../src/indexer/indexer.manager.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,0DAa+B;AAC/B,gDAa0B;AAe1B,8DAA0D;AAE1D,4DAA+D;AAG/D,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,SAAS,CAAC,CAAC;AAG7B,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,8BAUnC;IACW,WAAW,GAAG,4BAAW,CAAC;IAC1B,UAAU,GAAG,2BAAU,CAAC;IAElC,YACwB,UAAsB,EAC5C,UAAsB,EACtB,cAAsE,EACtE,kBAAsC,EACtC,gBAA0D,EAE1D,wBAAkD,EACpB,iBAAoC;QAElE,KAAK,CACH,UAAU,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,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H,CAAC,mCAAkB,CAAC,WAAW,CAAC,EAAE,CAChC,IAAwB,EACxB,MAAgC,EAChC,EAA0B,EAC1B,EAAE,CACF,mCAAmB,CAAC,0BAA0B,CAC5C,IAAI,EACJ,MAAM,EACN,EAAE,CAAC,OAAO,EAAE,OAAO,CACpB;IAEH,CAAC,mCAAkB,CAAC,kBAAkB,CAAC,EAAE,CACvC,IAAwB,EACxB,MAAgC,EAChC,EAA0B,EAC1B,EAAE,CACF,mCAAmB,CAAC,0BAA0B,CAC5C,IAAI,EACJ,MAAM,EACN,EAAE,CAAC,OAAO,EAAE,OAAO,CACpB;IAEH,CAAC,mCAAkB,CAAC,SAAS,CAAC,EAAE,CAC9B,IAAsB,EACtB,MAA8B,EAC9B,EAA0B,EAC1B,EAAE,CACF,mCAAmB,CAAC,wBAAwB,CAC1C,IAAI,EACJ,MAAM,EACN,EAAE,CAAC,OAAO,EAAE,OAAO,CACpB;IAEH,CAAC,mCAAkB,CAAC,OAAO,CAAC,EAAE,CAC5B,IAAmB,EACnB,MAA2B,EAC3B,EAA0B,EAC1B,EAAE,CACF,mCAAmB,CAAC,qBAAqB,CACvC,IAAI,EACJ,MAAM,EACN,EAAE,CAAC,OAAO,EAAE,OAAO,CACpB;IAEH,CAAC,mCAAkB,CAAC,KAAK,CAAC,EAAE,CAC1B,IAAkB,EAClB,MAA0B,EAC1B,EAA0B,EAC1B,EAAE,CACF,mCAAmB,CAAC,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;CAC9E,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport {\n isCustomDs,\n isRuntimeDs,\n SubqlStellarCustomDataSource,\n StellarHandlerKind,\n StellarRuntimeHandlerInputMap,\n SubqlStellarDataSource,\n isBlockHandlerProcessor,\n isTransactionHandlerProcessor,\n isOperationHandlerProcessor,\n isEffectHandlerProcessor,\n isEventHandlerProcessor,\n isSorobanTransactionHandlerProcessor,\n} from '@subql/common-stellar';\nimport {\n NodeConfig,\n getLogger,\n profiler,\n IndexerSandbox,\n ProcessBlockResponse,\n BaseIndexerManager,\n ApiService,\n IBlock,\n SandboxService,\n DsProcessorService,\n DynamicDsService,\n UnfinalizedBlocksService,\n} from '@subql/node-core';\nimport {\n StellarBlockWrapper,\n SubqlDatasource,\n StellarTransaction,\n StellarOperation,\n StellarEffect,\n StellarBlock,\n StellarBlockFilter,\n StellarTransactionFilter,\n StellarOperationFilter,\n StellarEffectFilter,\n SorobanEvent,\n SorobanEventFilter,\n} from '@subql/types-stellar';\nimport { BlockchainService } from '../blockchain.service';\nimport { StellarApi } from '../stellar';\nimport { StellarBlockWrapped } from '../stellar/block.stellar';\nimport SafeStellarProvider from '../stellar/safe-api';\n\nconst logger = getLogger('indexer');\n\n@Injectable()\nexport class IndexerManager extends BaseIndexerManager<\n StellarApi,\n SafeStellarProvider | null,\n StellarBlockWrapper,\n ApiService,\n SubqlStellarDataSource,\n SubqlStellarCustomDataSource,\n typeof FilterTypeMap,\n typeof ProcessorTypeMap,\n StellarRuntimeHandlerInputMap\n> {\n protected isRuntimeDs = isRuntimeDs;\n protected isCustomDs = isCustomDs;\n\n constructor(\n @Inject('APIService') apiService: ApiService,\n nodeConfig: NodeConfig,\n sandboxService: SandboxService<SafeStellarProvider | null, StellarApi>,\n dsProcessorService: DsProcessorService,\n dynamicDsService: DynamicDsService<SubqlStellarDataSource>,\n @Inject('IUnfinalizedBlocksService')\n unfinalizedBlocksService: UnfinalizedBlocksService,\n @Inject('IBlockchainService') blockchainService: BlockchainService,\n ) {\n super(\n apiService,\n nodeConfig,\n sandboxService,\n dsProcessorService,\n dynamicDsService,\n unfinalizedBlocksService,\n FilterTypeMap,\n ProcessorTypeMap,\n blockchainService,\n );\n }\n\n @profiler()\n async indexBlock(\n block: IBlock<StellarBlockWrapper>,\n dataSources: SubqlStellarDataSource[],\n ): Promise<ProcessBlockResponse> {\n return super.internalIndexBlock(block, dataSources, () =>\n this.getApi(block.block),\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n private async getApi(\n block: StellarBlockWrapper,\n ): Promise<SafeStellarProvider | null> {\n // return this.apiService.safeApi(block.block.sequence);\n return null;\n }\n\n protected async indexBlockData(\n { block, transactions }: StellarBlockWrapper,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n await this.indexBlockContent(block, dataSources, getVM);\n\n for (const tx of transactions) {\n await this.indexTransaction(tx, dataSources, getVM);\n\n for (const operation of tx.operations) {\n await this.indexOperation(operation, dataSources, getVM);\n\n for (const effect of operation.effects) {\n await this.indexEffect(effect, dataSources, getVM);\n }\n for (const event of operation.events) {\n await this.indexEvent(event, dataSources, getVM);\n }\n }\n }\n }\n\n private async indexBlockContent(\n block: StellarBlock,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(StellarHandlerKind.Block, block, ds, getVM);\n }\n }\n\n private async indexTransaction(\n transaction: StellarTransaction,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(\n StellarHandlerKind.Transaction,\n transaction,\n ds,\n getVM,\n );\n\n if (\n transaction.operations.some(\n (op) => op.type.toString() === 'invoke_host_function',\n )\n ) {\n await this.indexData(\n StellarHandlerKind.SorobanTransaction,\n transaction,\n ds,\n getVM,\n );\n }\n }\n }\n\n private async indexOperation(\n operation: StellarOperation,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(StellarHandlerKind.Operation, operation, ds, getVM);\n }\n }\n\n private async indexEffect(\n effect: StellarEffect,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(StellarHandlerKind.Effects, effect, ds, getVM);\n }\n }\n\n private async indexEvent(\n event: SorobanEvent,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(StellarHandlerKind.Event, event, ds, getVM);\n }\n }\n\n protected async prepareFilteredData<T = any>(\n kind: StellarHandlerKind,\n data: T,\n ds: SubqlDatasource,\n ): Promise<T> {\n return Promise.resolve(data);\n }\n}\n\ntype ProcessorTypeMap = {\n [StellarHandlerKind.Block]: typeof isBlockHandlerProcessor;\n [StellarHandlerKind.Transaction]: typeof isTransactionHandlerProcessor;\n [StellarHandlerKind.SorobanTransaction]: typeof isSorobanTransactionHandlerProcessor;\n [StellarHandlerKind.Operation]: typeof isOperationHandlerProcessor;\n [StellarHandlerKind.Effects]: typeof isEffectHandlerProcessor;\n [StellarHandlerKind.Event]: typeof isEventHandlerProcessor;\n};\n\nconst ProcessorTypeMap = {\n [StellarHandlerKind.Block]: isBlockHandlerProcessor,\n [StellarHandlerKind.Transaction]: isTransactionHandlerProcessor,\n [StellarHandlerKind.SorobanTransaction]: isSorobanTransactionHandlerProcessor,\n [StellarHandlerKind.Operation]: isOperationHandlerProcessor,\n [StellarHandlerKind.Effects]: isEffectHandlerProcessor,\n [StellarHandlerKind.Event]: isEventHandlerProcessor,\n};\n\nconst FilterTypeMap = {\n [StellarHandlerKind.Block]: (\n data: StellarBlock,\n filter: StellarBlockFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterBlocksProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.Transaction]: (\n data: StellarTransaction,\n filter: StellarTransactionFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterTransactionProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.SorobanTransaction]: (\n data: StellarTransaction,\n filter: StellarTransactionFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterTransactionProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.Operation]: (\n data: StellarOperation,\n filter: StellarOperationFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterOperationProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.Effects]: (\n data: StellarEffect,\n filter: StellarEffectFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterEffectProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.Event]: (\n data: SorobanEvent,\n filter: SorobanEventFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterEventProcessor(data, filter, ds.options?.address),\n};\n"]}
1
+ {"version":3,"file":"indexer.manager.js","sourceRoot":"","sources":["../../src/indexer/indexer.manager.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AAEpD,0DAa+B;AAC/B,gDAa0B;AAe1B,8DAA0D;AAC1D,wCAA2D;AAC3D,4DAA+D;AAG/D,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,SAAS,CAAC,CAAC;AAG7B,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,8BAUnC;IACW,WAAW,GAAG,4BAAW,CAAC;IAC1B,UAAU,GAAG,2BAAU,CAAC;IAElC,YACwB,UAA6B,EACnD,UAAsB,EACtB,cAAsE,EACtE,kBAAsC,EACtC,gBAA0D,EAE1D,wBAAkD,EACpB,iBAAoC;QAElE,KAAK,CACH,UAAU,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;IACJ,CAAC;IAGK,AAAN,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oB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;CAC9E,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { Horizon } from '@stellar/stellar-sdk';\nimport {\n isCustomDs,\n isRuntimeDs,\n SubqlStellarCustomDataSource,\n StellarHandlerKind,\n StellarRuntimeHandlerInputMap,\n SubqlStellarDataSource,\n isBlockHandlerProcessor,\n isTransactionHandlerProcessor,\n isOperationHandlerProcessor,\n isEffectHandlerProcessor,\n isEventHandlerProcessor,\n isSorobanTransactionHandlerProcessor,\n} from '@subql/common-stellar';\nimport {\n NodeConfig,\n getLogger,\n profiler,\n IndexerSandbox,\n ProcessBlockResponse,\n BaseIndexerManager,\n ApiService,\n IBlock,\n SandboxService,\n DsProcessorService,\n DynamicDsService,\n UnfinalizedBlocksService,\n} from '@subql/node-core';\nimport {\n StellarBlockWrapper,\n SubqlDatasource,\n StellarTransaction,\n StellarOperation,\n StellarEffect,\n StellarBlock,\n StellarBlockFilter,\n StellarTransactionFilter,\n StellarOperationFilter,\n StellarEffectFilter,\n SorobanEvent,\n SorobanEventFilter,\n} from '@subql/types-stellar';\nimport { BlockchainService } from '../blockchain.service';\nimport { StellarApi, StellarApiService } from '../stellar';\nimport { StellarBlockWrapped } from '../stellar/block.stellar';\nimport SafeStellarProvider from '../stellar/safe-api';\n\nconst logger = getLogger('indexer');\n\n@Injectable()\nexport class IndexerManager extends BaseIndexerManager<\n StellarApi,\n SafeStellarProvider | null,\n StellarBlockWrapper,\n StellarApiService,\n SubqlStellarDataSource,\n SubqlStellarCustomDataSource,\n typeof FilterTypeMap,\n typeof ProcessorTypeMap,\n StellarRuntimeHandlerInputMap\n> {\n protected isRuntimeDs = isRuntimeDs;\n protected isCustomDs = isCustomDs;\n\n constructor(\n @Inject('APIService') apiService: StellarApiService,\n nodeConfig: NodeConfig,\n sandboxService: SandboxService<SafeStellarProvider | null, StellarApi>,\n dsProcessorService: DsProcessorService,\n dynamicDsService: DynamicDsService<SubqlStellarDataSource>,\n @Inject('IUnfinalizedBlocksService')\n unfinalizedBlocksService: UnfinalizedBlocksService,\n @Inject('IBlockchainService') blockchainService: BlockchainService,\n ) {\n super(\n apiService,\n nodeConfig,\n sandboxService,\n dsProcessorService,\n dynamicDsService,\n unfinalizedBlocksService,\n FilterTypeMap,\n ProcessorTypeMap,\n blockchainService,\n );\n }\n\n @profiler()\n async indexBlock(\n block: IBlock<StellarBlockWrapper>,\n dataSources: SubqlStellarDataSource[],\n ): Promise<ProcessBlockResponse> {\n return super.internalIndexBlock(block, dataSources, () =>\n this.getApi(block.block),\n );\n }\n\n protected getDsProcessor(\n ds: SubqlStellarDataSource,\n safeApi: SafeStellarProvider,\n ): IndexerSandbox {\n // Expand on the type here to allow for extra injections, we also change the unsafeApi type\n const sandbox = this.sandboxService as unknown as SandboxService<\n SafeStellarProvider | null,\n Horizon.Server\n >;\n return sandbox.getDsProcessor(ds, safeApi, this.apiService.unsafeApi.api, {\n unsafeSorobanApi: this.nodeConfig.unsafe\n ? this.apiService.unsafeApi.sorobanClient\n : undefined,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n private async getApi(\n block: StellarBlockWrapper,\n ): Promise<SafeStellarProvider | null> {\n // return this.apiService.safeApi(block.block.sequence);\n return null;\n }\n\n protected async indexBlockData(\n { block, transactions }: StellarBlockWrapper,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n await this.indexBlockContent(block, dataSources, getVM);\n\n for (const tx of transactions) {\n await this.indexTransaction(tx, dataSources, getVM);\n\n for (const operation of tx.operations) {\n await this.indexOperation(operation, dataSources, getVM);\n\n for (const effect of operation.effects) {\n await this.indexEffect(effect, dataSources, getVM);\n }\n for (const event of operation.events) {\n await this.indexEvent(event, dataSources, getVM);\n }\n }\n }\n }\n\n private async indexBlockContent(\n block: StellarBlock,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(StellarHandlerKind.Block, block, ds, getVM);\n }\n }\n\n private async indexTransaction(\n transaction: StellarTransaction,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(\n StellarHandlerKind.Transaction,\n transaction,\n ds,\n getVM,\n );\n\n if (\n transaction.operations.some(\n (op) => op.type.toString() === 'invoke_host_function',\n )\n ) {\n await this.indexData(\n StellarHandlerKind.SorobanTransaction,\n transaction,\n ds,\n getVM,\n );\n }\n }\n }\n\n private async indexOperation(\n operation: StellarOperation,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(StellarHandlerKind.Operation, operation, ds, getVM);\n }\n }\n\n private async indexEffect(\n effect: StellarEffect,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(StellarHandlerKind.Effects, effect, ds, getVM);\n }\n }\n\n private async indexEvent(\n event: SorobanEvent,\n dataSources: SubqlDatasource[],\n getVM: (d: SubqlDatasource) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(StellarHandlerKind.Event, event, ds, getVM);\n }\n }\n\n protected async prepareFilteredData<T = any>(\n kind: StellarHandlerKind,\n data: T,\n ds: SubqlDatasource,\n ): Promise<T> {\n return Promise.resolve(data);\n }\n}\n\ntype ProcessorTypeMap = {\n [StellarHandlerKind.Block]: typeof isBlockHandlerProcessor;\n [StellarHandlerKind.Transaction]: typeof isTransactionHandlerProcessor;\n [StellarHandlerKind.SorobanTransaction]: typeof isSorobanTransactionHandlerProcessor;\n [StellarHandlerKind.Operation]: typeof isOperationHandlerProcessor;\n [StellarHandlerKind.Effects]: typeof isEffectHandlerProcessor;\n [StellarHandlerKind.Event]: typeof isEventHandlerProcessor;\n};\n\nconst ProcessorTypeMap = {\n [StellarHandlerKind.Block]: isBlockHandlerProcessor,\n [StellarHandlerKind.Transaction]: isTransactionHandlerProcessor,\n [StellarHandlerKind.SorobanTransaction]: isSorobanTransactionHandlerProcessor,\n [StellarHandlerKind.Operation]: isOperationHandlerProcessor,\n [StellarHandlerKind.Effects]: isEffectHandlerProcessor,\n [StellarHandlerKind.Event]: isEventHandlerProcessor,\n};\n\nconst FilterTypeMap = {\n [StellarHandlerKind.Block]: (\n data: StellarBlock,\n filter: StellarBlockFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterBlocksProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.Transaction]: (\n data: StellarTransaction,\n filter: StellarTransactionFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterTransactionProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.SorobanTransaction]: (\n data: StellarTransaction,\n filter: StellarTransactionFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterTransactionProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.Operation]: (\n data: StellarOperation,\n filter: StellarOperationFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterOperationProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.Effects]: (\n data: StellarEffect,\n filter: StellarEffectFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterEffectProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n\n [StellarHandlerKind.Event]: (\n data: SorobanEvent,\n filter: SorobanEventFilter,\n ds: SubqlStellarDataSource,\n ) =>\n StellarBlockWrapped.filterEventProcessor(data, filter, ds.options?.address),\n};\n"]}
@@ -1,9 +1,9 @@
1
1
  import { Horizon } from '@stellar/stellar-sdk';
2
2
  import { IBlock } from '@subql/node-core';
3
- import { ApiWrapper, SorobanEvent, StellarBlockWrapper, IStellarEndpointConfig } from '@subql/types-stellar';
3
+ import { SorobanEvent, StellarBlockWrapper, IStellarEndpointConfig } from '@subql/types-stellar';
4
4
  import SafeStellarProvider from './safe-api';
5
5
  import { SorobanServer } from './soroban.server';
6
- export declare class StellarApi implements ApiWrapper {
6
+ export declare class StellarApi {
7
7
  private endpoint;
8
8
  private _sorobanClient?;
9
9
  private stellarClient;
@@ -17,7 +17,6 @@ const logger = (0, node_core_1.getLogger)('api.Stellar');
17
17
  class StellarApi {
18
18
  endpoint;
19
19
  _sorobanClient;
20
- //private client: Server;
21
20
  stellarClient;
22
21
  chainId;
23
22
  pageLimit = utils_stellar_1.DEFAULT_PAGE_SIZE;
@@ -1 +1 @@
1
- {"version":3,"file":"api.stellar.js","sourceRoot":"","sources":["../../src/stellar/api.stellar.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;AAEnC,oDAA4B;AAE5B,gDAAqD;AAWrD,mCAAmC;AACnC,4DAA+D;AAC/D,0DAA6C;AAE7C,qDAAiD;AACjD,mDAAqE;AAErE,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,aAAa,CAAC,CAAC;AAExC,MAAa,UAAU;IAQX;IACA;IARV,yBAAyB;IACjB,aAAa,CAAgB;IAE7B,OAAO,CAAU;IACjB,SAAS,GAAG,iCAAiB,CAAC;IAEtC,YACU,QAAgB,EAChB,cAA8B,EACtC,MAA+B;QAFvB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,mBAAc,GAAd,cAAc,CAAgB;QAGtC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpE,IAAI,CAAC,SAAS,GAAG,MAAM,EAAE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ACb,aAAa,CAAC,YAAY,EAC1B,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,OAAO,EACrB,aAAa,CAAC,MAAM,CACrB,CAAC;QAEF,OAAO,IAAA,+BAAe,EAAC,qBAAqB,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,WAAW,CACf,YAAsB;QAEtB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,YAAY,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAClE,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,UAAU,CAAC,WAAmB;QAC5B,8BAA8B;QAC9B,OAAO,IAAI,kBAAmB,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,OAAO;QACX,MAAM,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,UAAU;QACd,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,WAAW,CAAC,CAAQ,EAAE,MAAc;QAClC,IAAI,CAAC,CAAC,OAAO,KAAK,+BAA+B,EAAE,CAAC;YAClD,OAAO,IAAI,KAAK,CAAC,+BAA+B,MAAM;;;;kFAIsB,CAAC,CAAC;QAChF,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA9YD,gCA8YC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport assert from 'assert';\nimport { Horizon } from '@stellar/stellar-sdk';\nimport { getLogger, IBlock } from '@subql/node-core';\nimport {\n ApiWrapper,\n SorobanEvent,\n StellarBlock,\n StellarBlockWrapper,\n StellarEffect,\n StellarOperation,\n StellarTransaction,\n IStellarEndpointConfig,\n} from '@subql/types-stellar';\nimport { cloneDeep } from 'lodash';\nimport { StellarBlockWrapped } from '../stellar/block.stellar';\nimport SafeStellarProvider from './safe-api';\nimport { SorobanServer } from './soroban.server';\nimport { StellarServer } from './stellar.server';\nimport { DEFAULT_PAGE_SIZE, formatBlockUtil } from './utils.stellar';\n\nconst logger = getLogger('api.Stellar');\n\nexport class StellarApi implements ApiWrapper {\n //private client: Server;\n private stellarClient: StellarServer;\n\n private chainId?: string;\n private pageLimit = DEFAULT_PAGE_SIZE;\n\n constructor(\n private endpoint: string,\n private _sorobanClient?: SorobanServer,\n config?: IStellarEndpointConfig,\n ) {\n const { hostname, protocol, searchParams } = new URL(this.endpoint);\n this.pageLimit = config?.pageLimit || this.pageLimit;\n\n const protocolStr = protocol.replace(':', '');\n\n logger.info(\n `Api host: ${hostname}, method: ${protocolStr}, pageLimit: ${this.pageLimit}`,\n );\n if (protocolStr === 'https' || protocolStr === 'http') {\n const options: Horizon.Server.Options = {\n allowHttp: protocolStr === 'http',\n headers: {\n ...config?.headers,\n },\n };\n\n this.stellarClient = new StellarServer(endpoint, options);\n } else {\n throw new Error(`Unsupported protocol: ${protocol}`);\n }\n }\n\n async init(): Promise<void> {\n //need archive node for genesis hash\n //const genesisLedger = (await this.stellarClient.ledgers().ledger(1).call()).records[0];\n this.chainId = (await this.stellarClient.getNetwork()).network_passphrase;\n //this.genesisHash = genesisLedger.hash;\n }\n\n get sorobanClient(): SorobanServer {\n assert(this._sorobanClient, 'Soraban client is not initialized');\n return this._sorobanClient;\n }\n\n async getFinalizedBlock(): Promise<Horizon.ServerApi.LedgerRecord> {\n return (await this.stellarClient.ledgers().order('desc').call()).records[0];\n }\n\n async getFinalizedBlockHeight(): Promise<number> {\n return (await this.getFinalizedBlock()).sequence;\n }\n\n async getBestBlockHeight(): Promise<number> {\n return (await this.getFinalizedBlockHeight()) + 1;\n }\n\n getRuntimeChain(): string {\n assert(this.chainId, 'Api has not been initialised');\n return this.chainId;\n }\n\n getChainId(): string {\n assert(this.chainId, 'Api has not been initialised');\n return this.chainId;\n }\n\n getGenesisHash(): string {\n assert(this.chainId, 'Api has not been initialised');\n return this.chainId;\n }\n\n getSpecName(): string {\n return 'Stellar';\n }\n\n private async fetchTransactionsForLedger(\n sequence: number,\n ): Promise<Horizon.ServerApi.TransactionRecord[]> {\n const txs: Horizon.ServerApi.TransactionRecord[] = [];\n let txsPage = await this.api\n .transactions()\n .forLedger(sequence)\n .limit(this.pageLimit)\n .call();\n while (txsPage.records.length !== 0) {\n txs.push(...txsPage.records);\n txsPage = await txsPage.next();\n }\n\n return txs;\n }\n\n private async fetchOperationsForLedger(\n sequence: number,\n ): Promise<Horizon.ServerApi.OperationRecord[]> {\n const operations: Horizon.ServerApi.OperationRecord[] = [];\n let operationsPage = await this.api\n .operations()\n .forLedger(sequence)\n .limit(this.pageLimit)\n .call();\n while (operationsPage.records.length !== 0) {\n operations.push(...operationsPage.records);\n operationsPage = await operationsPage.next();\n }\n\n return operations;\n }\n\n private async fetchEffectsForLedger(\n sequence: number,\n ): Promise<Horizon.ServerApi.EffectRecord[]> {\n const effects: Horizon.ServerApi.EffectRecord[] = [];\n\n let effectsPage = await this.api\n .effects()\n .forLedger(sequence)\n .limit(this.pageLimit)\n .call();\n while (effectsPage.records.length !== 0) {\n effects.push(...effectsPage.records);\n effectsPage = await effectsPage.next();\n }\n\n return effects;\n }\n\n async getAndWrapEvents(height: number): Promise<SorobanEvent[]> {\n const { events: events } = await this.sorobanClient.getEvents({\n startLedger: height,\n filters: [],\n limit: this.pageLimit,\n });\n return events.map((event) => {\n const wrappedEvent = {\n ...event,\n ledger: null,\n transaction: null,\n operation: null,\n } as SorobanEvent;\n\n return wrappedEvent;\n });\n }\n\n private wrapEffect(effect: Horizon.ServerApi.EffectRecord): StellarEffect {\n return {\n ...effect,\n ledger: null,\n transaction: null,\n operation: null,\n };\n }\n\n private wrapOperationsForTx(\n operations: Horizon.ServerApi.OperationRecord[],\n effectsForSequence: Record<string, Horizon.ServerApi.EffectRecord[]>,\n events: SorobanEvent[],\n ): StellarOperation[] {\n // If there are soroban events then there should only be a single operation.\n // This check is here in case there are furture changes to the network.\n assert(\n events.length > 0 ? operations.length === 1 : true,\n 'Unable to assign events to multiple operations',\n );\n\n return operations.map((op, index) => {\n const effects = (effectsForSequence[op.id] ?? []).map(\n this.wrapEffect.bind(this),\n );\n // const effects = this.wrapEffectsForOperation(index, effectsForSequence);\n\n const wrappedOp: StellarOperation = {\n ...op,\n ledger: null,\n transaction: null,\n effects: [],\n events,\n };\n\n const clonedOp = cloneDeep(wrappedOp);\n\n effects.forEach((effect) => {\n effect.operation = clonedOp;\n wrappedOp.effects.push(effect);\n });\n\n return wrappedOp;\n });\n }\n\n private wrapTransactionsForLedger(\n transactions: Horizon.ServerApi.TransactionRecord[],\n operationsForSequence: Horizon.ServerApi.OperationRecord[],\n effectsForSequence: Horizon.ServerApi.EffectRecord[],\n eventsForSequence: SorobanEvent[],\n ): StellarTransaction[] {\n return transactions.map((tx) => {\n const wrappedTx: StellarTransaction = {\n ...tx,\n ledger: null,\n operations: [] as StellarOperation[],\n effects: [] as StellarEffect[],\n events: [] as SorobanEvent[],\n };\n\n // Effects grouped by the operation id\n const groupedEffects = effectsForSequence.reduce((acc, item) => {\n // BigInt conversion is for stripping leading 0s\n const key = BigInt(item.id.split('-')[0]).toString();\n acc[key] ??= [];\n acc[key].push(item);\n\n return acc;\n }, {} as Record<string, Horizon.ServerApi.EffectRecord[]>);\n\n // Operations grouped by the transaction hash\n const groupedOperations = operationsForSequence.reduce((acc, item) => {\n acc[item.transaction_hash] ??= [];\n acc[item.transaction_hash].push(item);\n\n return acc;\n }, {} as Record<string, Horizon.ServerApi.OperationRecord[]>);\n\n // Events grouped by the transaction hash\n const groupedEvents = eventsForSequence.reduce((acc, item) => {\n acc[item.txHash] ??= [];\n acc[item.txHash].push(item);\n\n return acc;\n }, {} as Record<string, SorobanEvent[]>);\n\n const clonedTx = cloneDeep(wrappedTx);\n const operations = this.wrapOperationsForTx(\n // TODO, this include other attribute from HorizonApi.TransactionResponse, but type assertion incorrect\n // TransactionRecord extends Omit<HorizonApi.TransactionResponse, \"created_at\">\n groupedOperations[tx.hash] ?? [],\n groupedEffects,\n groupedEvents[tx.hash] ?? [],\n ).map((op) => {\n op.transaction = clonedTx;\n op.effects = op.effects.map((effect) => {\n effect.transaction = clonedTx;\n return effect;\n });\n op.events = op.events.map((event) => {\n event.transaction = clonedTx;\n return event;\n });\n return op;\n });\n\n wrappedTx.operations.push(...operations);\n operations.forEach((op) => {\n wrappedTx.effects.push(...op.effects);\n wrappedTx.events.push(...op.events);\n });\n\n return wrappedTx;\n });\n }\n\n private async fetchAndWrapLedger(\n sequence: number,\n ): Promise<IBlock<StellarBlockWrapper>> {\n const [ledger, transactions, operations, effects] = await Promise.all([\n this.api.ledgers().ledger(sequence).call(),\n this.fetchTransactionsForLedger(sequence),\n this.fetchOperationsForLedger(sequence),\n this.fetchEffectsForLedger(sequence),\n ]);\n\n let eventsForSequence: SorobanEvent[] = [];\n\n //check if there is InvokeHostFunctionOp operation\n //If yes then, there are soroban transactions and we should we fetch soroban events\n const hasInvokeHostFunctionOp = operations.some(\n (op) => op.type.toString() === 'invoke_host_function',\n );\n\n if (this.sorobanClient && hasInvokeHostFunctionOp) {\n try {\n eventsForSequence = await this.getAndWrapEvents(sequence);\n } catch (e: any) {\n if (e.message === 'start is after newest ledger') {\n const latestLedger = (await this.sorobanClient.getLatestLedger())\n .sequence;\n throw new Error(`The requested events for ledger number ${sequence} is not available on the current soroban node.\n This is because you're trying to access a ledger that is after the latest ledger number ${latestLedger} stored in this node.\n To resolve this issue, please check you endpoint node start height`);\n }\n\n if (e.message === 'start is before oldest ledger') {\n throw new Error(`The requested events for ledger number ${sequence} is not available on the current soroban node.\n This is because you're trying to access a ledger that is older than the oldest ledger stored in this node.\n To resolve this issue, you can either:\n 1. Increase the start ledger to a more recent one, or\n 2. Connect to a different node that might have a longer history of ledgers.`);\n }\n\n throw e;\n }\n }\n\n const wrappedLedger: StellarBlock = {\n ...(ledger as unknown as Horizon.ServerApi.LedgerRecord),\n transactions: [] as StellarTransaction[],\n operations: [] as StellarOperation[],\n effects: [] as StellarEffect[],\n events: eventsForSequence,\n };\n\n const wrapperTxs = this.wrapTransactionsForLedger(\n transactions,\n operations,\n effects,\n eventsForSequence,\n );\n\n const clonedLedger = cloneDeep(wrappedLedger);\n\n wrapperTxs.forEach((tx) => {\n tx.ledger = clonedLedger;\n tx.operations = tx.operations.map((op) => {\n op.ledger = clonedLedger;\n op.effects = op.effects.map((effect) => {\n effect.ledger = clonedLedger;\n return effect;\n });\n op.events = op.events.map((event) => {\n event.ledger = clonedLedger;\n return event;\n });\n return op;\n });\n\n wrappedLedger.transactions.push(tx);\n wrappedLedger.operations.push(...tx.operations);\n\n tx.operations.forEach((op) => {\n wrappedLedger.effects.push(...op.effects);\n });\n });\n\n const wrappedLedgerInstance = new StellarBlockWrapped(\n wrappedLedger,\n wrappedLedger.transactions,\n wrappedLedger.operations,\n wrappedLedger.effects,\n wrappedLedger.events,\n );\n\n return formatBlockUtil(wrappedLedgerInstance);\n }\n\n async fetchBlocks(\n bufferBlocks: number[],\n ): Promise<IBlock<StellarBlockWrapper>[]> {\n const ledgers = await Promise.all(\n bufferBlocks.map((sequence) => this.fetchAndWrapLedger(sequence)),\n );\n return ledgers;\n }\n\n get api(): Horizon.Server {\n return this.stellarClient;\n }\n\n getSafeApi(blockHeight: number): SafeStellarProvider {\n //safe api not implemented yet\n return new SafeStellarProvider(this.sorobanClient, blockHeight);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async connect(): Promise<void> {\n logger.error('Stellar API connect is not implemented');\n throw new Error('Not implemented');\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async disconnect(): Promise<void> {\n logger.error('Stellar API disconnect is not implemented');\n throw new Error('Not implemented');\n }\n\n handleError(e: Error, height: number): Error {\n if (e.message === 'start is before oldest ledger') {\n return new Error(`The requested ledger number ${height} is not available on the current blockchain node.\n This is because you're trying to access a ledger that is older than the oldest ledger stored in this node.\n To resolve this issue, you can either:\n 1. Increase the start ledger to a more recent one, or\n 2. Connect to a different node that might have a longer history of ledgers.`);\n }\n\n return e;\n }\n}\n"]}
1
+ {"version":3,"file":"api.stellar.js","sourceRoot":"","sources":["../../src/stellar/api.stellar.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;AAEnC,oDAA4B;AAE5B,gDAAqD;AAUrD,mCAAmC;AACnC,4DAA+D;AAC/D,0DAA6C;AAE7C,qDAAiD;AACjD,mDAAqE;AAErE,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,aAAa,CAAC,CAAC;AAExC,MAAa,UAAU;IAOX;IACA;IAPF,aAAa,CAAgB;IAE7B,OAAO,CAAU;IACjB,SAAS,GAAG,iCAAiB,CAAC;IAEtC,YACU,QAAgB,EAChB,cAA8B,EACtC,MAA+B;QAFvB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,mBAAc,GAAd,cAAc,CAAgB;QAGtC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpE,IAAI,CAAC,SAAS,GAAG,MAAM,EAAE,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QAErD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAE9C,MAAM,CAAC,IAAI,CACT,aAAa,QAAQ,aAAa,WAAW,gBAAgB,IAAI,CAAC,SAAS,EAAE,CAC9E,CAAC;QACF,IAAI,WAAW,KAAK,OAAO,IAAI,WAAW,KAAK,MAAM,EAAE,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AG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAClE,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,UAAU,CAAC,WAAmB;QAC5B,8BAA8B;QAC9B,OAAO,IAAI,kBAAmB,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,OAAO;QACX,MAAM,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,UAAU;QACd,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,WAAW,CAAC,CAAQ,EAAE,MAAc;QAClC,IAAI,CAAC,CAAC,OAAO,KAAK,+BAA+B,EAAE,CAAC;YAClD,OAAO,IAAI,KAAK,CAAC,+BAA+B,MAAM;;;;kFAIsB,CAAC,CAAC;QAChF,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA7YD,gCA6YC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport assert from 'assert';\nimport { Horizon } from '@stellar/stellar-sdk';\nimport { getLogger, IBlock } from '@subql/node-core';\nimport {\n SorobanEvent,\n StellarBlock,\n StellarBlockWrapper,\n StellarEffect,\n StellarOperation,\n StellarTransaction,\n IStellarEndpointConfig,\n} from '@subql/types-stellar';\nimport { cloneDeep } from 'lodash';\nimport { StellarBlockWrapped } from '../stellar/block.stellar';\nimport SafeStellarProvider from './safe-api';\nimport { SorobanServer } from './soroban.server';\nimport { StellarServer } from './stellar.server';\nimport { DEFAULT_PAGE_SIZE, formatBlockUtil } from './utils.stellar';\n\nconst logger = getLogger('api.Stellar');\n\nexport class StellarApi {\n private stellarClient: StellarServer;\n\n private chainId?: string;\n private pageLimit = DEFAULT_PAGE_SIZE;\n\n constructor(\n private endpoint: string,\n private _sorobanClient?: SorobanServer,\n config?: IStellarEndpointConfig,\n ) {\n const { hostname, protocol, searchParams } = new URL(this.endpoint);\n this.pageLimit = config?.pageLimit || this.pageLimit;\n\n const protocolStr = protocol.replace(':', '');\n\n logger.info(\n `Api host: ${hostname}, method: ${protocolStr}, pageLimit: ${this.pageLimit}`,\n );\n if (protocolStr === 'https' || protocolStr === 'http') {\n const options: Horizon.Server.Options = {\n allowHttp: protocolStr === 'http',\n headers: {\n ...config?.headers,\n },\n };\n\n this.stellarClient = new StellarServer(endpoint, options);\n } else {\n throw new Error(`Unsupported protocol: ${protocol}`);\n }\n }\n\n async init(): Promise<void> {\n //need archive node for genesis hash\n //const genesisLedger = (await this.stellarClient.ledgers().ledger(1).call()).records[0];\n this.chainId = (await this.stellarClient.getNetwork()).network_passphrase;\n //this.genesisHash = genesisLedger.hash;\n }\n\n get sorobanClient(): SorobanServer {\n assert(this._sorobanClient, 'Soraban client is not initialized');\n return this._sorobanClient;\n }\n\n async getFinalizedBlock(): Promise<Horizon.ServerApi.LedgerRecord> {\n return (await this.stellarClient.ledgers().order('desc').call()).records[0];\n }\n\n async getFinalizedBlockHeight(): Promise<number> {\n return (await this.getFinalizedBlock()).sequence;\n }\n\n async getBestBlockHeight(): Promise<number> {\n return (await this.getFinalizedBlockHeight()) + 1;\n }\n\n getRuntimeChain(): string {\n assert(this.chainId, 'Api has not been initialised');\n return this.chainId;\n }\n\n getChainId(): string {\n assert(this.chainId, 'Api has not been initialised');\n return this.chainId;\n }\n\n getGenesisHash(): string {\n assert(this.chainId, 'Api has not been initialised');\n return this.chainId;\n }\n\n getSpecName(): string {\n return 'Stellar';\n }\n\n private async fetchTransactionsForLedger(\n sequence: number,\n ): Promise<Horizon.ServerApi.TransactionRecord[]> {\n const txs: Horizon.ServerApi.TransactionRecord[] = [];\n let txsPage = await this.api\n .transactions()\n .forLedger(sequence)\n .limit(this.pageLimit)\n .call();\n while (txsPage.records.length !== 0) {\n txs.push(...txsPage.records);\n txsPage = await txsPage.next();\n }\n\n return txs;\n }\n\n private async fetchOperationsForLedger(\n sequence: number,\n ): Promise<Horizon.ServerApi.OperationRecord[]> {\n const operations: Horizon.ServerApi.OperationRecord[] = [];\n let operationsPage = await this.api\n .operations()\n .forLedger(sequence)\n .limit(this.pageLimit)\n .call();\n while (operationsPage.records.length !== 0) {\n operations.push(...operationsPage.records);\n operationsPage = await operationsPage.next();\n }\n\n return operations;\n }\n\n private async fetchEffectsForLedger(\n sequence: number,\n ): Promise<Horizon.ServerApi.EffectRecord[]> {\n const effects: Horizon.ServerApi.EffectRecord[] = [];\n\n let effectsPage = await this.api\n .effects()\n .forLedger(sequence)\n .limit(this.pageLimit)\n .call();\n while (effectsPage.records.length !== 0) {\n effects.push(...effectsPage.records);\n effectsPage = await effectsPage.next();\n }\n\n return effects;\n }\n\n async getAndWrapEvents(height: number): Promise<SorobanEvent[]> {\n const { events: events } = await this.sorobanClient.getEvents({\n startLedger: height,\n filters: [],\n limit: this.pageLimit,\n });\n return events.map((event) => {\n const wrappedEvent = {\n ...event,\n ledger: null,\n transaction: null,\n operation: null,\n } as SorobanEvent;\n\n return wrappedEvent;\n });\n }\n\n private wrapEffect(effect: Horizon.ServerApi.EffectRecord): StellarEffect {\n return {\n ...effect,\n ledger: null,\n transaction: null,\n operation: null,\n };\n }\n\n private wrapOperationsForTx(\n operations: Horizon.ServerApi.OperationRecord[],\n effectsForSequence: Record<string, Horizon.ServerApi.EffectRecord[]>,\n events: SorobanEvent[],\n ): StellarOperation[] {\n // If there are soroban events then there should only be a single operation.\n // This check is here in case there are furture changes to the network.\n assert(\n events.length > 0 ? operations.length === 1 : true,\n 'Unable to assign events to multiple operations',\n );\n\n return operations.map((op, index) => {\n const effects = (effectsForSequence[op.id] ?? []).map(\n this.wrapEffect.bind(this),\n );\n // const effects = this.wrapEffectsForOperation(index, effectsForSequence);\n\n const wrappedOp: StellarOperation = {\n ...op,\n ledger: null,\n transaction: null,\n effects: [],\n events,\n };\n\n const clonedOp = cloneDeep(wrappedOp);\n\n effects.forEach((effect) => {\n effect.operation = clonedOp;\n wrappedOp.effects.push(effect);\n });\n\n return wrappedOp;\n });\n }\n\n private wrapTransactionsForLedger(\n transactions: Horizon.ServerApi.TransactionRecord[],\n operationsForSequence: Horizon.ServerApi.OperationRecord[],\n effectsForSequence: Horizon.ServerApi.EffectRecord[],\n eventsForSequence: SorobanEvent[],\n ): StellarTransaction[] {\n return transactions.map((tx) => {\n const wrappedTx: StellarTransaction = {\n ...tx,\n ledger: null,\n operations: [] as StellarOperation[],\n effects: [] as StellarEffect[],\n events: [] as SorobanEvent[],\n };\n\n // Effects grouped by the operation id\n const groupedEffects = effectsForSequence.reduce((acc, item) => {\n // BigInt conversion is for stripping leading 0s\n const key = BigInt(item.id.split('-')[0]).toString();\n acc[key] ??= [];\n acc[key].push(item);\n\n return acc;\n }, {} as Record<string, Horizon.ServerApi.EffectRecord[]>);\n\n // Operations grouped by the transaction hash\n const groupedOperations = operationsForSequence.reduce((acc, item) => {\n acc[item.transaction_hash] ??= [];\n acc[item.transaction_hash].push(item);\n\n return acc;\n }, {} as Record<string, Horizon.ServerApi.OperationRecord[]>);\n\n // Events grouped by the transaction hash\n const groupedEvents = eventsForSequence.reduce((acc, item) => {\n acc[item.txHash] ??= [];\n acc[item.txHash].push(item);\n\n return acc;\n }, {} as Record<string, SorobanEvent[]>);\n\n const clonedTx = cloneDeep(wrappedTx);\n const operations = this.wrapOperationsForTx(\n // TODO, this include other attribute from HorizonApi.TransactionResponse, but type assertion incorrect\n // TransactionRecord extends Omit<HorizonApi.TransactionResponse, \"created_at\">\n groupedOperations[tx.hash] ?? [],\n groupedEffects,\n groupedEvents[tx.hash] ?? [],\n ).map((op) => {\n op.transaction = clonedTx;\n op.effects = op.effects.map((effect) => {\n effect.transaction = clonedTx;\n return effect;\n });\n op.events = op.events.map((event) => {\n event.transaction = clonedTx;\n return event;\n });\n return op;\n });\n\n wrappedTx.operations.push(...operations);\n operations.forEach((op) => {\n wrappedTx.effects.push(...op.effects);\n wrappedTx.events.push(...op.events);\n });\n\n return wrappedTx;\n });\n }\n\n private async fetchAndWrapLedger(\n sequence: number,\n ): Promise<IBlock<StellarBlockWrapper>> {\n const [ledger, transactions, operations, effects] = await Promise.all([\n this.api.ledgers().ledger(sequence).call(),\n this.fetchTransactionsForLedger(sequence),\n this.fetchOperationsForLedger(sequence),\n this.fetchEffectsForLedger(sequence),\n ]);\n\n let eventsForSequence: SorobanEvent[] = [];\n\n //check if there is InvokeHostFunctionOp operation\n //If yes then, there are soroban transactions and we should we fetch soroban events\n const hasInvokeHostFunctionOp = operations.some(\n (op) => op.type.toString() === 'invoke_host_function',\n );\n\n if (this.sorobanClient && hasInvokeHostFunctionOp) {\n try {\n eventsForSequence = await this.getAndWrapEvents(sequence);\n } catch (e: any) {\n if (e.message === 'start is after newest ledger') {\n const latestLedger = (await this.sorobanClient.getLatestLedger())\n .sequence;\n throw new Error(`The requested events for ledger number ${sequence} is not available on the current soroban node.\n This is because you're trying to access a ledger that is after the latest ledger number ${latestLedger} stored in this node.\n To resolve this issue, please check you endpoint node start height`);\n }\n\n if (e.message === 'start is before oldest ledger') {\n throw new Error(`The requested events for ledger number ${sequence} is not available on the current soroban node.\n This is because you're trying to access a ledger that is older than the oldest ledger stored in this node.\n To resolve this issue, you can either:\n 1. Increase the start ledger to a more recent one, or\n 2. Connect to a different node that might have a longer history of ledgers.`);\n }\n\n throw e;\n }\n }\n\n const wrappedLedger: StellarBlock = {\n ...(ledger as unknown as Horizon.ServerApi.LedgerRecord),\n transactions: [] as StellarTransaction[],\n operations: [] as StellarOperation[],\n effects: [] as StellarEffect[],\n events: eventsForSequence,\n };\n\n const wrapperTxs = this.wrapTransactionsForLedger(\n transactions,\n operations,\n effects,\n eventsForSequence,\n );\n\n const clonedLedger = cloneDeep(wrappedLedger);\n\n wrapperTxs.forEach((tx) => {\n tx.ledger = clonedLedger;\n tx.operations = tx.operations.map((op) => {\n op.ledger = clonedLedger;\n op.effects = op.effects.map((effect) => {\n effect.ledger = clonedLedger;\n return effect;\n });\n op.events = op.events.map((event) => {\n event.ledger = clonedLedger;\n return event;\n });\n return op;\n });\n\n wrappedLedger.transactions.push(tx);\n wrappedLedger.operations.push(...tx.operations);\n\n tx.operations.forEach((op) => {\n wrappedLedger.effects.push(...op.effects);\n });\n });\n\n const wrappedLedgerInstance = new StellarBlockWrapped(\n wrappedLedger,\n wrappedLedger.transactions,\n wrappedLedger.operations,\n wrappedLedger.effects,\n wrappedLedger.events,\n );\n\n return formatBlockUtil(wrappedLedgerInstance);\n }\n\n async fetchBlocks(\n bufferBlocks: number[],\n ): Promise<IBlock<StellarBlockWrapper>[]> {\n const ledgers = await Promise.all(\n bufferBlocks.map((sequence) => this.fetchAndWrapLedger(sequence)),\n );\n return ledgers;\n }\n\n get api(): Horizon.Server {\n return this.stellarClient;\n }\n\n getSafeApi(blockHeight: number): SafeStellarProvider {\n //safe api not implemented yet\n return new SafeStellarProvider(this.sorobanClient, blockHeight);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async connect(): Promise<void> {\n logger.error('Stellar API connect is not implemented');\n throw new Error('Not implemented');\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async disconnect(): Promise<void> {\n logger.error('Stellar API disconnect is not implemented');\n throw new Error('Not implemented');\n }\n\n handleError(e: Error, height: number): Error {\n if (e.message === 'start is before oldest ledger') {\n return new Error(`The requested ledger number ${height} is not available on the current blockchain node.\n This is because you're trying to access a ledger that is older than the oldest ledger stored in this node.\n To resolve this issue, you can either:\n 1. Increase the start ledger to a more recent one, or\n 2. Connect to a different node that might have a longer history of ledgers.`);\n }\n\n return e;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { Horizon } from '@stellar/stellar-sdk';
2
2
  import { Header, IBlock } from '@subql/node-core';
3
- import { ApiWrapper, StellarBlock, StellarBlockWrapper } from '@subql/types-stellar';
3
+ import { StellarBlock, StellarBlockWrapper } from '@subql/types-stellar';
4
4
  export declare function stellarBlockToHeader(block: StellarBlock | Horizon.ServerApi.LedgerRecord): Header;
5
5
  export declare function formatBlockUtil<B extends StellarBlockWrapper = StellarBlockWrapper>(block: B): IBlock<B>;
6
- export declare function calcInterval(api: ApiWrapper): number;
6
+ export declare function calcInterval(): number;
7
7
  export declare const DEFAULT_PAGE_SIZE = 150;
@@ -24,7 +24,7 @@ function formatBlockUtil(block) {
24
24
  getHeader: () => stellarBlockToHeader(block.block),
25
25
  };
26
26
  }
27
- function calcInterval(api) {
27
+ function calcInterval() {
28
28
  return 6000;
29
29
  }
30
30
  exports.DEFAULT_PAGE_SIZE = 150;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.stellar.js","sourceRoot":"","sources":["../../src/stellar/utils.stellar.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAUnC,oDAaC;AAED,0CAOC;AAED,oCAEC;AA1BD,SAAgB,oBAAoB,CAClC,KAAoD;IAEpD,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,QAAQ;QAC3B,mFAAmF;QACnF,0FAA0F;QAC1F,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE;QACpC,UAAU,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;QAC3C,oCAAoC;QACpC,0CAA0C;QAC1C,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;KACrC,CAAC;AACJ,CAAC;AAED,SAAgB,eAAe,CAE7B,KAAQ;IACR,OAAO;QACL,KAAK;QACL,SAAS,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC;KACnD,CAAC;AACJ,CAAC;AAED,SAAgB,YAAY,CAAC,GAAe;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC;AAEY,QAAA,iBAAiB,GAAG,GAAG,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Horizon } from '@stellar/stellar-sdk';\nimport { Header, IBlock } from '@subql/node-core';\nimport {\n ApiWrapper,\n StellarBlock,\n StellarBlockWrapper,\n} from '@subql/types-stellar';\n\nexport function stellarBlockToHeader(\n block: StellarBlock | Horizon.ServerApi.LedgerRecord,\n): Header {\n return {\n blockHeight: block.sequence,\n // Stellar has instant finalization and there is no RPC for getting blocks by hash.\n // For these reasons we use the block numbers for hashes so that unfinalized blocks works.\n blockHash: block.sequence.toString(),\n parentHash: (block.sequence - 1).toString(),\n // blockHash: block.hash.toString(),\n // parentHash: block.prev_hash.toString(),\n timestamp: new Date(block.closed_at),\n };\n}\n\nexport function formatBlockUtil<\n B extends StellarBlockWrapper = StellarBlockWrapper,\n>(block: B): IBlock<B> {\n return {\n block,\n getHeader: () => stellarBlockToHeader(block.block),\n };\n}\n\nexport function calcInterval(api: ApiWrapper): number {\n return 6000;\n}\n\nexport const DEFAULT_PAGE_SIZE = 150;\n"]}
1
+ {"version":3,"file":"utils.stellar.js","sourceRoot":"","sources":["../../src/stellar/utils.stellar.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAMnC,oDAaC;AAED,0CAOC;AAED,oCAEC;AA1BD,SAAgB,oBAAoB,CAClC,KAAoD;IAEpD,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,QAAQ;QAC3B,mFAAmF;QACnF,0FAA0F;QAC1F,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE;QACpC,UAAU,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;QAC3C,oCAAoC;QACpC,0CAA0C;QAC1C,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;KACrC,CAAC;AACJ,CAAC;AAED,SAAgB,eAAe,CAE7B,KAAQ;IACR,OAAO;QACL,KAAK;QACL,SAAS,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC;KACnD,CAAC;AACJ,CAAC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAI,CAAC;AACd,CAAC;AAEY,QAAA,iBAAiB,GAAG,GAAG,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Horizon } from '@stellar/stellar-sdk';\nimport { Header, IBlock } from '@subql/node-core';\nimport { StellarBlock, StellarBlockWrapper } from '@subql/types-stellar';\n\nexport function stellarBlockToHeader(\n block: StellarBlock | Horizon.ServerApi.LedgerRecord,\n): Header {\n return {\n blockHeight: block.sequence,\n // Stellar has instant finalization and there is no RPC for getting blocks by hash.\n // For these reasons we use the block numbers for hashes so that unfinalized blocks works.\n blockHash: block.sequence.toString(),\n parentHash: (block.sequence - 1).toString(),\n // blockHash: block.hash.toString(),\n // parentHash: block.prev_hash.toString(),\n timestamp: new Date(block.closed_at),\n };\n}\n\nexport function formatBlockUtil<\n B extends StellarBlockWrapper = StellarBlockWrapper,\n>(block: B): IBlock<B> {\n return {\n block,\n getHeader: () => stellarBlockToHeader(block.block),\n };\n}\n\nexport function calcInterval(): number {\n return 6000;\n}\n\nexport const DEFAULT_PAGE_SIZE = 150;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subql/node-stellar",
3
- "version": "5.0.2",
3
+ "version": "6.0.0",
4
4
  "description": "",
5
5
  "author": "Ian He",
6
6
  "license": "GPL-3.0",
@@ -27,9 +27,9 @@
27
27
  "@stellar/stellar-sdk": "^13.1.0",
28
28
  "@subql/common": "^5.6.0",
29
29
  "@subql/common-stellar": "4.4.2",
30
- "@subql/node-core": "^18.0.4",
30
+ "@subql/node-core": "^18.1.0",
31
31
  "@subql/testing": "^2.2.0",
32
- "@subql/types-stellar": "4.4.0",
32
+ "@subql/types-stellar": "5.0.0",
33
33
  "lodash": "^4.17.21",
34
34
  "reflect-metadata": "^0.1.13"
35
35
  },