From 6965c4fc12c181347db475551998a9e584a1ff66 Mon Sep 17 00:00:00 2001 From: Scott Twiname Date: Wed, 10 Apr 2024 13:28:37 +1200 Subject: [PATCH] Sync @subql dependencies (#35) * Update @subql deps * Sync changes * Fix test * Update changelogs --------- Co-authored-by: stwiname --- .github/actions/create-release/action.yml | 4 +- .../create-release/gh-release-script.js | 1 + .github/workflows/node-docker.yml | 17 +- .github/workflows/prerelease.yml | 17 +- .github/workflows/release.yml | 28 +- packages/common-concordium/CHANGELOG.md | 2 + packages/common-concordium/package.json | 2 +- .../common-concordium/src/project/models.ts | 29 +- .../common-concordium/src/project/types.ts | 17 +- .../common-concordium/src/project/utils.ts | 12 +- .../versioned/ProjectManifestVersioned.ts | 4 +- .../src/project/versioned/v1_0_0/model.ts | 15 +- packages/node/CHANGELOG.md | 2 + packages/node/package.json | 5 +- .../src/concordium/api.concordium.spec.ts | 2 +- .../node/src/concordium/api.concordium.ts | 26 +- .../node/src/concordium/api.connection.ts | 7 +- .../src/concordium/api.service.concordium.ts | 6 +- .../node/src/concordium/utils.concordium.ts | 4 +- .../node/src/configure/SubqueryProject.ts | 33 +- .../block-dispatcher.service.ts | 20 +- .../concordium-block-dispatcher.ts | 4 +- .../worker-block-dispatcher.service.ts | 17 +- .../node/src/indexer/dictionary.service.ts | 44 -- .../indexer/dictionary/dictionary.service.ts | 63 +++ .../src/indexer/dictionary/v1/dictionaryV1.ts | 206 +++++++ .../node/src/indexer/dictionary/v1/index.ts | 4 + .../node/src/indexer/ds-processor.service.ts | 23 +- .../node/src/indexer/dynamic-ds.service.ts | 20 +- packages/node/src/indexer/fetch.module.ts | 21 +- packages/node/src/indexer/fetch.service.ts | 201 +------ packages/node/src/indexer/indexer.manager.ts | 49 +- packages/node/src/indexer/project.service.ts | 13 +- .../src/indexer/unfinalizedBlocks.service.ts | 15 +- .../node/src/indexer/worker/worker.service.ts | 15 +- .../worker.unfinalizedBlocks.service.ts | 17 +- .../node/src/subcommands/testing.service.ts | 14 +- packages/node/src/utils/project.ts | 6 +- packages/types/CHANGELOG.md | 2 + packages/types/package.json | 2 +- packages/types/src/index.ts | 1 - packages/types/src/interfaces.ts | 17 - packages/types/src/project.ts | 60 ++- yarn.lock | 503 ++---------------- 44 files changed, 584 insertions(+), 986 deletions(-) delete mode 100644 packages/node/src/indexer/dictionary.service.ts create mode 100644 packages/node/src/indexer/dictionary/dictionary.service.ts create mode 100644 packages/node/src/indexer/dictionary/v1/dictionaryV1.ts create mode 100644 packages/node/src/indexer/dictionary/v1/index.ts delete mode 100644 packages/types/src/interfaces.ts diff --git a/.github/actions/create-release/action.yml b/.github/actions/create-release/action.yml index bacd1904..7dc90a46 100644 --- a/.github/actions/create-release/action.yml +++ b/.github/actions/create-release/action.yml @@ -17,13 +17,13 @@ runs: using: "composite" steps: - working-directory: ${{ inputs.package-path }} - run: echo "Changes exist in ${{ inputs.package-path }}" && yarn npm publish --access public + run: echo "Changes exist in ${{ inputs.package-path }}" && yarn npm publish --access public env: NPM_TOKEN: ${{ inputs.npm-token }} shell: bash - working-directory: ${{ github.workspace }} - run: node ${{ github.action_path }}/gh-release-script.js ${{ github.workspace }}/${{ inputs.package-path }} + run: node ${{ github.action_path }}/gh-release-script.js ${{ github.workspace }}/${{ inputs.package-path }} ${{ github.sha }} env: REPO_TOKEN: ${{ inputs.repo-token }} shell: bash diff --git a/.github/actions/create-release/gh-release-script.js b/.github/actions/create-release/gh-release-script.js index cac51ac6..af4e35df 100644 --- a/.github/actions/create-release/gh-release-script.js +++ b/.github/actions/create-release/gh-release-script.js @@ -70,6 +70,7 @@ async function publishRelease(releaseInfo) { name: `[${version}] ${repoName}`, repo: 'subql-concordium', tag_name: `${packageName[1]}/${version}`, + target_commitish: `${myArgs[1]}`, body: releaseInfo }).catch( err => { core.setFailed(err) diff --git a/.github/workflows/node-docker.yml b/.github/workflows/node-docker.yml index aac5e0f3..30413472 100644 --- a/.github/workflows/node-docker.yml +++ b/.github/workflows/node-docker.yml @@ -19,20 +19,21 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 2 + - name: Check for package changes and commit message id: check_changes run: | if [[ "${{ github.event_name }}" == "release" ]] then - COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") - if [[ $COMMIT_MESSAGE == "[release]"* ]] && git diff --name-only HEAD~1 HEAD -- './packages/node/package.json' + TAG_NAME=${GITHUB_REF#refs/tags/} + if [[ $TAG_NAME == "node/"* ]] then - echo "::set-output name=changes_found::true" + echo "changes_found=true" >> "$GITHUB_OUTPUT" else - echo "::set-output name=changes_found::false" + echo "changes_found=false" >> "$GITHUB_OUTPUT" fi else - echo "::set-output name=changes_found::true" + echo "changes_found=true" >> "$GITHUB_OUTPUT" fi node-build-push-docker: needs: check @@ -45,13 +46,13 @@ jobs: token: ${{ secrets.SQ_SDK_GITHUB_SECRET }} - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: subquerynetwork password: ${{ secrets.SQ_DOCKERHUB_TOKEN }} diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index da27f782..1a74eb80 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -6,22 +6,13 @@ on: paths-ignore: - '.github/workflows/**' -jobs: - pre-ci: - runs-on: ubuntu-latest - timeout-minutes: 1 - steps: - - name: 'Block Concurrent Executions' - uses: softprops/turnstyle@v1 - with: - poll-interval-seconds: 10 - env: - GITHUB_TOKEN: ${{ secrets.SQ_SDK_GITHUB_SECRET }} - +concurrency: + group: publish + cancel-in-progress: false +jobs: Bump-Prerelease-Publish: name: Bump-Prerelease-Publish - needs: pre-ci if: "!startsWith(github.event.head_commit.message, '[SKIP CI]') && !startsWith(github.event.head_commit.message, '[release]') && github.repository == 'subquery/subql-concordium'" runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a697c7f7..70175dd5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,22 +7,38 @@ on: - '.github/workflows/**' workflow_dispatch: +concurrency: + # Same group as prerelease + group: publish + cancel-in-progress: false + jobs: + + # This gets the commit message because workflow dispatch doesnt set: github.event.head_commit.message pre-ci: runs-on: ubuntu-latest timeout-minutes: 1 + outputs: + commit-message: ${{ steps.step1.outputs.commit-message }} steps: - - name: 'Block Concurrent Executions' - uses: softprops/turnstyle@v1 + - uses: actions/checkout@v4 with: - poll-interval-seconds: 10 - env: - GITHUB_TOKEN: ${{ secrets.SQ_SDK_GITHUB_SECRET }} + fetch-depth: 100 + + # Get the commit message, workflow_dispatch doesn't contain it so we need to get it through git cli + - id: step1 + run: | + if [ -n "${{ github.event.head_commit.message }}" ] + then + echo "commit-message=${{ github.event.head_commit.message }}" >> "$GITHUB_OUTPUT" + else + echo "commit-message=$(git log -1 --pretty=%B)" >> "$GITHUB_OUTPUT" + fi Build-Publish: name: Build-Publish needs: pre-ci - if: "!startsWith(github.event.head_commit.message, '[SKIP CI]') && startsWith(github.event.head_commit.message, '[release]') && github.repository == 'subquery/subql-concordium'" + if: "!startsWith(needs.pre-ci.outputs.commit-message, '[SKIP CI]') && startsWith(needs.pre-ci.outputs.commit-message, '[release]') && github.repository == 'subquery/subql-concordium'" runs-on: ubuntu-latest steps: #Check out diff --git a/packages/common-concordium/CHANGELOG.md b/packages/common-concordium/CHANGELOG.md index 66c0bcdc..6a2c9aed 100644 --- a/packages/common-concordium/CHANGELOG.md +++ b/packages/common-concordium/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Update types imports from types-concordium ## [3.4.2] - 2024-02-23 ### Changed diff --git a/packages/common-concordium/package.json b/packages/common-concordium/package.json index 73be4df6..15dcc6e8 100644 --- a/packages/common-concordium/package.json +++ b/packages/common-concordium/package.json @@ -15,7 +15,7 @@ "license": "GPL-3.0", "dependencies": { "@concordium/node-sdk": "9.4.0", - "@subql/common": "^3.4.1", + "@subql/common": "^3.5.0", "@subql/types-concordium": "workspace:*", "js-yaml": "^4.1.0", "pino": "^6.13.3", diff --git a/packages/common-concordium/src/project/models.ts b/packages/common-concordium/src/project/models.ts index 70aae3b0..00ebc460 100644 --- a/packages/common-concordium/src/project/models.ts +++ b/packages/common-concordium/src/project/models.ts @@ -10,8 +10,8 @@ import { SubqlMapping, SubqlHandler, SubqlRuntimeHandler, - SubqlRuntimeDatasource, - SubqlCustomDatasource, + ConcordiumRuntimeDatasource, + ConcordiumCustomDatasource, CustomDataSourceAsset, SubqlBlockHandler, ConcordiumTransactionFilter, @@ -24,7 +24,6 @@ import { import {FileReference, Processor} from '@subql/types-core'; import {plainToClass, Transform, Type} from 'class-transformer'; import {IsArray, IsEnum, IsInt, IsOptional, IsString, IsObject, ValidateNested} from 'class-validator'; -import {SubqlConcordiumDatasourceKind, SubqlConcordiumHandlerKind} from './types'; export class TransactionFilter implements ConcordiumTransactionFilter { @IsOptional() @@ -58,7 +57,7 @@ export class BlockHandler implements SubqlBlockHandler { @IsOptional() @Type(() => BlockFilterImpl) filter?: BlockFilterImpl; - @IsEnum(SubqlConcordiumHandlerKind, {groups: [SubqlConcordiumHandlerKind.Block]}) + @IsEnum(ConcordiumHandlerKind, {groups: [ConcordiumHandlerKind.Block]}) kind: ConcordiumHandlerKind.Block; @IsString() handler: string; @@ -69,7 +68,7 @@ export class TransactionHandler implements SubqlTransactionHandler { @ValidateNested() @Type(() => TransactionFilter) filter?: ConcordiumTransactionFilter; - @IsEnum(SubqlConcordiumHandlerKind, {groups: [SubqlConcordiumHandlerKind.Transaction]}) + @IsEnum(ConcordiumHandlerKind, {groups: [ConcordiumHandlerKind.Transaction]}) kind: ConcordiumHandlerKind.Transaction; @IsString() handler: string; @@ -80,7 +79,7 @@ export class TransactionEventHandler implements SubqlTransactionEventHandler { @ValidateNested() @Type(() => TransactionEventFilter) filter?: ConcordiumTransactionEventFilter; - @IsEnum(SubqlConcordiumHandlerKind, {groups: [SubqlConcordiumHandlerKind.TransactionEvent]}) + @IsEnum(ConcordiumHandlerKind, {groups: [ConcordiumHandlerKind.TransactionEvent]}) kind: ConcordiumHandlerKind.TransactionEvent; @IsString() handler: string; @@ -91,7 +90,7 @@ export class SpecialEventHandler implements SubqlSpecialEventHandler { @ValidateNested() @Type(() => SpecialEventFilter) filter?: ConcordiumTransactionEventFilter; - @IsEnum(SubqlConcordiumHandlerKind, {groups: [SubqlConcordiumHandlerKind.SpecialEvent]}) + @IsEnum(ConcordiumHandlerKind, {groups: [ConcordiumHandlerKind.SpecialEvent]}) kind: ConcordiumHandlerKind.SpecialEvent; @IsString() handler: string; @@ -112,13 +111,13 @@ export class ConcordiumMapping implements SubqlMapping { const handlers: SubqlHandler[] = params.value; return handlers.map((handler) => { switch (handler.kind) { - case SubqlConcordiumHandlerKind.SpecialEvent: + case ConcordiumHandlerKind.SpecialEvent: return plainToClass(SpecialEventHandler, handler); - case SubqlConcordiumHandlerKind.TransactionEvent: + case ConcordiumHandlerKind.TransactionEvent: return plainToClass(TransactionEventHandler, handler); - case SubqlConcordiumHandlerKind.Transaction: + case ConcordiumHandlerKind.Transaction: return plainToClass(TransactionHandler, handler); - case SubqlConcordiumHandlerKind.Block: + case ConcordiumHandlerKind.Block: return plainToClass(BlockHandler, handler); default: throw new Error(`handler ${(handler as any).kind} not supported`); @@ -143,10 +142,10 @@ export class CustomMapping implements SubqlMapping { export class RuntimeDataSourceBase> extends BaseDataSource - implements SubqlRuntimeDatasource + implements ConcordiumRuntimeDatasource { - @IsEnum(SubqlConcordiumDatasourceKind, { - groups: [SubqlConcordiumDatasourceKind.Runtime], + @IsEnum(ConcordiumDatasourceKind, { + groups: [ConcordiumDatasourceKind.Runtime], }) kind: ConcordiumDatasourceKind.Runtime; @Type(() => ConcordiumMapping) @@ -163,7 +162,7 @@ export class FileReferenceImpl implements FileReference { export class CustomDataSourceBase, O = any> extends BaseDataSource - implements SubqlCustomDatasource + implements ConcordiumCustomDatasource { @IsString() kind: K; diff --git a/packages/common-concordium/src/project/types.ts b/packages/common-concordium/src/project/types.ts index d3e4ef42..e3cf510e 100644 --- a/packages/common-concordium/src/project/types.ts +++ b/packages/common-concordium/src/project/types.ts @@ -1,17 +1,17 @@ // Copyright 2020-2023 SubQuery Pte Ltd authors & contributors // SPDX-License-Identifier: GPL-3.0 -import {SubqlDatasource} from '@subql/types-concordium'; -import {IProjectManifest, ProjectNetworkConfig} from '@subql/types-core'; +import {ConcordiumDatasource} from '@subql/types-concordium'; +import {IProjectManifest} from '@subql/types-core'; // All of these used to be redefined in this file, re-exporting for simplicity export { SubqlRuntimeHandler, SubqlCustomHandler, SubqlHandler, - ConcordiumHandlerKind as SubqlConcordiumHandlerKind, - SubqlDatasource as SubqlConcordiumDataSource, - SubqlCustomDatasource as SubqlConcordiumCustomDataSource, + ConcordiumHandlerKind, + ConcordiumDatasource, + ConcordiumCustomDatasource, ConcordiumBlockFilter, ConcordiumTransactionFilter, SubqlDatasourceProcessor, @@ -20,9 +20,4 @@ export { ConcordiumRuntimeHandlerInputMap as ConcordiumRuntimeHandlerInputMap, } from '@subql/types-concordium'; -export type IConcordiumProjectManifest = IProjectManifest; - -export interface ConcordiumProjectNetworkConfig extends ProjectNetworkConfig { - genesisHash?: string; - chainId?: string; -} +export type IConcordiumProjectManifest = IProjectManifest; diff --git a/packages/common-concordium/src/project/utils.ts b/packages/common-concordium/src/project/utils.ts index ee532074..ba3aeb21 100644 --- a/packages/common-concordium/src/project/utils.ts +++ b/packages/common-concordium/src/project/utils.ts @@ -3,11 +3,11 @@ import { SecondLayerHandlerProcessor, - SubqlCustomDatasource, - SubqlDatasource, + ConcordiumCustomDatasource, + ConcordiumDatasource, ConcordiumDatasourceKind, ConcordiumHandlerKind, - SubqlRuntimeDatasource, + ConcordiumRuntimeDatasource, } from '@subql/types-concordium'; export function isBlockHandlerProcessor( @@ -34,10 +34,10 @@ export function isSpecialEventHandlerProcessor( return hp.baseHandlerKind === ConcordiumHandlerKind.SpecialEvent; } -export function isCustomDs(ds: SubqlDatasource): ds is SubqlCustomDatasource { - return ds.kind !== ConcordiumDatasourceKind.Runtime && !!(ds as SubqlCustomDatasource).processor; +export function isCustomDs(ds: ConcordiumDatasource): ds is ConcordiumCustomDatasource { + return ds.kind !== ConcordiumDatasourceKind.Runtime && !!(ds as ConcordiumCustomDatasource).processor; } -export function isRuntimeDs(ds: SubqlDatasource): ds is SubqlRuntimeDatasource { +export function isRuntimeDs(ds: ConcordiumDatasource): ds is ConcordiumRuntimeDatasource { return ds.kind === ConcordiumDatasourceKind.Runtime; } diff --git a/packages/common-concordium/src/project/versioned/ProjectManifestVersioned.ts b/packages/common-concordium/src/project/versioned/ProjectManifestVersioned.ts index ab4c1441..6d871061 100644 --- a/packages/common-concordium/src/project/versioned/ProjectManifestVersioned.ts +++ b/packages/common-concordium/src/project/versioned/ProjectManifestVersioned.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-3.0 import {plainToClass} from 'class-transformer'; -import {IConcordiumProjectManifest, SubqlConcordiumDataSource} from '../types'; +import {ConcordiumDatasource, IConcordiumProjectManifest} from '../types'; import {ProjectManifestV1_0_0Impl} from './v1_0_0'; export type VersionedProjectManifest = {specVersion: string}; @@ -49,7 +49,7 @@ export class ConcordiumProjectManifestVersioned implements IConcordiumProjectMan return this._impl.validate(); } - get dataSources(): SubqlConcordiumDataSource[] { + get dataSources(): ConcordiumDatasource[] { return this._impl.dataSources; } diff --git a/packages/common-concordium/src/project/versioned/v1_0_0/model.ts b/packages/common-concordium/src/project/versioned/v1_0_0/model.ts index 6c65781b..1b3fdfcf 100644 --- a/packages/common-concordium/src/project/versioned/v1_0_0/model.ts +++ b/packages/common-concordium/src/project/versioned/v1_0_0/model.ts @@ -11,12 +11,14 @@ import { CommonProjectNetworkV1_0_0, } from '@subql/common'; import { - SubqlCustomDatasource, + ConcordiumCustomDatasource, SubqlMapping, - SubqlRuntimeDatasource, + ConcordiumRuntimeDatasource, RuntimeDatasourceTemplate, CustomDatasourceTemplate, ConcordiumProjectManifestV1_0_0, + ConcordiumDatasource, + SubqlRuntimeHandler, } from '@subql/types-concordium'; import {BaseMapping, NodeSpec, ParentProject, QuerySpec, RunnerSpecs} from '@subql/types-core'; import {plainToClass, Transform, TransformFnParams, Type} from 'class-transformer'; @@ -32,7 +34,6 @@ import { validateSync, } from 'class-validator'; import {CustomDataSourceBase, ConcordiumMapping, RuntimeDataSourceBase} from '../../models'; -import {SubqlConcordiumDataSource, SubqlRuntimeHandler} from '../../types'; const Concordium_NODE_NAME = `@subql/node-concordium`; const Flare_NODE_NAME = `@subql/node-flare`; @@ -59,7 +60,7 @@ function validateObject(object: any, errorMessage = 'failed to validate object.' export class ConcordiumRuntimeDataSourceImpl extends RuntimeDataSourceBase> - implements SubqlRuntimeDatasource + implements ConcordiumRuntimeDatasource { validate(): void { return validateObject(this, 'failed to validate runtime datasource.'); @@ -68,7 +69,7 @@ export class ConcordiumRuntimeDataSourceImpl export class ConcordiumCustomDataSourceImpl = BaseMapping> extends CustomDataSourceBase - implements SubqlCustomDatasource + implements ConcordiumCustomDatasource { validate(): void { return validateObject(this, 'failed to validate custom datasource.'); @@ -140,7 +141,7 @@ export class DeploymentV1_0_0 extends BaseDeploymentV1_0_0 { }, keepDiscriminatorProperty: true, }) - dataSources: (SubqlRuntimeDatasource | SubqlCustomDatasource)[]; + dataSources: (ConcordiumRuntimeDatasource | ConcordiumCustomDatasource)[]; @IsOptional() @IsArray() @ValidateNested() @@ -171,7 +172,7 @@ export class ProjectManifestV1_0_0Impl }, keepDiscriminatorProperty: true, }) - dataSources: SubqlConcordiumDataSource[]; + dataSources: ConcordiumDatasource[]; @Type(() => ProjectNetworkV1_0_0) network: ProjectNetworkV1_0_0; @IsString() diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 3a31d138..63dddac4 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Update `@subql/node-core` to latest major version with support for multiple dicitonary endpoints and various bug fixes (#35) ## [3.9.1] - 2024-03-14 ### Changed diff --git a/packages/node/package.json b/packages/node/package.json index 2b0ebb19..e8e7bbff 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -26,10 +26,9 @@ "@nestjs/event-emitter": "^2.0.0", "@nestjs/platform-express": "^9.4.0", "@nestjs/schedule": "^3.0.1", - "@subql/common": "^3.4.1", + "@subql/common": "^3.5.0", "@subql/common-concordium": "workspace:*", - "@subql/node-core": "^7.4.2", - "@subql/testing": "2.1.0", + "@subql/node-core": "^8.0.1", "@subql/types-concordium": "workspace:*", "cacheable-lookup": "6", "cron-converter": "^1.0.2", diff --git a/packages/node/src/concordium/api.concordium.spec.ts b/packages/node/src/concordium/api.concordium.spec.ts index 3fee6957..534ef837 100644 --- a/packages/node/src/concordium/api.concordium.spec.ts +++ b/packages/node/src/concordium/api.concordium.spec.ts @@ -25,7 +25,7 @@ describe('ConcordiumApi', () => { it('should get blocks at a specific height', async () => { const block = await api.fetchBlock(0); - expect(block.blockHeight).toEqual(BigInt(0)); + expect(block.getHeader().blockHeight).toEqual(0); }); it('should get finalized block height', async () => { diff --git a/packages/node/src/concordium/api.concordium.ts b/packages/node/src/concordium/api.concordium.ts index a16d13c1..ec3c622b 100644 --- a/packages/node/src/concordium/api.concordium.ts +++ b/packages/node/src/concordium/api.concordium.ts @@ -14,9 +14,8 @@ import { import { ChannelCredentials } from '@grpc/grpc-js'; import { EventEmitter2 } from '@nestjs/event-emitter'; import { GrpcTransport, GrpcOptions } from '@protobuf-ts/grpc-transport'; -import { getLogger } from '@subql/node-core'; +import { getLogger, Header, IBlock } from '@subql/node-core'; import { - ApiWrapper, ConcordiumBlock, ConcordiumSpecialEvent, ConcordiumTransaction, @@ -30,7 +29,15 @@ const { version: packageVersion } = require('../../package.json'); const logger = getLogger('api.concordium'); -export class ConcordiumApi implements ApiWrapper { +export function blockToHeader(block: ConcordiumBlock | BlockInfo): Header { + return { + blockHeight: Number(block.blockHeight), + blockHash: block.blockHash, + parentHash: block.blockParent, + }; +} + +export class ConcordiumApi { private client: ConcordiumGRPCClient; private transport: GrpcTransport; private chainId: string; @@ -238,7 +245,7 @@ export class ConcordiumApi implements ApiWrapper { }); } - async getAndWrapBlock(height: number): Promise { + async getAndWrapBlock(height: number): Promise> { const blockHash = (await this.client.getBlocksAtHeight(BigInt(height)))[0]; //there is only one finalized block per height const blockInfo = await this.getBlockByHash(blockHash); const wrappedBlock: ConcordiumBlock = { @@ -282,16 +289,21 @@ export class ConcordiumApi implements ApiWrapper { }, ); - return wrappedBlock; + return { + getHeader: () => blockToHeader(wrappedBlock), + block: wrappedBlock, + }; } - async fetchBlock(height: number): Promise { + async fetchBlock(height: number): Promise> { const block = await this.getAndWrapBlock(height); this.eventEmitter.emit('fetchBlock'); return block; } - async fetchBlocks(bufferBlocks: number[]): Promise { + async fetchBlocks( + bufferBlocks: number[], + ): Promise[]> { return Promise.all(bufferBlocks.map(async (num) => this.fetchBlock(num))); } diff --git a/packages/node/src/concordium/api.connection.ts b/packages/node/src/concordium/api.connection.ts index 06524650..0e2c9b8e 100644 --- a/packages/node/src/concordium/api.connection.ts +++ b/packages/node/src/concordium/api.connection.ts @@ -10,6 +10,7 @@ import { RateLimitError, TimeoutError, IApiConnectionSpecific, + IBlock, } from '@subql/node-core'; import { ConcordiumBlock } from '@subql/types-concordium'; import { ConcordiumApi } from './api.concordium'; @@ -18,14 +19,14 @@ import SafeConcordiumGRPCClient from './safe-api'; type FetchFunc = ( api: ConcordiumApi, batch: number[], -) => Promise; +) => Promise[]>; export class ConcordiumApiConnection implements IApiConnectionSpecific< ConcordiumApi, SafeConcordiumGRPCClient, - ConcordiumBlock[] + IBlock[] > { readonly networkMeta: NetworkMetadataPayload; @@ -65,7 +66,7 @@ export class ConcordiumApiConnection await this.unsafeApi.disconnect(); } - async fetchBlocks(heights: number[]): Promise { + async fetchBlocks(heights: number[]): Promise[]> { const blocks = await this.fetchBlocksBatches(this.unsafeApi, heights); return blocks; } diff --git a/packages/node/src/concordium/api.service.concordium.ts b/packages/node/src/concordium/api.service.concordium.ts index 3a40007f..983166ba 100644 --- a/packages/node/src/concordium/api.service.concordium.ts +++ b/packages/node/src/concordium/api.service.concordium.ts @@ -3,11 +3,11 @@ import { Inject, Injectable } from '@nestjs/common'; import { EventEmitter2 } from '@nestjs/event-emitter'; -import { ConcordiumProjectNetworkConfig } from '@subql/common-concordium'; import { ApiService, ConnectionPoolService, getLogger, + IBlock, NodeConfig, } from '@subql/node-core'; import { ConcordiumBlock } from '@subql/types-concordium'; @@ -22,7 +22,7 @@ const logger = getLogger('api'); export class ConcordiumApiService extends ApiService< ConcordiumApi, SafeConcordiumGRPCClient, - ConcordiumBlock[] + IBlock[] > { constructor( @Inject('ISubqueryProject') private project: SubqueryProject, @@ -123,7 +123,7 @@ export class ConcordiumApiService extends ApiService< private async fetchBlockBatches( api: ConcordiumApi, batch: number[], - ): Promise { + ): Promise[]> { return api.fetchBlocks(batch); } } diff --git a/packages/node/src/concordium/utils.concordium.ts b/packages/node/src/concordium/utils.concordium.ts index 05c1a2b8..a493f2d4 100644 --- a/packages/node/src/concordium/utils.concordium.ts +++ b/packages/node/src/concordium/utils.concordium.ts @@ -1,9 +1,7 @@ // Copyright 2020-2023 SubQuery Pte Ltd authors & contributors // SPDX-License-Identifier: GPL-3.0 -import { ApiWrapper } from '@subql/types-concordium'; - -export function calcInterval(api: ApiWrapper): number { +export function calcInterval(api): number { // TODO find a way to get this from the blockchain return 2000; } diff --git a/packages/node/src/configure/SubqueryProject.ts b/packages/node/src/configure/SubqueryProject.ts index dcfa71eb..5eb7bfb7 100644 --- a/packages/node/src/configure/SubqueryProject.ts +++ b/packages/node/src/configure/SubqueryProject.ts @@ -6,25 +6,24 @@ import { Injectable } from '@nestjs/common'; import { validateSemver } from '@subql/common'; import { - ConcordiumProjectNetworkConfig, parseConcordiumProjectManifest, - SubqlConcordiumDataSource, ConcordiumBlockFilter, ProjectManifestV1_0_0Impl, isRuntimeDs, - SubqlConcordiumHandlerKind, isCustomDs, } from '@subql/common-concordium'; import { insertBlockFiltersCronSchedules, ISubqueryProject, loadProjectTemplates, - SubqlProjectDs, updateDataSourcesV1_0_0, } from '@subql/node-core'; import { + ConcordiumNetworkConfig, CustomDatasourceTemplate, RuntimeDatasourceTemplate, + ConcordiumDatasource, + ConcordiumHandlerKind, } from '@subql/types-concordium'; import { ParentProject, Reader, RunnerSpecs } from '@subql/types-core'; import { buildSchemaFromString } from '@subql/utils'; @@ -33,11 +32,9 @@ import { GraphQLSchema } from 'graphql'; const { version: packageVersion } = require('../../package.json'); -export type ConcordiumProjectDs = SubqlProjectDs; - export type ConcordiumProjectDsTemplate = - | SubqlProjectDs - | SubqlProjectDs; + | RuntimeDatasourceTemplate + | CustomDatasourceTemplate; export type SubqlProjectBlockFilter = ConcordiumBlockFilter & { cronSchedule?: { @@ -50,18 +47,18 @@ const NOT_SUPPORT = (name: string) => { throw new Error(`Manifest specVersion ${name} is not supported`); }; -// This is the runtime type after we have mapped genesisHash to chainId and endpoint/dict have been provided when dealing with deployments -type NetworkConfig = ConcordiumProjectNetworkConfig & { chainId: string }; +// // This is the runtime type after we have mapped genesisHash to chainId and endpoint/dict have been provided when dealing with deployments +// type NetworkConfig = ConcordiumProjectNetworkConfig & { chainId: string }; @Injectable() export class SubqueryProject implements ISubqueryProject { - #dataSources: ConcordiumProjectDs[]; + #dataSources: ConcordiumDatasource[]; constructor( readonly id: string, readonly root: string, - readonly network: NetworkConfig, - dataSources: ConcordiumProjectDs[], + readonly network: ConcordiumNetworkConfig, + dataSources: ConcordiumDatasource[], readonly schema: GraphQLSchema, readonly templates: ConcordiumProjectDsTemplate[], readonly runner?: RunnerSpecs, @@ -70,7 +67,7 @@ export class SubqueryProject implements ISubqueryProject { this.#dataSources = dataSources; } - get dataSources(): ConcordiumProjectDs[] { + get dataSources(): ConcordiumDatasource[] { return this.#dataSources; } @@ -81,7 +78,7 @@ export class SubqueryProject implements ISubqueryProject { this.dataSources, getTimestamp, isRuntimeDs, - SubqlConcordiumHandlerKind.Block, + ConcordiumHandlerKind.Block, ); } @@ -90,7 +87,7 @@ export class SubqueryProject implements ISubqueryProject { rawManifest: unknown, reader: Reader, root: string, // If project local then directory otherwise temp directory - networkOverrides?: Partial, + networkOverrides?: Partial, ): Promise { // rawManifest and reader can be reused here. // It has been pre-fetched and used for rebase manifest runner options with args @@ -117,7 +114,7 @@ export class SubqueryProject implements ISubqueryProject { } } -function processChainId(network: any): NetworkConfig { +function processChainId(network: any): ConcordiumNetworkConfig { if (network.chainId && network.genesisHash) { throw new Error('Please only provide one of chainId and genesisHash'); } else if (network.genesisHash && !network.chainId) { @@ -134,7 +131,7 @@ async function loadProjectFromManifestBase( reader: Reader, path: string, root: string, - networkOverrides?: Partial, + networkOverrides?: Partial, ): Promise { if (typeof projectManifest.network.endpoint === 'string') { projectManifest.network.endpoint = [projectManifest.network.endpoint]; diff --git a/packages/node/src/indexer/blockDispatcher/block-dispatcher.service.ts b/packages/node/src/indexer/blockDispatcher/block-dispatcher.service.ts index 73eaf976..e6ed0698 100644 --- a/packages/node/src/indexer/blockDispatcher/block-dispatcher.service.ts +++ b/packages/node/src/indexer/blockDispatcher/block-dispatcher.service.ts @@ -14,12 +14,10 @@ import { ApiService, IProjectUpgradeService, PoiSyncService, + IBlock, } from '@subql/node-core'; -import { ConcordiumBlock } from '@subql/types-concordium'; -import { - ConcordiumProjectDs, - SubqueryProject, -} from '../../configure/SubqueryProject'; +import { ConcordiumBlock, ConcordiumDatasource } from '@subql/types-concordium'; +import { SubqueryProject } from '../../configure/SubqueryProject'; import { DynamicDsService } from '../dynamic-ds.service'; import { IndexerManager } from '../indexer.manager'; @@ -28,7 +26,7 @@ import { IndexerManager } from '../indexer.manager'; */ @Injectable() export class BlockDispatcherService - extends BlockDispatcher + extends BlockDispatcher implements OnApplicationShutdown { constructor( @@ -37,7 +35,7 @@ export class BlockDispatcherService private indexerManager: IndexerManager, eventEmitter: EventEmitter2, @Inject('IProjectService') - projectService: IProjectService, + projectService: IProjectService, @Inject('IProjectUpgradeService') projectUpgradeService: IProjectUpgradeService, smartBatchService: SmartBatchService, @@ -62,16 +60,12 @@ export class BlockDispatcherService ); } - protected getBlockHeight(block: ConcordiumBlock): number { - return Number(block.blockHeight); - } - protected async indexBlock( - block: ConcordiumBlock, + block: IBlock, ): Promise { return this.indexerManager.indexBlock( block, - await this.projectService.getDataSources(this.getBlockHeight(block)), + await this.projectService.getDataSources(block.getHeader().blockHeight), ); } } diff --git a/packages/node/src/indexer/blockDispatcher/concordium-block-dispatcher.ts b/packages/node/src/indexer/blockDispatcher/concordium-block-dispatcher.ts index 0c9f95e0..7f702c97 100644 --- a/packages/node/src/indexer/blockDispatcher/concordium-block-dispatcher.ts +++ b/packages/node/src/indexer/blockDispatcher/concordium-block-dispatcher.ts @@ -2,7 +2,9 @@ // SPDX-License-Identifier: GPL-3.0 import { IBlockDispatcher } from '@subql/node-core'; +import { ConcordiumBlock } from '@subql/types-concordium'; -export interface IConcordiumBlockDispatcher extends IBlockDispatcher { +export interface IConcordiumBlockDispatcher + extends IBlockDispatcher { init(onDynamicDsCreated: (height: number) => Promise): Promise; } diff --git a/packages/node/src/indexer/blockDispatcher/worker-block-dispatcher.service.ts b/packages/node/src/indexer/blockDispatcher/worker-block-dispatcher.service.ts index 83754daa..b4827ce5 100644 --- a/packages/node/src/indexer/blockDispatcher/worker-block-dispatcher.service.ts +++ b/packages/node/src/indexer/blockDispatcher/worker-block-dispatcher.service.ts @@ -17,13 +17,10 @@ import { InMemoryCacheService, createIndexerWorker, } from '@subql/node-core'; -import { ConcordiumBlock } from '@subql/types-concordium'; +import { ConcordiumBlock, ConcordiumDatasource } from '@subql/types-concordium'; import { ConcordiumApiConnection } from '../../concordium/api.connection'; -import { - ConcordiumProjectDs, - SubqueryProject, -} from '../../configure/SubqueryProject'; +import { SubqueryProject } from '../../configure/SubqueryProject'; import { DynamicDsService } from '../dynamic-ds.service'; import { UnfinalizedBlocksService } from '../unfinalizedBlocks.service'; import { IIndexerWorker } from '../worker/worker'; @@ -34,14 +31,18 @@ type IndexerWorker = IIndexerWorker & { @Injectable() export class WorkerBlockDispatcherService - extends WorkerBlockDispatcher + extends WorkerBlockDispatcher< + ConcordiumDatasource, + IndexerWorker, + ConcordiumBlock + > implements OnApplicationShutdown { constructor( nodeConfig: NodeConfig, eventEmitter: EventEmitter2, @Inject('IProjectService') - projectService: IProjectService, + projectService: IProjectService, @Inject('IProjectUpgradeService') projectUpgadeService: IProjectUpgradeService, smartBatchService: SmartBatchService, @@ -70,7 +71,7 @@ export class WorkerBlockDispatcherService IIndexerWorker, ConcordiumApiConnection, ConcordiumBlock, - ConcordiumProjectDs + ConcordiumDatasource >( path.resolve(__dirname, '../../../dist/indexer/worker/worker.js'), [], diff --git a/packages/node/src/indexer/dictionary.service.ts b/packages/node/src/indexer/dictionary.service.ts deleted file mode 100644 index 4f26f354..00000000 --- a/packages/node/src/indexer/dictionary.service.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors -// SPDX-License-Identifier: GPL-3.0 - -import { Inject, Injectable } from '@nestjs/common'; -import { EventEmitter2 } from '@nestjs/event-emitter'; -import { NETWORK_FAMILY } from '@subql/common'; -import { - NodeConfig, - DictionaryService as CoreDictionaryService, -} from '@subql/node-core'; -import { SubqueryProject } from '../configure/SubqueryProject'; - -@Injectable() -export class DictionaryService extends CoreDictionaryService { - private constructor( - @Inject('ISubqueryProject') protected project: SubqueryProject, - nodeConfig: NodeConfig, - eventEmitter: EventEmitter2, - dictionaryUrl?: string, - ) { - super( - dictionaryUrl ?? project.network.dictionary, - project.network.chainId, - nodeConfig, - eventEmitter, - ); - } - - static async create( - project: SubqueryProject, - nodeConfig: NodeConfig, - eventEmitter: EventEmitter2, - ): Promise { - const url = - project.network.dictionary ?? - (await CoreDictionaryService.resolveDictionary( - NETWORK_FAMILY.concordium, - project.network.chainId, - nodeConfig.dictionaryRegistry, - )); - - return new DictionaryService(project, nodeConfig, eventEmitter, url); - } -} diff --git a/packages/node/src/indexer/dictionary/dictionary.service.ts b/packages/node/src/indexer/dictionary/dictionary.service.ts new file mode 100644 index 00000000..cb6aaa61 --- /dev/null +++ b/packages/node/src/indexer/dictionary/dictionary.service.ts @@ -0,0 +1,63 @@ +// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors +// SPDX-License-Identifier: GPL-3.0 + +import { Inject, Injectable } from '@nestjs/common'; +import { EventEmitter2 } from '@nestjs/event-emitter'; +import { NETWORK_FAMILY } from '@subql/common'; +import { + NodeConfig, + DictionaryService as BaseDictionaryService, + getLogger, +} from '@subql/node-core'; +import { ConcordiumBlock, ConcordiumDatasource } from '@subql/types-concordium'; +import { SubqueryProject } from '../../configure/SubqueryProject'; +import { DsProcessorService } from '../ds-processor.service'; +import { DictionaryV1 } from './v1'; + +const logger = getLogger('eth-dictionary'); + +@Injectable() +export class DictionaryService extends BaseDictionaryService< + ConcordiumDatasource, + ConcordiumBlock +> { + constructor( + @Inject('ISubqueryProject') protected project: SubqueryProject, + nodeConfig: NodeConfig, + protected dsProcessorService: DsProcessorService, + eventEmitter: EventEmitter2, + ) { + super(project.network.chainId, nodeConfig, eventEmitter); + } + + async initDictionaries(): Promise { + const dictionariesV1: DictionaryV1[] = []; + + if (!this.project) { + throw new Error(`Project in Dictionary service not initialized `); + } + + const dictionaryEndpoints = await this.getDictionaryEndpoints( + NETWORK_FAMILY.concordium, + this.project.network, + ); + + for (const endpoint of dictionaryEndpoints) { + try { + const dictionary = await DictionaryV1.create( + this.project, + this.nodeConfig, + this.dsProcessorService.getDsProcessor.bind(this.dsProcessorService), + endpoint, + ); + dictionariesV1.push(dictionary); + } catch (e) { + logger.warn( + `Dictionary endpoint "${endpoint}" is not a valid dictionary`, + ); + } + } + // v2 should be prioritised + this.init(dictionariesV1); + } +} diff --git a/packages/node/src/indexer/dictionary/v1/dictionaryV1.ts b/packages/node/src/indexer/dictionary/v1/dictionaryV1.ts new file mode 100644 index 00000000..100f2eb4 --- /dev/null +++ b/packages/node/src/indexer/dictionary/v1/dictionaryV1.ts @@ -0,0 +1,206 @@ +// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors +// SPDX-License-Identifier: GPL-3.0 + +import { Inject, Injectable } from '@nestjs/common'; +import { NodeConfig, DictionaryV1 as BaseDictionaryV1 } from '@subql/node-core'; +import { + ConcordiumSpecialEventFilter, + ConcordiumTransactionEventFilter, + ConcordiumTransactionFilter, + DictionaryQueryCondition, + ConcordiumDatasource, + ConcordiumHandlerKind, +} from '@subql/types-concordium'; +import { DictionaryQueryEntry, DsProcessor } from '@subql/types-core'; +import { setWith, sortBy, uniqBy } from 'lodash'; +import { SubqueryProject } from '../../../configure/SubqueryProject'; + +export function txFilterToQueryEntry( + filter: ConcordiumTransactionFilter, +): DictionaryQueryEntry { + const conditions: DictionaryQueryCondition[] = [ + { + field: 'type', + value: filter.type, + matcher: 'equalTo', + }, + ]; + + if (filter.values !== undefined) { + const nested = {}; + + Object.keys(filter.values).map((key) => { + const value = filter.values[key]; + setWith(nested, key, value); + }); + + conditions.push({ + field: 'data', + value: nested as any, // Cast to any for compat with node core + matcher: 'contains', + }); + } + return { + entity: 'transactions', + conditions: conditions, + }; +} + +export function txEventFilterToQueryEntry( + filter: ConcordiumTransactionEventFilter, +): DictionaryQueryEntry { + const conditions: DictionaryQueryCondition[] = [ + { + field: 'type', + value: filter.type, + matcher: 'equalTo', + }, + ]; + + if (filter.values !== undefined) { + const nested = {}; + + Object.keys(filter.values).map((key) => { + const value = filter.values[key]; + setWith(nested, key, value); + }); + + conditions.push({ + field: 'data', + value: nested as any, // Cast to any for compat with node core + matcher: 'contains', + }); + } + return { + entity: 'txEvents', + conditions: conditions, + }; +} + +export function speicalEventFilterToQueryEntry( + filter: ConcordiumSpecialEventFilter, +): DictionaryQueryEntry { + const conditions: DictionaryQueryCondition[] = [ + { + field: 'type', + value: filter.type, + matcher: 'equalTo', + }, + ]; + + if (filter.values !== undefined) { + const nested = {}; + + Object.keys(filter.values).map((key) => { + const value = filter.values[key]; + setWith(nested, key, value); + }); + + conditions.push({ + field: 'data', + value: nested as any, // Cast to any for compat with node core + matcher: 'contains', + }); + } + return { + entity: 'specialEvents', + conditions: conditions, + }; +} + +export function buildDictionaryQueryEntries( + dataSources: ConcordiumDatasource[], +): DictionaryQueryEntry[] { + const queryEntries: DictionaryQueryEntry[] = []; + + for (const ds of dataSources) { + for (const handler of ds.mapping.handlers) { + // No filters, cant use dictionary + if (!handler.filter) return []; + + switch (handler.kind) { + case ConcordiumHandlerKind.Block: { + const filter = handler.filter; + if (filter.modulo === undefined) { + return []; + } + break; + } + case ConcordiumHandlerKind.Transaction: { + const filter = handler.filter; + if (filter.type || filter.values) { + queryEntries.push(txFilterToQueryEntry(filter)); + } else { + return []; + } + break; + } + case ConcordiumHandlerKind.TransactionEvent: { + const filter = handler.filter; + if (filter.type || filter.values) { + queryEntries.push(txEventFilterToQueryEntry(filter)); + } else { + return []; + } + break; + } + case ConcordiumHandlerKind.SpecialEvent: { + const filter = handler.filter; + if (filter.type || filter.values) { + queryEntries.push(speicalEventFilterToQueryEntry(filter)); + } else { + return []; + } + break; + } + default: + } + } + } + + return uniqBy( + queryEntries, + (item) => + `${item.entity}|${JSON.stringify( + sortBy(item.conditions, (c) => c.field), + )}`, + ); +} + +@Injectable() +export class DictionaryV1 extends BaseDictionaryV1 { + private constructor( + @Inject('ISubqueryProject') protected project: SubqueryProject, + nodeConfig: NodeConfig, + protected getDsProcessor: ( + ds: ConcordiumDatasource, + ) => DsProcessor, + dictionaryUrl?: string, + ) { + super(dictionaryUrl, project.network.chainId, nodeConfig); + } + + static async create( + project: SubqueryProject, + nodeConfig: NodeConfig, + getDsProcessor: ( + ds: ConcordiumDatasource, + ) => DsProcessor, + dictionaryUrl?: string, + ): Promise { + const dictionary = new DictionaryV1( + project, + nodeConfig, + getDsProcessor, + dictionaryUrl, + ); + await dictionary.init(); + return dictionary; + } + + buildDictionaryQueryEntries( + dataSources: ConcordiumDatasource[], + ): DictionaryQueryEntry[] { + return buildDictionaryQueryEntries(dataSources /*, this.getDsProcessor*/); + } +} diff --git a/packages/node/src/indexer/dictionary/v1/index.ts b/packages/node/src/indexer/dictionary/v1/index.ts new file mode 100644 index 00000000..370a512d --- /dev/null +++ b/packages/node/src/indexer/dictionary/v1/index.ts @@ -0,0 +1,4 @@ +// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors +// SPDX-License-Identifier: GPL-3.0 + +export * from './dictionaryV1'; diff --git a/packages/node/src/indexer/ds-processor.service.ts b/packages/node/src/indexer/ds-processor.service.ts index 890dadd8..03f3e848 100644 --- a/packages/node/src/indexer/ds-processor.service.ts +++ b/packages/node/src/indexer/ds-processor.service.ts @@ -3,24 +3,23 @@ import { Injectable } from '@nestjs/common'; import { - SubqlConcordiumHandlerKind, + ConcordiumHandlerKind, isCustomDs, - SubqlConcordiumCustomDataSource, - SubqlConcordiumDataSource, SubqlDatasourceProcessor, } from '@subql/common-concordium'; import { BaseDsProcessorService } from '@subql/node-core'; import { + ConcordiumCustomDatasource, + ConcordiumDatasource, SecondLayerHandlerProcessor_0_0_0, SecondLayerHandlerProcessor_1_0_0, - SubqlCustomDatasource, } from '@subql/types-concordium'; export function isSecondLayerHandlerProcessor_0_0_0< - K extends SubqlConcordiumHandlerKind, + K extends ConcordiumHandlerKind, F extends Record, E, - DS extends SubqlCustomDatasource = SubqlConcordiumCustomDataSource, + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource, >( processor: | SecondLayerHandlerProcessor_0_0_0 @@ -31,10 +30,10 @@ export function isSecondLayerHandlerProcessor_0_0_0< } export function isSecondLayerHandlerProcessor_1_0_0< - K extends SubqlConcordiumHandlerKind, + K extends ConcordiumHandlerKind, F extends Record, E, - DS extends SubqlConcordiumCustomDataSource = SubqlConcordiumCustomDataSource, + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource, >( processor: | SecondLayerHandlerProcessor_0_0_0 @@ -44,10 +43,10 @@ export function isSecondLayerHandlerProcessor_1_0_0< } export function asSecondLayerHandlerProcessor_1_0_0< - K extends SubqlConcordiumHandlerKind, + K extends ConcordiumHandlerKind, F extends Record, E, - DS extends SubqlConcordiumCustomDataSource = SubqlConcordiumCustomDataSource, + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource, >( processor: | SecondLayerHandlerProcessor_0_0_0 @@ -75,8 +74,8 @@ export function asSecondLayerHandlerProcessor_1_0_0< @Injectable() export class DsProcessorService extends BaseDsProcessorService< - SubqlConcordiumDataSource, - SubqlConcordiumCustomDataSource, + ConcordiumDatasource, + ConcordiumCustomDatasource, SubqlDatasourceProcessor> > { protected isCustomDs = isCustomDs; diff --git a/packages/node/src/indexer/dynamic-ds.service.ts b/packages/node/src/indexer/dynamic-ds.service.ts index e1e17219..a0ce2ed6 100644 --- a/packages/node/src/indexer/dynamic-ds.service.ts +++ b/packages/node/src/indexer/dynamic-ds.service.ts @@ -11,17 +11,15 @@ import { DatasourceParams, DynamicDsService as BaseDynamicDsService, } from '@subql/node-core'; +import { ConcordiumDatasource } from '@subql/types-concordium'; import { plainToClass } from 'class-transformer'; import { validateSync } from 'class-validator'; import { cloneDeep } from 'lodash'; -import { - ConcordiumProjectDs, - SubqueryProject, -} from '../configure/SubqueryProject'; +import { SubqueryProject } from '../configure/SubqueryProject'; import { DsProcessorService } from './ds-processor.service'; @Injectable() -export class DynamicDsService extends BaseDynamicDsService { +export class DynamicDsService extends BaseDynamicDsService { constructor( private readonly dsProcessorService: DsProcessorService, @Inject('ISubqueryProject') private readonly project: SubqueryProject, @@ -31,21 +29,23 @@ export class DynamicDsService extends BaseDynamicDsService protected async getDatasource( params: DatasourceParams, - ): Promise { - const { name, ...template } = cloneDeep( - this.project.templates?.find((t) => t.name === params.templateName), + ): Promise { + const t = this.project.templates?.find( + (t) => t.name === params.templateName, ); - if (!template) { + if (!t) { throw new Error( `Unable to find matching template in project for name: "${params.templateName}"`, ); } + const { name, ...template } = cloneDeep(t); + const dsObj = { ...template, startBlock: params.startBlock, - } as ConcordiumProjectDs; + } as ConcordiumDatasource; try { if (isCustomDs(dsObj)) { dsObj.processor.options = { diff --git a/packages/node/src/indexer/fetch.module.ts b/packages/node/src/indexer/fetch.module.ts index 6d8fd072..f6a5a7c0 100644 --- a/packages/node/src/indexer/fetch.module.ts +++ b/packages/node/src/indexer/fetch.module.ts @@ -25,7 +25,7 @@ import { BlockDispatcherService, WorkerBlockDispatcherService, } from './blockDispatcher'; -import { DictionaryService } from './dictionary.service'; +import { DictionaryService } from './dictionary/dictionary.service'; import { DsProcessorService } from './ds-processor.service'; import { DynamicDsService } from './dynamic-ds.service'; import { FetchService } from './fetch.service'; @@ -93,7 +93,7 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service'; unfinalizedBlocks: UnfinalizedBlocksService, connectionPoolState: ConnectionPoolStateManager, ) => - nodeConfig.workers !== undefined + nodeConfig.workers ? new WorkerBlockDispatcherService( nodeConfig, eventEmitter, @@ -145,22 +145,7 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service'; ConnectionPoolService, IndexingBenchmarkService, PoiBenchmarkService, - { - provide: DictionaryService, - useFactory: async ( - project: SubqueryProject, - nodeConfig: NodeConfig, - eventEmitter: EventEmitter2, - ) => { - const dictionaryService = await DictionaryService.create( - project, - nodeConfig, - eventEmitter, - ); - return dictionaryService; - }, - inject: ['ISubqueryProject', NodeConfig, EventEmitter2], - }, + DictionaryService, SandboxService, DsProcessorService, DynamicDsService, diff --git a/packages/node/src/indexer/fetch.service.ts b/packages/node/src/indexer/fetch.service.ts index bf53dca8..b3e21af2 100644 --- a/packages/node/src/indexer/fetch.service.ts +++ b/packages/node/src/indexer/fetch.service.ts @@ -5,11 +5,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { EventEmitter2 } from '@nestjs/event-emitter'; import { SchedulerRegistry } from '@nestjs/schedule'; -import { - isCustomDs, - SubqlConcordiumHandlerKind, - ConcordiumTransactionFilter, -} from '@subql/common-concordium'; +import { isCustomDs } from '@subql/common-concordium'; import { NodeConfig, BaseFetchService, @@ -18,27 +14,17 @@ import { getModulos, } from '@subql/node-core'; import { - ConcordiumSpecialEventFilter, - ConcordiumTransactionEventFilter, - SubqlDatasource, + ConcordiumBlock, + ConcordiumDatasource, + ConcordiumHandlerKind, } from '@subql/types-concordium'; -import { - DictionaryQueryCondition, - DictionaryQueryEntry, -} from '@subql/types-core'; -import { setWith, sortBy, uniqBy } from 'lodash'; -import { ConcordiumApi } from '../concordium'; +import { blockToHeader, ConcordiumApi } from '../concordium'; import { calcInterval } from '../concordium/utils.concordium'; import { SubqueryProject } from '../configure/SubqueryProject'; import { IConcordiumBlockDispatcher } from './blockDispatcher'; -import { DictionaryService } from './dictionary.service'; -import { DsProcessorService } from './ds-processor.service'; -import { DynamicDsService } from './dynamic-ds.service'; +import { DictionaryService } from './dictionary/dictionary.service'; import { ProjectService } from './project.service'; -import { - blockToHeader, - UnfinalizedBlocksService, -} from './unfinalizedBlocks.service'; +import { UnfinalizedBlocksService } from './unfinalizedBlocks.service'; const logger = getLogger('fetch.service'); @@ -46,163 +32,11 @@ const BLOCK_TIME_VARIANCE = 5000; const INTERVAL_PERCENT = 0.9; -export function txFilterToQueryEntry( - filter: ConcordiumTransactionFilter, -): DictionaryQueryEntry { - const conditions: DictionaryQueryCondition[] = [ - { - field: 'type', - value: filter.type, - matcher: 'equalTo', - }, - ]; - - if (filter.values !== undefined) { - const nested = {}; - - Object.keys(filter.values).map((key) => { - const value = filter.values[key]; - setWith(nested, key, value); - }); - - conditions.push({ - field: 'data', - value: nested as any, // Cast to any for compat with node core - matcher: 'contains', - }); - } - return { - entity: 'transactions', - conditions: conditions, - }; -} - -export function txEventFilterToQueryEntry( - filter: ConcordiumTransactionEventFilter, -): DictionaryQueryEntry { - const conditions: DictionaryQueryCondition[] = [ - { - field: 'type', - value: filter.type, - matcher: 'equalTo', - }, - ]; - - if (filter.values !== undefined) { - const nested = {}; - - Object.keys(filter.values).map((key) => { - const value = filter.values[key]; - setWith(nested, key, value); - }); - - conditions.push({ - field: 'data', - value: nested as any, // Cast to any for compat with node core - matcher: 'contains', - }); - } - return { - entity: 'txEvents', - conditions: conditions, - }; -} - -export function speicalEventFilterToQueryEntry( - filter: ConcordiumSpecialEventFilter, -): DictionaryQueryEntry { - const conditions: DictionaryQueryCondition[] = [ - { - field: 'type', - value: filter.type, - matcher: 'equalTo', - }, - ]; - - if (filter.values !== undefined) { - const nested = {}; - - Object.keys(filter.values).map((key) => { - const value = filter.values[key]; - setWith(nested, key, value); - }); - - conditions.push({ - field: 'data', - value: nested as any, // Cast to any for compat with node core - matcher: 'contains', - }); - } - return { - entity: 'specialEvents', - conditions: conditions, - }; -} - -export function buildDictionaryQueryEntries( - dataSources: SubqlDatasource[], -): DictionaryQueryEntry[] { - const queryEntries: DictionaryQueryEntry[] = []; - - for (const ds of dataSources) { - for (const handler of ds.mapping.handlers) { - // No filters, cant use dictionary - if (!handler.filter) return []; - - switch (handler.kind) { - case SubqlConcordiumHandlerKind.Block: { - const filter = handler.filter; - if (filter.modulo === undefined) { - return []; - } - break; - } - case SubqlConcordiumHandlerKind.Transaction: { - const filter = handler.filter; - if (filter.type || filter.values) { - queryEntries.push(txFilterToQueryEntry(filter)); - } else { - return []; - } - break; - } - case SubqlConcordiumHandlerKind.TransactionEvent: { - const filter = handler.filter; - if (filter.type || filter.values) { - queryEntries.push(txEventFilterToQueryEntry(filter)); - } else { - return []; - } - break; - } - case SubqlConcordiumHandlerKind.SpecialEvent: { - const filter = handler.filter; - if (filter.type || filter.values) { - queryEntries.push(speicalEventFilterToQueryEntry(filter)); - } else { - return []; - } - break; - } - default: - } - } - } - - return uniqBy( - queryEntries, - (item) => - `${item.entity}|${JSON.stringify( - sortBy(item.conditions, (c) => c.field), - )}`, - ); -} - @Injectable() export class FetchService extends BaseFetchService< - SubqlDatasource, + ConcordiumDatasource, IConcordiumBlockDispatcher, - DictionaryService + ConcordiumBlock > { constructor( private apiService: ApiService, @@ -212,8 +46,6 @@ export class FetchService extends BaseFetchService< @Inject('IBlockDispatcher') blockDispatcher: IConcordiumBlockDispatcher, dictionaryService: DictionaryService, - private dsProcessorService: DsProcessorService, - dynamicDsService: DynamicDsService, private unfinalizedBlocksService: UnfinalizedBlocksService, eventEmitter: EventEmitter2, schedulerRegistry: SchedulerRegistry, @@ -224,7 +56,6 @@ export class FetchService extends BaseFetchService< project.network, blockDispatcher, dictionaryService, - dynamicDsService, eventEmitter, schedulerRegistry, ); @@ -238,12 +69,6 @@ export class FetchService extends BaseFetchService< return this.apiService.networkMeta.genesisHash; } - protected buildDictionaryQueryEntries( - dataSources: (SubqlDatasource & { name?: string })[], - ): DictionaryQueryEntry[] { - return buildDictionaryQueryEntries(dataSources); - } - protected async getFinalizedHeight(): Promise { const block = await this.api.getFinalizedBlock(); @@ -264,12 +89,8 @@ export class FetchService extends BaseFetchService< return Math.min(BLOCK_TIME_VARIANCE, CHAIN_INTERVAL); } - protected getModulos(): number[] { - return getModulos( - this.projectService.getAllDataSources(), - isCustomDs, - SubqlConcordiumHandlerKind.Block, - ); + protected getModulos(dataSources: ConcordiumDatasource[]): number[] { + return getModulos(dataSources, isCustomDs, ConcordiumHandlerKind.Block); } protected async initBlockDispatcher(): Promise { diff --git a/packages/node/src/indexer/indexer.manager.ts b/packages/node/src/indexer/indexer.manager.ts index a0ecb62c..d0fea66d 100644 --- a/packages/node/src/indexer/indexer.manager.ts +++ b/packages/node/src/indexer/indexer.manager.ts @@ -8,9 +8,7 @@ import { isTransactionEventHandlerProcessor, isCustomDs, isRuntimeDs, - SubqlConcordiumCustomDataSource, ConcordiumRuntimeHandlerInputMap, - SubqlConcordiumDataSource, isSpecialEventHandlerProcessor, } from '@subql/common-concordium'; import { @@ -21,6 +19,7 @@ import { ProcessBlockResponse, BaseIndexerManager, ApiService, + IBlock, } from '@subql/node-core'; import { ConcordiumTransaction, @@ -32,7 +31,8 @@ import { ConcordiumSpecialEventFilter, ConcordiumTransactionEventFilter, ConcordiumHandlerKind, - SubqlDatasource, + ConcordiumDatasource, + ConcordiumCustomDatasource, } from '@subql/types-concordium'; import { ConcordiumApi, ConcordiumApiService } from '../concordium'; import { @@ -41,7 +41,6 @@ import { filterTxEventProcessor, } from '../concordium/block.concordium'; import SafeConcordiumGRPCClient from '../concordium/safe-api'; -import { ConcordiumProjectDs } from '../configure/SubqueryProject'; import { asSecondLayerHandlerProcessor_1_0_0, DsProcessorService, @@ -59,8 +58,8 @@ export class IndexerManager extends BaseIndexerManager< ConcordiumApi, ConcordiumBlock, ApiService, - SubqlConcordiumDataSource, - SubqlConcordiumCustomDataSource, + ConcordiumDatasource, + ConcordiumCustomDatasource, typeof FilterTypeMap, typeof ProcessorTypeMap, ConcordiumRuntimeHandlerInputMap @@ -97,18 +96,20 @@ export class IndexerManager extends BaseIndexerManager< @profiler() async indexBlock( - block: ConcordiumBlock, - dataSources: SubqlConcordiumDataSource[], + block: IBlock, + dataSources: ConcordiumDatasource[], ): Promise { return super.internalIndexBlock(block, dataSources, () => - this.getApi(block), + this.getApi(block.block), ); } + /** @deprecated remove once https://github.com/subquery/subql/pull/2346 is released */ getBlockHeight(block: ConcordiumBlock): number { return Number(block.blockHeight); } + /** @deprecated remove once https://github.com/subquery/subql/pull/2346 is released */ getBlockHash(block: ConcordiumBlock): string { return block.blockHash; } @@ -125,8 +126,8 @@ export class IndexerManager extends BaseIndexerManager< protected async indexBlockData( block: ConcordiumBlock, - dataSources: ConcordiumProjectDs[], - getVM: (d: ConcordiumProjectDs) => Promise, + dataSources: ConcordiumDatasource[], + getVM: (d: ConcordiumDatasource) => Promise, ): Promise { await this.indexBlockContent(block, dataSources, getVM); @@ -147,8 +148,8 @@ export class IndexerManager extends BaseIndexerManager< private async indexBlockContent( block: ConcordiumBlock, - dataSources: ConcordiumProjectDs[], - getVM: (d: ConcordiumProjectDs) => Promise, + dataSources: ConcordiumDatasource[], + getVM: (d: ConcordiumDatasource) => Promise, ): Promise { for (const ds of dataSources) { await this.indexData(ConcordiumHandlerKind.Block, block, ds, getVM); @@ -157,8 +158,8 @@ export class IndexerManager extends BaseIndexerManager< private async indexTransaction( tx: ConcordiumTransaction, - dataSources: ConcordiumProjectDs[], - getVM: (d: ConcordiumProjectDs) => Promise, + dataSources: ConcordiumDatasource[], + getVM: (d: ConcordiumDatasource) => Promise, ): Promise { for (const ds of dataSources) { await this.indexData(ConcordiumHandlerKind.Transaction, tx, ds, getVM); @@ -167,8 +168,8 @@ export class IndexerManager extends BaseIndexerManager< private async indexSpecialEvent( event: ConcordiumSpecialEvent, - dataSources: ConcordiumProjectDs[], - getVM: (d: ConcordiumProjectDs) => Promise, + dataSources: ConcordiumDatasource[], + getVM: (d: ConcordiumDatasource) => Promise, ): Promise { for (const ds of dataSources) { await this.indexData( @@ -182,8 +183,8 @@ export class IndexerManager extends BaseIndexerManager< private async indexTransactionEvent( event: ConcordiumTransactionEvent, - dataSources: ConcordiumProjectDs[], - getVM: (d: ConcordiumProjectDs) => Promise, + dataSources: ConcordiumDatasource[], + getVM: (d: ConcordiumDatasource) => Promise, ): Promise { for (const ds of dataSources) { await this.indexData( @@ -198,7 +199,7 @@ export class IndexerManager extends BaseIndexerManager< protected async prepareFilteredData( kind: ConcordiumHandlerKind, data: T, - ds: SubqlDatasource, + ds: ConcordiumDatasource, ): Promise { return Promise.resolve(data); } @@ -222,21 +223,21 @@ const FilterTypeMap = { [ConcordiumHandlerKind.Block]: ( data: ConcordiumBlock, filter: ConcordiumBlockFilter, - ds: SubqlConcordiumDataSource, + ds: ConcordiumDatasource, ) => filterBlocksProcessor(data, filter), [ConcordiumHandlerKind.SpecialEvent]: ( data: ConcordiumSpecialEvent, filter: ConcordiumSpecialEventFilter, - ds: SubqlConcordiumDataSource, + ds: ConcordiumDatasource, ) => filterTxEventProcessor(data, filter), [ConcordiumHandlerKind.TransactionEvent]: ( data: ConcordiumTransactionEvent, filter: ConcordiumTransactionEventFilter, - ds: SubqlConcordiumDataSource, + ds: ConcordiumDatasource, ) => filterTxEventProcessor(data, filter), [ConcordiumHandlerKind.Transaction]: ( data: ConcordiumTransaction, filter: ConcordiumTransactionFilter, - ds: SubqlConcordiumDataSource, + ds: ConcordiumDatasource, ) => filterTransactionsProcessor(data, filter), }; diff --git a/packages/node/src/indexer/project.service.ts b/packages/node/src/indexer/project.service.ts index be985068..f03be8d4 100644 --- a/packages/node/src/indexer/project.service.ts +++ b/packages/node/src/indexer/project.service.ts @@ -17,7 +17,7 @@ import { PoiSyncService, profiler, } from '@subql/node-core'; -import { ConcordiumBlock } from '@subql/types-concordium'; +import { ConcordiumBlock, ConcordiumDatasource } from '@subql/types-concordium'; import { IProjectNetworkConfig, BaseTemplateDataSource, @@ -25,10 +25,7 @@ import { import { Sequelize } from '@subql/x-sequelize'; import { ConcordiumApi } from '../concordium'; import SafeConcordiumGRPCClient from '../concordium/safe-api'; -import { - ConcordiumProjectDs, - SubqueryProject, -} from '../configure/SubqueryProject'; +import { SubqueryProject } from '../configure/SubqueryProject'; import { DsProcessorService } from './ds-processor.service'; import { DynamicDsService } from './dynamic-ds.service'; import { UnfinalizedBlocksService } from './unfinalizedBlocks.service'; @@ -38,7 +35,7 @@ const { version: packageVersion } = require('../../package.json'); @Injectable() export class ProjectService extends BaseProjectService< ApiService, - ConcordiumProjectDs + ConcordiumDatasource > { protected packageVersion = packageVersion; @@ -94,8 +91,8 @@ export class ProjectService extends BaseProjectService< protected onProjectChange( project: ISubqueryProject< IProjectNetworkConfig, - ConcordiumProjectDs, - BaseTemplateDataSource, + ConcordiumDatasource, + BaseTemplateDataSource, unknown >, ): void | Promise { diff --git a/packages/node/src/indexer/unfinalizedBlocks.service.ts b/packages/node/src/indexer/unfinalizedBlocks.service.ts index e8378be8..2f27629e 100644 --- a/packages/node/src/indexer/unfinalizedBlocks.service.ts +++ b/packages/node/src/indexer/unfinalizedBlocks.service.ts @@ -1,7 +1,6 @@ // Copyright 2020-2023 SubQuery Pte Ltd authors & contributors // SPDX-License-Identifier: GPL-3.0 -import { BlockInfo } from '@concordium/node-sdk'; import { Injectable } from '@nestjs/common'; import { ApiService, @@ -12,14 +11,7 @@ import { mainThreadOnly, } from '@subql/node-core'; import { ConcordiumBlock } from '@subql/types-concordium'; - -export function blockToHeader(block: ConcordiumBlock | BlockInfo): Header { - return { - blockHeight: Number(block.blockHeight), - blockHash: block.blockHash, - parentHash: block.blockParent, - }; -} +import { blockToHeader } from '../concordium'; @Injectable() export class UnfinalizedBlocksService extends BaseUnfinalizedBlocksService { @@ -31,11 +23,6 @@ export class UnfinalizedBlocksService extends BaseUnfinalizedBlocksService { const finalizedBlock = await this.apiService.api.getFinalizedBlock(); diff --git a/packages/node/src/indexer/worker/worker.service.ts b/packages/node/src/indexer/worker/worker.service.ts index 9f3fdcb7..de25f177 100644 --- a/packages/node/src/indexer/worker/worker.service.ts +++ b/packages/node/src/indexer/worker/worker.service.ts @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-3.0 import { Inject, Injectable } from '@nestjs/common'; -import { SubqlConcordiumDataSource } from '@subql/common-concordium'; import { NodeConfig, IProjectService, @@ -10,9 +9,9 @@ import { BaseWorkerService, IProjectUpgradeService, ApiService, + IBlock, } from '@subql/node-core'; -import { ConcordiumBlock } from '@subql/types-concordium'; -import { ConcordiumProjectDs } from '../../configure/SubqueryProject'; +import { ConcordiumBlock, ConcordiumDatasource } from '@subql/types-concordium'; import { IndexerManager } from '../indexer.manager'; export type FetchBlockResponse = { parentHash: string } | undefined; @@ -28,14 +27,14 @@ export type WorkerStatusResponse = { export class WorkerService extends BaseWorkerService< ConcordiumBlock, FetchBlockResponse, - SubqlConcordiumDataSource, + ConcordiumDatasource, {} > { constructor( private apiService: ApiService, private indexerManager: IndexerManager, @Inject('IProjectService') - projectService: IProjectService, + projectService: IProjectService, @Inject('IProjectUpgradeService') projectUpgradeService: IProjectUpgradeService, nodeConfig: NodeConfig, @@ -46,7 +45,7 @@ export class WorkerService extends BaseWorkerService< protected async fetchChainBlock( heights: number, extra: {}, - ): Promise { + ): Promise> { const [block] = await this.apiService.fetchBlocks([heights]); return block; } @@ -58,8 +57,8 @@ export class WorkerService extends BaseWorkerService< } protected async processFetchedBlock( - block: ConcordiumBlock, - dataSources: SubqlConcordiumDataSource[], + block: IBlock, + dataSources: ConcordiumDatasource[], ): Promise { return this.indexerManager.indexBlock(block, dataSources); } diff --git a/packages/node/src/indexer/worker/worker.unfinalizedBlocks.service.ts b/packages/node/src/indexer/worker/worker.unfinalizedBlocks.service.ts index 88bbf7d3..07600327 100644 --- a/packages/node/src/indexer/worker/worker.unfinalizedBlocks.service.ts +++ b/packages/node/src/indexer/worker/worker.unfinalizedBlocks.service.ts @@ -6,10 +6,13 @@ import { Injectable } from '@nestjs/common'; import { Header, HostUnfinalizedBlocks, + IBlock, IUnfinalizedBlocksService, } from '@subql/node-core'; import { ConcordiumBlock } from '@subql/types-concordium'; +/** + * @deprecated use node-core version once released https://github.com/subquery/subql/pull/2346 */ @Injectable() export class WorkerUnfinalizedBlocksService implements IUnfinalizedBlocksService @@ -24,16 +27,10 @@ export class WorkerUnfinalizedBlocksService return this.host.unfinalizedBlocksProcess(header); } - async processUnfinalizedBlocks({ - blockHash, - blockHeight, - blockParent, - }: ConcordiumBlock): Promise { - return this.host.unfinalizedBlocksProcess({ - blockHash, - blockHeight: Number(blockHeight), - parentHash: blockParent, - }); + async processUnfinalizedBlocks( + block: IBlock, + ): Promise { + return this.host.unfinalizedBlocksProcess(block.getHeader()); } // eslint-disable-next-line @typescript-eslint/promise-function-async diff --git a/packages/node/src/subcommands/testing.service.ts b/packages/node/src/subcommands/testing.service.ts index c60cee53..a9dbb0ec 100644 --- a/packages/node/src/subcommands/testing.service.ts +++ b/packages/node/src/subcommands/testing.service.ts @@ -9,14 +9,12 @@ import { TestingService as BaseTestingService, NestLogger, TestRunner, + IBlock, } from '@subql/node-core'; -import { ConcordiumBlock } from '@subql/types-concordium'; +import { ConcordiumBlock, ConcordiumDatasource } from '@subql/types-concordium'; import { ConcordiumApi } from '../concordium'; import SafeEthProvider from '../concordium/safe-api'; -import { - ConcordiumProjectDs, - SubqueryProject, -} from '../configure/SubqueryProject'; +import { SubqueryProject } from '../configure/SubqueryProject'; import { IndexerManager } from '../indexer/indexer.manager'; import { ProjectService } from '../indexer/project.service'; import { TestingModule } from './testing.module'; @@ -26,7 +24,7 @@ export class TestingService extends BaseTestingService< ConcordiumApi, SafeEthProvider, ConcordiumBlock, - ConcordiumProjectDs + ConcordiumDatasource > { constructor( nodeConfig: NodeConfig, @@ -42,7 +40,7 @@ export class TestingService extends BaseTestingService< ConcordiumApi, SafeEthProvider, ConcordiumBlock, - ConcordiumProjectDs + ConcordiumDatasource >, ] > { @@ -62,7 +60,7 @@ export class TestingService extends BaseTestingService< } async indexBlock( - block: ConcordiumBlock, + block: IBlock, handler: string, indexerManager: IndexerManager, ): Promise { diff --git a/packages/node/src/utils/project.ts b/packages/node/src/utils/project.ts index 2c048aef..22b8190a 100644 --- a/packages/node/src/utils/project.ts +++ b/packages/node/src/utils/project.ts @@ -5,15 +5,13 @@ import { SubqlRuntimeHandler, SubqlCustomHandler, SubqlHandler, - SubqlConcordiumHandlerKind, + ConcordiumHandlerKind, } from '@subql/common-concordium'; export function isBaseHandler( handler: SubqlHandler, ): handler is SubqlRuntimeHandler { - return Object.values(SubqlConcordiumHandlerKind).includes( - handler.kind, - ); + return Object.values(ConcordiumHandlerKind).includes(handler.kind); } export function isCustomHandler( diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index e6de3d10..b9d00f98 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Improve naming of types and be consistent with other SDKs (#35) ## [3.4.4] - 2024-02-07 ### Changed diff --git a/packages/types/package.json b/packages/types/package.json index dcf16757..5eda65f7 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -14,7 +14,7 @@ "license": "GPL-3.0", "dependencies": { "@concordium/node-sdk": "9.4.0", - "@subql/types-core": "^0.5.0" + "@subql/types-core": "^0.6.0" }, "files": [ "src/global.d.ts", diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 0840b47f..13896688 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,6 +1,5 @@ // Copyright 2020-2023 SubQuery Pte Ltd authors & contributors // SPDX-License-Identifier: GPL-3.0 -export * from './interfaces'; export * from './project'; export * from './concordium'; diff --git a/packages/types/src/interfaces.ts b/packages/types/src/interfaces.ts deleted file mode 100644 index a3f7d3f1..00000000 --- a/packages/types/src/interfaces.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors -// SPDX-License-Identifier: GPL-3.0 - -import {BlockInfo} from '@concordium/node-sdk'; -import {ConcordiumBlock} from './concordium'; - -export interface ApiWrapper { - init: () => Promise; - getGenesisHash: () => string; - getRuntimeChain: () => string; - getChainId: () => string; - getSpecName: () => string; - getFinalizedBlockHeight: () => Promise; - getBestBlockHeight: () => Promise; - getBlockByHash: (hash: string) => Promise; - fetchBlocks: (bufferBlocks: number[]) => Promise; -} diff --git a/packages/types/src/project.ts b/packages/types/src/project.ts index b5905f7a..97a955dc 100644 --- a/packages/types/src/project.ts +++ b/packages/types/src/project.ts @@ -1,6 +1,7 @@ // Copyright 2020-2023 SubQuery Pte Ltd authors & contributors // SPDX-License-Identifier: GPL-3.0 +import {ConcordiumGRPCClient} from '@concordium/node-sdk'; import { BaseTemplateDataSource, CommonSubqueryProject, @@ -19,12 +20,13 @@ import { ConcordiumTransactionEvent, ConcordiumTransactionEventFilter, } from './concordium'; -import {ApiWrapper} from './interfaces'; -export type RuntimeDatasourceTemplate = BaseTemplateDataSource; -export type CustomDatasourceTemplate = BaseTemplateDataSource; +export type RuntimeDatasourceTemplate = BaseTemplateDataSource; +export type CustomDatasourceTemplate = BaseTemplateDataSource; -export type ConcordiumProjectManifestV1_0_0 = ProjectManifestV1_0_0; +export type ConcordiumProjectManifestV1_0_0 = ProjectManifestV1_0_0< + ConcordiumRuntimeDatasource | ConcordiumCustomDatasource +>; /** * Kind of Concordium datasource. @@ -175,8 +177,9 @@ interface ISubqlDatasource { * @interface * @template M - The mapping type for the datasource (default: SubqlMapping). */ -export interface SubqlRuntimeDatasource = SubqlMapping> - extends ISubqlDatasource { +export interface ConcordiumRuntimeDatasource< + M extends SubqlMapping = SubqlMapping +> extends ISubqlDatasource { /** * The kind of the datasource, which is `concordium/Runtime`. * @type {ConcordiumDatasourceKind.Runtime} @@ -185,11 +188,11 @@ export interface SubqlRuntimeDatasource; } -export type SubqlDatasource = SubqlRuntimeDatasource | SubqlCustomDatasource; +export type ConcordiumDatasource = ConcordiumRuntimeDatasource | ConcordiumCustomDatasource; export type CustomDataSourceAsset = FileReference; -export interface SubqlCustomDatasource< +export interface ConcordiumCustomDatasource< K extends string = string, M extends SubqlMapping = SubqlMapping, O = any @@ -202,22 +205,27 @@ export interface SubqlCustomDatasource< export interface HandlerInputTransformer_0_0_0< T extends ConcordiumHandlerKind, E, - DS extends SubqlCustomDatasource = SubqlCustomDatasource + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource > { - (input: ConcordiumRuntimeHandlerInputMap[T], ds: DS, api: ApiWrapper, assets?: Record): Promise; // | SubstrateBuiltinDataSource + ( + input: ConcordiumRuntimeHandlerInputMap[T], + ds: DS, + api: ConcordiumGRPCClient, + assets?: Record + ): Promise; // | SubstrateBuiltinDataSource } export interface HandlerInputTransformer_1_0_0< T extends ConcordiumHandlerKind, F, E, - DS extends SubqlCustomDatasource = SubqlCustomDatasource + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource > { (params: { input: ConcordiumRuntimeHandlerInputMap[T]; ds: DS; filter?: F; - api: ApiWrapper; + api: ConcordiumGRPCClient; assets?: Record; }): Promise; // | SubstrateBuiltinDataSource } @@ -237,7 +245,7 @@ export type SecondLayerHandlerProcessorArray< K extends string, F, T, - DS extends SubqlCustomDatasource = SubqlCustomDatasource + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource > = | SecondLayerHandlerProcessor | SecondLayerHandlerProcessor @@ -247,7 +255,7 @@ export type SecondLayerHandlerProcessorArray< export interface SubqlDatasourceProcessor< K extends string, F, - DS extends SubqlCustomDatasource = SubqlCustomDatasource, + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource, P extends Record> = Record< string, SecondLayerHandlerProcessorArray @@ -255,14 +263,14 @@ export interface SubqlDatasourceProcessor< > { kind: K; validate(ds: DS, assets: Record): void; - dsFilterProcessor(ds: DS, api: ApiWrapper): boolean; + dsFilterProcessor(ds: DS, api: ConcordiumGRPCClient): boolean; handlerProcessors: P; } interface SecondLayerHandlerProcessorBase< K extends ConcordiumHandlerKind, F, - DS extends SubqlCustomDatasource = SubqlCustomDatasource + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource > { baseHandlerKind: K; baseFilter: ConcordiumRuntimeFilterMap[K] | ConcordiumRuntimeFilterMap[K][]; @@ -274,7 +282,7 @@ export interface SecondLayerHandlerProcessor_0_0_0< K extends ConcordiumHandlerKind, F, E, - DS extends SubqlCustomDatasource = SubqlCustomDatasource + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource > extends SecondLayerHandlerProcessorBase { specVersion: undefined; transformer: HandlerInputTransformer_0_0_0; @@ -285,7 +293,7 @@ export interface SecondLayerHandlerProcessor_1_0_0< K extends ConcordiumHandlerKind, F, E, - DS extends SubqlCustomDatasource = SubqlCustomDatasource + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource > extends SecondLayerHandlerProcessorBase { specVersion: '1.0.0'; transformer: HandlerInputTransformer_1_0_0; @@ -296,15 +304,21 @@ export type SecondLayerHandlerProcessor< K extends ConcordiumHandlerKind, F, E, - DS extends SubqlCustomDatasource = SubqlCustomDatasource + DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource > = SecondLayerHandlerProcessor_0_0_0 | SecondLayerHandlerProcessor_1_0_0; +/** + * Represents a Ethereum subquery network configuration, which is based on the CommonSubqueryNetworkConfig template. + * @type {IProjectNetworkConfig} + */ +export type ConcordiumNetworkConfig = IProjectNetworkConfig; + /** * Represents a Concordium project configuration based on the CommonSubqueryProject template. * @type {CommonSubqueryProject} */ -export type ConcordiumProject = CommonSubqueryProject< - IProjectNetworkConfig, - SubqlRuntimeDatasource | DS, - BaseTemplateDataSource | BaseTemplateDataSource +export type ConcordiumProject = CommonSubqueryProject< + ConcordiumNetworkConfig, + ConcordiumRuntimeDatasource | DS, + BaseTemplateDataSource | BaseTemplateDataSource >; diff --git a/yarn.lock b/yarn.lock index 59d1ba41..8a6410e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1573,48 +1573,6 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/common@npm:^3.2.0": - version: 3.2.0 - resolution: "@ethereumjs/common@npm:3.2.0" - dependencies: - "@ethereumjs/util": ^8.1.0 - crc-32: ^1.2.0 - checksum: cb9cc11f5c868cb577ba611cebf55046e509218bbb89b47ccce010776dafe8256d70f8f43fab238aec74cf71f62601cd5842bc03a83261200802de365732a14b - languageName: node - linkType: hard - -"@ethereumjs/rlp@npm:^4.0.1": - version: 4.0.1 - resolution: "@ethereumjs/rlp@npm:4.0.1" - bin: - rlp: bin/rlp - checksum: 30db19c78faa2b6ff27275ab767646929207bb207f903f09eb3e4c273ce2738b45f3c82169ddacd67468b4f063d8d96035f2bf36f02b6b7e4d928eefe2e3ecbc - languageName: node - linkType: hard - -"@ethereumjs/tx@npm:^4.2.0": - version: 4.2.0 - resolution: "@ethereumjs/tx@npm:4.2.0" - dependencies: - "@ethereumjs/common": ^3.2.0 - "@ethereumjs/rlp": ^4.0.1 - "@ethereumjs/util": ^8.1.0 - ethereum-cryptography: ^2.0.0 - checksum: 87a3f5f2452cfbf6712f8847525a80c213210ed453c211c793c5df801fe35ecef28bae17fadd222fcbdd94277478a47e52d2b916a90a6b30cda21f1e0cdaee42 - languageName: node - linkType: hard - -"@ethereumjs/util@npm:^8.0.6, @ethereumjs/util@npm:^8.1.0": - version: 8.1.0 - resolution: "@ethereumjs/util@npm:8.1.0" - dependencies: - "@ethereumjs/rlp": ^4.0.1 - ethereum-cryptography: ^2.0.0 - micro-ftch: ^0.3.1 - checksum: 9ae5dee8f12b0faf81cd83f06a41560e79b0ba96a48262771d897a510ecae605eb6d84f687da001ab8ccffd50f612ae50f988ef76e6312c752897f462f3ac08d - languageName: node - linkType: hard - "@fastify/busboy@npm:^2.0.0": version: 2.0.0 resolution: "@fastify/busboy@npm:2.0.0" @@ -2163,60 +2121,6 @@ __metadata: languageName: node linkType: hard -"@metamask/abi-utils@npm:^2.0.2": - version: 2.0.2 - resolution: "@metamask/abi-utils@npm:2.0.2" - dependencies: - "@metamask/utils": ^8.0.0 - superstruct: ^1.0.3 - checksum: 5ec153e7691a4e1dc8738a0ba1a99a354ddb13851fa88a40a19f002f6308310e71c2cee28c3a25d9f7f67e839c7dffe4760e93e308dd17fa725b08d0dc73a3d4 - languageName: node - linkType: hard - -"@metamask/eth-sig-util@npm:5.1.0": - version: 5.1.0 - resolution: "@metamask/eth-sig-util@npm:5.1.0" - dependencies: - "@ethereumjs/util": ^8.0.6 - bn.js: ^4.12.0 - ethereum-cryptography: ^2.0.0 - ethjs-util: ^0.1.6 - tweetnacl: ^1.0.3 - tweetnacl-util: ^0.15.1 - checksum: c639e3bf91625faeb0230a6314f0b2d05e8f5e2989542d3e0eed1d21b7b286e1860f68629870fd7e568c1a599b3993c4210403fb4c84a625fb1e75ef676eab4f - languageName: node - linkType: hard - -"@metamask/eth-sig-util@npm:^7.0.0": - version: 7.0.1 - resolution: "@metamask/eth-sig-util@npm:7.0.1" - dependencies: - "@ethereumjs/util": ^8.1.0 - "@metamask/abi-utils": ^2.0.2 - "@metamask/utils": ^8.1.0 - ethereum-cryptography: ^2.1.2 - tweetnacl: ^1.0.3 - tweetnacl-util: ^0.15.1 - checksum: 98d056bd83aeb2d29ec3de09cd18e67d97ea295a59d405a9ce3fe274badd2d4f18da1fe530a266b4c777650855ed75ecd3577decd607a561e938dd7a808c5839 - languageName: node - linkType: hard - -"@metamask/utils@npm:^8.0.0, @metamask/utils@npm:^8.1.0": - version: 8.3.0 - resolution: "@metamask/utils@npm:8.3.0" - dependencies: - "@ethereumjs/tx": ^4.2.0 - "@noble/hashes": ^1.3.1 - "@scure/base": ^1.1.3 - "@types/debug": ^4.1.7 - debug: ^4.3.4 - pony-cause: ^2.1.10 - semver: ^7.5.4 - superstruct: ^1.0.3 - checksum: cd60c49b4c0397fb31e6b38937a0d9346cbb8337cb8add59db8db0e0e2156fb063ff4df93a26410157f0cc02aa9a9b785fc1b53cfc4ab73204462893ed11cacb - languageName: node - linkType: hard - "@nestjs/common@npm:^9.4.0": version: 9.4.3 resolution: "@nestjs/common@npm:9.4.3" @@ -2345,24 +2249,6 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.1.0, @noble/curves@npm:~1.1.0": - version: 1.1.0 - resolution: "@noble/curves@npm:1.1.0" - dependencies: - "@noble/hashes": 1.3.1 - checksum: 2658cdd3f84f71079b4e3516c47559d22cf4b55c23ac8ee9d2b1f8e5b72916d9689e59820e0f9d9cb4a46a8423af5b56dc6bb7782405c88be06a015180508db5 - languageName: node - linkType: hard - -"@noble/curves@npm:1.3.0, @noble/curves@npm:~1.3.0": - version: 1.3.0 - resolution: "@noble/curves@npm:1.3.0" - dependencies: - "@noble/hashes": 1.3.3 - checksum: b65342ee66c4a440eee2978524412eabba9a9efdd16d6370e15218c6a7d80bddf35e66bb57ed52c0dfd32cb9a717b439ab3a72db618f1a0066dfebe3fd12a421 - languageName: node - linkType: hard - "@noble/curves@npm:^1.2.0": version: 1.2.0 resolution: "@noble/curves@npm:1.2.0" @@ -2379,27 +2265,13 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.3.1": - version: 1.3.1 - resolution: "@noble/hashes@npm:1.3.1" - checksum: 7fdefc0f7a0c1ec27acc6ff88841793e3f93ec4ce6b8a6a12bfc0dd70ae6b7c4c82fe305fdfeda1735d5ad4a9eebe761e6693b3d355689c559e91242f4bc95b1 - languageName: node - linkType: hard - -"@noble/hashes@npm:1.3.2, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:~1.3.0, @noble/hashes@npm:~1.3.1": +"@noble/hashes@npm:1.3.2, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:~1.3.0": version: 1.3.2 resolution: "@noble/hashes@npm:1.3.2" checksum: fe23536b436539d13f90e4b9be843cc63b1b17666a07634a2b1259dded6f490be3d050249e6af98076ea8f2ea0d56f578773c2197f2aa0eeaa5fba5bc18ba474 languageName: node linkType: hard -"@noble/hashes@npm:1.3.3, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:~1.3.2": - version: 1.3.3 - resolution: "@noble/hashes@npm:1.3.3" - checksum: 8a6496d1c0c64797339bc694ad06cdfaa0f9e56cd0c3f68ae3666cfb153a791a55deb0af9c653c7ed2db64d537aa3e3054629740d2f2338bb1dcb7ab60cd205b - languageName: node - linkType: hard - "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5" @@ -2852,36 +2724,7 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:~1.1.4": - version: 1.1.5 - resolution: "@scure/base@npm:1.1.5" - checksum: 9e9ee6088cb3aa0fb91f5a48497d26682c7829df3019b1251d088d166d7a8c0f941c68aaa8e7b96bbad20c71eb210397cb1099062cde3e29d4bad6b975c18519 - languageName: node - linkType: hard - -"@scure/bip32@npm:1.3.1": - version: 1.3.1 - resolution: "@scure/bip32@npm:1.3.1" - dependencies: - "@noble/curves": ~1.1.0 - "@noble/hashes": ~1.3.1 - "@scure/base": ~1.1.0 - checksum: 394d65f77a40651eba21a5096da0f4233c3b50d422864751d373fcf142eeedb94a1149f9ab1dbb078086dab2d0bc27e2b1afec8321bf22d4403c7df2fea5bfe2 - languageName: node - linkType: hard - -"@scure/bip32@npm:1.3.3": - version: 1.3.3 - resolution: "@scure/bip32@npm:1.3.3" - dependencies: - "@noble/curves": ~1.3.0 - "@noble/hashes": ~1.3.2 - "@scure/base": ~1.1.4 - checksum: f939ca733972622fcc1e61d4fdf170a0ad294b24ddb7ed7cdd4c467e1ef283b970154cb101cf5f1a7b64cf5337e917ad31135911dfc36b1d76625320167df2fa - languageName: node - linkType: hard - -"@scure/bip39@npm:1.2.1, @scure/bip39@npm:^1.1.0": +"@scure/bip39@npm:^1.1.0": version: 1.2.1 resolution: "@scure/bip39@npm:1.2.1" dependencies: @@ -2891,16 +2734,6 @@ __metadata: languageName: node linkType: hard -"@scure/bip39@npm:1.2.2": - version: 1.2.2 - resolution: "@scure/bip39@npm:1.2.2" - dependencies: - "@noble/hashes": ~1.3.2 - "@scure/base": ~1.1.4 - checksum: cb99505e6d2deef8e55e81df8c563ce8dbfdf1595596dc912bceadcf366c91b05a98130e928ecb090df74efdb20150b64acc4be55bc42768cab4d39a2833d234 - languageName: node - linkType: hard - "@sinclair/typebox@npm:^0.27.8": version: 0.27.8 resolution: "@sinclair/typebox@npm:0.27.8" @@ -2933,31 +2766,12 @@ __metadata: languageName: node linkType: hard -"@subql/apollo-links@npm:1.3.2": - version: 1.3.2 - resolution: "@subql/apollo-links@npm:1.3.2" - dependencies: - "@apollo/client": ^3.8.8 - "@metamask/eth-sig-util": 5.1.0 - "@subql/network-support": 0.2.0 - apollo-link-error: ^1.1.13 - buffer: ^6.0.3 - cross-fetch: ^4.0.0 - js-base64: ^3.7.5 - jwt-decode: ^3.1.2 - lru-cache: ^10.0.1 - peerDependencies: - graphql: "*" - checksum: 6eb9047062984744f2071db3dfc9f4aae56fb351e21961cf3743a97298a36bd227802a453d41ecf705732ace7ad85c3fa3d05c6c3ea2b38784d4fdc1072fc3b1 - languageName: node - linkType: hard - "@subql/common-concordium@workspace:*, @subql/common-concordium@workspace:packages/common-concordium": version: 0.0.0-use.local resolution: "@subql/common-concordium@workspace:packages/common-concordium" dependencies: "@concordium/node-sdk": 9.4.0 - "@subql/common": ^3.4.1 + "@subql/common": ^3.5.0 "@subql/types-concordium": "workspace:*" "@types/js-yaml": ^4.0.4 "@types/pino": ^6.3.12 @@ -2970,11 +2784,11 @@ __metadata: languageName: unknown linkType: soft -"@subql/common@npm:3.4.1, @subql/common@npm:^3.4.1": - version: 3.4.1 - resolution: "@subql/common@npm:3.4.1" +"@subql/common@npm:3.5.0, @subql/common@npm:^3.5.0": + version: 3.5.0 + resolution: "@subql/common@npm:3.5.0" dependencies: - "@subql/types-core": 0.5.0 + "@subql/types-core": 0.6.0 axios: ^0.28.0 class-transformer: ^0.5.1 class-validator: ^0.14.0 @@ -2984,20 +2798,7 @@ __metadata: reflect-metadata: ^0.1.13 semver: ^7.5.2 update-notifier: 5.1.0 - checksum: 334d1c4f937d16bd50106ffd14425cfc7f1ae6ea8046da8dadb6c6ce685a3de7acb81243f05de986a61fa918802730e5d4f788b5a20d86052841a12d7cbbc380 - languageName: node - linkType: hard - -"@subql/network-support@npm:0.2.0": - version: 0.2.0 - resolution: "@subql/network-support@npm:0.2.0" - dependencies: - "@metamask/eth-sig-util": ^7.0.0 - cross-fetch: ^4.0.0 - js-base64: ^3.7.5 - jwt-decode: ^3.1.2 - lru-cache: ^10.0.1 - checksum: 097d82687654a05f228bdbec227bc18b7bd3d577092123add7e6834274ba8a12401d4c24cb2301cd3bd07fe5755ffe3bd6a39414c95cf355d10c17586e2d69a0 + checksum: 63c374b82de90f2db5c76d8f3808e37100d3616707736806d3f43249ea0ca63f0c115104815cb842becb0d350e16e893a8d3942c0e865d62890e43362a455799 languageName: node linkType: hard @@ -3014,10 +2815,9 @@ __metadata: "@nestjs/schedule": ^3.0.1 "@nestjs/schematics": ^9.2.0 "@nestjs/testing": ^9.4.0 - "@subql/common": ^3.4.1 + "@subql/common": ^3.5.0 "@subql/common-concordium": "workspace:*" - "@subql/node-core": ^7.4.2 - "@subql/testing": 2.1.0 + "@subql/node-core": ^8.0.1 "@subql/types-concordium": "workspace:*" "@types/express": ^4.17.13 "@types/jest": ^27.4.0 @@ -3044,19 +2844,18 @@ __metadata: languageName: unknown linkType: soft -"@subql/node-core@npm:^7.4.2": - version: 7.4.2 - resolution: "@subql/node-core@npm:7.4.2" +"@subql/node-core@npm:^8.0.1": + version: 8.0.1 + resolution: "@subql/node-core@npm:8.0.1" dependencies: "@apollo/client": ^3.8.8 "@nestjs/common": ^9.4.0 "@nestjs/event-emitter": ^2.0.0 "@nestjs/schedule": ^3.0.1 - "@subql/apollo-links": 1.3.2 - "@subql/common": 3.4.1 + "@subql/common": 3.5.0 "@subql/testing": 2.1.1-0 - "@subql/types": 3.3.1 - "@subql/utils": 2.8.0 + "@subql/types": 3.4.0 + "@subql/utils": 2.9.0 "@willsoto/nestjs-prometheus": ^5.4.0 async-lock: ^1.4.0 async-mutex: ^0.4.0 @@ -3072,16 +2871,7 @@ __metadata: toposort-class: ^1.0.1 vm2: ^3.9.19 yargs: ^16.2.0 - checksum: d5115fd8981280821cad28779562282e6f2dd6fa7b7e8d0079142e56320e5748e1149a8db8ccd0e1f9e7d088a0c6ea0c4a2c5738cf5d4209641a66ad67e3781e - languageName: node - linkType: hard - -"@subql/testing@npm:2.1.0": - version: 2.1.0 - resolution: "@subql/testing@npm:2.1.0" - dependencies: - "@subql/types-core": ^0.1.2-0 - checksum: 42885519277ec48d079accbc68ca600da64e1c960930d506dcd4a207188ad399ff42f81dfeb5d447f235f3bf7ef61ea55d332d47cb10e6d89c4fafda61fe8bac + checksum: ead9feeef201b2ed9db1726e70d375d6a3ca5d44f7576dd14aa2949308d11a6a34abcc1013cd4d84eb8e57fd236609cdb93e359c0b85ff5b225257c99261635d languageName: node linkType: hard @@ -3099,25 +2889,16 @@ __metadata: resolution: "@subql/types-concordium@workspace:packages/types" dependencies: "@concordium/node-sdk": 9.4.0 - "@subql/types-core": ^0.5.0 + "@subql/types-core": ^0.6.0 languageName: unknown linkType: soft -"@subql/types-core@npm:0.5.0, @subql/types-core@npm:^0.5.0": - version: 0.5.0 - resolution: "@subql/types-core@npm:0.5.0" - dependencies: - package-json-type: ^1.0.3 - checksum: bc348655ead081a6e15c669e5b44dbb78a3673d2497d173a1d4a6e21c328702b3582ee0d8e71042b3e25d6e1d41fbc5a3cf4724a07e2062bd01b87cf5956f6d6 - languageName: node - linkType: hard - -"@subql/types-core@npm:^0.1.2-0": - version: 0.1.2-1 - resolution: "@subql/types-core@npm:0.1.2-1" +"@subql/types-core@npm:0.6.0, @subql/types-core@npm:^0.6.0": + version: 0.6.0 + resolution: "@subql/types-core@npm:0.6.0" dependencies: package-json-type: ^1.0.3 - checksum: 1c54fecfd7b99875528a87109a3cb8cfcb86a61221f7e715be49198381c6c97e481b60f351c8210df67d1074d3541cd6ee0aad17831f0896dcea63e9784bda64 + checksum: 0688f1973f830d1d2ab34864b00fc7efb105228b0328ac485c69950957da3a67a92d9477bc94945e57e3cccbf1b732bdea097c1a452a907e23704e9cbeff31fc languageName: node linkType: hard @@ -3130,20 +2911,20 @@ __metadata: languageName: node linkType: hard -"@subql/types@npm:3.3.1": - version: 3.3.1 - resolution: "@subql/types@npm:3.3.1" +"@subql/types@npm:3.4.0": + version: 3.4.0 + resolution: "@subql/types@npm:3.4.0" dependencies: - "@subql/types-core": 0.5.0 + "@subql/types-core": 0.6.0 peerDependencies: "@polkadot/api": ^10 - checksum: 4e949446d169ec6cfcc9ad32b8b5d14a6d82b8c69ac1f6513494f454d339014adfb554f5d7b95389f3faf507ddfde809592559aed8a098a63e748d08804895eb + checksum: a13e02ebdf35abc05104615f3884faf9f2d9037eece58ac05ba6cc4e07812ef40479645578327147ac82872e9466b5e2995a22076a7fdbc27fd6dd28f1cb669d languageName: node linkType: hard -"@subql/utils@npm:2.8.0": - version: 2.8.0 - resolution: "@subql/utils@npm:2.8.0" +"@subql/utils@npm:2.9.0": + version: 2.9.0 + resolution: "@subql/utils@npm:2.9.0" dependencies: "@polkadot/util": ^12.5.1 "@polkadot/util-crypto": ^12.5.1 @@ -3159,7 +2940,7 @@ __metadata: rotating-file-stream: ^3.0.2 semver: ^7.5.2 tar: ^6.1.11 - checksum: fa311fd7095f9e1ccc22f78113cccf744296722b921c1b1b405e9121f492baadd996eb68f5e21ef947295b767ab7172e7318b2a44e8a7c7f2ff577209a30eb11 + checksum: 2536add6833f9a1487ea17eccf0288e48f7a89bb67dfedbc46034902e350d4474be7f38cef06e938ee49ba25274c2271e2b5b6b46e04c965cdba5105f9af4599 languageName: node linkType: hard @@ -3836,15 +3617,6 @@ __metadata: languageName: node linkType: hard -"@wry/equality@npm:^0.1.2": - version: 0.1.11 - resolution: "@wry/equality@npm:0.1.11" - dependencies: - tslib: ^1.9.3 - checksum: 1a26a0fd11e3e3a6a197d9a54a5bec523caf693daa24ad2709f496e43dd3cd12290a0d17df81f8a783437795f6c64a1ca2717cdac6e79022bde4450c11e705c9 - languageName: node - linkType: hard - "@wry/equality@npm:^0.5.0, @wry/equality@npm:^0.5.6": version: 0.5.7 resolution: "@wry/equality@npm:0.5.7" @@ -4077,58 +3849,6 @@ __metadata: languageName: node linkType: hard -"apollo-link-error@npm:^1.1.13": - version: 1.1.13 - resolution: "apollo-link-error@npm:1.1.13" - dependencies: - apollo-link: ^1.2.14 - apollo-link-http-common: ^0.2.16 - tslib: ^1.9.3 - checksum: b417b77acbf464d8246eb79312c6d755f9d398c6c9f560c9e2270260519df639c3f0a8b9454ccc55c7f54eb57490706275ede120ecd7f475ec4627012feaf4b2 - languageName: node - linkType: hard - -"apollo-link-http-common@npm:^0.2.16": - version: 0.2.16 - resolution: "apollo-link-http-common@npm:0.2.16" - dependencies: - apollo-link: ^1.2.14 - ts-invariant: ^0.4.0 - tslib: ^1.9.3 - peerDependencies: - graphql: ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 - checksum: 46672f2b10a01f495ed91d32b9d21ed0747bf23c8c23a2041ca41dd92a05e0e18d7842d29c958f6ddfaee03bd89202788f593cdcb96d4167191aff125f109c67 - languageName: node - linkType: hard - -"apollo-link@npm:^1.2.14": - version: 1.2.14 - resolution: "apollo-link@npm:1.2.14" - dependencies: - apollo-utilities: ^1.3.0 - ts-invariant: ^0.4.0 - tslib: ^1.9.3 - zen-observable-ts: ^0.8.21 - peerDependencies: - graphql: ^0.11.3 || ^0.12.3 || ^0.13.0 || ^14.0.0 || ^15.0.0 - checksum: ad8d051ffceb270cdbbcc71d499bce2fda437a65fac6edc859a9e2dc0dbcb10b6a3f4da41789e786270aa358719c8b71315f383a698a74957df0d7aeea042918 - languageName: node - linkType: hard - -"apollo-utilities@npm:^1.3.0": - version: 1.3.4 - resolution: "apollo-utilities@npm:1.3.4" - dependencies: - "@wry/equality": ^0.1.2 - fast-json-stable-stringify: ^2.0.0 - ts-invariant: ^0.4.0 - tslib: ^1.10.0 - peerDependencies: - graphql: ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 - checksum: 6e0192a3420782909c930f5230808d7fbbdbcdfccddd960120e19bab251b77a16e590b05dbb4a7da2c27c59077fbfd53e56819a9fae694debe7f898e8b0ec1e9 - languageName: node - linkType: hard - "append-field@npm:^1.0.0": version: 1.0.0 resolution: "append-field@npm:1.0.0" @@ -4573,13 +4293,6 @@ __metadata: languageName: node linkType: hard -"bn.js@npm:^4.12.0": - version: 4.12.0 - resolution: "bn.js@npm:4.12.0" - checksum: 39afb4f15f4ea537b55eaf1446c896af28ac948fdcf47171961475724d1bb65118cca49fa6e3d67706e4790955ec0e74de584e45c8f1ef89f46c812bee5b5a12 - languageName: node - linkType: hard - "bn.js@npm:^5.2.1": version: 5.2.1 resolution: "bn.js@npm:5.2.1" @@ -5294,15 +5007,6 @@ __metadata: languageName: node linkType: hard -"crc-32@npm:^1.2.0": - version: 1.2.2 - resolution: "crc-32@npm:1.2.2" - bin: - crc32: bin/crc32.njs - checksum: ad2d0ad0cbd465b75dcaeeff0600f8195b686816ab5f3ba4c6e052a07f728c3e70df2e3ca9fd3d4484dc4ba70586e161ca5a2334ec8bf5a41bf022a6103ff243 - languageName: node - linkType: hard - "create-hash@npm:^1.1.0": version: 1.2.0 resolution: "create-hash@npm:1.2.0" @@ -5378,15 +5082,6 @@ __metadata: languageName: node linkType: hard -"cross-fetch@npm:^4.0.0": - version: 4.0.0 - resolution: "cross-fetch@npm:4.0.0" - dependencies: - node-fetch: ^2.6.12 - checksum: ecca4f37ffa0e8283e7a8a590926b66713a7ef7892757aa36c2d20ffa27b0ac5c60dcf453119c809abe5923fc0bae3702a4d896bfb406ef1077b0d0018213e24 - languageName: node - linkType: hard - "cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" @@ -6203,40 +5898,6 @@ __metadata: languageName: node linkType: hard -"ethereum-cryptography@npm:^2.0.0": - version: 2.1.2 - resolution: "ethereum-cryptography@npm:2.1.2" - dependencies: - "@noble/curves": 1.1.0 - "@noble/hashes": 1.3.1 - "@scure/bip32": 1.3.1 - "@scure/bip39": 1.2.1 - checksum: 2e8f7b8cc90232ae838ab6a8167708e8362621404d26e79b5d9e762c7b53d699f7520aff358d9254de658fcd54d2d0af168ff909943259ed27dc4cef2736410c - languageName: node - linkType: hard - -"ethereum-cryptography@npm:^2.1.2": - version: 2.1.3 - resolution: "ethereum-cryptography@npm:2.1.3" - dependencies: - "@noble/curves": 1.3.0 - "@noble/hashes": 1.3.3 - "@scure/bip32": 1.3.3 - "@scure/bip39": 1.2.2 - checksum: 7f9c14f868a588641179cace3eb86c332c4743290865db699870710253cabc4dc74bd4bce5e7bc6db667482e032e94d6f79521219eb6be5dc422059d279a27b7 - languageName: node - linkType: hard - -"ethjs-util@npm:^0.1.6": - version: 0.1.6 - resolution: "ethjs-util@npm:0.1.6" - dependencies: - is-hex-prefixed: 1.0.0 - strip-hex-prefix: 1.0.0 - checksum: 1f42959e78ec6f49889c49c8a98639e06f52a15966387dd39faf2930db48663d026efb7db2702dcffe7f2a99c4a0144b7ce784efdbf733f4077aae95de76d65f - languageName: node - linkType: hard - "eventemitter2@npm:6.4.9, eventemitter2@npm:^6.4.5": version: 6.4.9 resolution: "eventemitter2@npm:6.4.9" @@ -7584,13 +7245,6 @@ __metadata: languageName: node linkType: hard -"is-hex-prefixed@npm:1.0.0": - version: 1.0.0 - resolution: "is-hex-prefixed@npm:1.0.0" - checksum: 5ac58e6e528fb029cc43140f6eeb380fad23d0041cc23154b87f7c9a1b728bcf05909974e47248fd0b7fcc11ba33cf7e58d64804883056fabd23e2b898be41de - languageName: node - linkType: hard - "is-hexadecimal@npm:^1.0.0": version: 1.0.4 resolution: "is-hexadecimal@npm:1.0.4" @@ -8505,13 +8159,6 @@ __metadata: languageName: node linkType: hard -"js-base64@npm:^3.7.5": - version: 3.7.5 - resolution: "js-base64@npm:3.7.5" - checksum: 67a78c8b1c47b73f1c6fba1957e9fe6fd9dc78ac93ac46cc2e43472dcb9cf150d126fb0e593192e88e0497354fa634d17d255add7cc6ee3c7b4d29870faa8e18 - languageName: node - linkType: hard - "js-sha3@npm:^0.8.0": version: 0.8.0 resolution: "js-sha3@npm:0.8.0" @@ -8665,13 +8312,6 @@ __metadata: languageName: node linkType: hard -"jwt-decode@npm:^3.1.2": - version: 3.1.2 - resolution: "jwt-decode@npm:3.1.2" - checksum: 20a4b072d44ce3479f42d0d2c8d3dabeb353081ba4982e40b83a779f2459a70be26441be6c160bfc8c3c6eadf9f6380a036fbb06ac5406b5674e35d8c4205eeb - languageName: node - linkType: hard - "keyv@npm:^3.0.0": version: 3.1.0 resolution: "keyv@npm:3.1.0" @@ -8939,13 +8579,6 @@ __metadata: languageName: node linkType: hard -"lru-cache@npm:^10.0.1, lru-cache@npm:^9.1.1 || ^10.0.0": - version: 10.0.1 - resolution: "lru-cache@npm:10.0.1" - checksum: 06f8d0e1ceabd76bb6f644a26dbb0b4c471b79c7b514c13c6856113879b3bf369eb7b497dad4ff2b7e2636db202412394865b33c332100876d838ad1372f0181 - languageName: node - linkType: hard - "lru-cache@npm:^5.1.1": version: 5.1.1 resolution: "lru-cache@npm:5.1.1" @@ -8971,6 +8604,13 @@ __metadata: languageName: node linkType: hard +"lru-cache@npm:^9.1.1 || ^10.0.0": + version: 10.0.1 + resolution: "lru-cache@npm:10.0.1" + checksum: 06f8d0e1ceabd76bb6f644a26dbb0b4c471b79c7b514c13c6856113879b3bf369eb7b497dad4ff2b7e2636db202412394865b33c332100876d838ad1372f0181 + languageName: node + linkType: hard + "luxon@npm:~3.3.0": version: 3.3.0 resolution: "luxon@npm:3.3.0" @@ -9142,13 +8782,6 @@ __metadata: languageName: node linkType: hard -"micro-ftch@npm:^0.3.1": - version: 0.3.1 - resolution: "micro-ftch@npm:0.3.1" - checksum: 0e496547253a36e98a83fb00c628c53c3fb540fa5aaeaf718438873785afd193244988c09d219bb1802984ff227d04938d9571ef90fe82b48bd282262586aaff - languageName: node - linkType: hard - "micromark@npm:~2.11.0": version: 2.11.4 resolution: "micromark@npm:2.11.4" @@ -10247,13 +9880,6 @@ __metadata: languageName: node linkType: hard -"pony-cause@npm:^2.1.10": - version: 2.1.10 - resolution: "pony-cause@npm:2.1.10" - checksum: 8b61378f213e61056312dc274a1c79980154e9d864f6ad86e0c8b91a50d3ce900d430995ee24147c9f3caa440dfe7d51c274b488d7f033b65b206522536d7217 - languageName: node - linkType: hard - "postgres-array@npm:~2.0.0": version: 2.0.0 resolution: "postgres-array@npm:2.0.0" @@ -11553,15 +11179,6 @@ __metadata: languageName: node linkType: hard -"strip-hex-prefix@npm:1.0.0": - version: 1.0.0 - resolution: "strip-hex-prefix@npm:1.0.0" - dependencies: - is-hex-prefixed: 1.0.0 - checksum: 4cafe7caee1d281d3694d14920fd5d3c11adf09371cef7e2ccedd5b83efd9e9bd2219b5d6ce6e809df6e0f437dc9d30db1192116580875698aad164a6d6b285b - languageName: node - linkType: hard - "strip-json-comments@npm:^3.1.1": version: 3.1.1 resolution: "strip-json-comments@npm:3.1.1" @@ -11612,13 +11229,6 @@ __metadata: languageName: unknown linkType: soft -"superstruct@npm:^1.0.3": - version: 1.0.3 - resolution: "superstruct@npm:1.0.3" - checksum: 761790bb111e6e21ddd608299c252f3be35df543263a7ebbc004e840d01fcf8046794c274bcb351bdf3eae4600f79d317d085cdbb19ca05803a4361840cc9bb1 - languageName: node - linkType: hard - "supports-color@npm:^5.3.0, supports-color@npm:^5.5.0": version: 5.5.0 resolution: "supports-color@npm:5.5.0" @@ -11836,15 +11446,6 @@ __metadata: languageName: node linkType: hard -"ts-invariant@npm:^0.4.0": - version: 0.4.4 - resolution: "ts-invariant@npm:0.4.4" - dependencies: - tslib: ^1.9.3 - checksum: 58b32fb6b7c479e602e55b9eb63bb99a203c5db09367d3aa7c3cbe000ba62f919eea7f031f55172df9b6d362a6f1a87e906df84b04b8c74c88e507ac58f7a554 - languageName: node - linkType: hard - "ts-invariant@npm:^0.9.4": version: 0.9.4 resolution: "ts-invariant@npm:0.9.4" @@ -11960,7 +11561,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^1.10.0, tslib@npm:^1.8.1, tslib@npm:^1.9.3": +"tslib@npm:^1.8.1": version: 1.14.1 resolution: "tslib@npm:1.14.1" checksum: dbe628ef87f66691d5d2959b3e41b9ca0045c3ee3c7c7b906cc1e328b39f199bb1ad9e671c39025bd56122ac57dfbf7385a94843b1cc07c60a4db74795829acd @@ -11992,20 +11593,6 @@ __metadata: languageName: node linkType: hard -"tweetnacl-util@npm:^0.15.1": - version: 0.15.1 - resolution: "tweetnacl-util@npm:0.15.1" - checksum: ae6aa8a52cdd21a95103a4cc10657d6a2040b36c7a6da7b9d3ab811c6750a2d5db77e8c36969e75fdee11f511aa2b91c552496c6e8e989b6e490e54aca2864fc - languageName: node - linkType: hard - -"tweetnacl@npm:^1.0.3": - version: 1.0.3 - resolution: "tweetnacl@npm:1.0.3" - checksum: e4a57cac188f0c53f24c7a33279e223618a2bfb5fea426231991652a13247bea06b081fd745d71291fcae0f4428d29beba1b984b1f1ce6f66b06a6d1ab90645c - languageName: node - linkType: hard - "type-check@npm:^0.4.0, type-check@npm:~0.4.0": version: 0.4.0 resolution: "type-check@npm:0.4.0" @@ -12815,16 +12402,6 @@ __metadata: languageName: node linkType: hard -"zen-observable-ts@npm:^0.8.21": - version: 0.8.21 - resolution: "zen-observable-ts@npm:0.8.21" - dependencies: - tslib: ^1.9.3 - zen-observable: ^0.8.0 - checksum: 2931628598937effcc77acf88ac8d3468c0584bbc4488726ae2c94f6a02615ff80e9d6dc0943b71bc874466ab371837737ce8245eed3bfea38daa466a2fdc6ce - languageName: node - linkType: hard - "zen-observable-ts@npm:^1.2.0, zen-observable-ts@npm:^1.2.5": version: 1.2.5 resolution: "zen-observable-ts@npm:1.2.5" @@ -12834,7 +12411,7 @@ __metadata: languageName: node linkType: hard -"zen-observable@npm:0.8.15, zen-observable@npm:^0.8.0": +"zen-observable@npm:0.8.15": version: 0.8.15 resolution: "zen-observable@npm:0.8.15" checksum: b7289084bc1fc74a559b7259faa23d3214b14b538a8843d2b001a35e27147833f4107590b1b44bf5bc7f6dfe6f488660d3a3725f268e09b3925b3476153b7821