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

Clean up deps, remove deprecated types #116

Merged
merged 2 commits into from
May 1, 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
3 changes: 3 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Update dependencies and apply changes to match (#115)

### Removed
- Unused deps and deprecated type (#116)

## [3.10.0] - 2024-04-10
### Changed
- Updated with node-core.Now dictionary support multiple dictionary endpoints, indexer will fetch and switch dictionaries base on available blocks
Expand Down
6 changes: 0 additions & 6 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"subql-node-algorand": "./bin/run"
},
"dependencies": {
"@apollo/client": "3.5.8",
"@nestjs/common": "^9.4.0",
"@nestjs/core": "^9.4.0",
"@nestjs/event-emitter": "^2.0.0",
Expand All @@ -32,14 +31,9 @@
"algosdk": "^2.2.0",
"axios": "^1.3.4",
"cron-converter": "^1.0.2",
"dayjs": "^1.10.7",
"eventemitter2": "^6.4.5",
"lodash": "^4.17.21",
"pg": "^8.7.1",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.2",
"tar": "^6.2.1",
"yargs": "^16.2.0"
},
"devDependencies": {
Expand Down
15 changes: 6 additions & 9 deletions packages/node/src/configure/SubqueryProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Injectable } from '@nestjs/common';
import { validateSemver } from '@subql/common';
import {
parseAlgorandProjectManifest,
AlgorandDataSource,
ProjectManifestV1_0_0Impl,
BlockFilter,
isRuntimeDs,
Expand All @@ -16,10 +15,10 @@ import {
import {
insertBlockFiltersCronSchedules,
loadProjectTemplates,
SubqlProjectDs,
updateDataSourcesV1_0_0,
} from '@subql/node-core';
import {
AlgorandDataSource,
CustomDatasourceTemplate,
RuntimeDatasourceTemplate,
} from '@subql/types-algorand';
Expand All @@ -35,11 +34,9 @@ import { GraphQLSchema } from 'graphql';

const { version: packageVersion } = require('../../package.json');

export type AlgorandProjectDs = SubqlProjectDs<AlgorandDataSource>;

export type AlgorandProjectDsTemplate =
| SubqlProjectDs<RuntimeDatasourceTemplate>
| SubqlProjectDs<CustomDatasourceTemplate>;
| RuntimeDatasourceTemplate
| CustomDatasourceTemplate;

export type SubqlProjectBlockFilter = BlockFilter & {
cronSchedule?: {
Expand All @@ -57,13 +54,13 @@ type NetworkConfig = IProjectNetworkConfig & { chainId: string };

@Injectable()
export class SubqueryProject {
#dataSources: AlgorandProjectDs[];
#dataSources: AlgorandDataSource[];

constructor(
readonly id: string,
readonly root: string,
readonly network: NetworkConfig,
dataSources: AlgorandProjectDs[],
dataSources: AlgorandDataSource[],
readonly schema: GraphQLSchema,
readonly templates: AlgorandProjectDsTemplate[],
readonly runner?: RunnerSpecs,
Expand All @@ -72,7 +69,7 @@ export class SubqueryProject {
this.#dataSources = dataSources;
}

get dataSources(): AlgorandProjectDs[] {
get dataSources(): AlgorandDataSource[] {
return this.#dataSources;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,26 @@ import {
IProjectUpgradeService,
IBlock,
} from '@subql/node-core';
import { AlgorandBlock } from '@subql/types-algorand';
import { AlgorandBlock, AlgorandDataSource } from '@subql/types-algorand';
import { AlgorandApiService } from '../../algorand';
import {
AlgorandProjectDs,
SubqueryProject,
} from '../../configure/SubqueryProject';
import { SubqueryProject } from '../../configure/SubqueryProject';
import { IndexerManager } from '../indexer.manager';

/**
* @description Intended to behave the same as WorkerBlockDispatcherService but doesn't use worker threads or any parallel processing
*/
@Injectable()
export class BlockDispatcherService
extends BlockDispatcher<AlgorandBlock, AlgorandProjectDs>
extends BlockDispatcher<AlgorandBlock, AlgorandDataSource>
implements OnApplicationShutdown
{
constructor(
private apiService: AlgorandApiService,
apiService: AlgorandApiService,
nodeConfig: NodeConfig,
private indexerManager: IndexerManager,
eventEmitter: EventEmitter2,
@Inject('IProjectService')
projectService: IProjectService<AlgorandProjectDs>,
projectService: IProjectService<AlgorandDataSource>,
@Inject('IProjectUpgradeService')
projectUpgradeService: IProjectUpgradeService,
storeService: StoreService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ import {
InMemoryCacheService,
createIndexerWorker,
} from '@subql/node-core';
import { AlgorandBlock } from '@subql/types-algorand';
import { AlgorandBlock, AlgorandDataSource } from '@subql/types-algorand';
import { AlgorandApiConnection } from '../../algorand';
import {
AlgorandProjectDs,
SubqueryProject,
} from '../../configure/SubqueryProject';
import { SubqueryProject } from '../../configure/SubqueryProject';
import { DynamicDsService } from '../dynamic-ds.service';
import { BlockContent } from '../types';
import { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';
Expand All @@ -33,14 +30,18 @@ type IndexerWorker = IIndexerWorker & {

@Injectable()
export class WorkerBlockDispatcherService
extends WorkerBlockDispatcher<AlgorandProjectDs, IndexerWorker, AlgorandBlock>
extends WorkerBlockDispatcher<
AlgorandDataSource,
IndexerWorker,
AlgorandBlock
>
implements OnApplicationShutdown
{
constructor(
nodeConfig: NodeConfig,
eventEmitter: EventEmitter2,
@Inject('IProjectService')
projectService: IProjectService<AlgorandProjectDs>,
projectService: IProjectService<AlgorandDataSource>,
@Inject('IProjectUpgradeService')
projectUpgadeService: IProjectUpgradeService,
cacheService: InMemoryCacheService,
Expand All @@ -66,7 +67,7 @@ export class WorkerBlockDispatcherService
IIndexerWorker,
AlgorandApiConnection,
BlockContent,
AlgorandProjectDs
AlgorandDataSource
>(
path.resolve(__dirname, '../../../dist/indexer/worker/worker.js'),
[],
Expand Down
12 changes: 5 additions & 7 deletions packages/node/src/indexer/dynamic-ds.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ import {
DatasourceParams,
DynamicDsService as BaseDynamicDsService,
} from '@subql/node-core';
import { AlgorandDataSource } from '@subql/types-algorand';
import { TransactionType } from 'algosdk';
import {
AlgorandProjectDs,
SubqueryProject,
} from '../configure/SubqueryProject';
import { SubqueryProject } from '../configure/SubqueryProject';
import { DsProcessorService } from './ds-processor.service';

@Injectable()
export class DynamicDsService extends BaseDynamicDsService<
AlgorandProjectDs,
AlgorandDataSource,
SubqueryProject
> {
constructor(
Expand All @@ -28,8 +26,8 @@ export class DynamicDsService extends BaseDynamicDsService<

protected async getDatasource(
params: DatasourceParams,
): Promise<AlgorandProjectDs> {
const dsObj = this.getTemplate<AlgorandProjectDs>(
): Promise<AlgorandDataSource> {
const dsObj = this.getTemplate<AlgorandDataSource>(
params.templateName,
params.startBlock,
);
Expand Down
13 changes: 6 additions & 7 deletions packages/node/src/indexer/indexer.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
filterBlock,
filterTransaction,
} from '../algorand';
import { AlgorandProjectDs } from '../configure/SubqueryProject';
import { DsProcessorService } from './ds-processor.service';
import { DynamicDsService } from './dynamic-ds.service';
import { BlockContent } from './types';
Expand Down Expand Up @@ -90,8 +89,8 @@ export class IndexerManager extends BaseIndexerManager<

protected async indexBlockData(
block: BlockContent,
dataSources: AlgorandProjectDs[],
getVM: (d: AlgorandProjectDs) => Promise<IndexerSandbox>,
dataSources: AlgorandDataSource[],
getVM: (d: AlgorandDataSource) => Promise<IndexerSandbox>,
): Promise<void> {
await this.indexBlockContent(block, dataSources, getVM);
for (const tx of block.transactions) {
Expand All @@ -101,8 +100,8 @@ export class IndexerManager extends BaseIndexerManager<

private async indexBlockContent(
block: AlgorandBlock,
dataSources: AlgorandProjectDs[],
getVM: (d: AlgorandProjectDs) => Promise<IndexerSandbox>,
dataSources: AlgorandDataSource[],
getVM: (d: AlgorandDataSource) => Promise<IndexerSandbox>,
): Promise<void> {
for (const ds of dataSources) {
await this.indexData(AlgorandHandlerKind.Block, block, ds, getVM);
Expand All @@ -111,8 +110,8 @@ export class IndexerManager extends BaseIndexerManager<

private async indexBlockTransactionContent(
txn: AlgorandTransaction,
dataSources: AlgorandProjectDs[],
getVM: (d: AlgorandProjectDs) => Promise<IndexerSandbox>,
dataSources: AlgorandDataSource[],
getVM: (d: AlgorandDataSource) => Promise<IndexerSandbox>,
): Promise<void> {
for (const ds of dataSources) {
await this.indexData(AlgorandHandlerKind.Transaction, txn, ds, getVM);
Expand Down
8 changes: 3 additions & 5 deletions packages/node/src/indexer/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ import {
IProjectUpgradeService,
profiler,
} from '@subql/node-core';
import { AlgorandDataSource } from '@subql/types-algorand';
import { Sequelize } from '@subql/x-sequelize';
import { AlgorandApiService } from '../algorand';
import {
SubqueryProject,
AlgorandProjectDs,
} from '../configure/SubqueryProject';
import { SubqueryProject } from '../configure/SubqueryProject';
import { DsProcessorService } from './ds-processor.service';
import { DynamicDsService } from './dynamic-ds.service';
import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
Expand All @@ -29,7 +27,7 @@ const { version: packageVersion } = require('../../package.json');
@Injectable()
export class ProjectService extends BaseProjectService<
AlgorandApiService,
AlgorandProjectDs
AlgorandDataSource
> {
protected packageVersion = packageVersion;

Expand Down
10 changes: 2 additions & 8 deletions packages/node/src/indexer/worker/worker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ import {
IProjectService,
BaseWorkerService,
IProjectUpgradeService,
ApiService,
IBlock,
} from '@subql/node-core';
import { AlgorandBlock, AlgorandDataSource } from '@subql/types-algorand';
import {
AlgorandApi,
AlgorandApiService,
SafeAPIService,
} from '../../algorand';
import { AlgorandProjectDs } from '../../configure/SubqueryProject';
import { AlgorandApiService } from '../../algorand';
import { IndexerManager } from '../indexer.manager';
import { BlockContent } from '../types';

Expand Down Expand Up @@ -46,7 +40,7 @@ export class WorkerService extends BaseWorkerService<
private apiService: AlgorandApiService,
private indexerManager: IndexerManager,
@Inject('IProjectService')
projectService: IProjectService<AlgorandProjectDs>,
projectService: IProjectService<AlgorandDataSource>,
@Inject('IProjectUpgradeService')
projectUpgradeService: IProjectUpgradeService,
nodeConfig: NodeConfig,
Expand Down
10 changes: 4 additions & 6 deletions packages/node/src/subcommands/testing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import {
TestRunner,
IBlock,
} from '@subql/node-core';
import { AlgorandDataSource } from '@subql/types-algorand';
import { AlgorandApi, AlgorandApiService, SafeAPIService } from '../algorand';
import {
AlgorandProjectDs,
SubqueryProject,
} from '../configure/SubqueryProject';
import { SubqueryProject } from '../configure/SubqueryProject';
import { IndexerManager } from '../indexer/indexer.manager';
import { ProjectService } from '../indexer/project.service';
import { BlockContent } from '../indexer/types';
Expand All @@ -25,7 +23,7 @@ export class TestingService extends BaseTestingService<
AlgorandApi,
SafeAPIService,
BlockContent,
AlgorandProjectDs
AlgorandDataSource
> {
constructor(
nodeConfig: NodeConfig,
Expand All @@ -41,7 +39,7 @@ export class TestingService extends BaseTestingService<
AlgorandApi,
SafeAPIService,
BlockContent,
AlgorandProjectDs
AlgorandDataSource
>,
]
> {
Expand Down
Loading
Loading