Skip to content

Commit

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

* Sync changes

* Fix test

* Update changelogs

---------

Co-authored-by: stwiname <[email protected]>
  • Loading branch information
stwiname and stwiname authored Apr 10, 2024
1 parent 8959bb7 commit 6965c4f
Show file tree
Hide file tree
Showing 44 changed files with 584 additions and 986 deletions.
4 changes: 2 additions & 2 deletions .github/actions/create-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ runs:
using: "composite"
steps:
- working-directory: ${{ inputs.package-path }}
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn npm publish --access public
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn npm publish --access public
env:
NPM_TOKEN: ${{ inputs.npm-token }}
shell: bash

- working-directory: ${{ github.workspace }}
run: node ${{ github.action_path }}/gh-release-script.js ${{ github.workspace }}/${{ inputs.package-path }}
run: node ${{ github.action_path }}/gh-release-script.js ${{ github.workspace }}/${{ inputs.package-path }} ${{ github.sha }}
env:
REPO_TOKEN: ${{ inputs.repo-token }}
shell: bash
1 change: 1 addition & 0 deletions .github/actions/create-release/gh-release-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ async function publishRelease(releaseInfo) {
name: `[${version}] ${repoName}`,
repo: 'subql-concordium',
tag_name: `${packageName[1]}/${version}`,
target_commitish: `${myArgs[1]}`,
body: releaseInfo
}).catch( err => {
core.setFailed(err)
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/node-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Check for package changes and commit message
id: check_changes
run: |
if [[ "${{ github.event_name }}" == "release" ]]
then
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
if [[ $COMMIT_MESSAGE == "[release]"* ]] && git diff --name-only HEAD~1 HEAD -- './packages/node/package.json'
TAG_NAME=${GITHUB_REF#refs/tags/}
if [[ $TAG_NAME == "node/"* ]]
then
echo "::set-output name=changes_found::true"
echo "changes_found=true" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=changes_found::false"
echo "changes_found=false" >> "$GITHUB_OUTPUT"
fi
else
echo "::set-output name=changes_found::true"
echo "changes_found=true" >> "$GITHUB_OUTPUT"
fi
node-build-push-docker:
needs: check
Expand All @@ -45,13 +46,13 @@ jobs:
token: ${{ secrets.SQ_SDK_GITHUB_SECRET }}

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

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

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: subquerynetwork
password: ${{ secrets.SQ_DOCKERHUB_TOKEN }}
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,13 @@ on:
paths-ignore:
- '.github/workflows/**'

jobs:
pre-ci:
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: 'Block Concurrent Executions'
uses: softprops/turnstyle@v1
with:
poll-interval-seconds: 10
env:
GITHUB_TOKEN: ${{ secrets.SQ_SDK_GITHUB_SECRET }}

concurrency:
group: publish
cancel-in-progress: false

jobs:
Bump-Prerelease-Publish:
name: Bump-Prerelease-Publish
needs: pre-ci
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]') && !startsWith(github.event.head_commit.message, '[release]') && github.repository == 'subquery/subql-concordium'"
runs-on: ubuntu-latest
steps:
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,38 @@ on:
- '.github/workflows/**'
workflow_dispatch:

concurrency:
# Same group as prerelease
group: publish
cancel-in-progress: false

jobs:

# This gets the commit message because workflow dispatch doesnt set: github.event.head_commit.message
pre-ci:
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
commit-message: ${{ steps.step1.outputs.commit-message }}
steps:
- name: 'Block Concurrent Executions'
uses: softprops/turnstyle@v1
- uses: actions/checkout@v4
with:
poll-interval-seconds: 10
env:
GITHUB_TOKEN: ${{ secrets.SQ_SDK_GITHUB_SECRET }}
fetch-depth: 100

# Get the commit message, workflow_dispatch doesn't contain it so we need to get it through git cli
- id: step1
run: |
if [ -n "${{ github.event.head_commit.message }}" ]
then
echo "commit-message=${{ github.event.head_commit.message }}" >> "$GITHUB_OUTPUT"
else
echo "commit-message=$(git log -1 --pretty=%B)" >> "$GITHUB_OUTPUT"
fi
Build-Publish:
name: Build-Publish
needs: pre-ci
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]') && startsWith(github.event.head_commit.message, '[release]') && github.repository == 'subquery/subql-concordium'"
if: "!startsWith(needs.pre-ci.outputs.commit-message, '[SKIP CI]') && startsWith(needs.pre-ci.outputs.commit-message, '[release]') && github.repository == 'subquery/subql-concordium'"
runs-on: ubuntu-latest
steps:
#Check out
Expand Down
2 changes: 2 additions & 0 deletions packages/common-concordium/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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 types imports from types-concordium

## [3.4.2] - 2024-02-23
### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/common-concordium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "GPL-3.0",
"dependencies": {
"@concordium/node-sdk": "9.4.0",
"@subql/common": "^3.4.1",
"@subql/common": "^3.5.0",
"@subql/types-concordium": "workspace:*",
"js-yaml": "^4.1.0",
"pino": "^6.13.3",
Expand Down
29 changes: 14 additions & 15 deletions packages/common-concordium/src/project/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
SubqlMapping,
SubqlHandler,
SubqlRuntimeHandler,
SubqlRuntimeDatasource,
SubqlCustomDatasource,
ConcordiumRuntimeDatasource,
ConcordiumCustomDatasource,
CustomDataSourceAsset,
SubqlBlockHandler,
ConcordiumTransactionFilter,
Expand All @@ -24,7 +24,6 @@ import {
import {FileReference, Processor} from '@subql/types-core';
import {plainToClass, Transform, Type} from 'class-transformer';
import {IsArray, IsEnum, IsInt, IsOptional, IsString, IsObject, ValidateNested} from 'class-validator';
import {SubqlConcordiumDatasourceKind, SubqlConcordiumHandlerKind} from './types';

export class TransactionFilter implements ConcordiumTransactionFilter {
@IsOptional()
Expand Down Expand Up @@ -58,7 +57,7 @@ export class BlockHandler implements SubqlBlockHandler {
@IsOptional()
@Type(() => BlockFilterImpl)
filter?: BlockFilterImpl;
@IsEnum(SubqlConcordiumHandlerKind, {groups: [SubqlConcordiumHandlerKind.Block]})
@IsEnum(ConcordiumHandlerKind, {groups: [ConcordiumHandlerKind.Block]})
kind: ConcordiumHandlerKind.Block;
@IsString()
handler: string;
Expand All @@ -69,7 +68,7 @@ export class TransactionHandler implements SubqlTransactionHandler {
@ValidateNested()
@Type(() => TransactionFilter)
filter?: ConcordiumTransactionFilter;
@IsEnum(SubqlConcordiumHandlerKind, {groups: [SubqlConcordiumHandlerKind.Transaction]})
@IsEnum(ConcordiumHandlerKind, {groups: [ConcordiumHandlerKind.Transaction]})
kind: ConcordiumHandlerKind.Transaction;
@IsString()
handler: string;
Expand All @@ -80,7 +79,7 @@ export class TransactionEventHandler implements SubqlTransactionEventHandler {
@ValidateNested()
@Type(() => TransactionEventFilter)
filter?: ConcordiumTransactionEventFilter;
@IsEnum(SubqlConcordiumHandlerKind, {groups: [SubqlConcordiumHandlerKind.TransactionEvent]})
@IsEnum(ConcordiumHandlerKind, {groups: [ConcordiumHandlerKind.TransactionEvent]})
kind: ConcordiumHandlerKind.TransactionEvent;
@IsString()
handler: string;
Expand All @@ -91,7 +90,7 @@ export class SpecialEventHandler implements SubqlSpecialEventHandler {
@ValidateNested()
@Type(() => SpecialEventFilter)
filter?: ConcordiumTransactionEventFilter;
@IsEnum(SubqlConcordiumHandlerKind, {groups: [SubqlConcordiumHandlerKind.SpecialEvent]})
@IsEnum(ConcordiumHandlerKind, {groups: [ConcordiumHandlerKind.SpecialEvent]})
kind: ConcordiumHandlerKind.SpecialEvent;
@IsString()
handler: string;
Expand All @@ -112,13 +111,13 @@ export class ConcordiumMapping implements SubqlMapping {
const handlers: SubqlHandler[] = params.value;
return handlers.map((handler) => {
switch (handler.kind) {
case SubqlConcordiumHandlerKind.SpecialEvent:
case ConcordiumHandlerKind.SpecialEvent:
return plainToClass(SpecialEventHandler, handler);
case SubqlConcordiumHandlerKind.TransactionEvent:
case ConcordiumHandlerKind.TransactionEvent:
return plainToClass(TransactionEventHandler, handler);
case SubqlConcordiumHandlerKind.Transaction:
case ConcordiumHandlerKind.Transaction:
return plainToClass(TransactionHandler, handler);
case SubqlConcordiumHandlerKind.Block:
case ConcordiumHandlerKind.Block:
return plainToClass(BlockHandler, handler);
default:
throw new Error(`handler ${(handler as any).kind} not supported`);
Expand All @@ -143,10 +142,10 @@ export class CustomMapping implements SubqlMapping<SubqlCustomHandler> {

export class RuntimeDataSourceBase<M extends SubqlMapping<SubqlRuntimeHandler>>
extends BaseDataSource
implements SubqlRuntimeDatasource<M>
implements ConcordiumRuntimeDatasource<M>
{
@IsEnum(SubqlConcordiumDatasourceKind, {
groups: [SubqlConcordiumDatasourceKind.Runtime],
@IsEnum(ConcordiumDatasourceKind, {
groups: [ConcordiumDatasourceKind.Runtime],
})
kind: ConcordiumDatasourceKind.Runtime;
@Type(() => ConcordiumMapping)
Expand All @@ -163,7 +162,7 @@ export class FileReferenceImpl implements FileReference {

export class CustomDataSourceBase<K extends string, M extends SubqlMapping = SubqlMapping<SubqlCustomHandler>, O = any>
extends BaseDataSource
implements SubqlCustomDatasource<K, M>
implements ConcordiumCustomDatasource<K, M>
{
@IsString()
kind: K;
Expand Down
17 changes: 6 additions & 11 deletions packages/common-concordium/src/project/types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {SubqlDatasource} from '@subql/types-concordium';
import {IProjectManifest, ProjectNetworkConfig} from '@subql/types-core';
import {ConcordiumDatasource} from '@subql/types-concordium';
import {IProjectManifest} from '@subql/types-core';

// All of these used to be redefined in this file, re-exporting for simplicity
export {
SubqlRuntimeHandler,
SubqlCustomHandler,
SubqlHandler,
ConcordiumHandlerKind as SubqlConcordiumHandlerKind,
SubqlDatasource as SubqlConcordiumDataSource,
SubqlCustomDatasource as SubqlConcordiumCustomDataSource,
ConcordiumHandlerKind,
ConcordiumDatasource,
ConcordiumCustomDatasource,
ConcordiumBlockFilter,
ConcordiumTransactionFilter,
SubqlDatasourceProcessor,
Expand All @@ -20,9 +20,4 @@ export {
ConcordiumRuntimeHandlerInputMap as ConcordiumRuntimeHandlerInputMap,
} from '@subql/types-concordium';

export type IConcordiumProjectManifest = IProjectManifest<SubqlDatasource>;

export interface ConcordiumProjectNetworkConfig extends ProjectNetworkConfig {
genesisHash?: string;
chainId?: string;
}
export type IConcordiumProjectManifest = IProjectManifest<ConcordiumDatasource>;
12 changes: 6 additions & 6 deletions packages/common-concordium/src/project/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

import {
SecondLayerHandlerProcessor,
SubqlCustomDatasource,
SubqlDatasource,
ConcordiumCustomDatasource,
ConcordiumDatasource,
ConcordiumDatasourceKind,
ConcordiumHandlerKind,
SubqlRuntimeDatasource,
ConcordiumRuntimeDatasource,
} from '@subql/types-concordium';

export function isBlockHandlerProcessor<E>(
Expand All @@ -34,10 +34,10 @@ export function isSpecialEventHandlerProcessor<E>(
return hp.baseHandlerKind === ConcordiumHandlerKind.SpecialEvent;
}

export function isCustomDs(ds: SubqlDatasource): ds is SubqlCustomDatasource<string> {
return ds.kind !== ConcordiumDatasourceKind.Runtime && !!(ds as SubqlCustomDatasource<string>).processor;
export function isCustomDs(ds: ConcordiumDatasource): ds is ConcordiumCustomDatasource<string> {
return ds.kind !== ConcordiumDatasourceKind.Runtime && !!(ds as ConcordiumCustomDatasource<string>).processor;
}

export function isRuntimeDs(ds: SubqlDatasource): ds is SubqlRuntimeDatasource {
export function isRuntimeDs(ds: ConcordiumDatasource): ds is ConcordiumRuntimeDatasource {
return ds.kind === ConcordiumDatasourceKind.Runtime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0

import {plainToClass} from 'class-transformer';
import {IConcordiumProjectManifest, SubqlConcordiumDataSource} from '../types';
import {ConcordiumDatasource, IConcordiumProjectManifest} from '../types';
import {ProjectManifestV1_0_0Impl} from './v1_0_0';
export type VersionedProjectManifest = {specVersion: string};

Expand Down Expand Up @@ -49,7 +49,7 @@ export class ConcordiumProjectManifestVersioned implements IConcordiumProjectMan
return this._impl.validate();
}

get dataSources(): SubqlConcordiumDataSource[] {
get dataSources(): ConcordiumDatasource[] {
return this._impl.dataSources;
}

Expand Down
15 changes: 8 additions & 7 deletions packages/common-concordium/src/project/versioned/v1_0_0/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import {
CommonProjectNetworkV1_0_0,
} from '@subql/common';
import {
SubqlCustomDatasource,
ConcordiumCustomDatasource,
SubqlMapping,
SubqlRuntimeDatasource,
ConcordiumRuntimeDatasource,
RuntimeDatasourceTemplate,
CustomDatasourceTemplate,
ConcordiumProjectManifestV1_0_0,
ConcordiumDatasource,
SubqlRuntimeHandler,
} from '@subql/types-concordium';
import {BaseMapping, NodeSpec, ParentProject, QuerySpec, RunnerSpecs} from '@subql/types-core';
import {plainToClass, Transform, TransformFnParams, Type} from 'class-transformer';
Expand All @@ -32,7 +34,6 @@ import {
validateSync,
} from 'class-validator';
import {CustomDataSourceBase, ConcordiumMapping, RuntimeDataSourceBase} from '../../models';
import {SubqlConcordiumDataSource, SubqlRuntimeHandler} from '../../types';

const Concordium_NODE_NAME = `@subql/node-concordium`;
const Flare_NODE_NAME = `@subql/node-flare`;
Expand All @@ -59,7 +60,7 @@ function validateObject(object: any, errorMessage = 'failed to validate object.'

export class ConcordiumRuntimeDataSourceImpl
extends RuntimeDataSourceBase<SubqlMapping<SubqlRuntimeHandler>>
implements SubqlRuntimeDatasource
implements ConcordiumRuntimeDatasource
{
validate(): void {
return validateObject(this, 'failed to validate runtime datasource.');
Expand All @@ -68,7 +69,7 @@ export class ConcordiumRuntimeDataSourceImpl

export class ConcordiumCustomDataSourceImpl<K extends string = string, M extends BaseMapping<any> = BaseMapping<any>>
extends CustomDataSourceBase<K, M>
implements SubqlCustomDatasource<K, M>
implements ConcordiumCustomDatasource<K, M>
{
validate(): void {
return validateObject(this, 'failed to validate custom datasource.');
Expand Down Expand Up @@ -140,7 +141,7 @@ export class DeploymentV1_0_0 extends BaseDeploymentV1_0_0 {
},
keepDiscriminatorProperty: true,
})
dataSources: (SubqlRuntimeDatasource | SubqlCustomDatasource)[];
dataSources: (ConcordiumRuntimeDatasource | ConcordiumCustomDatasource)[];
@IsOptional()
@IsArray()
@ValidateNested()
Expand Down Expand Up @@ -171,7 +172,7 @@ export class ProjectManifestV1_0_0Impl
},
keepDiscriminatorProperty: true,
})
dataSources: SubqlConcordiumDataSource[];
dataSources: ConcordiumDatasource[];
@Type(() => ProjectNetworkV1_0_0)
network: ProjectNetworkV1_0_0;
@IsString()
Expand Down
Loading

0 comments on commit 6965c4f

Please sign in to comment.