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

Changes to types to fix issues with eth SDK #2484

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions packages/common-substrate/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]
### Removed
- Unused functions (#2484)

## [4.0.1] - 2024-07-09
### Changed
Expand Down
16 changes: 0 additions & 16 deletions packages/common-substrate/src/project/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ import {
SubstrateDatasourceKind,
SubstrateHandlerKind,
SubstrateRuntimeDatasource,
CustomDatasourceTemplate,
RuntimeDatasourceTemplate,
SubstrateMapping,
SubstrateCustomHandler,
SecondLayerHandlerProcessorArray,
} from '@subql/types';
import {BaseTemplateDataSource} from '@subql/types-core';
import {gte} from 'semver';

export function isBlockHandlerProcessor<F extends Record<string, unknown>, E>(
hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>
Expand All @@ -35,12 +32,6 @@ export function isCallHandlerProcessor<F extends Record<string, unknown>, E>(
return hp.baseHandlerKind === SubstrateHandlerKind.Call;
}

function debug<F extends Record<string, unknown>, E>(
hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>
): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Call, F, E> {
return hp.baseHandlerKind === SubstrateHandlerKind.Call;
}

export function isCustomDs<F extends SubstrateMapping<SubstrateCustomHandler>>(
ds: SubstrateDatasource | BaseTemplateDataSource<SubstrateDatasource>
): ds is SubstrateCustomDatasource<string, F> {
Expand All @@ -50,10 +41,3 @@ export function isCustomDs<F extends SubstrateMapping<SubstrateCustomHandler>>(
export function isRuntimeDs(ds: SubstrateDatasource): ds is SubstrateRuntimeDatasource {
return ds.kind === SubstrateDatasourceKind.Runtime;
}

export function isSubstrateTemplates(
templatesData: any,
specVersion: string
): templatesData is (RuntimeDatasourceTemplate | CustomDatasourceTemplate)[] {
return (isRuntimeDs(templatesData[0]) || isCustomDs(templatesData[0])) && gte(specVersion, '0.2.1');
}
1 change: 1 addition & 0 deletions packages/node-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Create interval for flushing the cache, this is to support chains that only produce blocks with new transactions (#2485)
- Improved types for strict TS setting (#2484)

## [10.10.2] - 2024-07-10
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/node-core/src/indexer/dictionary/v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export interface DictionaryV2Metadata {
supported: string[];
}

export type DictionaryV2QueryEntry = Record<string, object>;
export type DictionaryV2QueryEntry = Record<string, unknown>;
12 changes: 7 additions & 5 deletions packages/node-core/src/indexer/indexer.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ export type FilterTypeMap<DS extends BaseDataSource = BaseDataSource> = Record<
string,
(data: any, filter: any, ds: DS) => boolean
>;
export type ProcessorTypeMap<FM extends FilterTypeMap> = {[K in keyof FM]: (data: any) => boolean};
export type HandlerInputTypeMap<FM extends FilterTypeMap> = {[K in keyof FM]: any};
export type ProcessorTypeMap<DS extends BaseDataSource, FM extends FilterTypeMap<DS>> = {
[K in keyof FM]: (data: any) => boolean;
};
export type HandlerInputTypeMap<DS extends BaseDataSource, FM extends FilterTypeMap<DS>> = {[K in keyof FM]: any};

export interface CustomHandler<K extends string = string, F = Record<string, unknown>> {
handler: string;
Expand All @@ -39,9 +41,9 @@ export abstract class BaseIndexerManager<
API extends IApi<A, SA, IBlock<B>[]>,
DS extends BaseDataSource,
CDS extends DS & BaseCustomDataSource, // Custom datasource
FilterMap extends FilterTypeMap,
ProcessorMap extends ProcessorTypeMap<FilterMap>,
HandlerInputMap extends HandlerInputTypeMap<FilterMap>
FilterMap extends FilterTypeMap<DS>,
ProcessorMap extends ProcessorTypeMap<DS, FilterMap>,
HandlerInputMap extends HandlerInputTypeMap<DS, FilterMap>,
> implements IIndexerManager<B, DS>
{
abstract indexBlock(block: IBlock<B>, datasources: DS[], ...args: any[]): Promise<ProcessBlockResponse>;
Expand Down
2 changes: 1 addition & 1 deletion packages/node-core/src/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export async function updateDataSourcesV1_0_0<DS extends BaseDataSource, CDS ext
_dataSources.map(async (dataSource) => {
dataSource.startBlock = dataSource.startBlock ?? 1;
const entryScript = await loadDataSourceScript(reader, dataSource.mapping.file);
if (isAssetsDs(dataSource)) {
if (isAssetsDs(dataSource) && dataSource.assets) {
for (const [, asset] of dataSource.assets.entries()) {
// Only need to resolve path for local file
if (reader instanceof LocalReader) {
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]
### Removed
- Unused type (#2484)

## [4.8.0] - 2024-07-10
### Changed
Expand Down
6 changes: 0 additions & 6 deletions packages/node/src/indexer/indexer.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@ export class IndexerManager extends BaseIndexerManager<
}
}

type ProcessorTypeMap = {
[SubstrateHandlerKind.Block]: typeof isBlockHandlerProcessor;
[SubstrateHandlerKind.Event]: typeof isEventHandlerProcessor;
[SubstrateHandlerKind.Call]: typeof isCallHandlerProcessor;
};

const ProcessorTypeMap = {
[SubstrateHandlerKind.Block]: isBlockHandlerProcessor,
[SubstrateHandlerKind.Event]: isEventHandlerProcessor,
Expand Down
2 changes: 2 additions & 0 deletions packages/types-core/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
- Make assets optional on `BaseAssetsDataSource` (#2484)

## [0.9.1] - 2024-07-09
### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/types-core/src/project/versioned/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface BaseAssetsDataSource {
* @example
* assets: new Map([['erc20', './abis/erc20.json']])
*/
assets: Map<string, FileReference>;
assets?: Map<string, FileReference>;
}

export interface BaseMapping<T extends BaseHandler> extends FileReference {
Expand Down
Loading