Skip to content

Commit

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

* Sync node core changes

---------

Co-authored-by: stwiname <[email protected]>
  • Loading branch information
stwiname and stwiname committed Nov 13, 2023
1 parent 0e4a4cf commit 7c0e2e2
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 306 deletions.
4 changes: 4 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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
- Updates to match changes in `@subql/node-core` (#209)
- Dictionary service to use dictionary registry
- Use yargs from node core

## [3.3.1] - 2023-11-08
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@nestjs/schedule": "^3.0.1",
"@subql/common": "^3.3.0",
"@subql/common-cosmos": "workspace:*",
"@subql/node-core": "^6.3.0",
"@subql/node-core": "^6.4.0",
"@subql/types-cosmos": "workspace:*",
"cosmjs-types": "^0.7.0",
"cron-converter": "^1.0.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/indexer/dictionary.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { DictionaryService } from './dictionary.service';
describe('dictionary service', () => {
let dictionaryService: DictionaryService;

beforeEach(() => {
dictionaryService = new DictionaryService(
beforeEach(async () => {
dictionaryService = await DictionaryService.create(
{
network: {
chainId: 'juno-1',
Expand Down
22 changes: 20 additions & 2 deletions packages/node/src/indexer/dictionary.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { Inject, Injectable } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { NETWORK_FAMILY } from '@subql/common';
import {
NodeConfig,
DictionaryService as CoreDictionaryService,
Expand All @@ -11,17 +12,34 @@ import { SubqueryProject } from '../configure/SubqueryProject';

@Injectable()
export class DictionaryService extends CoreDictionaryService {
constructor(
private constructor(
@Inject('ISubqueryProject') protected project: SubqueryProject,
nodeConfig: NodeConfig,
eventEmitter: EventEmitter2,
dictionaryUrl?: string,
) {
super(
project.network.dictionary,
dictionaryUrl ?? project.network.dictionary,
project.network.chainId,
nodeConfig,
eventEmitter,
['lastProcessedHeight', 'chain'],
);
}

static async create(
project: SubqueryProject,
nodeConfig: NodeConfig,
eventEmitter: EventEmitter2,
): Promise<DictionaryService> {
const url =
project.network.dictionary ??
(await CoreDictionaryService.resolveDictionary(
NETWORK_FAMILY.cosmos,
project.network.chainId,
nodeConfig.dictionaryRegistry,
));

return new DictionaryService(project, nodeConfig, eventEmitter, url);
}
}
17 changes: 16 additions & 1 deletion packages/node/src/indexer/fetch.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,22 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
ConnectionPoolService,
IndexingBenchmarkService,
PoiBenchmarkService,
DictionaryService,
{
provide: DictionaryService,
useFactory: async (
project: SubqueryProject,
nodeConfig: NodeConfig,
eventEmitter: EventEmitter2,
) => {
const dictionaryService = await DictionaryService.create(
project,
nodeConfig,
eventEmitter,
);
return dictionaryService;
},
inject: ['ISubqueryProject', NodeConfig, EventEmitter2],
},
SandboxService,
DsProcessorService,
DynamicDsService,
Expand Down
11 changes: 7 additions & 4 deletions packages/node/src/indexer/fetch.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ const nodeConfig = new NodeConfig({
dictionaryTimeout: 10,
});

function mockDictionaryService(url: string): DictionaryServicePrivate {
return new DictionaryService(
// eslint-disable-next-line @typescript-eslint/require-await
async function mockDictionaryService(
url: string,
): Promise<DictionaryServicePrivate> {
return DictionaryService.create(
{
network: {
dictionary: url,
Expand All @@ -34,8 +37,8 @@ function mockDictionaryService(url: string): DictionaryServicePrivate {
describe('Dictionary Queries', () => {
let dictionary: DictionaryServicePrivate;

beforeAll(() => {
dictionary = mockDictionaryService('http://localhost:3000'); // TODO get url
beforeAll(async () => {
dictionary = await mockDictionaryService('http://localhost:3000'); // TODO get url
});

describe('Message Filter Queries', () => {
Expand Down
Loading

0 comments on commit 7c0e2e2

Please sign in to comment.