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 #130

Merged
merged 4 commits into from
Aug 7, 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
5 changes: 5 additions & 0 deletions packages/common-algorand/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ 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]
### Removed
- `apiKey` option from network config, please use endpoint config and specify the `X-Indexer-API-Token` header instead (#130)

### Added
- Suport for network endpoint config providing the ability to set headers (#130)

## [4.0.0] - 2024-07-03
### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/common-algorand/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.0.0",
"@subql/types-algorand": "workspace:*"
},
"peerDependencies": {
Expand Down
34 changes: 17 additions & 17 deletions packages/common-algorand/src/project/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@

export class BlockHandler implements AlgorandBlockHandler {
@IsEnum(AlgorandHandlerKind, {groups: [AlgorandHandlerKind.Block]})
kind: AlgorandHandlerKind.Block;
kind!: AlgorandHandlerKind.Block;

@IsString()
handler: string;
handler!: string;

@IsOptional()
@ValidateNested()
Expand All @@ -113,18 +113,18 @@
filter?: AlgorandTransactionFilter;

@IsEnum(AlgorandHandlerKind, {groups: [AlgorandHandlerKind.Block]})
kind: AlgorandHandlerKind.Transaction;
kind!: AlgorandHandlerKind.Transaction;

@IsString()
handler: string;
handler!: string;
}

export class CustomHandler implements AlgorandCustomHandler {
@IsString()
kind: string;
kind!: string;

@IsString()
handler: string;
handler!: string;

@IsObject()
@IsOptional()
Expand All @@ -141,58 +141,58 @@
case AlgorandHandlerKind.Transaction:
return plainToClass(TransactionHandler, handler);
default:
throw new Error(`handler ${(handler as any).kind} not supported`);

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

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
}
});
})
@IsArray()
@ValidateNested()
handlers: AlgorandRuntimeHandler[];
handlers!: AlgorandRuntimeHandler[];

@IsString()
file: string;
file!: string;
}

export class CustomMapping implements BaseMapping<AlgorandCustomHandler> {
@IsArray()
@Type(() => CustomHandler)
@ValidateNested()
handlers: CustomHandler[];
handlers!: CustomHandler[];

@IsString()
file: string;
file!: string;
}

export class RuntimeDataSourceBase extends BaseDataSource implements AlgorandRuntimeDataSource {
@IsEnum(AlgorandDataSourceKind, {groups: [AlgorandDataSourceKind.Runtime]})
kind: AlgorandDataSourceKind.Runtime;
kind!: AlgorandDataSourceKind.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 180 in packages/common-algorand/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
extends BaseDataSource
implements AlgorandCustomDataSource<K, M>
{
@IsString()
kind: K;
kind!: K;

@Type(() => CustomMapping)
@ValidateNested()
mapping: M;
mapping!: M;

@Type(() => FileReferenceImpl)
@ValidateNested({each: true})
assets: Map<string, AlgorandCustomDataSourceAsset>;
assets!: Map<string, AlgorandCustomDataSourceAsset>;

@Type(() => ProcessorImpl)
@IsObject()
processor: Processor<O>;
processor!: Processor<O>;
}
1 change: 0 additions & 1 deletion packages/common-algorand/src/project/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ export {
} from '@subql/types-algorand';

export type IAlgorandProjectManifest = IProjectManifest<AlgorandDataSource>;
export type TokenHeader = Record<string, string>;
5 changes: 3 additions & 2 deletions packages/common-algorand/src/project/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0

import {
SecondLayerHandlerProcessorArray,
SecondLayerHandlerProcessor,
AlgorandCustomDataSource,
AlgorandDataSource,
Expand All @@ -11,13 +12,13 @@ import {
} from '@subql/types-algorand';

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

export function isTransactionHandlerProcessor<F extends Record<string, unknown>, E>(
hp: SecondLayerHandlerProcessor<AlgorandHandlerKind, F, unknown>
hp: SecondLayerHandlerProcessorArray<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 @@ -42,7 +42,7 @@ export class AlgorandProjectManifestVersioned implements IAlgorandProjectManifes
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 AlgorandProjectManifestVersioned implements IAlgorandProjectManifes
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;
}
}
38 changes: 16 additions & 22 deletions packages/common-algorand/src/project/versioned/v1_0_0/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@
import {Equals, IsArray, IsObject, IsOptional, IsString, Validate, ValidateNested, validateSync} from 'class-validator';
import yaml from 'js-yaml';
import {CustomDataSourceBase, RuntimeDataSourceBase} from '../../models';
import {TokenHeader} from '../../types';
import {IsStringOrObject} from '../../validation/is-string-or-object.validation';
const ALGORAND_NODE_NAME = `@subql/node-algorand`;

export class AlgorandRunnerNodeImpl implements NodeSpec {
@Equals(ALGORAND_NODE_NAME, {message: `Runner algorand node name incorrect, suppose be '${ALGORAND_NODE_NAME}'`})
name: string;
name!: string;

@IsString()
@Validate(SemverVersionValidator)
Expand All @@ -40,27 +38,23 @@
@IsObject()
@ValidateNested()
@Type(() => AlgorandRunnerNodeImpl)
node: NodeSpec;
node!: NodeSpec;

@IsObject()
@ValidateNested()
@Type(() => RunnerQueryBaseModel)
query: QuerySpec;
query!: QuerySpec;
}

export class ProjectNetworkDeploymentV1_0_0 {
@IsString()
chainId: string;
chainId!: string;
@IsOptional()
@IsArray()
bypassBlocks?: (number | string)[];
}

export class ProjectNetworkV1_0_0 extends CommonProjectNetworkV1_0_0<FileType> {
@IsStringOrObject()
@IsOptional()
apiKey?: string | TokenHeader;
}
export class ProjectNetworkV1_0_0 extends CommonProjectNetworkV1_0_0<FileType> {}

export class AlgorandRuntimeDataSourceV1_0_0Impl extends RuntimeDataSourceBase {
validate(): void {
Expand All @@ -70,7 +64,7 @@

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

Check warning on line 67 in packages/common-algorand/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 67 in packages/common-algorand/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 AlgorandCustomDataSource<K, M>
Expand All @@ -85,15 +79,15 @@
implements RuntimeDatasourceTemplate
{
@IsString()
name: string;
name!: string;
}

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

export class DeploymentV1_0_0 extends BaseDeploymentV1_0_0 {
Expand All @@ -105,11 +99,11 @@
})
@ValidateNested()
@Type(() => ProjectNetworkDeploymentV1_0_0)
network: ProjectNetworkDeploymentV1_0_0;
network!: ProjectNetworkDeploymentV1_0_0;
@IsObject()
@ValidateNested()
@Type(() => AlgorandRunnerSpecsImpl)
runner: RunnerSpecs;
runner!: RunnerSpecs;

@IsArray()
@ValidateNested()
Expand All @@ -120,7 +114,7 @@
},
keepDiscriminatorProperty: true,
})
dataSources: (AlgorandCustomDataSource | AlgorandRuntimeDataSource)[];
dataSources!: (AlgorandCustomDataSource | AlgorandRuntimeDataSource)[];
@IsOptional()
@IsArray()
@ValidateNested()
Expand All @@ -146,19 +140,19 @@
specVersion = '1.0.0';

@IsString()
name: string;
name!: string;

@IsString()
version: string;
version!: string;

@IsObject()
@ValidateNested()
@Type(() => ProjectNetworkV1_0_0)
network: ProjectNetworkV1_0_0;
network!: ProjectNetworkV1_0_0;

@ValidateNested()
@Type(() => FileType)
schema: FileType;
schema!: FileType;

@IsArray()
@ValidateNested()
Expand All @@ -169,7 +163,7 @@
},
keepDiscriminatorProperty: true,
})
dataSources: (AlgorandRuntimeDataSource | AlgorandCustomDataSource)[];
dataSources!: (AlgorandRuntimeDataSource | AlgorandCustomDataSource)[];

@IsOptional()
@IsArray()
Expand All @@ -186,7 +180,7 @@
@IsObject()
@ValidateNested()
@Type(() => AlgorandRunnerSpecsImpl)
runner: RunnerSpecs;
runner!: RunnerSpecs;

@IsOptional()
@IsObject()
Expand Down
5 changes: 5 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ 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 dependencies and apply dependent changes (#130)

### Added
- Support for specifying headers for network endpoints (#130)

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

# Make the user not ROOT
USER 1000
ENV TZ=utc

# Set Entry point and command
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/lib/node_modules/@subql/node-algorand/bin/run"]
Expand Down
10 changes: 5 additions & 5 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
"@nestjs/event-emitter": "^2.0.0",
"@nestjs/platform-express": "^9.4.0",
"@nestjs/schedule": "^3.0.1",
"@subql/common": "^5.0.0",
"@subql/common-algorand": "workspace:*",
"@subql/node-core": "^10.10.0",
"@subql/node-core": "^14.0.0",
"@subql/types-algorand": "workspace:*",
"algosdk": "^2.2.0",
"axios": "^1.3.4",
"algosdk": "^2.8.0",
"lodash": "^4.17.21",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"yargs": "^16.2.0"
},
"devDependencies": {
Expand All @@ -44,7 +43,8 @@
"@types/tar": "^6.1.1",
"@types/yargs": "^16.0.4",
"dotenv": "^15.0.1",
"nodemon": "^2.0.15"
"nodemon": "^2.0.15",
"rimraf": "^6.0.1"
},
"peerDependencies": {
"@subql/utils": "*"
Expand Down
13 changes: 0 additions & 13 deletions packages/node/src/admin/admin.module.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/node/src/algorand/algorand.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
root: './',
schema: new GraphQLSchema({}),
templates: [],
} as any;

Check warning on line 35 in packages/node/src/algorand/algorand.spec.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
}

// eslint-disable-next-line jest/no-export
Expand Down Expand Up @@ -114,7 +114,7 @@
};

expect(
filterTransaction(tx as any, {

Check warning on line 117 in packages/node/src/algorand/algorand.spec.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
txType: 'acfg',
sender: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',
}),
Expand All @@ -122,17 +122,16 @@
});

// This is failing since switching from algo explorer api. This is due to a node configuration limit
it.skip('paginate large blocks', async () => {
it('paginate large blocks', async () => {
[app, apiService] = await prepareApiService(
testnetEndpoint,
testnetChainId,
);
const failingBlock = 27739202; // testnet
const passingBlock = 27739200; // testnet
const api = apiService.api;

const paginateSpy = jest.spyOn(api, 'paginatedTransactions');
const result = await api.getBlockByHeight(failingBlock)();
const result = await api.getBlockByHeight(failingBlock);
expect(paginateSpy).toHaveBeenCalledTimes(3);
expect(result.transactions.length).toEqual(13916);
});
Expand Down
Loading
Loading