Skip to content

Commit

Permalink
Simplify types relating to datasource processors (subquery#2475)
Browse files Browse the repository at this point in the history
* Simplify types relating to datasource processors

* Update changelog

* Revert tsconfig change

* Fix build issues

* Further fixes to tsconfig, fix runtime service error
  • Loading branch information
stwiname authored Jul 7, 2024
1 parent 5c5ce14 commit e49ec27
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 62 deletions.
3 changes: 2 additions & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*"],
Expand Down
3 changes: 2 additions & 1 deletion packages/common-substrate/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo",
"outDir": "dist"
"outDir": "dist",
"noImplicitAny": true
},
"references": [{"path": "../types"}, {"path": "../common"}],
"include": ["src/**/*"]
Expand Down
3 changes: 2 additions & 1 deletion packages/common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo",
"outDir": "dist"
"outDir": "dist",
"noImplicitAny": true
},
"references": [{"path": "../types"}],
"include": ["src/**/*"]
Expand Down
7 changes: 5 additions & 2 deletions packages/node-core/src/indexer/poi/poi.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/node-core/src/utils/blockHeightMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class BlockHeightMap<T> {

getWithinRange(startHeight: number, endHeight: number): Map<number, T> {
const result = new Map<number, T>();
let previousKey = null;
let previousKey: number | null = null;

for (const [key, value] of this.#map) {
if (previousKey !== null && previousKey < startHeight && key >= startHeight) {
Expand Down
3 changes: 2 additions & 1 deletion packages/node-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*"]
Expand Down
7 changes: 5 additions & 2 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
14 changes: 1 addition & 13 deletions packages/node/src/indexer/runtime/base-runtime.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<boolean> {
if (this.parentSpecVersion !== specVersion) {
const parentSpecVersionCopy = this.parentSpecVersion;
Expand Down
3 changes: 1 addition & 2 deletions packages/node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"sourceMap": true,
"tsBuildInfoFile": "dist/.tsbuildinfo",
"rootDir": "src",
"outDir": "./dist",
"noImplicitAny": false
"outDir": "./dist"
},
"references": [
{ "path": "../common" },
Expand Down
3 changes: 1 addition & 2 deletions packages/query/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*"]
Expand Down
3 changes: 2 additions & 1 deletion packages/testing/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"tsBuildInfoFile": "dist/.tsbuildinfo",
"rootDir": "src",
"outDir": "dist"
"outDir": "dist",
"noImplicitAny": true
},
"include": ["src/**/*"],
"references": [{"path": "../common"}, {"path": "../common-substrate"}]
Expand Down
3 changes: 2 additions & 1 deletion packages/types-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"strictNullChecks": true,
"tsBuildInfoFile": "dist/.tsbuildinfo",
"rootDir": "src",
"outDir": "dist"
"outDir": "dist",
"noImplicitAny": true
},
"include": ["src/**/*"]
}
7 changes: 5 additions & 2 deletions packages/types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
32 changes: 5 additions & 27 deletions packages/types/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -332,35 +331,14 @@ export type SubstrateDatasourceProcessor<
>,
> = DsProcessor<DS, P, ApiPromise>;

/**
* @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<string, unknown>,
E,
DS extends SubstrateCustomDatasource = SubstrateCustomDatasource,
> = BaseSecondLayerHandlerProcessor_0_0_0<RuntimeFilterMap, K, F, E, DS, ApiPromise>;

/**
* @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<string, unknown>,
E,
DS extends SubstrateCustomDatasource = SubstrateCustomDatasource,
> = BaseSecondLayerHandlerProcessor_1_0_0<RuntimeFilterMap, K, F, E, DS, ApiPromise>;

/**
* @deprecated use types core version. datasource processors need updating before this can be removed
* */
export type SecondLayerHandlerProcessor<
K extends SubstrateHandlerKind,
F extends Record<string, unknown>,
E,
DS extends SubstrateCustomDatasource = SubstrateCustomDatasource,
> = BaseSecondLayerHandlerProcessor<RuntimeFilterMap, K, F, E, DS, ApiPromise>;
> =
| SecondLayerHandlerProcessor_0_0_0<RuntimeFilterMap, K, F, E, DS, ApiPromise>
| SecondLayerHandlerProcessor_1_0_0<RuntimeFilterMap, K, F, E, DS, ApiPromise>;

/**
* Represents a Substrate subquery network configuration, which is based on the CommonSubqueryNetworkConfig template.
Expand Down
3 changes: 2 additions & 1 deletion packages/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"strictNullChecks": true,
"tsBuildInfoFile": "dist/.tsbuildinfo",
"rootDir": "src",
"outDir": "dist"
"outDir": "dist",
"noImplicitAny": true
},
"references": [{"path": "../types-core"}],
"include": ["src/**/*"]
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"tsBuildInfoFile": "dist/.tsbuildinfo",
"rootDir": "src",
"outDir": "./dist",
"noImplicitThis": true
"noImplicitThis": true,
"noImplicitAny": true
},
"references": [{"path": "../types"}],
"include": ["src/**/*"]
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"],
Expand All @@ -32,9 +35,6 @@
"@subql/testing": ["packages/testing/src"],
"@subql/testing/*": ["packages/testing/src/*"]
},
"skipLibCheck": true,
"noImplicitAny": true,
"strict": true
},
"references": [
{"path": "packages/cli"},
Expand Down

0 comments on commit e49ec27

Please sign in to comment.