Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync @subql dependencies #119

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"ts-loader": "^9.2.6",
"ts-node": "^10.4.0",
"tsconfig-paths": "^3.12.0",
"typescript": "^4.9.5"
"typescript": "^5.5.4"
},
"resolutions": {
"node-fetch": "2.6.7"
Expand Down
6 changes: 6 additions & 0 deletions packages/common-near/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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
- Update `@subql/common` (#119)
- Enable strict TS (119)

### Added
- Support for network endpoint config (#119)

## [4.0.0] - 2024-07-03
### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/common-near/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"main": "dist/index.js",
"license": "GPL-3.0",
"dependencies": {
"@subql/common": "^4.0.0",
"@subql/common": "^5.1.1",
"@subql/types-near": "workspace:*",
"js-yaml": "^4.1.0",
"reflect-metadata": "^0.1.13"
Expand Down
47 changes: 22 additions & 25 deletions packages/common-near/src/project/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
NearHandlerKind,
NearRuntimeDatasource,
NearRuntimeHandler,
NearRuntimeHandlerFilter,
NearCustomDatasource,
ActionType,
NearReceiptHandler,
Expand All @@ -26,15 +25,13 @@
import {
IsArray,
IsEnum,
IsInt,
IsOptional,
IsString,
IsObject,
ValidateNested,
registerDecorator,
ValidationArguments,
ValidationOptions,
Min,
ValidateIf,
} from 'class-validator';

Expand All @@ -50,7 +47,7 @@
}

export function IsActionType(validationOptions?: ValidationOptions) {
return function (object: object, propertyName: string) {

Check warning on line 50 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Missing return type on function
registerDecorator({
name: 'isActionType',
target: object.constructor,
Expand All @@ -58,7 +55,7 @@
constraints: [],
options: validationOptions,
validator: {
validate(value: any, args: ValidationArguments) {

Check warning on line 58 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type

Check warning on line 58 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

'args' is defined but never used
return Object.values(ActionType).includes(value);
},
},
Expand All @@ -75,7 +72,7 @@
export class ActionFilter extends ReceiptFilter implements NearActionFilter {
@IsString()
@IsActionType()
type: ActionType;
type!: ActionType;

@IsString()
@IsOptional()
Expand Down Expand Up @@ -119,9 +116,9 @@
@Type(() => BlockFilter)
filter?: NearBlockFilter;
@IsEnum(NearHandlerKind, {groups: [NearHandlerKind.Block]})
kind: NearHandlerKind.Block;
kind!: NearHandlerKind.Block;
@IsString()
handler: string;
handler!: string;
}

export class TransactionHandler implements NearTransactionHandler {
Expand All @@ -130,9 +127,9 @@
@Type(() => TransactionFilter)
filter?: NearTransactionFilter;
@IsEnum(NearHandlerKind, {groups: [NearHandlerKind.Transaction]})
kind: NearHandlerKind.Transaction;
kind!: NearHandlerKind.Transaction;
@IsString()
handler: string;
handler!: string;
}

export class ActionHandler implements NearActionHandler {
Expand All @@ -141,9 +138,9 @@
@Type(() => ActionFilter)
filter?: NearActionFilter;
@IsEnum(NearHandlerKind, {groups: [NearHandlerKind.Action]})
kind: NearHandlerKind.Action;
kind!: NearHandlerKind.Action;
@IsString()
handler: string;
handler!: string;
}

export class ReceiptHandler implements NearReceiptHandler {
Expand All @@ -152,16 +149,16 @@
@Type(() => ReceiptFilter)
filter?: NearReceiptFilter;
@IsEnum(NearHandlerKind, {groups: [NearHandlerKind.Receipt]})
kind: NearHandlerKind.Receipt;
kind!: NearHandlerKind.Receipt;
@IsString()
handler: string;
handler!: string;
}

export class CustomHandler implements NearCustomHandler {
@IsString()
kind: string;
kind!: string;
@IsString()
handler: string;
handler!: string;
@IsObject()
@IsOptional()
filter?: Record<string, unknown>;
Expand All @@ -181,52 +178,52 @@
case NearHandlerKind.Block:
return plainToClass(BlockHandler, handler);
default:
throw new Error(`handler ${(handler as any).kind} not supported`);

Check warning on line 181 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
}
});
})
@IsArray()
@ValidateNested()
handlers: NearRuntimeHandler[];
handlers!: NearRuntimeHandler[];
@IsString()
file: string;
file!: string;
}

export class CustomMapping implements BaseMapping<NearCustomHandler> {
@IsArray()
@Type(() => CustomHandler)
@ValidateNested()
handlers: CustomHandler[];
handlers!: CustomHandler[];
@IsString()
file: string;
file!: string;
}

export class RuntimeDataSourceBase extends BaseDataSource implements NearRuntimeDatasource {
@IsEnum(NearDatasourceKind, {groups: [NearDatasourceKind.Runtime]})
kind: NearDatasourceKind.Runtime;
kind!: NearDatasourceKind.Runtime;
@Type(() => RuntimeMapping)
@ValidateNested()
mapping: RuntimeMapping;
mapping!: RuntimeMapping;
}

export class FileReferenceImpl implements FileReference {
@IsString()
file: string;
file!: string;
}

export class CustomDataSourceBase<K extends string, M extends CustomMapping, O = any>

Check warning on line 214 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

'O' is defined but never used

Check warning on line 214 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
extends BaseDataSource
implements NearCustomDatasource<K, M>
{
@IsString()
kind: K;
kind!: K;
@Type(() => CustomMapping)
@ValidateNested()
mapping: M;
mapping!: M;
@Type(() => FileReferenceImpl)
@ValidateNested({each: true})
assets: Map<string, NearCustomDataSourceAsset>;
assets!: Map<string, NearCustomDataSourceAsset>;
@Type(() => ProcessorImpl)
@IsObject()
processor: Processor;
processor!: Processor;
}
9 changes: 5 additions & 4 deletions packages/common-near/src/project/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import {
SecondLayerHandlerProcessor,
SecondLayerHandlerProcessorArray,
NearCustomDatasource,
NearDatasource,
NearDatasourceKind,
Expand All @@ -13,25 +14,25 @@ import {
} from '@subql/types-near';

export function isBlockHandlerProcessor<T extends Record<string, unknown>, E>(
hp: SecondLayerHandlerProcessor<NearHandlerKind, T, unknown>
hp: SecondLayerHandlerProcessorArray<NearHandlerKind, T, unknown>
): hp is SecondLayerHandlerProcessor<NearHandlerKind.Block, T, E> {
return hp.baseHandlerKind === NearHandlerKind.Block;
}

export function isTransactionHandlerProcessor<T extends Record<string, unknown>, E>(
hp: SecondLayerHandlerProcessor<NearHandlerKind, T, unknown>
hp: SecondLayerHandlerProcessorArray<NearHandlerKind, T, unknown>
): hp is SecondLayerHandlerProcessor<NearHandlerKind.Transaction, T, E> {
return hp.baseHandlerKind === NearHandlerKind.Transaction;
}

export function isActionHandlerProcessor<T extends Record<string, unknown>, E>(
hp: SecondLayerHandlerProcessor<NearHandlerKind, T, unknown>
hp: SecondLayerHandlerProcessorArray<NearHandlerKind, T, unknown>
): hp is SecondLayerHandlerProcessor<NearHandlerKind.Action, T, E> {
return hp.baseHandlerKind === NearHandlerKind.Action;
}

export function isReceiptHandlerProcessor<T extends Record<string, unknown>, E>(
hp: SecondLayerHandlerProcessor<NearHandlerKind, T, unknown>
hp: SecondLayerHandlerProcessorArray<NearHandlerKind, T, unknown>
): hp is SecondLayerHandlerProcessor<NearHandlerKind.Receipt, T, E> {
return hp.baseHandlerKind === NearHandlerKind.Receipt;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class NearProjectManifestVersioned implements INearProjectManifest {
return this._impl as ProjectManifestV1_0_0Impl;
}

toDeployment(): string | undefined {
toDeployment(): string {
return this._impl.deployment.toYaml();
}

Expand All @@ -62,11 +62,11 @@ export class NearProjectManifestVersioned implements INearProjectManifest {
return this._impl.specVersion;
}

get description(): string {
get description(): string | undefined {
return this._impl.description;
}

get repository(): string {
get repository(): string | undefined {
return this._impl.repository;
}
}
28 changes: 14 additions & 14 deletions packages/common-near/src/project/versioned/v1_0_0/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
}

export class NearCustomDataSourceImpl<K extends string = string, M extends BaseMapping<any> = BaseMapping<any>>

Check warning on line 39 in packages/common-near/src/project/versioned/v1_0_0/model.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type

Check warning on line 39 in packages/common-near/src/project/versioned/v1_0_0/model.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
extends CustomDataSourceBase<K, M>
implements NearCustomDatasource<K, M>
{
Expand All @@ -47,30 +47,30 @@

export class RuntimeDatasourceTemplateImpl extends NearRuntimeDataSourceImpl implements RuntimeDatasourceTemplate {
@IsString()
name: string;
name!: string;
}

export class CustomDatasourceTemplateImpl extends NearCustomDataSourceImpl implements CustomDatasourceTemplate {
@IsString()
name: string;
name!: string;
}

export class NearRunnerSpecsImpl implements RunnerSpecs {
@IsObject()
@ValidateNested()
@Type(() => NearRunnerNodeImpl)
node: NodeSpec;
node!: NodeSpec;
@IsObject()
@ValidateNested()
@Type(() => RunnerQueryBaseModel)
query: QuerySpec;
query!: QuerySpec;
}

export class ProjectNetworkDeploymentV1_0_0 {
@IsNotEmpty()
@Transform(({value}: TransformFnParams) => value.trim())
@IsString()
chainId: string;
chainId!: string;
@IsOptional()
@IsArray()
bypassBlocks?: (number | `${number}-${number}`)[];
Expand All @@ -92,12 +92,12 @@
})
@ValidateNested()
@Type(() => ProjectNetworkDeploymentV1_0_0)
network: ProjectNetworkDeploymentV1_0_0;
network!: ProjectNetworkDeploymentV1_0_0;

@IsObject()
@ValidateNested()
@Type(() => NearRunnerSpecsImpl)
runner: RunnerSpecs;
runner!: RunnerSpecs;

@IsArray()
@ValidateNested()
Expand All @@ -108,7 +108,7 @@
},
keepDiscriminatorProperty: true,
})
dataSources: (NearRuntimeDatasource | NearCustomDatasource)[];
dataSources!: (NearRuntimeDatasource | NearCustomDatasource)[];
@IsOptional()
@IsArray()
@ValidateNested()
Expand Down Expand Up @@ -139,16 +139,16 @@
},
keepDiscriminatorProperty: true,
})
dataSources: (NearRuntimeDatasource | NearCustomDatasource)[];
dataSources!: (NearRuntimeDatasource | NearCustomDatasource)[];
@Type(() => ProjectNetworkV1_0_0)
network: ProjectNetworkV1_0_0;
network!: ProjectNetworkV1_0_0;
@IsString()
name: string;
name!: string;
@IsString()
version: string;
version!: string;
@ValidateNested()
@Type(() => FileType)
schema: FileType;
schema!: FileType;
@IsOptional()
@IsArray()
@ValidateNested()
Expand All @@ -163,7 +163,7 @@
@IsObject()
@ValidateNested()
@Type(() => NearRunnerSpecsImpl)
runner: RunnerSpecs;
runner!: RunnerSpecs;

@IsOptional()
@IsObject()
Expand Down
3 changes: 2 additions & 1 deletion packages/common-near/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo",
"outDir": "dist",
"noImplicitAny": true
"noImplicitAny": true,
"strict": true
},
"references": [{"path": "../types"}],
"include": ["src/**/*"]
Expand Down
11 changes: 11 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ 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
- Support for network endpoint config providing the ability to set headers (#119)

### Changed
- Enable strict TS (#119)
- Breaking change: Update to latest `@subql/node-core`, require indexing environment timezone set to UTC (#119)
- Use more code from node core (#119)

### Fixed
- Actions filter issue (#119)
- Various issues causing poi inconsistency (#119)

## [3.12.0] - 2024-07-03
### Changed
Expand Down
2 changes: 2 additions & 0 deletions packages/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ RUN mkdir -p .monitor && \

# Make the user not ROOT
USER 1000
# Fix timezone to UTC
ENV TZ=utc

# Set Entry point and command
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/lib/node_modules/@subql/node-near/bin/run"]
Expand Down
3 changes: 2 additions & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
"@nestjs/event-emitter": "^2.0.0",
"@nestjs/platform-express": "^9.4.0",
"@nestjs/schedule": "^3.0.1",
"@subql/common": "^5.1.1",
"@subql/common-near": "workspace:*",
"@subql/node-core": "^10.10.0",
"@subql/node-core": "^14.1.2",
"@subql/types-near": "workspace:*",
"lodash": "^4.17.21",
"near-api-js": "^2.1.4",
Expand Down
13 changes: 0 additions & 13 deletions packages/node/src/admin/admin.module.ts

This file was deleted.

Loading
Loading