@subql/node-stellar 4.3.1-0 → 4.3.1-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/app.module.js +1 -1
  3. package/dist/app.module.js.map +1 -1
  4. package/dist/configure/SubqueryProject.js +1 -1
  5. package/dist/configure/SubqueryProject.js.map +1 -1
  6. package/dist/configure/configure.module.js +1 -1
  7. package/dist/configure/configure.module.js.map +1 -1
  8. package/dist/indexer/blockDispatcher/block-dispatcher.service.js +1 -1
  9. package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -1
  10. package/dist/indexer/blockDispatcher/index.js +1 -1
  11. package/dist/indexer/blockDispatcher/index.js.map +1 -1
  12. package/dist/indexer/blockDispatcher/stellar-block-dispatcher.js +1 -1
  13. package/dist/indexer/blockDispatcher/stellar-block-dispatcher.js.map +1 -1
  14. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +1 -1
  15. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -1
  16. package/dist/indexer/dictionary/index.js +1 -1
  17. package/dist/indexer/dictionary/index.js.map +1 -1
  18. package/dist/indexer/dictionary/stellarDictionary.service.js +1 -1
  19. package/dist/indexer/dictionary/stellarDictionary.service.js.map +1 -1
  20. package/dist/indexer/dictionary/v1/index.js +1 -1
  21. package/dist/indexer/dictionary/v1/index.js.map +1 -1
  22. package/dist/indexer/dictionary/v1/stellarDictionaryV1.js +1 -1
  23. package/dist/indexer/dictionary/v1/stellarDictionaryV1.js.map +1 -1
  24. package/dist/indexer/dictionary/v1/stellarDictionaryV1.spec.js +1 -1
  25. package/dist/indexer/dictionary/v1/stellarDictionaryV1.spec.js.map +1 -1
  26. package/dist/indexer/ds-processor.service.js +1 -1
  27. package/dist/indexer/ds-processor.service.js.map +1 -1
  28. package/dist/indexer/dynamic-ds.service.js +1 -1
  29. package/dist/indexer/dynamic-ds.service.js.map +1 -1
  30. package/dist/indexer/fetch.module.js +1 -1
  31. package/dist/indexer/fetch.module.js.map +1 -1
  32. package/dist/indexer/fetch.service.js +1 -1
  33. package/dist/indexer/fetch.service.js.map +1 -1
  34. package/dist/indexer/indexer.manager.js +1 -1
  35. package/dist/indexer/indexer.manager.js.map +1 -1
  36. package/dist/indexer/project.service.js +1 -1
  37. package/dist/indexer/project.service.js.map +1 -1
  38. package/dist/indexer/types.js +1 -1
  39. package/dist/indexer/types.js.map +1 -1
  40. package/dist/indexer/unfinalizedBlocks.service.js +1 -1
  41. package/dist/indexer/unfinalizedBlocks.service.js.map +1 -1
  42. package/dist/indexer/worker/worker-fetch.module.js +1 -1
  43. package/dist/indexer/worker/worker-fetch.module.js.map +1 -1
  44. package/dist/indexer/worker/worker.js +1 -1
  45. package/dist/indexer/worker/worker.js.map +1 -1
  46. package/dist/indexer/worker/worker.module.js +1 -1
  47. package/dist/indexer/worker/worker.module.js.map +1 -1
  48. package/dist/indexer/worker/worker.service.js +1 -1
  49. package/dist/indexer/worker/worker.service.js.map +1 -1
  50. package/dist/init.js +1 -1
  51. package/dist/init.js.map +1 -1
  52. package/dist/main.js +1 -1
  53. package/dist/main.js.map +1 -1
  54. package/dist/stellar/api.connection.js +1 -1
  55. package/dist/stellar/api.connection.js.map +1 -1
  56. package/dist/stellar/api.connection.spec.js +1 -1
  57. package/dist/stellar/api.connection.spec.js.map +1 -1
  58. package/dist/stellar/api.service.stellar.js +1 -1
  59. package/dist/stellar/api.service.stellar.js.map +1 -1
  60. package/dist/stellar/api.service.stellar.spec.js +1 -1
  61. package/dist/stellar/api.service.stellar.spec.js.map +1 -1
  62. package/dist/stellar/api.stellar.js +1 -1
  63. package/dist/stellar/api.stellar.js.map +1 -1
  64. package/dist/stellar/api.stellar.spec.js +1 -1
  65. package/dist/stellar/api.stellar.spec.js.map +1 -1
  66. package/dist/stellar/block.stellar.js +1 -1
  67. package/dist/stellar/block.stellar.js.map +1 -1
  68. package/dist/stellar/block.stellar.spec.js +1 -1
  69. package/dist/stellar/block.stellar.spec.js.map +1 -1
  70. package/dist/stellar/index.js +1 -1
  71. package/dist/stellar/index.js.map +1 -1
  72. package/dist/stellar/safe-api.js +1 -1
  73. package/dist/stellar/safe-api.js.map +1 -1
  74. package/dist/stellar/soroban.server.js +1 -1
  75. package/dist/stellar/soroban.server.js.map +1 -1
  76. package/dist/stellar/soroban.server.spec.js +1 -1
  77. package/dist/stellar/soroban.server.spec.js.map +1 -1
  78. package/dist/stellar/stellar.server.js +1 -1
  79. package/dist/stellar/stellar.server.js.map +1 -1
  80. package/dist/stellar/utils.stellar.js +1 -1
  81. package/dist/stellar/utils.stellar.js.map +1 -1
  82. package/dist/subcommands/forceClean.init.js +1 -1
  83. package/dist/subcommands/forceClean.init.js.map +1 -1
  84. package/dist/subcommands/forceClean.module.js +1 -1
  85. package/dist/subcommands/forceClean.module.js.map +1 -1
  86. package/dist/subcommands/reindex.init.js +1 -1
  87. package/dist/subcommands/reindex.init.js.map +1 -1
  88. package/dist/subcommands/reindex.module.js +1 -1
  89. package/dist/subcommands/reindex.module.js.map +1 -1
  90. package/dist/subcommands/testing.init.js +1 -1
  91. package/dist/subcommands/testing.init.js.map +1 -1
  92. package/dist/subcommands/testing.module.js +1 -1
  93. package/dist/subcommands/testing.module.js.map +1 -1
  94. package/dist/subcommands/testing.service.js +1 -1
  95. package/dist/subcommands/testing.service.js.map +1 -1
  96. package/dist/utils/project.js +1 -1
  97. package/dist/utils/project.js.map +1 -1
  98. package/dist/utils/string.js +1 -1
  99. package/dist/utils/string.js.map +1 -1
  100. package/dist/yargs.js +1 -1
  101. package/dist/yargs.js.map +1 -1
  102. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"project.service.js","sourceRoot":"","sources":["../../src/indexer/project.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,mDAA8C;AAC9C,2CAAoD;AACpD,yDAAsD;AAEtD,g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CAAC,CAAA;IAC1C,WAAA,IAAA,eAAM,EAAC,6BAAY,CAAC,CAAC,CAAC,0BAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAE9C,WAAA,IAAA,eAAM,EAAC,6BAAY,CAAC,CAAC,CAAC,uBAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACzC,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,IAAA,eAAM,EAAC,wBAAwB,CAAC,CAAA;IAEhC,WAAA,IAAA,eAAM,EAAC,6BAAY,CAAC,CAAC,CAAC,wBAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;qCATzB,yCAAkB;QAC1B,sBAAU;QACkC,sBAAU;QAElD,0BAAc;QACwB,uBAAS,kBAIH,wBAAY;QAC5D,sBAAU;QACJ,qCAAgB;QACpB,6BAAa;QACF,oDAAwB;GApBxC,cAAc,CA0D1B;AA1DY,wCAAc","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { isMainThread } from 'worker_threads';\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { Horizon } from '@stellar/stellar-sdk';\nimport {\n PoiService,\n PoiSyncService,\n BaseProjectService,\n StoreService,\n NodeConfig,\n ApiService,\n IProjectUpgradeService,\n profiler,\n} from '@subql/node-core';\nimport { StellarBlockWrapper, SubqlDatasource } from '@subql/types-stellar';\nimport { Sequelize } from '@subql/x-sequelize';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { StellarApi } from '../stellar';\nimport SafeStellarProvider from '../stellar/safe-api';\nimport { DsProcessorService } from './ds-processor.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { version: packageVersion } = require('../../package.json');\n\n@Injectable()\nexport class ProjectService extends BaseProjectService<\n ApiService<StellarApi, SafeStellarProvider, StellarBlockWrapper[]>,\n SubqlDatasource\n> {\n protected packageVersion = packageVersion;\n\n constructor(\n dsProcessorService: DsProcessorService,\n apiService: ApiService,\n @Inject(isMainThread ? PoiService : 'Null') poiService: PoiService,\n @Inject(isMainThread ? PoiSyncService : 'Null')\n poiSyncService: PoiSyncService,\n @Inject(isMainThread ? Sequelize : 'Null') sequelize: Sequelize,\n @Inject('ISubqueryProject') project: SubqueryProject,\n @Inject('IProjectUpgradeService')\n projectUpgradeService: IProjectUpgradeService<SubqueryProject>,\n @Inject(isMainThread ? StoreService : 'Null') storeService: StoreService,\n nodeConfig: NodeConfig,\n dynamicDsService: DynamicDsService,\n eventEmitter: EventEmitter2,\n unfinalizedBlockService: UnfinalizedBlocksService,\n ) {\n super(\n dsProcessorService,\n apiService,\n poiService,\n poiSyncService,\n sequelize,\n project,\n projectUpgradeService,\n storeService,\n nodeConfig,\n dynamicDsService,\n eventEmitter,\n unfinalizedBlockService,\n );\n }\n\n @profiler()\n async init(startHeight?: number): Promise<void> {\n return super.init(startHeight);\n }\n\n protected async getBlockTimestamp(height: number): Promise<Date> {\n const block = await this.apiService.unsafeApi.api\n .ledgers()\n .ledger(height)\n .call();\n\n return new Date(\n (block as unknown as Horizon.ServerApi.LedgerRecord).closed_at,\n ); // TODO test and make sure its in MS not S\n }\n\n protected onProjectChange(project: SubqueryProject): void | Promise<void> {\n // TODO update this when implementing skipBlock feature for Eth\n // this.apiService.updateBlockFetching();\n }\n}\n"]}
1
+ {"version":3,"file":"project.service.js","sourceRoot":"","sources":["../../src/indexer/project.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,mDAA8C;AAC9C,2CAAoD;AACpD,yDAAsD;AAEtD,gDAS0B;AAE1B,oDAA+C;AAI/C,iEAA4D;AAC5D,6DAAwD;AACxD,2EAAuE;AAEvE,8DAA8D;AAC9D,MAAM,EAAE,OAAO,EA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IAE9C,WAAA,IAAA,eAAM,EAAC,6BAAY,CAAC,CAAC,CAAC,uBAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACzC,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,IAAA,eAAM,EAAC,wBAAwB,CAAC,CAAA;IAEhC,WAAA,IAAA,eAAM,EAAC,6BAAY,CAAC,CAAC,CAAC,wBAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;qCATzB,yCAAkB;QAC1B,sBAAU;QACkC,sBAAU;QAElD,0BAAc;QACwB,uBAAS,kBAIH,wBAAY;QAC5D,sBAAU;QACJ,qCAAgB;QACpB,6BAAa;QACF,oDAAwB;GApBxC,cAAc,CA0D1B;AA1DY,wCAAc","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { isMainThread } from 'worker_threads';\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { Horizon } from '@stellar/stellar-sdk';\nimport {\n PoiService,\n PoiSyncService,\n BaseProjectService,\n StoreService,\n NodeConfig,\n ApiService,\n IProjectUpgradeService,\n profiler,\n} from '@subql/node-core';\nimport { StellarBlockWrapper, SubqlDatasource } from '@subql/types-stellar';\nimport { Sequelize } from '@subql/x-sequelize';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { StellarApi } from '../stellar';\nimport SafeStellarProvider from '../stellar/safe-api';\nimport { DsProcessorService } from './ds-processor.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { version: packageVersion } = require('../../package.json');\n\n@Injectable()\nexport class ProjectService extends BaseProjectService<\n ApiService<StellarApi, SafeStellarProvider, StellarBlockWrapper[]>,\n SubqlDatasource\n> {\n protected packageVersion = packageVersion;\n\n constructor(\n dsProcessorService: DsProcessorService,\n apiService: ApiService,\n @Inject(isMainThread ? PoiService : 'Null') poiService: PoiService,\n @Inject(isMainThread ? PoiSyncService : 'Null')\n poiSyncService: PoiSyncService,\n @Inject(isMainThread ? Sequelize : 'Null') sequelize: Sequelize,\n @Inject('ISubqueryProject') project: SubqueryProject,\n @Inject('IProjectUpgradeService')\n projectUpgradeService: IProjectUpgradeService<SubqueryProject>,\n @Inject(isMainThread ? StoreService : 'Null') storeService: StoreService,\n nodeConfig: NodeConfig,\n dynamicDsService: DynamicDsService,\n eventEmitter: EventEmitter2,\n unfinalizedBlockService: UnfinalizedBlocksService,\n ) {\n super(\n dsProcessorService,\n apiService,\n poiService,\n poiSyncService,\n sequelize,\n project,\n projectUpgradeService,\n storeService,\n nodeConfig,\n dynamicDsService,\n eventEmitter,\n unfinalizedBlockService,\n );\n }\n\n @profiler()\n async init(startHeight?: number): Promise<void> {\n return super.init(startHeight);\n }\n\n protected async getBlockTimestamp(height: number): Promise<Date> {\n const block = await this.apiService.unsafeApi.api\n .ledgers()\n .ledger(height)\n .call();\n\n return new Date(\n (block as unknown as Horizon.ServerApi.LedgerRecord).closed_at,\n ); // TODO test and make sure its in MS not S\n }\n\n protected onProjectChange(project: SubqueryProject): void | Promise<void> {\n // TODO update this when implementing skipBlock feature for Eth\n // this.apiService.updateBlockFetching();\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.getBlockSize = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/indexer/types.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAMnC,SAAgB,YAAY,CAAC,KAA0B;IACrD,MAAM,EACJ,wBAAwB,EACxB,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,GACvB,GAAG,KAAK,CAAC,KAAK,CAAC;IAChB,OAAO,CACL,CAAC,sBAAsB;QACrB,4BAA4B,GAAG,wBAAwB,CAAC,GAAG,eAAe,CAC7E,CAAC;AACJ,CAAC;AAXD,oCAWC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { StellarBlockWrapper } from '@subql/types-stellar';\n\nexport type BestBlocks = Record<number, string>;\n\nexport function getBlockSize(block: StellarBlockWrapper): number {\n const {\n failed_transaction_count,\n operation_count,\n successful_transaction_count,\n tx_set_operation_count,\n } = block.block;\n return (\n (tx_set_operation_count ??\n successful_transaction_count + failed_transaction_count) + operation_count\n );\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/indexer/types.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAMnC,SAAgB,YAAY,CAAC,KAA0B;IACrD,MAAM,EACJ,wBAAwB,EACxB,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,GACvB,GAAG,KAAK,CAAC,KAAK,CAAC;IAChB,OAAO,CACL,CAAC,sBAAsB;QACrB,4BAA4B,GAAG,wBAAwB,CAAC,GAAG,eAAe,CAC7E,CAAC;AACJ,CAAC;AAXD,oCAWC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { StellarBlockWrapper } from '@subql/types-stellar';\n\nexport type BestBlocks = Record<number, string>;\n\nexport function getBlockSize(block: StellarBlockWrapper): number {\n const {\n failed_transaction_count,\n operation_count,\n successful_transaction_count,\n tx_set_operation_count,\n } = block.block;\n return (\n (tx_set_operation_count ??\n successful_transaction_count + failed_transaction_count) + operation_count\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1 +1 @@
1
- {"version":3,"file":"unfinalizedBlocks.service.js","sourceRoot":"","sources":["../../src/indexer/unfinalizedBlocks.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,gDAQ0B;AAE1B,4DAAgE;AAEhE,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,aAAa,CAAC,CAAC;AAGjC,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,wCAA0C;IAEnE;IADnB,YACmB,UAAsB,EACvC,UAAsB,EACS,kBAAuC;QAEtE,KAAK,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;QAJrB,eAAU,GAAV,UAAU,CAAY;IAKzC,CAAC;IAGe,AAAN,KAAK,CAAC,gBAAgB;QAC9B,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QACrE,OAAO,IAAA,oCAAoB,EAAC,cAAc,CAAC,CAAC;IAC9C,CAAC;IAGe,AAAN,KAAK,CAAC,gBAAgB,CAAC,IAAY;QAC3C,OAAO,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;IAGK,AAAN,KAAK,CAAC,kBAAkB,CAAC,MAAc;QACrC,MAAM,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,OAAO,IAAA,oCAAoB,EAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AAfiB;IADf,IAAA,0BAAc,GAAE;;;;gEAIhB;AAGe;IADf,IAAA,0BAAc,GAAE;;;;gEAGhB;AAGK;IADL,IAAA,0BAAc,GAAE;;;;kEAIhB;AAxBU,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,qBAAqB,CAAC,CAAA;qCAFD,sBAAU;QAC3B,sBAAU;GAHb,wBAAwB,CAyBpC;AAzBY,4DAAwB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport {\n ApiService,\n BaseUnfinalizedBlocksService,\n Header,\n NodeConfig,\n IStoreModelProvider,\n getLogger,\n mainThreadOnly,\n} from '@subql/node-core';\nimport { BlockWrapper } from '@subql/types-stellar';\nimport { stellarBlockToHeader } from '../stellar/utils.stellar';\n\nconst logger = getLogger('unfinalized');\n\n@Injectable()\nexport class UnfinalizedBlocksService extends BaseUnfinalizedBlocksService<BlockWrapper> {\n constructor(\n private readonly apiService: ApiService,\n nodeConfig: NodeConfig,\n @Inject('IStoreModelProvider') storeModelProvider: IStoreModelProvider,\n ) {\n super(nodeConfig, storeModelProvider);\n }\n\n @mainThreadOnly()\n protected async getFinalizedHead(): Promise<Header> {\n const finalizedBlock = await this.apiService.api.getFinalizedBlock();\n return stellarBlockToHeader(finalizedBlock);\n }\n\n @mainThreadOnly()\n protected async getHeaderForHash(hash: string): Promise<Header> {\n return this.getHeaderForHeight(parseInt(hash, 10));\n }\n\n @mainThreadOnly()\n async getHeaderForHeight(height: number): Promise<Header> {\n const block = (await this.apiService.api.fetchBlocks([height]))[0];\n return stellarBlockToHeader(block);\n }\n}\n"]}
1
+ {"version":3,"file":"unfinalizedBlocks.service.js","sourceRoot":"","sources":["../../src/indexer/unfinalizedBlocks.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,gD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L-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport {\n ApiService,\n BaseUnfinalizedBlocksService,\n Header,\n NodeConfig,\n IStoreModelProvider,\n getLogger,\n mainThreadOnly,\n} from '@subql/node-core';\nimport { BlockWrapper } from '@subql/types-stellar';\nimport { stellarBlockToHeader } from '../stellar/utils.stellar';\n\nconst logger = getLogger('unfinalized');\n\n@Injectable()\nexport class UnfinalizedBlocksService extends BaseUnfinalizedBlocksService<BlockWrapper> {\n constructor(\n private readonly apiService: ApiService,\n nodeConfig: NodeConfig,\n @Inject('IStoreModelProvider') storeModelProvider: IStoreModelProvider,\n ) {\n super(nodeConfig, storeModelProvider);\n }\n\n @mainThreadOnly()\n protected async getFinalizedHead(): Promise<Header> {\n const finalizedBlock = await this.apiService.api.getFinalizedBlock();\n return stellarBlockToHeader(finalizedBlock);\n }\n\n @mainThreadOnly()\n protected async getHeaderForHash(hash: string): Promise<Header> {\n return this.getHeaderForHeight(parseInt(hash, 10));\n }\n\n @mainThreadOnly()\n async getHeaderForHeight(height: number): Promise<Header> {\n const block = (await this.apiService.api.fetchBlocks([height]))[0];\n return stellarBlockToHeader(block);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1 +1 @@
1
- {"version":3,"file":"worker-fetch.module.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker-fetch.module.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;AAEnC,mDAA8C;AAC9C,2CAAwC;AACxC,yDAAsD;AACtD,gDAO0B;AAE1B,2CAAkD;AAElD,kEAA6D;AAC7D,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right 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { isMainThread } from 'worker_threads';\nimport { Module } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n WorkerCoreModule,\n ConnectionPoolService,\n WorkerDynamicDsService,\n NodeConfig,\n WorkerUnfinalizedBlocksService,\n ApiService,\n} from '@subql/node-core';\nimport { SubqueryProject } from '../../configure/SubqueryProject';\nimport { StellarApiService } from '../../stellar';\nimport { StellarApiConnection } from '../../stellar/api.connection';\nimport { DsProcessorService } from '../ds-processor.service';\nimport { DynamicDsService } from '../dynamic-ds.service';\nimport { IndexerManager } from '../indexer.manager';\nimport { ProjectService } from '../project.service';\nimport { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';\nimport { WorkerService } from './worker.service';\n\n@Module({\n imports: [WorkerCoreModule],\n providers: [\n IndexerManager,\n {\n provide: ApiService,\n useFactory: async (\n project: SubqueryProject,\n connectionPoolService: ConnectionPoolService<StellarApiConnection>,\n eventEmitter: EventEmitter2,\n nodeConfig: NodeConfig,\n ) => {\n const apiService = new StellarApiService(\n project,\n connectionPoolService,\n eventEmitter,\n nodeConfig,\n );\n await apiService.init();\n return apiService;\n },\n inject: [\n 'ISubqueryProject',\n ConnectionPoolService,\n EventEmitter2,\n NodeConfig,\n ],\n },\n DsProcessorService,\n {\n provide: DynamicDsService,\n useFactory: () => {\n if (isMainThread) {\n throw new Error('Expected to be worker thread');\n }\n return new WorkerDynamicDsService((global as any).host);\n },\n },\n {\n provide: 'IProjectService',\n useClass: ProjectService,\n },\n WorkerService,\n {\n provide: UnfinalizedBlocksService,\n useFactory: () => {\n if (isMainThread) {\n throw new Error('Expected to be worker thread');\n }\n return new WorkerUnfinalizedBlocksService((global as any).host);\n },\n },\n ],\n})\nexport class WorkerFetchModule {}\n"]}
1
+ {"version":3,"file":"worker-fetch.module.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker-fetch.module.ts"],"names":[],"mappings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,OAAO,IAAI,0CAA8B,CAAE,MAAc,CAAC,IAAI,CAAC,CAAC;gBAClE,CAAC;aACF;SACF;KACF,CAAC;GACW,iBAAiB,CAAG;AAApB,8CAAiB","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { isMainThread } from 'worker_threads';\nimport { Module } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n WorkerCoreModule,\n ConnectionPoolService,\n WorkerDynamicDsService,\n NodeConfig,\n WorkerUnfinalizedBlocksService,\n ApiService,\n} from '@subql/node-core';\nimport { SubqueryProject } from '../../configure/SubqueryProject';\nimport { StellarApiService } from '../../stellar';\nimport { StellarApiConnection } from '../../stellar/api.connection';\nimport { DsProcessorService } from '../ds-processor.service';\nimport { DynamicDsService } from '../dynamic-ds.service';\nimport { IndexerManager } from '../indexer.manager';\nimport { ProjectService } from '../project.service';\nimport { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';\nimport { WorkerService } from './worker.service';\n\n@Module({\n imports: [WorkerCoreModule],\n providers: [\n IndexerManager,\n {\n provide: ApiService,\n useFactory: async (\n project: SubqueryProject,\n connectionPoolService: ConnectionPoolService<StellarApiConnection>,\n eventEmitter: EventEmitter2,\n nodeConfig: NodeConfig,\n ) => {\n const apiService = new StellarApiService(\n project,\n connectionPoolService,\n eventEmitter,\n nodeConfig,\n );\n await apiService.init();\n return apiService;\n },\n inject: [\n 'ISubqueryProject',\n ConnectionPoolService,\n EventEmitter2,\n NodeConfig,\n ],\n },\n DsProcessorService,\n {\n provide: DynamicDsService,\n useFactory: () => {\n if (isMainThread) {\n throw new Error('Expected to be worker thread');\n }\n return new WorkerDynamicDsService((global as any).host);\n },\n },\n {\n provide: 'IProjectService',\n useClass: ProjectService,\n },\n WorkerService,\n {\n provide: UnfinalizedBlocksService,\n useFactory: () => {\n if (isMainThread) {\n throw new Error('Expected to be worker thread');\n }\n return new WorkerUnfinalizedBlocksService((global as any).host);\n },\n },\n ],\n})\nexport class WorkerFetchModule {}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  // initlogger and yargs must be imported before all other imports
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,iEAAiE;AACjE,kDAAkD;AAClD,wCAAwC;AACxC,oDAAqD;AACrD,wCAAwC;AACxC,uCAA2C;AAE3C,MAAM,EAAE,IAAI,EAAE,GAAG,oBAAY,CAAC;AAE9B,IAAA,mBAAU,EACR,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;AAEF,6DAA+C;AAC/C,uCAA2C;AAC3C,gDAM0B;AAE1B,mDAA+C;AAC/C,qDAAiD;AAEjD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,WAAW,8BAAQ,EAAE,CAAC,CAAC;AAEhD,KAAK,UAAU,UAAU,CAAC,WAAoB;IAC5C,IAAI;QACF,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,4BAAY,EAAE;YACjD,MAAM,EAAE,IAAI,sBAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,0EAA0E;SACjH,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,MAAM,cAAc,GAAmB,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAClE,uGAAuG;QACvG,MAAM,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEvC,MAAM,aAAa,GAAG,GAAG,CAAC,GAAG,CAAC,8BAAa,CAAC,CAAC;QAE7C,IAAA,8BAAkB,EAAC,GAAG,EAAE,aAAa,CAAC,CAAC;KACxC;IAAC,OAAO,CAAM,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC;QAC1C,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AAGA,MAAc,CAAC,IAAI,GAAG,IAAA,4BAAgB,EAAC,EAAE,EAAE;IAC1C,UAAU;CACX,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\n// initlogger and yargs must be imported before all other imports\n// making sure logger is defined before its called\n// eslint-disable-next-line import/order\nimport { initLogger } from '@subql/node-core/logger';\n// eslint-disable-next-line import/order\nimport { yargsOptions } from '../../yargs';\n\nconst { argv } = yargsOptions;\n\ninitLogger(\n argv.debug,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n);\n\nimport { threadId } from 'node:worker_threads';\nimport { NestFactory } from '@nestjs/core';\nimport {\n getLogger,\n NestLogger,\n initWorkerServices,\n IBaseIndexerWorker,\n createWorkerHost,\n} from '@subql/node-core';\nimport { ProjectService } from '../project.service';\nimport { WorkerModule } from './worker.module';\nimport { WorkerService } from './worker.service';\n\nconst logger = getLogger(`worker #${threadId}`);\n\nasync function initWorker(startHeight?: number): Promise<void> {\n try {\n const app = await NestFactory.create(WorkerModule, {\n logger: new NestLogger(!!argv.debug), // TIP: If the worker is crashing comment out this line for better logging\n });\n\n await app.init();\n\n const projectService: ProjectService = app.get('IProjectService');\n // Initialise async services, we do this here rather than in factories so we can capture one off events\n await projectService.init(startHeight);\n\n const workerService = app.get(WorkerService);\n\n initWorkerServices(app, workerService);\n } catch (e: any) {\n console.log('Failed to start worker', e);\n logger.error(e, 'Failed to start worker');\n throw e;\n }\n}\nexport type IIndexerWorker = IBaseIndexerWorker;\n\n(global as any).host = createWorkerHost([], {\n initWorker,\n});\n"]}
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,iEAAiE;AACjE,kDAAkD;AAClD,wCAAwC;AACxC,oDAAqD;AACrD,wCAAwC;AACxC,uCAA2C;AAE3C,MAAM,EAAE,IAAI,EAAE,GAAG,oBAAY,CAAC;AAE9B,IAAA,mBAAU,EACR,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;AAEF,6DAA+C;AAC/C,uCAA2C;AAC3C,gDAM0B;AAE1B,mDAA+C;AAC/C,qDAAiD;AAEjD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,WAAW,8BAAQ,EAAE,CAAC,CAAC;AAEhD,KAAK,UAAU,UAAU,CAAC,WAAoB;IAC5C,IAAI;QACF,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,4BAAY,EAAE;YACjD,MAAM,EAAE,IAAI,sBAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,0EAA0E;SACjH,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,MAAM,cAAc,GAAmB,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAClE,uGAAuG;QACvG,MAAM,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEvC,MAAM,aAAa,GAAG,GAAG,CAAC,GAAG,CAAC,8BAAa,CAAC,CAAC;QAE7C,IAAA,8BAAkB,EAAC,GAAG,EAAE,aAAa,CAAC,CAAC;KACxC;IAAC,OAAO,CAAM,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC;QAC1C,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AAGA,MAAc,CAAC,IAAI,GAAG,IAAA,4BAAgB,EAAC,EAAE,EAAE;IAC1C,UAAU;CACX,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\n// initlogger and yargs must be imported before all other imports\n// making sure logger is defined before its called\n// eslint-disable-next-line import/order\nimport { initLogger } from '@subql/node-core/logger';\n// eslint-disable-next-line import/order\nimport { yargsOptions } from '../../yargs';\n\nconst { argv } = yargsOptions;\n\ninitLogger(\n argv.debug,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n);\n\nimport { threadId } from 'node:worker_threads';\nimport { NestFactory } from '@nestjs/core';\nimport {\n getLogger,\n NestLogger,\n initWorkerServices,\n IBaseIndexerWorker,\n createWorkerHost,\n} from '@subql/node-core';\nimport { ProjectService } from '../project.service';\nimport { WorkerModule } from './worker.module';\nimport { WorkerService } from './worker.service';\n\nconst logger = getLogger(`worker #${threadId}`);\n\nasync function initWorker(startHeight?: number): Promise<void> {\n try {\n const app = await NestFactory.create(WorkerModule, {\n logger: new NestLogger(!!argv.debug), // TIP: If the worker is crashing comment out this line for better logging\n });\n\n await app.init();\n\n const projectService: ProjectService = app.get('IProjectService');\n // Initialise async services, we do this here rather than in factories so we can capture one off events\n await projectService.init(startHeight);\n\n const workerService = app.get(WorkerService);\n\n initWorkerServices(app, workerService);\n } catch (e: any) {\n console.log('Failed to start worker', e);\n logger.error(e, 'Failed to start worker');\n throw e;\n }\n}\nexport type IIndexerWorker = IBaseIndexerWorker;\n\n(global as any).host = createWorkerHost([], {\n initWorker,\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1 +1 @@
1
- {"version":3,"file":"worker.module.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.module.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;AAEnC,2CAAwC;AACxC,yDAA2D;AAC3D,+CAAkD;AAClD,gDAA8D;AAC9D,uEAAmE;AACnE,+DAA0D;AAanD,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,YAAY;IAXxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,oBAAQ,CAAC,OAAO,EAAE;YAClB,kCAAkB,CAAC,OAAO,EAAE;YAC5B,kCAAe,CAAC,QAAQ,EAAE;YAC1B,yBAAc,CAAC,OAAO,EAAE;YACxB,4BAAgB;YAChB,uCAAiB;SAClB;QACD,WAAW,EAAE,EAAE;KAChB,CAAC;GACW,YAAY,CAAG;AAAf,oCAAY","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Module } from '@nestjs/common';\nimport { EventEmitterModule } from '@nestjs/event-emitter';\nimport { ScheduleModule } from '@nestjs/schedule';\nimport { DbModule, WorkerCoreModule } from '@subql/node-core';\nimport { ConfigureModule } from '../../configure/configure.module';\nimport { WorkerFetchModule } from './worker-fetch.module';\n\n@Module({\n imports: [\n DbModule.forRoot(),\n EventEmitterModule.forRoot(),\n ConfigureModule.register(),\n ScheduleModule.forRoot(),\n WorkerCoreModule,\n WorkerFetchModule,\n ],\n controllers: [],\n})\nexport class WorkerModule {}\n"]}
1
+ {"version":3,"file":"worker.module.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.module.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;AAEnC,2CAAwC;AACxC,yDAA2D;AAC3D,+CAAkD;AAClD,gDAA8D;AAC9D,uEAAmE;AACnE,+DAA0D;AAanD,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,YAAY;IAXxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,oBAAQ,CAAC,OAAO,EAAE;YAClB,kCAAkB,CAAC,OAAO,EAAE;YAC5B,kCAAe,CAAC,QAAQ,EAAE;YAC1B,yBAAc,CAAC,OAAO,EAAE;YACxB,4BAAgB;YAChB,uCAAiB;SAClB;QACD,WAAW,EAAE,EAAE;KAChB,CAAC;GACW,YAAY,CAAG;AAAf,oCAAY","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Module } from '@nestjs/common';\nimport { EventEmitterModule } from '@nestjs/event-emitter';\nimport { ScheduleModule } from '@nestjs/schedule';\nimport { DbModule, WorkerCoreModule } from '@subql/node-core';\nimport { ConfigureModule } from '../../configure/configure.module';\nimport { WorkerFetchModule } from './worker-fetch.module';\n\n@Module({\n imports: [\n DbModule.forRoot(),\n EventEmitterModule.forRoot(),\n ConfigureModule.register(),\n ScheduleModule.forRoot(),\n WorkerCoreModule,\n WorkerFetchModule,\n ],\n controllers: [],\n})\nexport class WorkerModule {}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1 +1 @@
1
- {"version":3,"file":"worker.service.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,6DAA+C;AA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ors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { threadId } from 'node:worker_threads';\nimport { Inject, Injectable } from '@nestjs/common';\nimport { SubqlStellarDataSource } from '@subql/common-stellar';\nimport {\n NodeConfig,\n getLogger,\n IProjectService,\n ProcessBlockResponse,\n ApiService,\n BaseWorkerService,\n IProjectUpgradeService,\n IBlock,\n Header,\n} from '@subql/node-core';\nimport { StellarBlockWrapper, SubqlDatasource } from '@subql/types-stellar';\nimport { stellarBlockToHeader } from '../../stellar/utils.stellar';\nimport { IndexerManager } from '../indexer.manager';\nimport { getBlockSize } from '../types';\n\nexport type FetchBlockResponse = Header;\n\nexport type WorkerStatusResponse = {\n threadId: number;\n isIndexing: boolean;\n fetchedBlocks: number;\n toFetchBlocks: number;\n};\n\nconst logger = getLogger(`Worker Service #${threadId}`);\n\n@Injectable()\nexport class WorkerService extends BaseWorkerService<\n StellarBlockWrapper,\n FetchBlockResponse,\n SubqlStellarDataSource,\n {}\n> {\n constructor(\n private apiService: ApiService,\n private indexerManager: IndexerManager,\n @Inject('IProjectService')\n projectService: IProjectService<SubqlDatasource>,\n @Inject('IProjectUpgradeService')\n projectUpgradeService: IProjectUpgradeService,\n nodeConfig: NodeConfig,\n ) {\n super(projectService, projectUpgradeService, nodeConfig);\n }\n protected async fetchChainBlock(\n heights: number,\n extra: {},\n ): Promise<IBlock<StellarBlockWrapper>> {\n const [block] = await this.apiService.fetchBlocks([heights]);\n return block;\n }\n\n protected toBlockResponse(block: StellarBlockWrapper): Header {\n return stellarBlockToHeader(block.block);\n }\n\n protected async processFetchedBlock(\n block: IBlock<StellarBlockWrapper>,\n dataSources: SubqlStellarDataSource[],\n ): Promise<ProcessBlockResponse> {\n return this.indexerManager.indexBlock(block, dataSources);\n }\n\n protected getBlockSize(block: IBlock<StellarBlockWrapper>): number {\n return getBlockSize(block.block);\n }\n}\n"]}
1
+ {"version":3,"file":"worker.service.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.service.ts"],"names":[],"mapp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aAAa,CAuCzB;AAvCY,sCAAa","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { threadId } from 'node:worker_threads';\nimport { Inject, Injectable } from '@nestjs/common';\nimport { SubqlStellarDataSource } from '@subql/common-stellar';\nimport {\n NodeConfig,\n getLogger,\n IProjectService,\n ProcessBlockResponse,\n ApiService,\n BaseWorkerService,\n IProjectUpgradeService,\n IBlock,\n Header,\n} from '@subql/node-core';\nimport { StellarBlockWrapper, SubqlDatasource } from '@subql/types-stellar';\nimport { stellarBlockToHeader } from '../../stellar/utils.stellar';\nimport { IndexerManager } from '../indexer.manager';\nimport { getBlockSize } from '../types';\n\nexport type FetchBlockResponse = Header;\n\nexport type WorkerStatusResponse = {\n threadId: number;\n isIndexing: boolean;\n fetchedBlocks: number;\n toFetchBlocks: number;\n};\n\nconst logger = getLogger(`Worker Service #${threadId}`);\n\n@Injectable()\nexport class WorkerService extends BaseWorkerService<\n StellarBlockWrapper,\n FetchBlockResponse,\n SubqlStellarDataSource,\n {}\n> {\n constructor(\n private apiService: ApiService,\n private indexerManager: IndexerManager,\n @Inject('IProjectService')\n projectService: IProjectService<SubqlDatasource>,\n @Inject('IProjectUpgradeService')\n projectUpgradeService: IProjectUpgradeService,\n nodeConfig: NodeConfig,\n ) {\n super(projectService, projectUpgradeService, nodeConfig);\n }\n protected async fetchChainBlock(\n heights: number,\n extra: {},\n ): Promise<IBlock<StellarBlockWrapper>> {\n const [block] = await this.apiService.fetchBlocks([heights]);\n return block;\n }\n\n protected toBlockResponse(block: StellarBlockWrapper): Header {\n return stellarBlockToHeader(block.block);\n }\n\n protected async processFetchedBlock(\n block: IBlock<StellarBlockWrapper>,\n dataSources: SubqlStellarDataSource[],\n ): Promise<ProcessBlockResponse> {\n return this.indexerManager.indexBlock(block, dataSources);\n }\n\n protected getBlockSize(block: IBlock<StellarBlockWrapper>): number {\n return getBlockSize(block.block);\n }\n}\n"]}
package/dist/init.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.bootstrap = void 0;
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAEnC,uCAA2C;AAC3C,0CAA8C;AAC9C,gDAK0B;AAC1B,6CAAyC;AACzC,2DAAuD;AAEvD,mCAAuC;AACvC,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEzC,MAAM,EAAE,IAAI,EAAE,GAAG,oBAAY,CAAC;AAE9B,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,YAAY,CAAC,CAAC;AAEvC,IAAA,sBAAa,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEtB,KAAK,UAAU,SAAS;IAC7B,MAAM,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,IAAI,eAAe,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEjE,MAAM,IAAI,GAAG,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,IAAI,EAAE;QACT,IAAA,yBAAa,EACX,wDAAwD,IAAI,KAC1D,IAAI,GAAG,EACT,iEAAiE,EACjE,MAAM,CACP,CAAC;KACH;IAED,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,MAAM,CAAC,IAAI,CACT,mHAAmH,CACpH,CAAC;KACH;IAED,IAAI;QACF,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,EAAE;YAC9C,MAAM,EAAE,IAAI,sBAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;SACrC,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,MAAM,cAAc,GAAmB,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAClE,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,4BAAY,CAAC,CAAC;QAE3C,yGAAyG;QACzG,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAEpD,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAE1B,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEvB,MAAM,CAAC,IAAI,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;KAC9C;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,yBAAa,EAAC,IAAI,KAAK,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;KACxE;AACH,CAAC;AAzCD,8BAyCC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NestFactory } from '@nestjs/core';\nimport { notifyUpdates } from '@subql/common';\nimport {\n exitWithError,\n getLogger,\n NestLogger,\n getValidPort,\n} from '@subql/node-core';\nimport { AppModule } from './app.module';\nimport { FetchService } from './indexer/fetch.service';\nimport { ProjectService } from './indexer/project.service';\nimport { yargsOptions } from './yargs';\nconst pjson = require('../package.json');\n\nconst { argv } = yargsOptions;\n\nconst logger = getLogger('subql-node');\n\nnotifyUpdates(pjson, logger);\n\nexport async function bootstrap(): Promise<void> {\n logger.info(`Current ${pjson.name} version is ${pjson.version}`);\n\n const port = await getValidPort(argv.port);\n if (!port) {\n exitWithError(\n `Unable to find available port (tried ports in range (${port}..${\n port + 10\n })). Try setting a free port manually by setting the --port flag`,\n logger,\n );\n }\n\n if (argv.unsafe) {\n logger.warn(\n 'UNSAFE MODE IS ENABLED. This is not recommended for most projects and will not be supported by our hosted service',\n );\n }\n\n try {\n const app = await NestFactory.create(AppModule, {\n logger: new NestLogger(!!argv.debug),\n });\n\n await app.init();\n\n const projectService: ProjectService = app.get('IProjectService');\n const fetchService = app.get(FetchService);\n\n // Initialise async services, we do this here rather than in factories, so we can capture one off eventss\n await projectService.init();\n await fetchService.init(projectService.startHeight);\n\n app.enableShutdownHooks();\n\n await app.listen(port);\n\n logger.info(`Node started on port: ${port}`);\n } catch (e) {\n exitWithError(new Error('Node failed to start', { cause: e }), logger);\n }\n}\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAEnC,uCAA2C;AAC3C,0CAA8C;AAC9C,gDAK0B;AAC1B,6CAAyC;AACzC,2DAAuD;AAEvD,mCAAuC;AACvC,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEzC,MAAM,EAAE,IAAI,EAAE,GAAG,oBAAY,CAAC;AAE9B,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,YAAY,CAAC,CAAC;AAEvC,IAAA,sBAAa,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEtB,KAAK,UAAU,SAAS;IAC7B,MAAM,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,IAAI,eAAe,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEjE,MAAM,IAAI,GAAG,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,IAAI,EAAE;QACT,IAAA,yBAAa,EACX,wDAAwD,IAAI,KAC1D,IAAI,GAAG,EACT,iEAAiE,EACjE,MAAM,CACP,CAAC;KACH;IAED,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,MAAM,CAAC,IAAI,CACT,mHAAmH,CACpH,CAAC;KACH;IAED,IAAI;QACF,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,EAAE;YAC9C,MAAM,EAAE,IAAI,sBAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;SACrC,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,MAAM,cAAc,GAAmB,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAClE,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,4BAAY,CAAC,CAAC;QAE3C,yGAAyG;QACzG,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAEpD,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAE1B,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEvB,MAAM,CAAC,IAAI,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;KAC9C;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,yBAAa,EAAC,IAAI,KAAK,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;KACxE;AACH,CAAC;AAzCD,8BAyCC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NestFactory } from '@nestjs/core';\nimport { notifyUpdates } from '@subql/common';\nimport {\n exitWithError,\n getLogger,\n NestLogger,\n getValidPort,\n} from '@subql/node-core';\nimport { AppModule } from './app.module';\nimport { FetchService } from './indexer/fetch.service';\nimport { ProjectService } from './indexer/project.service';\nimport { yargsOptions } from './yargs';\nconst pjson = require('../package.json');\n\nconst { argv } = yargsOptions;\n\nconst logger = getLogger('subql-node');\n\nnotifyUpdates(pjson, logger);\n\nexport async function bootstrap(): Promise<void> {\n logger.info(`Current ${pjson.name} version is ${pjson.version}`);\n\n const port = await getValidPort(argv.port);\n if (!port) {\n exitWithError(\n `Unable to find available port (tried ports in range (${port}..${\n port + 10\n })). Try setting a free port manually by setting the --port flag`,\n logger,\n );\n }\n\n if (argv.unsafe) {\n logger.warn(\n 'UNSAFE MODE IS ENABLED. This is not recommended for most projects and will not be supported by our hosted service',\n );\n }\n\n try {\n const app = await NestFactory.create(AppModule, {\n logger: new NestLogger(!!argv.debug),\n });\n\n await app.init();\n\n const projectService: ProjectService = app.get('IProjectService');\n const fetchService = app.get(FetchService);\n\n // Initialise async services, we do this here rather than in factories, so we can capture one off eventss\n await projectService.init();\n await fetchService.init(projectService.startHeight);\n\n app.enableShutdownHooks();\n\n await app.listen(port);\n\n logger.info(`Node started on port: ${port}`);\n } catch (e) {\n exitWithError(new Error('Node failed to start', { cause: e }), logger);\n }\n}\n"]}
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  const logger_1 = require("@subql/node-core/logger");
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,oDAAqD;AACrD,mCAAuC;AAEvC,MAAM,EAAE,IAAI,EAAE,GAAG,oBAAY,CAAC;AAE7B,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IACjC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,iIAAiI;AACjI,IAAA,mBAAU,EACR,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;AAEF,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;IACd,oEAAoE;IACpE,kDAAkD;IAClD,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,KAAK,SAAS,EAAE,CAAC;CAClB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { initLogger } from '@subql/node-core/logger';\nimport { yargsOptions } from './yargs';\n\nconst { argv } = yargsOptions;\n\n(BigInt.prototype as any).toJSON = function () {\n return this.toString();\n};\n\n// initLogger is imported from true path, to make sure getLogger (or other logger values that relies on logger) isn't initialised\ninitLogger(\n argv.debug,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n);\n\nif (!argv._[0]) {\n // Lazy import, to allow logger to be initialised before bootstrap()\n // As bootstrap runs services that requires logger\n const { bootstrap } = require('./init');\n void bootstrap();\n}\n"]}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,oDAAqD;AACrD,mCAAuC;AAEvC,MAAM,EAAE,IAAI,EAAE,GAAG,oBAAY,CAAC;AAE7B,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IACjC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,iIAAiI;AACjI,IAAA,mBAAU,EACR,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;AAEF,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;IACd,oEAAoE;IACpE,kDAAkD;IAClD,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,KAAK,SAAS,EAAE,CAAC;CAClB","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { initLogger } from '@subql/node-core/logger';\nimport { yargsOptions } from './yargs';\n\nconst { argv } = yargsOptions;\n\n(BigInt.prototype as any).toJSON = function () {\n return this.toString();\n};\n\n// initLogger is imported from true path, to make sure getLogger (or other logger values that relies on logger) isn't initialised\ninitLogger(\n argv.debug,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n);\n\nif (!argv._[0]) {\n // Lazy import, to allow logger to be initialised before bootstrap()\n // As bootstrap runs services that requires logger\n const { bootstrap } = require('./init');\n void bootstrap();\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.StellarApiConnection = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"api.connection.js","sourceRoot":"","sources":["../../src/stellar/api.connection.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAEnC,gDAU0B;AAK1B,+CAA2C;AAS3C,MAAa,oBAAoB;IAWtB;IACC;IAJD,WAAW,CAAyB;IAE7C,YACS,SAAqB,EACpB,kBAA6B;QAD9B,cAAS,GAAT,SAAS,CAAY;QACpB,uBAAkB,GAAlB,kBAAkB,CAAW;QAErC,IAAI,CAAC,WAAW,GAAG;YACjB,KAAK,EAAE,SAAS,CAAC,UAAU,EAAE;YAC7B,QAAQ,EAAE,SAAS,CAAC,WAAW,EAAE;YACjC,WAAW,EAAE,SAAS,CAAC,cAAc,EAAE;SACxC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,QAAgB,EAChB,iBAA4B,EAC5B,OAAuB,EACvB,MAA+B;QAE/B,MAAM,GAAG,GAAG,IAAI,wBAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEtD,MAAM,GAAG,CAAC,IAAI,EAAE,CAA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Ae,GAAG,IAAI,8BAAkB,CACtC,CAAC,CAAC,IAAI,EACN,CAAC,CAAC,OAAO,EACT,wBAAY,CAAC,OAAO,CACrB,CAAC;SACH;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AA5ED,oDA4EC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n ApiConnectionError,\n ApiErrorType,\n IApiConnectionSpecific,\n NetworkMetadataPayload,\n TimeoutError,\n RateLimitError,\n DisconnectionError,\n LargeResponseError,\n IBlock,\n} from '@subql/node-core';\nimport {\n StellarBlockWrapper,\n IStellarEndpointConfig,\n} from '@subql/types-stellar';\nimport { StellarApi } from './api.stellar';\nimport SafeStellarProvider from './safe-api';\nimport { SorobanServer } from './soroban.server';\n\ntype FetchFunc = (\n api: StellarApi,\n batch: number[],\n) => Promise<IBlock<StellarBlockWrapper>[]>;\n\nexport class StellarApiConnection\n implements\n IApiConnectionSpecific<\n StellarApi,\n SafeStellarProvider,\n IBlock<StellarBlockWrapper>[]\n >\n{\n readonly networkMeta: NetworkMetadataPayload;\n\n constructor(\n public unsafeApi: StellarApi,\n private fetchBlocksBatches: FetchFunc,\n ) {\n this.networkMeta = {\n chain: unsafeApi.getChainId(),\n specName: unsafeApi.getSpecName(),\n genesisHash: unsafeApi.getGenesisHash(),\n };\n }\n\n static async create(\n endpoint: string,\n fetchBlockBatches: FetchFunc,\n soroban?: SorobanServer,\n config?: IStellarEndpointConfig,\n ): Promise<StellarApiConnection> {\n const api = new StellarApi(endpoint, soroban, config);\n\n await api.init();\n\n return new StellarApiConnection(api, fetchBlockBatches);\n }\n\n safeApi(height: number): SafeStellarProvider {\n //safe api not implemented\n throw new Error(`Not Implemented`);\n }\n\n async apiConnect(): Promise<void> {\n await this.unsafeApi.connect();\n }\n\n async apiDisconnect(): Promise<void> {\n await this.unsafeApi.disconnect();\n }\n\n async fetchBlocks(heights: number[]): Promise<IBlock<StellarBlockWrapper>[]> {\n const blocks = await this.fetchBlocksBatches(this.unsafeApi, heights);\n return blocks;\n }\n\n handleError = StellarApiConnection.handleError;\n\n static handleError(e: Error): ApiConnectionError {\n let formatted_error: ApiConnectionError;\n if (e.message.includes(`Timeout`)) {\n formatted_error = new TimeoutError(e);\n } else if (e.message.startsWith(`disconnected from `)) {\n formatted_error = new DisconnectionError(e);\n } else if (\n e.message.includes(`Rate Limit Exceeded`) ||\n e.message.includes('Too Many Requests')\n ) {\n formatted_error = new RateLimitError(e);\n } else if (e.message.includes(`limit must not exceed`)) {\n formatted_error = new LargeResponseError(e);\n } else {\n formatted_error = new ApiConnectionError(\n e.name,\n e.message,\n ApiErrorType.Default,\n );\n }\n return formatted_error;\n }\n}\n"]}
1
+ {"version":3,"file":"api.connection.js","sourceRoot":"","sources":["../../src/stellar/api.connection.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAEnC,gDAU0B;AAK1B,+CAA2C;AAS3C,MAAa,oBAAoB;IAWtB;IACC;IAJD,WAAW,CAAyB;IAE7C,YACS,SAAqB,EACpB,kBAA6B;QAD9B,cAAS,GAAT,SAAS,CAAY;QACpB,uBAAkB,GAAlB,kBAAkB,CAAW;QAErC,IAAI,CAAC,WAAW,GAAG;YACjB,KAAK,EAAE,SAAS,CAAC,UAAU,EAAE;YAC7B,QAAQ,EAAE,SAAS,CAAC,WAAW,EAAE;YACjC,WAAW,EAAE,SAAS,CAAC,cAAc,EAAE;SACxC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,QAAgB,EAChB,iBAA4B,EAC5B,OAAuB,EACvB,MAA+B;QAE/B,MAAM,GAAG,GAAG,IAAI,wBAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEtD,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,OAAO,IAAI,oBAAoB,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAC1D,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wBAAY,CAAC,OAAO,CACrB,CAAC;SACH;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AA5ED,oDA4EC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n ApiConnectionError,\n ApiErrorType,\n IApiConnectionSpecific,\n NetworkMetadataPayload,\n TimeoutError,\n RateLimitError,\n DisconnectionError,\n LargeResponseError,\n IBlock,\n} from '@subql/node-core';\nimport {\n StellarBlockWrapper,\n IStellarEndpointConfig,\n} from '@subql/types-stellar';\nimport { StellarApi } from './api.stellar';\nimport SafeStellarProvider from './safe-api';\nimport { SorobanServer } from './soroban.server';\n\ntype FetchFunc = (\n api: StellarApi,\n batch: number[],\n) => Promise<IBlock<StellarBlockWrapper>[]>;\n\nexport class StellarApiConnection\n implements\n IApiConnectionSpecific<\n StellarApi,\n SafeStellarProvider,\n IBlock<StellarBlockWrapper>[]\n >\n{\n readonly networkMeta: NetworkMetadataPayload;\n\n constructor(\n public unsafeApi: StellarApi,\n private fetchBlocksBatches: FetchFunc,\n ) {\n this.networkMeta = {\n chain: unsafeApi.getChainId(),\n specName: unsafeApi.getSpecName(),\n genesisHash: unsafeApi.getGenesisHash(),\n };\n }\n\n static async create(\n endpoint: string,\n fetchBlockBatches: FetchFunc,\n soroban?: SorobanServer,\n config?: IStellarEndpointConfig,\n ): Promise<StellarApiConnection> {\n const api = new StellarApi(endpoint, soroban, config);\n\n await api.init();\n\n return new StellarApiConnection(api, fetchBlockBatches);\n }\n\n safeApi(height: number): SafeStellarProvider {\n //safe api not implemented\n throw new Error(`Not Implemented`);\n }\n\n async apiConnect(): Promise<void> {\n await this.unsafeApi.connect();\n }\n\n async apiDisconnect(): Promise<void> {\n await this.unsafeApi.disconnect();\n }\n\n async fetchBlocks(heights: number[]): Promise<IBlock<StellarBlockWrapper>[]> {\n const blocks = await this.fetchBlocksBatches(this.unsafeApi, heights);\n return blocks;\n }\n\n handleError = StellarApiConnection.handleError;\n\n static handleError(e: Error): ApiConnectionError {\n let formatted_error: ApiConnectionError;\n if (e.message.includes(`Timeout`)) {\n formatted_error = new TimeoutError(e);\n } else if (e.message.startsWith(`disconnected from `)) {\n formatted_error = new DisconnectionError(e);\n } else if (\n e.message.includes(`Rate Limit Exceeded`) ||\n e.message.includes('Too Many Requests')\n ) {\n formatted_error = new RateLimitError(e);\n } else if (e.message.includes(`limit must not exceed`)) {\n formatted_error = new LargeResponseError(e);\n } else {\n formatted_error = new ApiConnectionError(\n e.name,\n e.message,\n ApiErrorType.Default,\n );\n }\n return formatted_error;\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  const node_core_1 = require("@subql/node-core");
@@ -1 +1 @@
1
- {"version":3,"file":"api.connection.spec.js","sourceRoot":"","sources":["../../src/stellar/api.connection.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,gDAO0B;AAE1B,qDAAwD;AACxD,+CAA2C;AAC3C,qDAAiD;AAEjD,MAAM,aAAa,GAAG,uCAAuC,CAAC;AAC9D,MAAM,gBAAgB,GAAG,mCAAmC,CAAC;AAE7D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,aAAmC,CAAC;IACxC,IAAI,SAAqB,CAAC;IAC1B,IAAI,UAAyB,CAAC;IAC9B,MAAM,UAAU,GAA0B;QACxC;YACE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAA6B;YAChE,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,EAAE;SACZ;QACD;YACE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,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AO,CAAC,wBAAY,CAAC,OAAO,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n ApiConnectionError,\n ApiErrorType,\n DisconnectionError,\n LargeResponseError,\n RateLimitError,\n TimeoutError,\n} from '@subql/node-core';\nimport { StellarBlock, StellarBlockWrapper } from '@subql/types-stellar';\nimport { StellarApiConnection } from './api.connection';\nimport { StellarApi } from './api.stellar';\nimport { SorobanServer } from './soroban.server';\n\nconst HTTP_ENDPOINT = 'https://horizon-futurenet.stellar.org';\nconst SOROBAN_ENDPOINT = 'https://rpc-futurenet.stellar.org';\n\ndescribe('StellarApiConnection', () => {\n let apiConnection: StellarApiConnection;\n let unsafeApi: StellarApi;\n let sorobanApi: SorobanServer;\n const mockBlocks: StellarBlockWrapper[] = [\n {\n block: { sequence: 1, hash: 'hash1' } as unknown as StellarBlock,\n transactions: [],\n operations: [],\n effects: [],\n },\n {\n block: { sequence: 2, hash: 'hash2' } as unknown as StellarBlock,\n transactions: [],\n operations: [],\n effects: [],\n },\n ];\n\n const fetchBlockBatches = jest.fn().mockResolvedValue(mockBlocks);\n\n beforeEach(async () => {\n sorobanApi = new SorobanServer(SOROBAN_ENDPOINT);\n unsafeApi = new StellarApi(HTTP_ENDPOINT, sorobanApi);\n await unsafeApi.init();\n apiConnection = new StellarApiConnection(unsafeApi, fetchBlockBatches);\n });\n\n it('creates a connection', async () => {\n expect(\n await StellarApiConnection.create(\n HTTP_ENDPOINT,\n fetchBlockBatches,\n sorobanApi,\n ),\n ).toBeInstanceOf(StellarApiConnection);\n });\n\n it('fetches blocks', async () => {\n const result = await apiConnection.fetchBlocks([1, 2]);\n expect(result).toEqual(mockBlocks);\n expect(fetchBlockBatches).toHaveBeenCalledWith(unsafeApi, [1, 2]);\n });\n\n describe('Error handling', () => {\n it('handles timeout errors', () => {\n const error = new Error('Timeout');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(TimeoutError);\n });\n\n it('handles disconnection errors', () => {\n const error = new Error('disconnected from ');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(DisconnectionError);\n });\n\n it('handles rate limit errors', () => {\n const error = new Error('Rate Limit Exceeded');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(RateLimitError);\n });\n\n it('handles large response errors', () => {\n const error = new Error('limit must not exceed');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(LargeResponseError);\n });\n\n it('handles default errors', () => {\n const error = new Error('default error');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(ApiConnectionError);\n expect(handledError.errorType).toEqual(ApiErrorType.Default);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"api.connection.spec.js","sourceRoot":"","sources":["../../src/stellar/api.connection.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,gDAO0B;AAE1B,qDAAwD;AACxD,+CAA2C;AAC3C,qDAAiD;AAEjD,MAAM,aAAa,GAAG,uCAAuC,CAAC;AAC9D,MAAM,gBAAgB,GAAG,mCAAmC,CAAC;AAE7D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,aAAmC,CAAC;IACxC,IAAI,SAAqB,CAAC;IAC1B,IAAI,UAAyB,CAAC;IAC9B,MAAM,UAAU,GAA0B;QACxC;YACE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAA6B;YAChE,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,EAAE;SACZ;QACD;YACE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAA6B;YAChE,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE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CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n ApiConnectionError,\n ApiErrorType,\n DisconnectionError,\n LargeResponseError,\n RateLimitError,\n TimeoutError,\n} from '@subql/node-core';\nimport { StellarBlock, StellarBlockWrapper } from '@subql/types-stellar';\nimport { StellarApiConnection } from './api.connection';\nimport { StellarApi } from './api.stellar';\nimport { SorobanServer } from './soroban.server';\n\nconst HTTP_ENDPOINT = 'https://horizon-futurenet.stellar.org';\nconst SOROBAN_ENDPOINT = 'https://rpc-futurenet.stellar.org';\n\ndescribe('StellarApiConnection', () => {\n let apiConnection: StellarApiConnection;\n let unsafeApi: StellarApi;\n let sorobanApi: SorobanServer;\n const mockBlocks: StellarBlockWrapper[] = [\n {\n block: { sequence: 1, hash: 'hash1' } as unknown as StellarBlock,\n transactions: [],\n operations: [],\n effects: [],\n },\n {\n block: { sequence: 2, hash: 'hash2' } as unknown as StellarBlock,\n transactions: [],\n operations: [],\n effects: [],\n },\n ];\n\n const fetchBlockBatches = jest.fn().mockResolvedValue(mockBlocks);\n\n beforeEach(async () => {\n sorobanApi = new SorobanServer(SOROBAN_ENDPOINT);\n unsafeApi = new StellarApi(HTTP_ENDPOINT, sorobanApi);\n await unsafeApi.init();\n apiConnection = new StellarApiConnection(unsafeApi, fetchBlockBatches);\n });\n\n it('creates a connection', async () => {\n expect(\n await StellarApiConnection.create(\n HTTP_ENDPOINT,\n fetchBlockBatches,\n sorobanApi,\n ),\n ).toBeInstanceOf(StellarApiConnection);\n });\n\n it('fetches blocks', async () => {\n const result = await apiConnection.fetchBlocks([1, 2]);\n expect(result).toEqual(mockBlocks);\n expect(fetchBlockBatches).toHaveBeenCalledWith(unsafeApi, [1, 2]);\n });\n\n describe('Error handling', () => {\n it('handles timeout errors', () => {\n const error = new Error('Timeout');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(TimeoutError);\n });\n\n it('handles disconnection errors', () => {\n const error = new Error('disconnected from ');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(DisconnectionError);\n });\n\n it('handles rate limit errors', () => {\n const error = new Error('Rate Limit Exceeded');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(RateLimitError);\n });\n\n it('handles large response errors', () => {\n const error = new Error('limit must not exceed');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(LargeResponseError);\n });\n\n it('handles default errors', () => {\n const error = new Error('default error');\n const handledError = StellarApiConnection.handleError(error);\n expect(handledError).toBeInstanceOf(ApiConnectionError);\n expect(handledError.errorType).toEqual(ApiErrorType.Default);\n });\n });\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1 +1 @@
1
- {"version":3,"file":"api.service.stellar.js","sourceRoot":"","sources":["../../src/stellar/api.service.stellar.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,yDAAsD;AAEtD,gDAO0B;AAO1B,kEAGsC;AACtC,qDAAwD;AAGxD,qDAAiD;AAEjD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;AAGzB,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,sBAMtC;IAGuC;IAF9B,UAAU,CAAa;IAC/B,YACsC,OAAwB,EAC5D,qBAAkE,EAClE,YAA2B,EAC3B,UAAsB;QAEtB,KAAK,CAAC,qBAAqB,EAA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AAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC7C,CAAC;SACF,CAAC;QAEF,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAC7B,GAAe,EACf,KAAe;QAEf,OAAO,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF,CAAA;AAvHY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAUR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;6CACJ,iCAAqB;QAC9B,6BAAa;QACf,sBAAU;GAZb,iBAAiB,CAuH7B;AAvHY,8CAAiB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { StellarProjectNetworkConfig } from '@subql/common-stellar';\nimport {\n ApiService,\n ConnectionPoolService,\n getLogger,\n IBlock,\n exitWithError,\n NodeConfig,\n} from '@subql/node-core';\nimport { IEndpointConfig } from '@subql/types-core';\nimport {\n StellarBlockWrapper,\n SubqlDatasource,\n IStellarEndpointConfig,\n} from '@subql/types-stellar';\nimport {\n SubqueryProject,\n dsHasSorobanEventHandler,\n} from '../configure/SubqueryProject';\nimport { StellarApiConnection } from './api.connection';\nimport { StellarApi } from './api.stellar';\nimport SafeStellarProvider from './safe-api';\nimport { SorobanServer } from './soroban.server';\n\nconst logger = getLogger('api');\n\n@Injectable()\nexport class StellarApiService extends ApiService<\n StellarApi,\n SafeStellarProvider,\n IBlock<StellarBlockWrapper>[],\n StellarApiConnection,\n IStellarEndpointConfig\n> {\n private nodeConfig: NodeConfig;\n constructor(\n @Inject('ISubqueryProject') private project: SubqueryProject,\n connectionPoolService: ConnectionPoolService<StellarApiConnection>,\n eventEmitter: EventEmitter2,\n nodeConfig: NodeConfig,\n ) {\n super(connectionPoolService, eventEmitter);\n this.nodeConfig = nodeConfig;\n }\n\n async init(): Promise<StellarApiService> {\n let network: StellarProjectNetworkConfig;\n try {\n network = this.project.network;\n } catch (e) {\n exitWithError(new Error(`Failed to init api`, { cause: e }), logger);\n }\n\n if (this.nodeConfig.primaryNetworkEndpoint) {\n const [endpoint, config] = this.nodeConfig.primaryNetworkEndpoint;\n (network.endpoint as Record<string, IEndpointConfig>)[endpoint] = config;\n }\n\n const sorobanEndpoint: string | undefined = network.sorobanEndpoint;\n\n if (!network.sorobanEndpoint && sorobanEndpoint) {\n //update sorobanEndpoint from parent project\n this.project.network.sorobanEndpoint = sorobanEndpoint;\n }\n\n if (\n dsHasSorobanEventHandler([\n ...this.project.dataSources,\n ...(this.project.templates as SubqlDatasource[]),\n ]) &&\n !sorobanEndpoint\n ) {\n throw new Error(\n `Soroban network endpoint must be provided for network. chainId=\"${this.project.network.chainId}\"`,\n );\n }\n\n const sorobanClient = sorobanEndpoint\n ? new SorobanServer(sorobanEndpoint)\n : undefined;\n\n await this.createConnections(network, (endpoint, config) =>\n StellarApiConnection.create(\n endpoint,\n this.fetchBlockBatches,\n sorobanClient,\n config,\n ),\n );\n\n return this;\n }\n\n get api(): StellarApi {\n return this.unsafeApi;\n }\n\n safeApi(height: number): SafeStellarProvider {\n const maxRetries = 5;\n\n const handler: ProxyHandler<SafeStellarProvider> = {\n get: (target, prop, receiver) => {\n const originalMethod = target[prop as keyof SafeStellarProvider];\n if (typeof originalMethod === 'function') {\n return async (\n ...args: any[]\n ): Promise<ReturnType<typeof originalMethod>> => {\n let retries = 0;\n let currentApi = target;\n let throwingError: Error | undefined;\n\n while (retries < maxRetries) {\n try {\n return await originalMethod.apply(currentApi, args);\n } catch (error: any) {\n logger.warn(\n `Request failed with api at height ${height} (retry ${retries}): ${error.message}`,\n );\n throwingError = error;\n currentApi = this.unsafeApi.getSafeApi(height);\n retries++;\n }\n }\n\n logger.error(\n `Maximum retries (${maxRetries}) exceeded for api at height ${height}`,\n );\n if (!throwingError) {\n throw new Error('Failed to make request, maximum retries failed');\n }\n throw throwingError;\n };\n }\n return Reflect.get(target, prop, receiver);\n },\n };\n\n return new Proxy(this.unsafeApi.getSafeApi(height), handler);\n }\n\n private async fetchBlockBatches(\n api: StellarApi,\n batch: number[],\n ): Promise<IBlock<StellarBlockWrapper>[]> {\n return api.fetchBlocks(batch);\n }\n}\n"]}
1
+ {"version":3,"file":"api.service.stellar.js","sourceRoot":"","sources":["../../src/stellar/api.service.stellar.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,yDAAsD;AAEtD,gDAO0B;AAO1B,kEAGsC;AACtC,qDAAwD;AAGxD,qDAAiD;AAEjD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;AAGzB,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,sBAMtC;IAGuC;IAF9B,UAAU,CAAa;IAC/B,YACsC,OAAwB,EAC5D,qBAAkE,EAClE,YAA2B,EAC3B,UAAsB;QAEtB,KAAK,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC;QALP,YAAO,GAAP,OAAO,CAAiB;QAM5D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,OAAoC,CAAC;QACzC,IAAI;YACF,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SAChC;QAAC,OAAO,CAAC,EAAE;YACV,IAAA,yBAAa,EAAC,IAAI,KAAK,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;SACtE;QAED,IAAI,IAAI,CAAC,UAAU,CAAC,sBAAsB,EAAE;YAC1C,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GA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B,CAuH7B;AAvHY,8CAAiB","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { StellarProjectNetworkConfig } from '@subql/common-stellar';\nimport {\n ApiService,\n ConnectionPoolService,\n getLogger,\n IBlock,\n exitWithError,\n NodeConfig,\n} from '@subql/node-core';\nimport { IEndpointConfig } from '@subql/types-core';\nimport {\n StellarBlockWrapper,\n SubqlDatasource,\n IStellarEndpointConfig,\n} from '@subql/types-stellar';\nimport {\n SubqueryProject,\n dsHasSorobanEventHandler,\n} from '../configure/SubqueryProject';\nimport { StellarApiConnection } from './api.connection';\nimport { StellarApi } from './api.stellar';\nimport SafeStellarProvider from './safe-api';\nimport { SorobanServer } from './soroban.server';\n\nconst logger = getLogger('api');\n\n@Injectable()\nexport class StellarApiService extends ApiService<\n StellarApi,\n SafeStellarProvider,\n IBlock<StellarBlockWrapper>[],\n StellarApiConnection,\n IStellarEndpointConfig\n> {\n private nodeConfig: NodeConfig;\n constructor(\n @Inject('ISubqueryProject') private project: SubqueryProject,\n connectionPoolService: ConnectionPoolService<StellarApiConnection>,\n eventEmitter: EventEmitter2,\n nodeConfig: NodeConfig,\n ) {\n super(connectionPoolService, eventEmitter);\n this.nodeConfig = nodeConfig;\n }\n\n async init(): Promise<StellarApiService> {\n let network: StellarProjectNetworkConfig;\n try {\n network = this.project.network;\n } catch (e) {\n exitWithError(new Error(`Failed to init api`, { cause: e }), logger);\n }\n\n if (this.nodeConfig.primaryNetworkEndpoint) {\n const [endpoint, config] = this.nodeConfig.primaryNetworkEndpoint;\n (network.endpoint as Record<string, IEndpointConfig>)[endpoint] = config;\n }\n\n const sorobanEndpoint: string | undefined = network.sorobanEndpoint;\n\n if (!network.sorobanEndpoint && sorobanEndpoint) {\n //update sorobanEndpoint from parent project\n this.project.network.sorobanEndpoint = sorobanEndpoint;\n }\n\n if (\n dsHasSorobanEventHandler([\n ...this.project.dataSources,\n ...(this.project.templates as SubqlDatasource[]),\n ]) &&\n !sorobanEndpoint\n ) {\n throw new Error(\n `Soroban network endpoint must be provided for network. chainId=\"${this.project.network.chainId}\"`,\n );\n }\n\n const sorobanClient = sorobanEndpoint\n ? new SorobanServer(sorobanEndpoint)\n : undefined;\n\n await this.createConnections(network, (endpoint, config) =>\n StellarApiConnection.create(\n endpoint,\n this.fetchBlockBatches,\n sorobanClient,\n config,\n ),\n );\n\n return this;\n }\n\n get api(): StellarApi {\n return this.unsafeApi;\n }\n\n safeApi(height: number): SafeStellarProvider {\n const maxRetries = 5;\n\n const handler: ProxyHandler<SafeStellarProvider> = {\n get: (target, prop, receiver) => {\n const originalMethod = target[prop as keyof SafeStellarProvider];\n if (typeof originalMethod === 'function') {\n return async (\n ...args: any[]\n ): Promise<ReturnType<typeof originalMethod>> => {\n let retries = 0;\n let currentApi = target;\n let throwingError: Error | undefined;\n\n while (retries < maxRetries) {\n try {\n return await originalMethod.apply(currentApi, args);\n } catch (error: any) {\n logger.warn(\n `Request failed with api at height ${height} (retry ${retries}): ${error.message}`,\n );\n throwingError = error;\n currentApi = this.unsafeApi.getSafeApi(height);\n retries++;\n }\n }\n\n logger.error(\n `Maximum retries (${maxRetries}) exceeded for api at height ${height}`,\n );\n if (!throwingError) {\n throw new Error('Failed to make request, maximum retries failed');\n }\n throw throwingError;\n };\n }\n return Reflect.get(target, prop, receiver);\n },\n };\n\n return new Proxy(this.unsafeApi.getSafeApi(height), handler);\n }\n\n private async fetchBlockBatches(\n api: StellarApi,\n batch: number[],\n ): Promise<IBlock<StellarBlockWrapper>[]> {\n return api.fetchBlocks(batch);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  const event_emitter_1 = require("@nestjs/event-emitter");
@@ -1 +1 @@
1
- {"version":3,"file":"api.service.stellar.spec.js","sourceRoot":"","sources":["../../src/stellar/api.service.stellar.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAGnC,yDAA2D;AAC3D,6CAAuC;AACvC,sDAAqD;AACrD,gDAAqE;AACrE,gDAAmE;AACnE,qCAAwC;AACxC,mCAA+B;AAE/B,+DAA0D;AAC1D,+CAA2C;AAE3C,MAAM,aAAa,GAAG,uCAAuC,CAAC;AAC9D,MAAM,gBAAgB,GAAG,mCAAmC,CAAC;AAE7D,SAAS,mBAAmB,CAC1B,QAAgB,EAChB,eAAuB;IAEvB,OAAO;QACL,OAAO,EAAE;YACP,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,eAAe;YACf,OAAO,EAAE,wCAAwC;SAClD;QACD,WAAW,EAAE,EAAE;QACf,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,IAAI,uBAAa,CAAC,EAAE,CAAC;QAC7B,SAAS,EAAE,EAAE;KACgB,CAAC;AAClC,CAAC;AAED,MAAM,iBAAiB,GAAG,KAAK,EAC7B,WAAmB,aAAa,EAChC,UAAkB,gBAAgB,EAClC,OAAyB,EACuB,EAAE;IAClD,MAAM,MAAM,GAAG,MAAM,cAAI,CAAC,mBAAmB,CAAC;QAC5C,SAAS,EAAE;YACT,iCAAqB;YACrB,iCAA0B;YAC1B;gBACE,OAAO,EAAE,wBAAwB;gBACjC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;aACvB;YACD;gBACE,OAAO,EAAE,sBAAU;gBACnB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;aACvB;YACD;gBACE,OAAO,EAAE,kBAAkB;gBAC3B,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,IAAI,mBAAmB,CAAC,QAAQ,EAAE,OAAO,C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L-3.0\n\nimport { INestApplication } from '@nestjs/common';\nimport { EventEmitterModule } from '@nestjs/event-emitter';\nimport { Test } from '@nestjs/testing';\nimport { scValToNative } from '@stellar/stellar-sdk';\nimport { ConnectionPoolService, NodeConfig } from '@subql/node-core';\nimport { ConnectionPoolStateManager } from '@subql/node-core/dist';\nimport { GraphQLSchema } from 'graphql';\nimport { range } from 'lodash';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { StellarApiService } from './api.service.stellar';\nimport { StellarApi } from './api.stellar';\n\nconst HTTP_ENDPOINT = 'https://horizon-futurenet.stellar.org';\nconst SOROBAN_ENDPOINT = 'https://rpc-futurenet.stellar.org';\n\nfunction testSubqueryProject(\n endpoint: string,\n sorobanEndpoint: string,\n): SubqueryProject {\n return {\n network: {\n endpoint: [endpoint],\n sorobanEndpoint,\n chainId: 'Test SDF Future Network ; October 2022',\n },\n dataSources: [],\n id: 'test',\n root: './',\n schema: new GraphQLSchema({}),\n templates: [],\n } as unknown as SubqueryProject;\n}\n\nconst prepareApiService = async (\n endpoint: string = HTTP_ENDPOINT,\n soroban: string = SOROBAN_ENDPOINT,\n project?: SubqueryProject,\n): Promise<[StellarApiService, INestApplication]> => {\n const module = await Test.createTestingModule({\n providers: [\n ConnectionPoolService,\n ConnectionPoolStateManager,\n {\n provide: 'IProjectUpgradeService',\n useFactory: () => ({}),\n },\n {\n provide: NodeConfig,\n useFactory: () => ({}),\n },\n {\n provide: 'ISubqueryProject',\n useFactory: () => project ?? testSubqueryProject(endpoint, soroban),\n },\n StellarApiService,\n ],\n imports: [EventEmitterModule.forRoot()],\n }).compile();\n\n const app = module.createNestApplication();\n await app.init();\n const apiService = app.get(StellarApiService);\n await apiService.init();\n return [apiService, app];\n};\n\njest.setTimeout(90000);\ndescribe('StellarApiService', () => {\n let apiService: StellarApiService;\n let app: INestApplication;\n\n beforeEach(async () => {\n [apiService, app] = await prepareApiService();\n });\n\n it('should instantiate api', () => {\n expect(apiService.api).toBeInstanceOf(StellarApi);\n });\n\n it('should fetch blocks', async () => {\n const latestHeight = await apiService.api.getFinalizedBlockHeight();\n const blocks = await apiService.fetchBlocks(\n range(latestHeight - 1, latestHeight),\n );\n expect(blocks).toBeDefined();\n expect(blocks[0].block.block.sequence).toEqual(latestHeight - 1);\n });\n\n it('should throw error when chainId does not match', async () => {\n const faultyProject = {\n ...testSubqueryProject(HTTP_ENDPOINT, SOROBAN_ENDPOINT),\n network: {\n ...testSubqueryProject(HTTP_ENDPOINT, SOROBAN_ENDPOINT).network,\n chainId: 'Incorrect ChainId',\n },\n };\n\n await expect(\n prepareApiService(\n HTTP_ENDPOINT,\n SOROBAN_ENDPOINT,\n faultyProject as unknown as SubqueryProject,\n ),\n ).rejects.toThrow();\n });\n\n it('fails after maximum retries', async () => {\n const api = apiService.unsafeApi;\n\n // Mock the fetchBlocks method to always throw an error\n (api as any).fetchBlocks = jest\n .fn()\n .mockRejectedValue(new Error('Network error'));\n\n await expect(\n (api as any).fetchBlocks(range(50000, 50100)),\n ).rejects.toThrow();\n });\n});\n\n// Skip test as rpc is pruned and block can be missing,\n// To test this, find any block with transfer event first\ndescribe.skip('testnet StellarApiService', () => {\n let apiService: StellarApiService;\n let app: INestApplication;\n\n function testSubqueryProject2(\n endpoint: string,\n sorobanEndpoint: string,\n ): SubqueryProject {\n return {\n network: {\n endpoint: [endpoint],\n sorobanEndpoint,\n chainId: 'Test SDF Network ; September 2015',\n },\n dataSources: [],\n id: 'test',\n root: './',\n schema: new GraphQLSchema({}),\n templates: [],\n } as unknown as SubqueryProject;\n }\n\n beforeEach(async () => {\n [apiService, app] = await prepareApiService(\n 'https://horizon-testnet.stellar.org',\n 'https://soroban-testnet.stellar.org',\n testSubqueryProject2(\n 'https://horizon-testnet.stellar.org',\n 'https://soroban-testnet.stellar.org',\n ),\n );\n });\n\n it('should fetch blocks, and decode address', async () => {\n const blocks = await apiService.fetchBlocks([228236]);\n expect(blocks).toBeDefined();\n\n const block228236 = blocks[0];\n const transferEvent = block228236.block.events?.find(\n (e) => e.id === '0000980266155778048-0000000001',\n );\n\n const [sys, from, to] = transferEvent!.topic;\n const decodedFrom = scValToNative(from).toString();\n const decodedTo = scValToNative(to).toString();\n\n console.log(scValToNative(sys));\n console.log(decodedFrom);\n console.log(decodedTo);\n });\n});\n"]}
1
+ {"version":3,"file":"api.service.stellar.spec.js","sourceRoot":"","sources":["../../src/stellar/api.service.stellar.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAGnC,yDAA2D;AAC3D,6CAAuC;AACvC,sDAAqD;AACrD,gDAAqE;AACrE,gDAAmE;AACnE,qCAAwC;AACxC,mCAA+B;AAE/B,+DAA0D;AAC1D,+CAA2C;AAE3C,MAAM,aAAa,GAAG,uCAAuC,CAAC;AAC9D,MAAM,gBAAgB,GAAG,mCAAmC,CAAC;AAE7D,SAAS,mBAAmB,CAC1B,QAAgB,EAChB,eAAuB;IAEvB,OAAO;QACL,OAAO,EAAE;YACP,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,eAAe;YACf,OAAO,EAAE,wCAAwC;SAClD;QACD,WAAW,EAAE,EAAE;QACf,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,IAAI,uBAAa,CAAC,EAAE,CAAC;QAC7B,SAAS,EAAE,EAAE;KACgB,CAAC;AAClC,CAAC;AAED,MAAM,iBAAiB,GAAG,KAAK,EAC7B,WAAmB,aAAa,EAChC,UAAkB,gBAAgB,EAClC,OAAyB,EACuB,EAAE;IAClD,MAAM,MAAM,GAAG,MAAM,cAAI,CAAC,mBAAmB,CAAC;QAC5C,SAAS,EAAE;YACT,iCAAqB;YACrB,iCAA0B;YAC1B;gBACE,OAAO,EAAE,wBAAwB;gBACjC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;aACvB;YACD;gBACE,OAAO,EAAE,sBAAU;gBACnB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;aACv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CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { INestApplication } from '@nestjs/common';\nimport { EventEmitterModule } from '@nestjs/event-emitter';\nimport { Test } from '@nestjs/testing';\nimport { scValToNative } from '@stellar/stellar-sdk';\nimport { ConnectionPoolService, NodeConfig } from '@subql/node-core';\nimport { ConnectionPoolStateManager } from '@subql/node-core/dist';\nimport { GraphQLSchema } from 'graphql';\nimport { range } from 'lodash';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { StellarApiService } from './api.service.stellar';\nimport { StellarApi } from './api.stellar';\n\nconst HTTP_ENDPOINT = 'https://horizon-futurenet.stellar.org';\nconst SOROBAN_ENDPOINT = 'https://rpc-futurenet.stellar.org';\n\nfunction testSubqueryProject(\n endpoint: string,\n sorobanEndpoint: string,\n): SubqueryProject {\n return {\n network: {\n endpoint: [endpoint],\n sorobanEndpoint,\n chainId: 'Test SDF Future Network ; October 2022',\n },\n dataSources: [],\n id: 'test',\n root: './',\n schema: new GraphQLSchema({}),\n templates: [],\n } as unknown as SubqueryProject;\n}\n\nconst prepareApiService = async (\n endpoint: string = HTTP_ENDPOINT,\n soroban: string = SOROBAN_ENDPOINT,\n project?: SubqueryProject,\n): Promise<[StellarApiService, INestApplication]> => {\n const module = await Test.createTestingModule({\n providers: [\n ConnectionPoolService,\n ConnectionPoolStateManager,\n {\n provide: 'IProjectUpgradeService',\n useFactory: () => ({}),\n },\n {\n provide: NodeConfig,\n useFactory: () => ({}),\n },\n {\n provide: 'ISubqueryProject',\n useFactory: () => project ?? testSubqueryProject(endpoint, soroban),\n },\n StellarApiService,\n ],\n imports: [EventEmitterModule.forRoot()],\n }).compile();\n\n const app = module.createNestApplication();\n await app.init();\n const apiService = app.get(StellarApiService);\n await apiService.init();\n return [apiService, app];\n};\n\njest.setTimeout(90000);\ndescribe('StellarApiService', () => {\n let apiService: StellarApiService;\n let app: INestApplication;\n\n beforeEach(async () => {\n [apiService, app] = await prepareApiService();\n });\n\n it('should instantiate api', () => {\n expect(apiService.api).toBeInstanceOf(StellarApi);\n });\n\n it('should fetch blocks', async () => {\n const latestHeight = await apiService.api.getFinalizedBlockHeight();\n const blocks = await apiService.fetchBlocks(\n range(latestHeight - 1, latestHeight),\n );\n expect(blocks).toBeDefined();\n expect(blocks[0].block.block.sequence).toEqual(latestHeight - 1);\n });\n\n it('should throw error when chainId does not match', async () => {\n const faultyProject = {\n ...testSubqueryProject(HTTP_ENDPOINT, SOROBAN_ENDPOINT),\n network: {\n ...testSubqueryProject(HTTP_ENDPOINT, SOROBAN_ENDPOINT).network,\n chainId: 'Incorrect ChainId',\n },\n };\n\n await expect(\n prepareApiService(\n HTTP_ENDPOINT,\n SOROBAN_ENDPOINT,\n faultyProject as unknown as SubqueryProject,\n ),\n ).rejects.toThrow();\n });\n\n it('fails after maximum retries', async () => {\n const api = apiService.unsafeApi;\n\n // Mock the fetchBlocks method to always throw an error\n (api as any).fetchBlocks = jest\n .fn()\n .mockRejectedValue(new Error('Network error'));\n\n await expect(\n (api as any).fetchBlocks(range(50000, 50100)),\n ).rejects.toThrow();\n });\n});\n\n// Skip test as rpc is pruned and block can be missing,\n// To test this, find any block with transfer event first\ndescribe.skip('testnet StellarApiService', () => {\n let apiService: StellarApiService;\n let app: INestApplication;\n\n function testSubqueryProject2(\n endpoint: string,\n sorobanEndpoint: string,\n ): SubqueryProject {\n return {\n network: {\n endpoint: [endpoint],\n sorobanEndpoint,\n chainId: 'Test SDF Network ; September 2015',\n },\n dataSources: [],\n id: 'test',\n root: './',\n schema: new GraphQLSchema({}),\n templates: [],\n } as unknown as SubqueryProject;\n }\n\n beforeEach(async () => {\n [apiService, app] = await prepareApiService(\n 'https://horizon-testnet.stellar.org',\n 'https://soroban-testnet.stellar.org',\n testSubqueryProject2(\n 'https://horizon-testnet.stellar.org',\n 'https://soroban-testnet.stellar.org',\n ),\n );\n });\n\n it('should fetch blocks, and decode address', async () => {\n const blocks = await apiService.fetchBlocks([228236]);\n expect(blocks).toBeDefined();\n\n const block228236 = blocks[0];\n const transferEvent = block228236.block.events?.find(\n (e) => e.id === '0000980266155778048-0000000001',\n );\n\n const [sys, from, to] = transferEvent!.topic;\n const decodedFrom = scValToNative(from).toString();\n const decodedTo = scValToNative(to).toString();\n\n console.log(scValToNative(sys));\n console.log(decodedFrom);\n console.log(decodedTo);\n });\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -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,mDAAkD;AAElD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,aAAa,CAAC,CAAC;AAExC,MAAa,UAAU;IAOX;IACA;IAPV,yBAAyB;IACjB,aAAa,CAAgB;IAE7B,OAAO,CAAU;IAEzB,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;QAEpE,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAE9C,MAAM,CAAC,IAAI,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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;YACjD,OAAO,IAAI,KAAK,CAAC,+BAA+B,MAAM;;;;kFAIsB,CAAC,CAAC;SAC/E;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA7XD,gCA6XC","sourcesContent":["// Copyright 2020-2024 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 { 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\n constructor(\n private endpoint: string,\n private _sorobanClient?: SorobanServer,\n config?: IStellarEndpointConfig,\n ) {\n const { hostname, protocol, searchParams } = new URL(this.endpoint);\n\n const protocolStr = protocol.replace(':', '');\n\n logger.info(`Api host: ${hostname}, method: ${protocolStr}`);\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.transactions().forLedger(sequence).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.operations().forLedger(sequence).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 let effectsPage = await this.api.effects().forLedger(sequence).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 private getOperationIndex(id: string) {\n // Pick the first part of the ID before the '-' character\n const idPart = id.split('-')[0];\n\n // Create a mask for 12 bits to isolate the Operation Index\n const mask = BigInt((1 << 12) - 1);\n\n // Apply bitwise AND operation with the mask to get the Operation Index\n const operationIndex = BigInt(idPart) & mask;\n\n return Number(operationIndex);\n }\n\n async getAndWrapEvents(height: number): Promise<SorobanEvent[]> {\n const { events: events } = await this.sorobanClient.getEvents({\n startLedger: height,\n filters: [],\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 wrapEffectsForOperation(\n operationIndex: number,\n effectsForSequence: Horizon.ServerApi.EffectRecord[],\n ): StellarEffect[] {\n return effectsForSequence\n .filter((effect) => this.getOperationIndex(effect.id) === operationIndex)\n .map((effect) => ({\n ...effect,\n ledger: null,\n transaction: null,\n operation: null,\n }));\n }\n\n private wrapOperationsForTx(\n transactionId: string,\n operationsForSequence: Horizon.ServerApi.OperationRecord[],\n effectsForSequence: Horizon.ServerApi.EffectRecord[],\n eventsForSequence: SorobanEvent[],\n ): StellarOperation[] {\n const operations = operationsForSequence.filter(\n (op) => op.transaction_hash === transactionId,\n );\n\n const events = eventsForSequence.filter(\n (evt) => evt.txHash === transactionId,\n );\n\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 = 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 sequence: number,\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 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 (tx as any).id,\n operationsForSequence,\n effectsForSequence,\n eventsForSequence,\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 sequence,\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;AAWrD,mCAAmC;AACnC,4DAA+D;AAC/D,0DAA6C;AAE7C,qDAAiD;AACjD,mDAAkD;AAElD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,aAAa,CAAC,CAAC;AAExC,MAAa,UAAU;IAOX;IACA;IAPV,yBAAyB;IACjB,aAAa,CAAgB;IAE7B,OAAO,CAAU;IAEzB,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;QAEpE,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAE9C,MAAM,CAAC,IAAI,CAAC,aAAa,QAAQ,aAAa,WAAW,EAAE,CAAC,CAAC;QAC7D,IAAI,WAAW,KAAK,OAAO,IAAI,WAAW,KAAK,MA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CAAC,CAAC;IACrC,CAAC;IAED,WAAW,CAAC,CAAQ,EAAE,MAAc;QAClC,IAAI,CAAC,CAAC,OAAO,KAAK,+BAA+B,EAAE;YACjD,OAAO,IAAI,KAAK,CAAC,+BAA+B,MAAM;;;;kFAIsB,CAAC,CAAC;SAC/E;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA7XD,gCA6XC","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 { 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\n constructor(\n private endpoint: string,\n private _sorobanClient?: SorobanServer,\n config?: IStellarEndpointConfig,\n ) {\n const { hostname, protocol, searchParams } = new URL(this.endpoint);\n\n const protocolStr = protocol.replace(':', '');\n\n logger.info(`Api host: ${hostname}, method: ${protocolStr}`);\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.transactions().forLedger(sequence).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.operations().forLedger(sequence).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 let effectsPage = await this.api.effects().forLedger(sequence).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 private getOperationIndex(id: string) {\n // Pick the first part of the ID before the '-' character\n const idPart = id.split('-')[0];\n\n // Create a mask for 12 bits to isolate the Operation Index\n const mask = BigInt((1 << 12) - 1);\n\n // Apply bitwise AND operation with the mask to get the Operation Index\n const operationIndex = BigInt(idPart) & mask;\n\n return Number(operationIndex);\n }\n\n async getAndWrapEvents(height: number): Promise<SorobanEvent[]> {\n const { events: events } = await this.sorobanClient.getEvents({\n startLedger: height,\n filters: [],\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 wrapEffectsForOperation(\n operationIndex: number,\n effectsForSequence: Horizon.ServerApi.EffectRecord[],\n ): StellarEffect[] {\n return effectsForSequence\n .filter((effect) => this.getOperationIndex(effect.id) === operationIndex)\n .map((effect) => ({\n ...effect,\n ledger: null,\n transaction: null,\n operation: null,\n }));\n }\n\n private wrapOperationsForTx(\n transactionId: string,\n operationsForSequence: Horizon.ServerApi.OperationRecord[],\n effectsForSequence: Horizon.ServerApi.EffectRecord[],\n eventsForSequence: SorobanEvent[],\n ): StellarOperation[] {\n const operations = operationsForSequence.filter(\n (op) => op.transaction_hash === transactionId,\n );\n\n const events = eventsForSequence.filter(\n (evt) => evt.txHash === transactionId,\n );\n\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 = 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 sequence: number,\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 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 (tx as any).id,\n operationsForSequence,\n effectsForSequence,\n eventsForSequence,\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 sequence,\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,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  const api_stellar_1 = require("./api.stellar");
@@ -1 +1 @@
1
- {"version":3,"file":"api.stellar.spec.js","sourceRoot":"","sources":["../../src/stellar/api.stellar.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,+CAA2C;AAC3C,qDAAiD;AAEjD,MAAM,aAAa,GAAG,uCAAuC,CAAC;AAC9D,MAAM,gBAAgB,GAAG,mCAAmC,CAAC;AAE7D,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAEvB,MAAM,iBAAiB,GAAG,KAAK;IAC7B,MAAM,OAAO,GAAG,IAAI,8BAAa,CAAC,gBAAgB,CAAC,CAAC;IACpD,MAAM,GAAG,GAAG,IAAI,wBAAU,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACnD,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IACjB,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAI,UAAsB,CAAC;IAE3B,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,UAAU,GAAG,MAAM,iBAAiB,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AE;QAC9B,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACxD,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;YACzC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QACF,UAAkB,CAAC,wBAAwB,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC;YACtE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,sBAAsB,EAAE,EAAE;SACrD,CAAC,CAAC;QACH,MAAM,MAAM,CAAE,UAAkB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CACvE,kBAAkB,CACnB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { StellarApi } from './api.stellar';\nimport { SorobanServer } from './soroban.server';\n\nconst HTTP_ENDPOINT = 'https://horizon-futurenet.stellar.org';\nconst SOROBAN_ENDPOINT = 'https://rpc-futurenet.stellar.org';\n\njest.setTimeout(60000);\n\nconst prepareStellarApi = async function () {\n const soroban = new SorobanServer(SOROBAN_ENDPOINT);\n const api = new StellarApi(HTTP_ENDPOINT, soroban);\n await api.init();\n return api;\n};\n\ndescribe('StellarApi', () => {\n let stellarApi: StellarApi;\n\n beforeEach(async () => {\n stellarApi = await prepareStellarApi();\n });\n\n it('should initialize chainId', () => {\n expect(stellarApi.getChainId()).toEqual(\n 'Test SDF Future Network ; October 2022',\n );\n });\n\n it('should get finalized block height', async () => {\n const height = await stellarApi.getFinalizedBlockHeight();\n expect(height).not.toBeNaN();\n expect(height).toBeGreaterThan(0);\n });\n\n it('should get best block height', async () => {\n const height = await stellarApi.getBestBlockHeight();\n expect(height).not.toBeNaN();\n expect(height).toBeGreaterThan(0);\n });\n\n it('should fetch block', async () => {\n const latestHeight = await stellarApi.getFinalizedBlockHeight();\n const block = (await stellarApi.fetchBlocks([latestHeight]))[0];\n expect(block.getHeader().blockHeight).toEqual(latestHeight);\n });\n\n it('should throw on calling connect', async () => {\n await expect(stellarApi.connect()).rejects.toThrow('Not implemented');\n });\n\n it('should throw on calling disconnect', async () => {\n await expect(stellarApi.disconnect()).rejects.toThrow('Not implemented');\n });\n\n it('handleError - pruned node errors', () => {\n const error = new Error('start is before oldest ledger');\n const handled = stellarApi.handleError(error, 1000);\n expect(handled.message).toContain(\n 'The requested ledger number 1000 is not available on the current blockchain node',\n );\n });\n\n it('handleError - non pruned node errors should return the same error', () => {\n const error = new Error('Generic error');\n const handled = stellarApi.handleError(error, 1000);\n expect(handled).toBe(error);\n });\n\n it('should get runtime chain', () => {\n const runtimeChain = stellarApi.getRuntimeChain();\n expect(runtimeChain).toEqual((stellarApi as any).chainId);\n });\n\n it('should return chainId for genesis hash', () => {\n const genesisHash = stellarApi.getGenesisHash();\n expect(genesisHash).toEqual(stellarApi.getChainId());\n });\n\n it('should get spec name', () => {\n const specName = stellarApi.getSpecName();\n expect(specName).toEqual('Stellar');\n });\n\n it('handleError - soroban node been reset', async () => {\n const error = new Error('start is after newest ledger');\n stellarApi.getAndWrapEvents = jest.fn(() => {\n throw new Error('start is after newest ledger');\n });\n (stellarApi as any).fetchOperationsForLedger = jest.fn((seq: number) => [\n { type: { toString: () => 'invoke_host_function' } },\n ]);\n await expect((stellarApi as any).fetchAndWrapLedger(100)).rejects.toThrow(\n /(Gone|Not Found)/,\n );\n });\n});\n"]}
1
+ {"version":3,"file":"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;SACrD,CAAC,CAAC;QACH,MAAM,MAAM,CAAE,UAAkB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CACvE,kBAAkB,CACnB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { StellarApi } from './api.stellar';\nimport { SorobanServer } from './soroban.server';\n\nconst HTTP_ENDPOINT = 'https://horizon-futurenet.stellar.org';\nconst SOROBAN_ENDPOINT = 'https://rpc-futurenet.stellar.org';\n\njest.setTimeout(60000);\n\nconst prepareStellarApi = async function () {\n const soroban = new SorobanServer(SOROBAN_ENDPOINT);\n const api = new StellarApi(HTTP_ENDPOINT, soroban);\n await api.init();\n return api;\n};\n\ndescribe('StellarApi', () => {\n let stellarApi: StellarApi;\n\n beforeEach(async () => {\n stellarApi = await prepareStellarApi();\n });\n\n it('should initialize chainId', () => {\n expect(stellarApi.getChainId()).toEqual(\n 'Test SDF Future Network ; October 2022',\n );\n });\n\n it('should get finalized block height', async () => {\n const height = await stellarApi.getFinalizedBlockHeight();\n expect(height).not.toBeNaN();\n expect(height).toBeGreaterThan(0);\n });\n\n it('should get best block height', async () => {\n const height = await stellarApi.getBestBlockHeight();\n expect(height).not.toBeNaN();\n expect(height).toBeGreaterThan(0);\n });\n\n it('should fetch block', async () => {\n const latestHeight = await stellarApi.getFinalizedBlockHeight();\n const block = (await stellarApi.fetchBlocks([latestHeight]))[0];\n expect(block.getHeader().blockHeight).toEqual(latestHeight);\n });\n\n it('should throw on calling connect', async () => {\n await expect(stellarApi.connect()).rejects.toThrow('Not implemented');\n });\n\n it('should throw on calling disconnect', async () => {\n await expect(stellarApi.disconnect()).rejects.toThrow('Not implemented');\n });\n\n it('handleError - pruned node errors', () => {\n const error = new Error('start is before oldest ledger');\n const handled = stellarApi.handleError(error, 1000);\n expect(handled.message).toContain(\n 'The requested ledger number 1000 is not available on the current blockchain node',\n );\n });\n\n it('handleError - non pruned node errors should return the same error', () => {\n const error = new Error('Generic error');\n const handled = stellarApi.handleError(error, 1000);\n expect(handled).toBe(error);\n });\n\n it('should get runtime chain', () => {\n const runtimeChain = stellarApi.getRuntimeChain();\n expect(runtimeChain).toEqual((stellarApi as any).chainId);\n });\n\n it('should return chainId for genesis hash', () => {\n const genesisHash = stellarApi.getGenesisHash();\n expect(genesisHash).toEqual(stellarApi.getChainId());\n });\n\n it('should get spec name', () => {\n const specName = stellarApi.getSpecName();\n expect(specName).toEqual('Stellar');\n });\n\n it('handleError - soroban node been reset', async () => {\n const error = new Error('start is after newest ledger');\n stellarApi.getAndWrapEvents = jest.fn(() => {\n throw new Error('start is after newest ledger');\n });\n (stellarApi as any).fetchOperationsForLedger = jest.fn((seq: number) => [\n { type: { toString: () => 'invoke_host_function' } },\n ]);\n await expect((stellarApi as any).fetchAndWrapLedger(100)).rejects.toThrow(\n /(Gone|Not Found)/,\n );\n });\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.StellarBlockWrapped = void 0;