diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index 905abe70d1..dabc104a0b 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -7,7 +7,8 @@ "importHelpers": true, "rootDir": "src", "tsBuildInfoFile": "lib/.tsbuildinfo", - "outDir": "lib" + "outDir": "lib", + "noImplicitAny": true }, "references": [{"path": "../common"}, {"path": "../common-substrate"}, {"path": "../utils"}], "include": ["src/**/*"], diff --git a/packages/common-substrate/tsconfig.json b/packages/common-substrate/tsconfig.json index a950a198d4..fede5593cb 100644 --- a/packages/common-substrate/tsconfig.json +++ b/packages/common-substrate/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "rootDir": "src", "tsBuildInfoFile": "dist/.tsbuildinfo", - "outDir": "dist" + "outDir": "dist", + "noImplicitAny": true }, "references": [{"path": "../types"}, {"path": "../common"}], "include": ["src/**/*"] diff --git a/packages/common/tsconfig.json b/packages/common/tsconfig.json index 3245ff5273..b3866a63d8 100644 --- a/packages/common/tsconfig.json +++ b/packages/common/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "rootDir": "src", "tsBuildInfoFile": "dist/.tsbuildinfo", - "outDir": "dist" + "outDir": "dist", + "noImplicitAny": true }, "references": [{"path": "../types"}], "include": ["src/**/*"] diff --git a/packages/node-core/src/indexer/poi/poi.service.ts b/packages/node-core/src/indexer/poi/poi.service.ts index 609c3220b2..e4cc050d3f 100644 --- a/packages/node-core/src/indexer/poi/poi.service.ts +++ b/packages/node-core/src/indexer/poi/poi.service.ts @@ -25,7 +25,10 @@ export class PoiService implements OnApplicationShutdown { private isShutdown = false; private _poiRepo?: CachePoiModel; - constructor(protected readonly nodeConfig: NodeConfig, private storeCache: StoreCacheService) {} + constructor( + protected readonly nodeConfig: NodeConfig, + private storeCache: StoreCacheService + ) {} onApplicationShutdown(): void { this.isShutdown = true; @@ -93,7 +96,7 @@ export class PoiService implements OnApplicationShutdown { // Drop previous keys in metadata this.storeCache.metadata.bulkRemove(['blockOffset', 'latestPoiWithMmr', 'lastPoiHeight']); - const queries = []; + const queries: string[] = []; if (checkResult) { if (checkResult.mmr_exists) { diff --git a/packages/node-core/src/utils/blockHeightMap.ts b/packages/node-core/src/utils/blockHeightMap.ts index a1c6d886b3..707ddae8f6 100644 --- a/packages/node-core/src/utils/blockHeightMap.ts +++ b/packages/node-core/src/utils/blockHeightMap.ts @@ -76,7 +76,7 @@ export class BlockHeightMap { getWithinRange(startHeight: number, endHeight: number): Map { const result = new Map(); - let previousKey = null; + let previousKey: number | null = null; for (const [key, value] of this.#map) { if (previousKey !== null && previousKey < startHeight && key >= startHeight) { diff --git a/packages/node-core/tsconfig.json b/packages/node-core/tsconfig.json index 75b4acfbcb..9c0d2edfe1 100644 --- a/packages/node-core/tsconfig.json +++ b/packages/node-core/tsconfig.json @@ -5,7 +5,8 @@ "rootDir": "src", "outDir": "dist", "esModuleInterop": true, - "importHelpers": true + "importHelpers": true, + "noImplicitAny": true }, "references": [{"path": "../common"}, {"path": "../utils"}, {"path": "../testing"}], "include": ["src/**/*"] diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 147e66423e..9e082168f8 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -5,9 +5,12 @@ 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] - ### Added -- Enable ts strict model +- Enable ts strict model + +### Fixed +- "currentRuntimeVersion is undefined" error (#2475) + ## [4.7.0] - 2024-07-01 ### Changed - Update with `@subql/node-core`, `@subql/common-substrate` diff --git a/packages/node/src/indexer/runtime/base-runtime.service.ts b/packages/node/src/indexer/runtime/base-runtime.service.ts index 9236eb1757..49dbdf7d04 100644 --- a/packages/node/src/indexer/runtime/base-runtime.service.ts +++ b/packages/node/src/indexer/runtime/base-runtime.service.ts @@ -1,7 +1,6 @@ // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors // SPDX-License-Identifier: GPL-3.0 -import assert from 'assert'; import { Injectable } from '@nestjs/common'; import { ApiPromise } from '@polkadot/api'; import { RuntimeVersion } from '@polkadot/types/interfaces'; @@ -17,22 +16,11 @@ type GetLatestFinalizedHeight = () => number; export abstract class BaseRuntimeService { parentSpecVersion?: number; specVersionMap: SpecVersion[] = []; - protected _currentRuntimeVersion?: RuntimeVersion; + private currentRuntimeVersion?: RuntimeVersion; latestFinalizedHeight?: number; constructor(protected apiService: ApiService) {} - protected get currentRuntimeVersion(): RuntimeVersion { - assert( - this._currentRuntimeVersion !== undefined, - 'currentRuntimeVersion is undefined', - ); - return this._currentRuntimeVersion; - } - protected set currentRuntimeVersion(value: RuntimeVersion) { - this._currentRuntimeVersion = value; - } - async specChanged(height: number, specVersion: number): Promise { if (this.parentSpecVersion !== specVersion) { const parentSpecVersionCopy = this.parentSpecVersion; diff --git a/packages/node/tsconfig.json b/packages/node/tsconfig.json index e438811c40..621baaff7a 100644 --- a/packages/node/tsconfig.json +++ b/packages/node/tsconfig.json @@ -4,8 +4,7 @@ "sourceMap": true, "tsBuildInfoFile": "dist/.tsbuildinfo", "rootDir": "src", - "outDir": "./dist", - "noImplicitAny": false + "outDir": "./dist" }, "references": [ { "path": "../common" }, diff --git a/packages/query/tsconfig.json b/packages/query/tsconfig.json index 8282f567b1..9270b4e7a0 100644 --- a/packages/query/tsconfig.json +++ b/packages/query/tsconfig.json @@ -5,8 +5,7 @@ "sourceMap": true, "tsBuildInfoFile": "dist/.tsbuildinfo", "rootDir": "src", - "outDir": "./dist", - "noImplicitAny": false + "outDir": "./dist" }, "references": [{"path": "../common"}, {"path": "../types"}, {"path": "../utils"}], "include": ["src/**/*"] diff --git a/packages/testing/tsconfig.json b/packages/testing/tsconfig.json index 432b70e167..0e24dd001e 100644 --- a/packages/testing/tsconfig.json +++ b/packages/testing/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "tsBuildInfoFile": "dist/.tsbuildinfo", "rootDir": "src", - "outDir": "dist" + "outDir": "dist", + "noImplicitAny": true }, "include": ["src/**/*"], "references": [{"path": "../common"}, {"path": "../common-substrate"}] diff --git a/packages/types-core/tsconfig.json b/packages/types-core/tsconfig.json index fefa803748..516aeb0163 100644 --- a/packages/types-core/tsconfig.json +++ b/packages/types-core/tsconfig.json @@ -4,7 +4,8 @@ "strictNullChecks": true, "tsBuildInfoFile": "dist/.tsbuildinfo", "rootDir": "src", - "outDir": "dist" + "outDir": "dist", + "noImplicitAny": true }, "include": ["src/**/*"] } diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index d5d5cfb1d4..58c64bb412 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -5,9 +5,12 @@ 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 +### Changed - Enable strict mode for the other packages. + +### Removed +- Deprecated types relating to datasource processors (#2475) + ## [3.8.0] - 2024-07-01 ### Changed - Bump version with `@subql/types-core` diff --git a/packages/types/src/project.ts b/packages/types/src/project.ts index be613d5206..9cbdeb94c6 100644 --- a/packages/types/src/project.ts +++ b/packages/types/src/project.ts @@ -17,9 +17,8 @@ import { BaseCustomDataSource, HandlerInputTransformer_0_0_0 as BaseHandlerInputTransformer_0_0_0, HandlerInputTransformer_1_0_0 as BaseHandlerInputTransformer_1_0_0, - SecondLayerHandlerProcessor_0_0_0 as BaseSecondLayerHandlerProcessor_0_0_0, - SecondLayerHandlerProcessor_1_0_0 as BaseSecondLayerHandlerProcessor_1_0_0, - SecondLayerHandlerProcessor as BaseSecondLayerHandlerProcessor, + SecondLayerHandlerProcessor_0_0_0, + SecondLayerHandlerProcessor_1_0_0, DsProcessor, } from '@subql/types-core'; import {LightSubstrateEvent, SubstrateBlock, SubstrateEvent, SubstrateExtrinsic} from './interfaces'; @@ -332,35 +331,14 @@ export type SubstrateDatasourceProcessor< >, > = DsProcessor; -/** - * @deprecated use types core version. datasource processors need updating before this can be removed - * */ -export type SecondLayerHandlerProcessor_0_0_0< - K extends SubstrateHandlerKind, - F extends Record, - E, - DS extends SubstrateCustomDatasource = SubstrateCustomDatasource, -> = BaseSecondLayerHandlerProcessor_0_0_0; - -/** - * @deprecated use types core version. datasource processors need updating before this can be removed - * */ -export type SecondLayerHandlerProcessor_1_0_0< - K extends SubstrateHandlerKind, - F extends Record, - E, - DS extends SubstrateCustomDatasource = SubstrateCustomDatasource, -> = BaseSecondLayerHandlerProcessor_1_0_0; - -/** - * @deprecated use types core version. datasource processors need updating before this can be removed - * */ export type SecondLayerHandlerProcessor< K extends SubstrateHandlerKind, F extends Record, E, DS extends SubstrateCustomDatasource = SubstrateCustomDatasource, -> = BaseSecondLayerHandlerProcessor; +> = + | SecondLayerHandlerProcessor_0_0_0 + | SecondLayerHandlerProcessor_1_0_0; /** * Represents a Substrate subquery network configuration, which is based on the CommonSubqueryNetworkConfig template. diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index 5e263203ce..adb2cb1ef1 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -4,7 +4,8 @@ "strictNullChecks": true, "tsBuildInfoFile": "dist/.tsbuildinfo", "rootDir": "src", - "outDir": "dist" + "outDir": "dist", + "noImplicitAny": true }, "references": [{"path": "../types-core"}], "include": ["src/**/*"] diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index c782383e40..d34d8444d7 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -6,7 +6,8 @@ "tsBuildInfoFile": "dist/.tsbuildinfo", "rootDir": "src", "outDir": "./dist", - "noImplicitThis": true + "noImplicitThis": true, + "noImplicitAny": true }, "references": [{"path": "../types"}], "include": ["src/**/*"] diff --git a/tsconfig.json b/tsconfig.json index e042322ff3..462313a42e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,9 @@ "sourceMap": true, "inlineSources": true, "composite": true, + "skipLibCheck": true, + "strict": true, + "noImplicitAny": false, "paths": { "@subql/utils": ["packages/utils/src"], "@subql/utils/*": ["packages/utils/src/*"], @@ -32,9 +35,6 @@ "@subql/testing": ["packages/testing/src"], "@subql/testing/*": ["packages/testing/src/*"] }, - "skipLibCheck": true, - "noImplicitAny": true, - "strict": true }, "references": [ {"path": "packages/cli"},