Skip to content

Commit

Permalink
Sync @subql dependencies (#119)
Browse files Browse the repository at this point in the history
* Update @subql deps

* Sync up changes

* Update changelogs

---------

Co-authored-by: stwiname <[email protected]>
  • Loading branch information
stwiname and stwiname authored Aug 29, 2024
1 parent e35f06a commit cf5dd23
Show file tree
Hide file tree
Showing 45 changed files with 662 additions and 1,352 deletions.
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 @@ import {
NearHandlerKind,
NearRuntimeDatasource,
NearRuntimeHandler,
NearRuntimeHandlerFilter,
NearCustomDatasource,
ActionType,
NearReceiptHandler,
Expand All @@ -26,15 +25,13 @@ import {plainToClass, Transform, Type} from 'class-transformer';
import {
IsArray,
IsEnum,
IsInt,
IsOptional,
IsString,
IsObject,
ValidateNested,
registerDecorator,
ValidationArguments,
ValidationOptions,
Min,
ValidateIf,
} from 'class-validator';

Expand Down Expand Up @@ -75,7 +72,7 @@ export class ReceiptFilter extends TransactionFilter implements NearReceiptFilte
export class ActionFilter extends ReceiptFilter implements NearActionFilter {
@IsString()
@IsActionType()
type: ActionType;
type!: ActionType;

@IsString()
@IsOptional()
Expand Down Expand Up @@ -119,9 +116,9 @@ export class BlockHandler implements NearBlockHandler {
@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 @@ export class TransactionHandler implements NearTransactionHandler {
@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 @@ export class ActionHandler implements NearActionHandler {
@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 @@ export class ReceiptHandler implements NearReceiptHandler {
@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 @@ -187,46 +184,46 @@ export class RuntimeMapping implements BaseMapping<NearRuntimeHandler> {
})
@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>
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 @@ -47,30 +47,30 @@ export class NearCustomDataSourceImpl<K extends string = string, M extends BaseM

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 @@ export class DeploymentV1_0_0 extends BaseDeploymentV1_0_0 {
})
@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 @@ export class DeploymentV1_0_0 extends BaseDeploymentV1_0_0 {
},
keepDiscriminatorProperty: true,
})
dataSources: (NearRuntimeDatasource | NearCustomDatasource)[];
dataSources!: (NearRuntimeDatasource | NearCustomDatasource)[];
@IsOptional()
@IsArray()
@ValidateNested()
Expand Down Expand Up @@ -139,16 +139,16 @@ export class ProjectManifestV1_0_0Impl
},
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 @@ export class ProjectManifestV1_0_0Impl
@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

0 comments on commit cf5dd23

Please sign in to comment.