Skip to content

Commit

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

* Apply changes relating to updated deps

* Update changelogs

---------

Co-authored-by: stwiname <[email protected]>
  • Loading branch information
stwiname and stwiname authored Apr 29, 2024
1 parent 8419959 commit b67cad1
Show file tree
Hide file tree
Showing 24 changed files with 113 additions and 430 deletions.
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 dependencies and apply changes to match (#40)

## [3.5.1] - 2024-04-11
### Fixed
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.5.0",
"@subql/common": "^3.5.1",
"@subql/types-concordium": "workspace:*",
"js-yaml": "^4.1.0",
"pino": "^6.13.3",
Expand Down
18 changes: 10 additions & 8 deletions packages/common-concordium/src/project/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@ import {
ConcordiumRuntimeDatasource,
} from '@subql/types-concordium';

type DefaultFilter = Record<string, unknown>;

export function isBlockHandlerProcessor<E>(
hp: SecondLayerHandlerProcessor<ConcordiumHandlerKind, unknown, unknown>
): hp is SecondLayerHandlerProcessor<ConcordiumHandlerKind.Block, unknown, E> {
hp: SecondLayerHandlerProcessor<ConcordiumHandlerKind, DefaultFilter, unknown>
): hp is SecondLayerHandlerProcessor<ConcordiumHandlerKind.Block, DefaultFilter, E> {
return hp.baseHandlerKind === ConcordiumHandlerKind.Block;
}

export function isTransactionHandlerProcessor<E>(
hp: SecondLayerHandlerProcessor<ConcordiumHandlerKind, unknown, unknown>
): hp is SecondLayerHandlerProcessor<ConcordiumHandlerKind.Transaction, unknown, E> {
hp: SecondLayerHandlerProcessor<ConcordiumHandlerKind, DefaultFilter, unknown>
): hp is SecondLayerHandlerProcessor<ConcordiumHandlerKind.Transaction, DefaultFilter, E> {
return hp.baseHandlerKind === ConcordiumHandlerKind.Transaction;
}

export function isTransactionEventHandlerProcessor<E>(
hp: SecondLayerHandlerProcessor<ConcordiumHandlerKind, unknown, unknown>
): hp is SecondLayerHandlerProcessor<ConcordiumHandlerKind.TransactionEvent, unknown, E> {
hp: SecondLayerHandlerProcessor<ConcordiumHandlerKind, DefaultFilter, unknown>
): hp is SecondLayerHandlerProcessor<ConcordiumHandlerKind.TransactionEvent, DefaultFilter, E> {
return hp.baseHandlerKind === ConcordiumHandlerKind.TransactionEvent;
}

export function isSpecialEventHandlerProcessor<E>(
hp: SecondLayerHandlerProcessor<ConcordiumHandlerKind, unknown, unknown>
): hp is SecondLayerHandlerProcessor<ConcordiumHandlerKind.SpecialEvent, unknown, E> {
hp: SecondLayerHandlerProcessor<ConcordiumHandlerKind, DefaultFilter, unknown>
): hp is SecondLayerHandlerProcessor<ConcordiumHandlerKind.SpecialEvent, DefaultFilter, E> {
return hp.baseHandlerKind === ConcordiumHandlerKind.SpecialEvent;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/node/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 dependencies and apply changes to match (#40)

## [3.10.1] - 2024-04-11
### Fixed
Expand Down
4 changes: 2 additions & 2 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"@nestjs/event-emitter": "^2.0.0",
"@nestjs/platform-express": "^9.4.0",
"@nestjs/schedule": "^3.0.1",
"@subql/common": "^3.5.0",
"@subql/common": "^3.5.1",
"@subql/common-concordium": "workspace:*",
"@subql/node-core": "^8.0.1",
"@subql/node-core": "^10.0.0",
"@subql/types-concordium": "workspace:*",
"cacheable-lookup": "6",
"cron-converter": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import {
NodeConfig,
SmartBatchService,
StoreCacheService,
StoreService,
IProjectService,
Expand All @@ -18,7 +17,6 @@ import {
} from '@subql/node-core';
import { ConcordiumBlock, ConcordiumDatasource } from '@subql/types-concordium';
import { SubqueryProject } from '../../configure/SubqueryProject';
import { DynamicDsService } from '../dynamic-ds.service';
import { IndexerManager } from '../indexer.manager';

/**
Expand All @@ -38,24 +36,20 @@ export class BlockDispatcherService
projectService: IProjectService<ConcordiumDatasource>,
@Inject('IProjectUpgradeService')
projectUpgradeService: IProjectUpgradeService,
smartBatchService: SmartBatchService,
storeService: StoreService,
storeCacheService: StoreCacheService,
poiSyncService: PoiSyncService,
@Inject('ISubqueryProject') project: SubqueryProject,
dynamicDsService: DynamicDsService,
) {
super(
nodeConfig,
eventEmitter,
projectService,
projectUpgradeService,
smartBatchService,
storeService,
storeCacheService,
poiSyncService,
project,
dynamicDsService,
apiService.fetchBlocks.bind(apiService),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import {
NodeConfig,
SmartBatchService,
StoreService,
StoreCacheService,
IProjectService,
Expand Down Expand Up @@ -45,7 +44,6 @@ export class WorkerBlockDispatcherService
projectService: IProjectService<ConcordiumDatasource>,
@Inject('IProjectUpgradeService')
projectUpgadeService: IProjectUpgradeService,
smartBatchService: SmartBatchService,
cacheService: InMemoryCacheService,
storeService: StoreService,
storeCacheService: StoreCacheService,
Expand All @@ -60,12 +58,10 @@ export class WorkerBlockDispatcherService
eventEmitter,
projectService,
projectUpgadeService,
smartBatchService,
storeService,
storeCacheService,
poiSyncService,
project,
dynamicDsService,
() =>
createIndexerWorker<
IIndexerWorker,
Expand Down
7 changes: 5 additions & 2 deletions packages/node/src/indexer/dictionary/v1/dictionaryV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import {
ConcordiumSpecialEventFilter,
ConcordiumTransactionEventFilter,
ConcordiumTransactionFilter,
DictionaryQueryCondition,
ConcordiumDatasource,
ConcordiumHandlerKind,
} from '@subql/types-concordium';
import { DictionaryQueryEntry, DsProcessor } from '@subql/types-core';
import {
DictionaryQueryCondition,
DictionaryQueryEntry,
DsProcessor,
} from '@subql/types-core';
import { setWith, sortBy, uniqBy } from 'lodash';
import { SubqueryProject } from '../../../configure/SubqueryProject';

Expand Down
65 changes: 1 addition & 64 deletions packages/node/src/indexer/ds-processor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,13 @@
// SPDX-License-Identifier: GPL-3.0

import { Injectable } from '@nestjs/common';
import {
ConcordiumHandlerKind,
isCustomDs,
SubqlDatasourceProcessor,
} from '@subql/common-concordium';
import { isCustomDs, SubqlDatasourceProcessor } from '@subql/common-concordium';
import { BaseDsProcessorService } from '@subql/node-core';
import {
ConcordiumCustomDatasource,
ConcordiumDatasource,
SecondLayerHandlerProcessor_0_0_0,
SecondLayerHandlerProcessor_1_0_0,
} from '@subql/types-concordium';

export function isSecondLayerHandlerProcessor_0_0_0<
K extends ConcordiumHandlerKind,
F extends Record<string, unknown>,
E,
DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource,
>(
processor:
| SecondLayerHandlerProcessor_0_0_0<K, F, E, DS>
| SecondLayerHandlerProcessor_1_0_0<K, F, E, DS>,
): processor is SecondLayerHandlerProcessor_0_0_0<K, F, E, DS> {
// Exisiting datasource processors had no concept of specVersion, therefore undefined is equivalent to 0.0.0
return processor.specVersion === undefined;
}

export function isSecondLayerHandlerProcessor_1_0_0<
K extends ConcordiumHandlerKind,
F extends Record<string, unknown>,
E,
DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource,
>(
processor:
| SecondLayerHandlerProcessor_0_0_0<K, F, E, DS>
| SecondLayerHandlerProcessor_1_0_0<K, F, E, DS>,
): processor is SecondLayerHandlerProcessor_1_0_0<K, F, E, DS> {
return processor.specVersion === '1.0.0';
}

export function asSecondLayerHandlerProcessor_1_0_0<
K extends ConcordiumHandlerKind,
F extends Record<string, unknown>,
E,
DS extends ConcordiumCustomDatasource = ConcordiumCustomDatasource,
>(
processor:
| SecondLayerHandlerProcessor_0_0_0<K, F, E, DS>
| SecondLayerHandlerProcessor_1_0_0<K, F, E, DS>,
): SecondLayerHandlerProcessor_1_0_0<K, F, E, DS> {
if (isSecondLayerHandlerProcessor_1_0_0(processor)) {
return processor;
}

if (!isSecondLayerHandlerProcessor_0_0_0(processor)) {
throw new Error('Unsupported ds processor version');
}

return {
...processor,
specVersion: '1.0.0',
filterProcessor: (params) =>
processor.filterProcessor(params.filter, params.input, params.ds),
transformer: (params) =>
processor
.transformer(params.input, params.ds, params.api, params.assets)
.then((res) => [res]),
};
}

@Injectable()
export class DsProcessorService extends BaseDsProcessorService<
ConcordiumDatasource,
Expand Down
28 changes: 9 additions & 19 deletions packages/node/src/indexer/dynamic-ds.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,28 @@ import {
import { ConcordiumDatasource } from '@subql/types-concordium';
import { plainToClass } from 'class-transformer';
import { validateSync } from 'class-validator';
import { cloneDeep } from 'lodash';
import { SubqueryProject } from '../configure/SubqueryProject';
import { DsProcessorService } from './ds-processor.service';

@Injectable()
export class DynamicDsService extends BaseDynamicDsService<ConcordiumDatasource> {
export class DynamicDsService extends BaseDynamicDsService<
ConcordiumDatasource,
SubqueryProject
> {
constructor(
private readonly dsProcessorService: DsProcessorService,
@Inject('ISubqueryProject') private readonly project: SubqueryProject,
@Inject('ISubqueryProject') project: SubqueryProject,
) {
super();
super(project);
}

protected async getDatasource(
params: DatasourceParams,
): Promise<ConcordiumDatasource> {
const t = this.project.templates?.find(
(t) => t.name === params.templateName,
const dsObj = this.getTemplate<ConcordiumDatasource>(
params.templateName,
params.startBlock,
);

if (!t) {
throw new Error(
`Unable to find matching template in project for name: "${params.templateName}"`,
);
}

const { name, ...template } = cloneDeep(t);

const dsObj = {
...template,
startBlock: params.startBlock,
} as ConcordiumDatasource;
try {
if (isCustomDs(dsObj)) {
dsObj.processor.options = {
Expand Down
15 changes: 1 addition & 14 deletions packages/node/src/indexer/fetch.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
NodeConfig,
ConnectionPoolService,
ConnectionPoolStateManager,
SmartBatchService,
StoreCacheService,
IProjectUpgradeService,
PoiSyncService,
InMemoryCacheService,
SandboxService,
} from '@subql/node-core';
import { ConcordiumApiConnection } from '../concordium/api.connection';
import { ConcordiumApiService } from '../concordium/api.service.concordium';
Expand All @@ -31,7 +31,6 @@ import { DynamicDsService } from './dynamic-ds.service';
import { FetchService } from './fetch.service';
import { IndexerManager } from './indexer.manager';
import { ProjectService } from './project.service';
import { SandboxService } from './sandbox.service';
import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';

@Module({
Expand Down Expand Up @@ -67,13 +66,6 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
ConnectionPoolStateManager,
ConnectionPoolService,
PoiSyncService,
{
provide: SmartBatchService,
useFactory: (nodeConfig: NodeConfig) => {
return new SmartBatchService(nodeConfig.batchSize);
},
inject: [NodeConfig],
},
{
provide: 'IBlockDispatcher',
useFactory: (
Expand All @@ -83,7 +75,6 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
projectUpgradeService: IProjectUpgradeService,
apiService: ConcordiumApiService,
indexerManager: IndexerManager,
smartBatchService: SmartBatchService,
cacheService: InMemoryCacheService,
storeService: StoreService,
storeCacheService: StoreCacheService,
Expand All @@ -99,7 +90,6 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
eventEmitter,
projectService,
projectUpgradeService,
smartBatchService,
cacheService,
storeService,
storeCacheService,
Expand All @@ -116,12 +106,10 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
eventEmitter,
projectService,
projectUpgradeService,
smartBatchService,
storeService,
storeCacheService,
poiSyncService,
project,
dynamicDsService,
),
inject: [
NodeConfig,
Expand All @@ -130,7 +118,6 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
'IProjectUpgradeService',
ApiService,
IndexerManager,
SmartBatchService,
InMemoryCacheService,
StoreService,
StoreCacheService,
Expand Down
4 changes: 0 additions & 4 deletions packages/node/src/indexer/fetch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ export class FetchService extends BaseFetchService<
return this.apiService.unsafeApi;
}

protected getGenesisHash(): string {
return this.apiService.networkMeta.genesisHash;
}

protected async getFinalizedHeight(): Promise<number> {
const block = await this.api.getFinalizedBlock();

Expand Down
Loading

0 comments on commit b67cad1

Please sign in to comment.