Skip to content

Commit

Permalink
Sync @subql dependencies (#62)
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 899b66f commit b0b4648
Show file tree
Hide file tree
Showing 25 changed files with 103 additions and 426 deletions.
2 changes: 2 additions & 0 deletions packages/common-stellar/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 (#62)

## [3.4.1] - 2024-04-11
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/common-stellar/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": "^3.5.0",
"@subql/common": "^3.5.1",
"@subql/types-stellar": "workspace:*",
"js-yaml": "^4.1.0",
"pino": "^6.13.3",
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 (#62)

## [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 @@ -25,9 +25,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-stellar": "workspace:*",
"@subql/node-core": "^8.0.1",
"@subql/node-core": "^10.0.0",
"@subql/testing": "^2.0.0",
"@subql/types": "^2.2.1-1",
"@subql/types-stellar": "workspace:*",
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 @@ -21,7 +20,6 @@ import {
StellarProjectDs,
SubqueryProject,
} from '../../configure/SubqueryProject';
import { DynamicDsService } from '../dynamic-ds.service';
import { IndexerManager } from '../indexer.manager';

/**
Expand All @@ -41,24 +39,20 @@ export class BlockDispatcherService
projectService: IProjectService<StellarProjectDs>,
@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 @@ -7,7 +7,6 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
import {
getLogger,
NodeConfig,
SmartBatchService,
StoreService,
PoiSyncService,
StoreCacheService,
Expand Down Expand Up @@ -51,7 +50,6 @@ export class WorkerBlockDispatcherService
projectService: IProjectService<StellarProjectDs>,
@Inject('IProjectUpgradeService')
projectUpgradeService: IProjectUpgradeService,
smartBatchService: SmartBatchService,
cacheService: InMemoryCacheService,
storeService: StoreService,
storeCacheService: StoreCacheService,
Expand All @@ -66,12 +64,10 @@ export class WorkerBlockDispatcherService
eventEmitter,
projectService,
projectUpgradeService,
smartBatchService,
storeService,
storeCacheService,
poiSyncService,
project,
dynamicDsService,
() =>
createIndexerWorker<
IIndexerWorker,
Expand Down
63 changes: 0 additions & 63 deletions packages/node/src/indexer/ds-processor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,12 @@

import { Injectable } from '@nestjs/common';
import {
StellarHandlerKind,
isCustomDs,
SubqlStellarCustomDataSource,
SubqlStellarDataSource,
SubqlDatasourceProcessor,
} from '@subql/common-stellar';
import { BaseDsProcessorService } from '@subql/node-core';
import {
SecondLayerHandlerProcessor_0_0_0,
SecondLayerHandlerProcessor_1_0_0,
SubqlCustomDatasource,
} from '@subql/types-stellar';

export function isSecondLayerHandlerProcessor_0_0_0<
K extends StellarHandlerKind,
F extends Record<string, unknown>,
E,
DS extends SubqlCustomDatasource = SubqlStellarCustomDataSource,
>(
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 StellarHandlerKind,
F extends Record<string, unknown>,
E,
DS extends SubqlStellarCustomDataSource = SubqlStellarCustomDataSource,
>(
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 StellarHandlerKind,
F extends Record<string, unknown>,
E,
DS extends SubqlStellarCustomDataSource = SubqlStellarCustomDataSource,
>(
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<
Expand Down
25 changes: 9 additions & 16 deletions packages/node/src/indexer/dynamic-ds.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,32 @@ import {
} from '@subql/node-core';
import { plainToClass } from 'class-transformer';
import { validateSync } from 'class-validator';
import { cloneDeep } from 'lodash';
import {
StellarProjectDs,
SubqueryProject,
} from '../configure/SubqueryProject';
import { DsProcessorService } from './ds-processor.service';

@Injectable()
export class DynamicDsService extends BaseDynamicDsService<StellarProjectDs> {
export class DynamicDsService extends BaseDynamicDsService<
StellarProjectDs,
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<StellarProjectDs> {
const t = this.project.templates.find(
(t) => t.name === params.templateName,
const dsObj = this.getTemplate<StellarProjectDs>(
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 StellarProjectDs;
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 @@ -11,13 +11,13 @@ import {
PoiSyncService,
ApiService,
ConnectionPoolService,
SmartBatchService,
StoreCacheService,
ConnectionPoolStateManager,
NodeConfig,
IProjectUpgradeService,
ProjectUpgradeService,
InMemoryCacheService,
SandboxService,
} from '@subql/node-core';
import { SubqueryProject } from '../configure/SubqueryProject';
import { StellarApiConnection } from '../stellar/api.connection';
Expand All @@ -32,7 +32,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';
IndexerManager,
ConnectionPoolService,
ConnectionPoolStateManager,
{
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: ApiService,
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
8 changes: 0 additions & 8 deletions packages/node/src/indexer/fetch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import { StellarApi } from '../stellar';
import { blockToHeader, calcInterval } from '../stellar/utils.stellar';
import { IStellarBlockDispatcher } from './blockDispatcher';
import { StellarDictionaryService } from './dictionary';
import { DsProcessorService } from './ds-processor.service';
import { DynamicDsService } from './dynamic-ds.service';
import { ProjectService } from './project.service';
import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';

Expand All @@ -41,8 +39,6 @@ export class FetchService extends BaseFetchService<
@Inject('IBlockDispatcher')
blockDispatcher: IStellarBlockDispatcher,
dictionaryService: StellarDictionaryService,
private dsProcessorService: DsProcessorService,
dynamicDsService: DynamicDsService,
private unfinalizedBlocksService: UnfinalizedBlocksService,
eventEmitter: EventEmitter2,
schedulerRegistry: SchedulerRegistry,
Expand All @@ -62,10 +58,6 @@ export class FetchService extends BaseFetchService<
return this.apiService.unsafeApi;
}

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

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

Expand Down
Loading

0 comments on commit b0b4648

Please sign in to comment.