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 with main SKD for project upgrades feature #74

Merged
merged 15 commits into from
Oct 4, 2023
Merged
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:jest/recommended',
],
rules: {
// rules turned off in upstream project (also required when recommended-requiring-type-checking is extended)
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/node-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,53 @@ jobs:
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

node-build-push-docker-subquery:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 100
token: ${{ secrets.REPO_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: subquerynetwork
password: ${{ secrets.SQ_DOCKERHUB_TOKEN }}

## node
- name: Get updated node version
id: get-node-version
run: |
sh .github/workflows/scripts/nodeVersion.sh

- name: Build and push
if: github.event.inputs.isLatest == 'false'
uses: docker/build-push-action@v2
with:
push: true
platforms: arm64,amd64
file: ./packages/node/Dockerfile
tags: subquerynetwork/subql-node-algorand:v${{ steps.get-node-version.outputs.NODE_VERSION }},
build-args: RELEASE_VERSION=${{ steps.get-node-version.outputs.NODE_VERSION }}

- name: Build and push
if: github.event.inputs.isLatest == 'true'
uses: docker/build-push-action@v2
with:
push: true
platforms: arm64,amd64
file: ./packages/node/Dockerfile
tags: subquerynetwork/subql-node-algorand:v${{ steps.get-node-version.outputs.NODE_VERSION }},subquerynetwork/subql-node-algorand:latest
build-args: RELEASE_VERSION=${{ steps.get-node-version.outputs.NODE_VERSION }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-sort-destructure-keys": "^1.4.0",
"husky": "^7.0.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/common-algorand/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"main": "dist/index.js",
"license": "GPL-3.0",
"dependencies": {
"@subql/common": "^2.4.0",
"@subql/common": "^3.1.1",
"@subql/types-algorand": "workspace:*",
"class-transformer": "0.4.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"fs-extra": "^10.1.0",
"ipfs-http-client": "^52.0.3",
Expand Down
8 changes: 0 additions & 8 deletions packages/common-algorand/src/project/load.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {getManifestPath, loadFromJsonOrYaml} from '@subql/common';
import {AlgorandProjectManifestVersioned, VersionedProjectManifest} from './versioned';

export function parseAlgorandProjectManifest(raw: unknown): AlgorandProjectManifestVersioned {
const projectManifest = new AlgorandProjectManifestVersioned(raw as VersionedProjectManifest);
projectManifest.validate();
return projectManifest;
}

export function loadSubstrateProjectManifest(file: string): AlgorandProjectManifestVersioned {
const doc = loadFromJsonOrYaml(getManifestPath(file));
const projectManifest = new AlgorandProjectManifestVersioned(doc as VersionedProjectManifest);
projectManifest.validate();
return projectManifest;
}
14 changes: 8 additions & 6 deletions packages/common-algorand/src/project/models.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {BaseMapping, FileReference} from '@subql/common';
import {ProcessorImpl} from '@subql/common';
import {
CustomDataSourceAsset as AlgorandCustomDataSourceAsset,
AlgorandBlockFilter,
Expand All @@ -11,11 +11,13 @@
AlgorandHandlerKind,
AlgorandRuntimeDataSource,
AlgorandRuntimeHandler,
AlgorandRuntimeHandlerFilter,

Check warning on line 14 in packages/common-algorand/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

'AlgorandRuntimeHandlerFilter' is defined but never used
AlgorandCustomDataSource,
AlgorandTransactionHandler,
AlgorandTransactionFilter,
} from '@subql/types-algorand';
import {BaseMapping, FileReference, Processor} from '@subql/types-core';

import {TransactionType} from 'algosdk';
import {plainToClass, Transform, Type} from 'class-transformer';
import {
Expand Down Expand Up @@ -130,7 +132,7 @@
filter?: Record<string, unknown>;
}

export class RuntimeMapping implements BaseMapping<AlgorandRuntimeHandlerFilter, AlgorandRuntimeHandler> {
export class RuntimeMapping implements BaseMapping<AlgorandRuntimeHandler> {
@Transform((params) => {
const handlers: AlgorandRuntimeHandler[] = params.value;
return handlers.map((handler) => {
Expand All @@ -140,7 +142,7 @@
case AlgorandHandlerKind.Transaction:
return plainToClass(TransactionHandler, handler);
default:
throw new Error(`handler ${(handler as any).kind} not supported`);

Check warning on line 145 in packages/common-algorand/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
}
});
})
Expand All @@ -152,7 +154,7 @@
file: string;
}

export class CustomMapping implements BaseMapping<Record<string, unknown>, AlgorandCustomHandler> {
export class CustomMapping implements BaseMapping<AlgorandCustomHandler> {
@IsArray()
@Type(() => CustomHandler)
@ValidateNested()
Expand Down Expand Up @@ -180,8 +182,8 @@
file: string;
}

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

Check warning on line 185 in packages/common-algorand/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
implements AlgorandCustomDataSource<K, M, O>
implements AlgorandCustomDataSource<K, M>
{
@IsString()
kind: K;
Expand All @@ -198,7 +200,7 @@
@ValidateNested({each: true})
assets: Map<string, AlgorandCustomDataSourceAsset>;

@Type(() => FileReferenceImpl)
@Type(() => ProcessorImpl)
@IsObject()
processor: FileReference;
processor: Processor<O>;
}
9 changes: 1 addition & 8 deletions packages/common-algorand/src/project/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {IProjectManifest, ProjectNetworkConfig} from '@subql/common';
import {AlgorandDataSource} from '@subql/types-algorand';
import {IProjectManifest} from '@subql/types-core';

// All of these used to be redefined in this file, re-exporting for simplicity
export {
Expand All @@ -21,10 +21,3 @@ export {

export type IAlgorandProjectManifest = IProjectManifest<AlgorandDataSource>;
export type TokenHeader = Record<string, string>;

export interface AlgorandProjectNetworkConfig extends ProjectNetworkConfig {
genesisHash?: string;
chainId?: string;
apiKey?: string | TokenHeader;
bypassBlocks?: (number | string)[];
}
12 changes: 6 additions & 6 deletions packages/common-algorand/src/project/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {
AlgorandRuntimeDataSource,
} from '@subql/types-algorand';

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const ALGORAND_SUPPORTED_VERSIONS = {

type Versions = keyof typeof ALGORAND_SUPPORTED_VERSIONS;

type ProjectManifestImpls = InstanceType<(typeof ALGORAND_SUPPORTED_VERSIONS)[Versions]>;
export type ProjectManifestImpls = InstanceType<(typeof ALGORAND_SUPPORTED_VERSIONS)[Versions]>;

export function manifestIsV1_0_0(manifest: IAlgorandProjectManifest): manifest is ProjectManifestV1_0_0Impl {
return manifest.specVersion === '1.0.0';
Expand Down Expand Up @@ -43,7 +43,7 @@ export class AlgorandProjectManifestVersioned implements IAlgorandProjectManifes
}

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

validate(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
// SPDX-License-Identifier: GPL-3.0

export * from './model';
export * from './types';
Loading
Loading