@subql/common-substrate 4.4.0 → 4.4.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/dist/.tsbuildinfo +1 -1
- package/package.json +18 -4
- package/dist/project/load.spec.d.ts +0 -1
- package/dist/project/load.spec.js +0 -15
- package/dist/project/load.spec.js.map +0 -1
- package/dist/project/project.spec.d.ts +0 -1
- package/dist/project/project.spec.js +0 -117
- package/dist/project/project.spec.js.map +0 -1
- package/src/index.ts +0 -14
- package/src/project/index.ts +0 -11
- package/src/project/load.spec.ts +0 -16
- package/src/project/load.ts +0 -34
- package/src/project/models.ts +0 -180
- package/src/project/project.spec.ts +0 -148
- package/src/project/types.ts +0 -25
- package/src/project/utils.ts +0 -45
- package/src/project/versioned/ProjectManifestVersioned.ts +0 -73
- package/src/project/versioned/index.ts +0 -5
- package/src/project/versioned/v1_0_0/index.ts +0 -4
- package/src/project/versioned/v1_0_0/model.ts +0 -175
- package/test/project_1.0.0.yaml +0 -91
- package/test/project_1.0.0_bad_processor.yaml +0 -93
- package/test/project_1.0.0_bad_runner.yaml +0 -91
- package/test/project_1.0.0_bad_runner_version.yaml +0 -91
- package/test/project_1.0.0_chainId.yaml +0 -91
- package/test/project_1.0.0_custom_ds.yaml +0 -34
- package/test/project_1.0.0_falsy.yaml +0 -33
- package/test/project_1.0.0_falsy_array.yaml +0 -32
- package/test/project_1.0.0_node_options.yaml +0 -94
- package/test/project_1.0.0_runner_ds_mismatch.yaml +0 -34
- package/test/project_bypass.yaml +0 -36
- package/test/project_bypass_range.yaml +0 -36
- package/test/project_invalid_version.yaml +0 -29
- package/tsconfig.json +0 -11
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
3
|
-
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import {
|
|
6
|
-
getManifestPath,
|
|
7
|
-
loadFromJsonOrYaml,
|
|
8
|
-
RunnerQueryBaseModel,
|
|
9
|
-
SemverVersionValidator,
|
|
10
|
-
toJsonObject,
|
|
11
|
-
} from '@subql/common';
|
|
12
|
-
import {validateSync} from 'class-validator';
|
|
13
|
-
import {DeploymentV1_0_0, SubstrateRunnerNodeImpl, SubstrateRunnerSpecsImpl} from '../project/versioned/v1_0_0';
|
|
14
|
-
import {SubstrateProjectManifestVersioned, VersionedProjectManifest} from './versioned';
|
|
15
|
-
|
|
16
|
-
const projectsDir = path.join(__dirname, '../../test');
|
|
17
|
-
|
|
18
|
-
function loadSubstrateProjectManifest(file: string): SubstrateProjectManifestVersioned {
|
|
19
|
-
const doc = loadFromJsonOrYaml(getManifestPath(file));
|
|
20
|
-
const projectManifest = new SubstrateProjectManifestVersioned(doc as VersionedProjectManifest);
|
|
21
|
-
projectManifest.validate();
|
|
22
|
-
return projectManifest;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe('project.yaml', () => {
|
|
26
|
-
it('can validate project.yaml', () => {
|
|
27
|
-
expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_falsy.yaml'))).toThrow();
|
|
28
|
-
expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_falsy_array.yaml'))).toThrow();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('can fail validation if version not supported', () => {
|
|
32
|
-
expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_invalid_version.yaml'))).toThrow();
|
|
33
|
-
});
|
|
34
|
-
it('can validate a v1.0.0 project.yaml with a custom data source', () => {
|
|
35
|
-
expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_custom_ds.yaml'))).not.toThrow();
|
|
36
|
-
});
|
|
37
|
-
it('can validate a v1.0.0 project.yaml with templates', () => {
|
|
38
|
-
expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0.yaml'))).not.toThrow();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('can convert genesis hash in v1.0.0 to chainId in deployment', () => {
|
|
42
|
-
const deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0.yaml')).asV1_0_0.deployment;
|
|
43
|
-
expect(deployment.network.chainId).not.toBeNull();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('can get chainId for deployment', () => {
|
|
47
|
-
const deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_chainId.yaml')).asV1_0_0
|
|
48
|
-
.deployment;
|
|
49
|
-
expect(deployment.network.chainId).toBe('moonbeamChainId');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('can get runner options for deployment', () => {
|
|
53
|
-
const deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_node_options.yaml')).asV1_0_0
|
|
54
|
-
.deployment;
|
|
55
|
-
expect(deployment.runner.node.options?.unsafe).toBeTruthy();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('can validate deployment runner versions', () => {
|
|
59
|
-
const deployment = new DeploymentV1_0_0();
|
|
60
|
-
const nodeImp = new SubstrateRunnerNodeImpl();
|
|
61
|
-
const queryImp = new RunnerQueryBaseModel();
|
|
62
|
-
deployment.specVersion = '1.0.0';
|
|
63
|
-
deployment.runner = new SubstrateRunnerSpecsImpl();
|
|
64
|
-
|
|
65
|
-
nodeImp.name = '@subql/node';
|
|
66
|
-
nodeImp.version = '0.29.1';
|
|
67
|
-
deployment.runner.node = nodeImp;
|
|
68
|
-
|
|
69
|
-
queryImp.name = '@subql/query';
|
|
70
|
-
queryImp.version = '0.213.1';
|
|
71
|
-
|
|
72
|
-
deployment.runner.query = queryImp;
|
|
73
|
-
|
|
74
|
-
validateSync(deployment.runner, {whitelist: true, forbidNonWhitelisted: true});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('can validate bypass blocks', () => {
|
|
78
|
-
const deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_bypass.yaml')).asV1_0_0.deployment;
|
|
79
|
-
const range_deployment = loadSubstrateProjectManifest(path.join(projectsDir, 'project_bypass_range.yaml')).asV1_0_0
|
|
80
|
-
.deployment;
|
|
81
|
-
|
|
82
|
-
expect(deployment.network.bypassBlocks).not.toBeNull();
|
|
83
|
-
expect(range_deployment.network.bypassBlocks).not.toBeNull();
|
|
84
|
-
|
|
85
|
-
expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_bypass.yaml'))).not.toThrow();
|
|
86
|
-
expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_bypass_range.yaml'))).not.toThrow();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('can validate a v1.0.0 project.yaml with unsupported runner node', () => {
|
|
90
|
-
expect(() => loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_bad_runner.yaml'))).toThrow();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('can throw error with unsupported runner version', () => {
|
|
94
|
-
expect(() =>
|
|
95
|
-
loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_bad_runner_version.yaml'))
|
|
96
|
-
).toThrow();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('can validate a v1.0.0 project.yaml runner and datasource mismatches', () => {
|
|
100
|
-
expect(() =>
|
|
101
|
-
loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0_runner_ds_mismatch.yaml'))
|
|
102
|
-
).toThrow();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('can fail validation if custom ds missing processor', () => {
|
|
106
|
-
expect(() =>
|
|
107
|
-
loadSubstrateProjectManifest(path.join(projectsDir, 'project_0.2.0_invalid_custom_ds.yaml'))
|
|
108
|
-
).toThrow();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('can convert project with assets to deployment', () => {
|
|
112
|
-
const manifest = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0.yaml'));
|
|
113
|
-
expect(manifest.isV1_0_0).toBeTruthy();
|
|
114
|
-
expect(() => manifest.toDeployment()).not.toThrow();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('validate versions', () => {
|
|
118
|
-
const checkVersion = new SemverVersionValidator();
|
|
119
|
-
// Versions
|
|
120
|
-
expect(checkVersion.validate('*')).toBeTruthy();
|
|
121
|
-
expect(checkVersion.validate('0.0.0')).toBeTruthy();
|
|
122
|
-
expect(checkVersion.validate('0.1.0')).toBeTruthy();
|
|
123
|
-
expect(checkVersion.validate('1.2.0')).toBeTruthy();
|
|
124
|
-
expect(checkVersion.validate('^0.0.0')).toBeTruthy();
|
|
125
|
-
expect(checkVersion.validate('>=0.1.0')).toBeTruthy();
|
|
126
|
-
expect(checkVersion.validate('<0.1.1-1')).toBeTruthy();
|
|
127
|
-
expect(checkVersion.validate('>=1.2.0')).toBeTruthy();
|
|
128
|
-
expect(checkVersion.validate('~1.2.0-1')).toBeTruthy();
|
|
129
|
-
expect(checkVersion.validate('>=1.2.0-abc')).toBeTruthy();
|
|
130
|
-
|
|
131
|
-
expect(checkVersion.validate('0.1.1-1')).toBeFalsy();
|
|
132
|
-
expect(checkVersion.validate('1.2.0-1')).toBeFalsy();
|
|
133
|
-
expect(checkVersion.validate('1.2.0-abc')).toBeFalsy();
|
|
134
|
-
expect(checkVersion.validate('~')).toBeFalsy();
|
|
135
|
-
expect(checkVersion.validate('latest')).toBeFalsy();
|
|
136
|
-
expect(checkVersion.validate('dev')).toBeFalsy();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('Preserve Map content on deployment', () => {
|
|
140
|
-
const manifest = loadSubstrateProjectManifest(path.join(projectsDir, 'project_1.0.0.yaml'));
|
|
141
|
-
|
|
142
|
-
expect((toJsonObject(manifest.asImpl.deployment.dataSources[0]) as any).assets).toEqual({
|
|
143
|
-
settings: {
|
|
144
|
-
file: './src/settings.abi.json',
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
package/src/project/types.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
3
|
-
|
|
4
|
-
import {SubstrateDatasource} from '@subql/types';
|
|
5
|
-
import {IProjectManifest} from '@subql/types-core';
|
|
6
|
-
|
|
7
|
-
// All of these used to be redefined in this file, re-exporting for simplicity
|
|
8
|
-
export {
|
|
9
|
-
SubstrateRuntimeHandler,
|
|
10
|
-
SubstrateCustomHandler,
|
|
11
|
-
SubstrateHandler,
|
|
12
|
-
SubstrateHandlerKind,
|
|
13
|
-
SubstrateDatasource as SubstrateDataSource,
|
|
14
|
-
SubstrateCustomDatasource as SubstrateCustomDataSource,
|
|
15
|
-
SubstrateBlockFilter,
|
|
16
|
-
SubstrateCallFilter,
|
|
17
|
-
SubstrateEventFilter,
|
|
18
|
-
SubstrateDatasourceProcessor,
|
|
19
|
-
SubstrateRuntimeHandlerFilter,
|
|
20
|
-
SubstrateDatasourceKind,
|
|
21
|
-
RuntimeHandlerInputMap as SubstrateRuntimeHandlerInputMap,
|
|
22
|
-
} from '@subql/types';
|
|
23
|
-
|
|
24
|
-
//make exception for runtime datasource 0.0.1
|
|
25
|
-
export type ISubstrateProjectManifest = IProjectManifest<SubstrateDatasource>;
|
package/src/project/utils.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
SecondLayerHandlerProcessor,
|
|
6
|
-
SubstrateCustomDatasource,
|
|
7
|
-
SubstrateDatasource,
|
|
8
|
-
SubstrateDatasourceKind,
|
|
9
|
-
SubstrateHandlerKind,
|
|
10
|
-
SubstrateRuntimeDatasource,
|
|
11
|
-
SubstrateMapping,
|
|
12
|
-
SubstrateCustomHandler,
|
|
13
|
-
SecondLayerHandlerProcessorArray,
|
|
14
|
-
} from '@subql/types';
|
|
15
|
-
import {BaseTemplateDataSource} from '@subql/types-core';
|
|
16
|
-
|
|
17
|
-
export function isBlockHandlerProcessor<F extends Record<string, unknown>, E>(
|
|
18
|
-
hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>
|
|
19
|
-
): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Block, F, E> {
|
|
20
|
-
return hp.baseHandlerKind === SubstrateHandlerKind.Block;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function isEventHandlerProcessor<F extends Record<string, unknown>, E>(
|
|
24
|
-
hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>
|
|
25
|
-
): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Event, F, E> {
|
|
26
|
-
return hp.baseHandlerKind === SubstrateHandlerKind.Event;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function isCallHandlerProcessor<F extends Record<string, unknown>, E>(
|
|
30
|
-
hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>
|
|
31
|
-
): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Call, F, E> {
|
|
32
|
-
return hp.baseHandlerKind === SubstrateHandlerKind.Call;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function isCustomDs<F extends SubstrateMapping<SubstrateCustomHandler>>(
|
|
36
|
-
ds: SubstrateDatasource | BaseTemplateDataSource<SubstrateDatasource>
|
|
37
|
-
): ds is SubstrateCustomDatasource<string, F> {
|
|
38
|
-
return ds.kind !== SubstrateDatasourceKind.Runtime && !!(ds as SubstrateCustomDatasource<string, F>).processor;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function isRuntimeDs(
|
|
42
|
-
ds: SubstrateDatasource | BaseTemplateDataSource<SubstrateDatasource>
|
|
43
|
-
): ds is SubstrateRuntimeDatasource {
|
|
44
|
-
return ds.kind === SubstrateDatasourceKind.Runtime;
|
|
45
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
3
|
-
|
|
4
|
-
import {SubstrateDatasource} from '@subql/types';
|
|
5
|
-
import {plainToClass} from 'class-transformer';
|
|
6
|
-
import {ISubstrateProjectManifest} from '../types';
|
|
7
|
-
import {ProjectManifestV1_0_0Impl} from './v1_0_0';
|
|
8
|
-
export type VersionedProjectManifest = {specVersion: string};
|
|
9
|
-
|
|
10
|
-
/* Retain support for all versions here to continue support for migrations */
|
|
11
|
-
const SUBSTRATE_SUPPORTED_VERSIONS = {
|
|
12
|
-
'1.0.0': ProjectManifestV1_0_0Impl,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type Versions = keyof typeof SUBSTRATE_SUPPORTED_VERSIONS;
|
|
16
|
-
|
|
17
|
-
export type ProjectManifestImpls = InstanceType<(typeof SUBSTRATE_SUPPORTED_VERSIONS)[Versions]>;
|
|
18
|
-
|
|
19
|
-
export function manifestIsV1_0_0(manifest: ISubstrateProjectManifest): manifest is ProjectManifestV1_0_0Impl {
|
|
20
|
-
return manifest.specVersion === '1.0.0';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class SubstrateProjectManifestVersioned implements ISubstrateProjectManifest {
|
|
24
|
-
private _impl: ProjectManifestImpls;
|
|
25
|
-
|
|
26
|
-
constructor(projectManifest: VersionedProjectManifest) {
|
|
27
|
-
const klass = SUBSTRATE_SUPPORTED_VERSIONS[projectManifest.specVersion as Versions];
|
|
28
|
-
if (!klass) {
|
|
29
|
-
throw new Error('specVersion not supported for project manifest file');
|
|
30
|
-
}
|
|
31
|
-
this._impl = plainToClass<ProjectManifestImpls, VersionedProjectManifest>(klass, projectManifest);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get asImpl(): ProjectManifestImpls {
|
|
35
|
-
return this._impl;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get isV1_0_0(): boolean {
|
|
39
|
-
return this.specVersion === '1.0.0';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get asV1_0_0(): ProjectManifestV1_0_0Impl {
|
|
43
|
-
return this._impl as ProjectManifestV1_0_0Impl;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
toDeployment(): string {
|
|
47
|
-
return this._impl.deployment.toYaml();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
validate(): void {
|
|
51
|
-
return this._impl.validate();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get dataSources(): SubstrateDatasource[] {
|
|
55
|
-
return this._impl.dataSources;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
get schema(): string {
|
|
59
|
-
return this._impl.schema.file;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
get specVersion(): string {
|
|
63
|
-
return this._impl.specVersion;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
get description(): string | undefined {
|
|
67
|
-
return this._impl.description;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
get repository(): string | undefined {
|
|
71
|
-
return this._impl.repository;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
BaseDeploymentV1_0_0,
|
|
6
|
-
FileType,
|
|
7
|
-
ParentProjectModel,
|
|
8
|
-
ProjectManifestBaseImpl,
|
|
9
|
-
RunnerNodeImpl,
|
|
10
|
-
RunnerQueryBaseModel,
|
|
11
|
-
validateObject,
|
|
12
|
-
CommonProjectNetworkV1_0_0,
|
|
13
|
-
} from '@subql/common';
|
|
14
|
-
import {
|
|
15
|
-
SubstrateCustomDatasource,
|
|
16
|
-
SubstrateRuntimeDatasource,
|
|
17
|
-
CustomDatasourceTemplate,
|
|
18
|
-
RuntimeDatasourceTemplate,
|
|
19
|
-
SubstrateProjectManifestV1_0_0,
|
|
20
|
-
} from '@subql/types';
|
|
21
|
-
import {BaseMapping, NodeSpec, ParentProject, QuerySpec, RunnerSpecs} from '@subql/types-core';
|
|
22
|
-
import {plainToInstance, Transform, TransformFnParams, Type} from 'class-transformer';
|
|
23
|
-
import {Equals, IsArray, IsNotEmpty, IsObject, IsOptional, IsString, ValidateNested} from 'class-validator';
|
|
24
|
-
import {CustomDataSourceBase, RuntimeDataSourceBase} from '../../models';
|
|
25
|
-
|
|
26
|
-
const SUBSTRATE_NODE_NAME = `@subql/node`;
|
|
27
|
-
|
|
28
|
-
export class SubstrateRunnerNodeImpl extends RunnerNodeImpl {
|
|
29
|
-
@Equals(SUBSTRATE_NODE_NAME, {message: `Runner Substrate node name incorrect, suppose be '${SUBSTRATE_NODE_NAME}'`})
|
|
30
|
-
name: string = SUBSTRATE_NODE_NAME;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class SubstrateRuntimeDataSourceImpl extends RuntimeDataSourceBase implements SubstrateRuntimeDatasource {
|
|
34
|
-
validate(): void {
|
|
35
|
-
return validateObject(this, 'failed to validate runtime datasource.');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class SubstrateCustomDataSourceImpl<K extends string = string, M extends BaseMapping<any> = BaseMapping<any>>
|
|
40
|
-
extends CustomDataSourceBase<K, M>
|
|
41
|
-
implements SubstrateCustomDatasource<K, M>
|
|
42
|
-
{
|
|
43
|
-
validate(): void {
|
|
44
|
-
return validateObject(this, 'failed to validate custom datasource.');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export class RuntimeDatasourceTemplateImpl extends SubstrateRuntimeDataSourceImpl implements RuntimeDatasourceTemplate {
|
|
49
|
-
@IsString()
|
|
50
|
-
name!: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class CustomDatasourceTemplateImpl extends SubstrateCustomDataSourceImpl implements CustomDatasourceTemplate {
|
|
54
|
-
@IsString()
|
|
55
|
-
name!: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export class SubstrateRunnerSpecsImpl implements RunnerSpecs {
|
|
59
|
-
@IsObject()
|
|
60
|
-
@ValidateNested()
|
|
61
|
-
@Type(() => SubstrateRunnerNodeImpl)
|
|
62
|
-
node!: NodeSpec;
|
|
63
|
-
@IsObject()
|
|
64
|
-
@ValidateNested()
|
|
65
|
-
@Type(() => RunnerQueryBaseModel)
|
|
66
|
-
query!: QuerySpec;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ChainTypes is different with other network
|
|
70
|
-
export class ProjectNetworkDeploymentV1_0_0 {
|
|
71
|
-
@IsNotEmpty()
|
|
72
|
-
@Transform(({value}: TransformFnParams) => value.trim())
|
|
73
|
-
@IsString()
|
|
74
|
-
chainId!: string;
|
|
75
|
-
@ValidateNested()
|
|
76
|
-
@Type(() => FileType)
|
|
77
|
-
@IsOptional()
|
|
78
|
-
chaintypes?: FileType = undefined;
|
|
79
|
-
@IsOptional()
|
|
80
|
-
@IsArray()
|
|
81
|
-
bypassBlocks?: (number | string)[];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export class ProjectNetworkV1_0_0 extends CommonProjectNetworkV1_0_0<FileType> {
|
|
85
|
-
@Type(() => FileType)
|
|
86
|
-
@IsOptional()
|
|
87
|
-
chaintypes?: FileType = undefined;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export class DeploymentV1_0_0 extends BaseDeploymentV1_0_0 {
|
|
91
|
-
@Transform((params) => {
|
|
92
|
-
if (params.value.genesisHash && !params.value.chainId) {
|
|
93
|
-
params.value.chainId = params.value.genesisHash;
|
|
94
|
-
}
|
|
95
|
-
return plainToInstance(ProjectNetworkDeploymentV1_0_0, params.value);
|
|
96
|
-
})
|
|
97
|
-
@ValidateNested()
|
|
98
|
-
@Type(() => ProjectNetworkDeploymentV1_0_0)
|
|
99
|
-
network!: ProjectNetworkDeploymentV1_0_0;
|
|
100
|
-
@IsObject()
|
|
101
|
-
@ValidateNested()
|
|
102
|
-
@Type(() => SubstrateRunnerSpecsImpl)
|
|
103
|
-
runner!: RunnerSpecs;
|
|
104
|
-
@IsArray()
|
|
105
|
-
@ValidateNested()
|
|
106
|
-
@Type(() => SubstrateCustomDataSourceImpl, {
|
|
107
|
-
discriminator: {
|
|
108
|
-
property: 'kind',
|
|
109
|
-
subTypes: [{value: SubstrateRuntimeDataSourceImpl, name: 'substrate/Runtime'}],
|
|
110
|
-
},
|
|
111
|
-
keepDiscriminatorProperty: true,
|
|
112
|
-
})
|
|
113
|
-
dataSources!: (SubstrateRuntimeDatasource | SubstrateCustomDatasource)[];
|
|
114
|
-
@IsOptional()
|
|
115
|
-
@IsArray()
|
|
116
|
-
@ValidateNested()
|
|
117
|
-
@Type(() => CustomDatasourceTemplateImpl, {
|
|
118
|
-
discriminator: {
|
|
119
|
-
property: 'kind',
|
|
120
|
-
subTypes: [{value: RuntimeDatasourceTemplateImpl, name: 'substrate/Runtime'}],
|
|
121
|
-
},
|
|
122
|
-
keepDiscriminatorProperty: true,
|
|
123
|
-
})
|
|
124
|
-
templates?: (RuntimeDatasourceTemplate | CustomDatasourceTemplate)[];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export class ProjectManifestV1_0_0Impl
|
|
128
|
-
extends ProjectManifestBaseImpl<DeploymentV1_0_0>
|
|
129
|
-
implements SubstrateProjectManifestV1_0_0
|
|
130
|
-
{
|
|
131
|
-
constructor() {
|
|
132
|
-
super(DeploymentV1_0_0);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
@Equals('1.0.0')
|
|
136
|
-
specVersion = '1.0.0';
|
|
137
|
-
@Type(() => SubstrateCustomDataSourceImpl, {
|
|
138
|
-
discriminator: {
|
|
139
|
-
property: 'kind',
|
|
140
|
-
subTypes: [{value: SubstrateRuntimeDataSourceImpl, name: 'substrate/Runtime'}],
|
|
141
|
-
},
|
|
142
|
-
keepDiscriminatorProperty: true,
|
|
143
|
-
})
|
|
144
|
-
dataSources!: (SubstrateRuntimeDatasource | SubstrateCustomDatasource)[];
|
|
145
|
-
@Type(() => ProjectNetworkV1_0_0)
|
|
146
|
-
network!: ProjectNetworkV1_0_0;
|
|
147
|
-
@IsOptional()
|
|
148
|
-
@IsString()
|
|
149
|
-
name?: string;
|
|
150
|
-
@IsString()
|
|
151
|
-
version!: string;
|
|
152
|
-
@ValidateNested()
|
|
153
|
-
@Type(() => FileType)
|
|
154
|
-
schema!: FileType;
|
|
155
|
-
@IsOptional()
|
|
156
|
-
@IsArray()
|
|
157
|
-
@ValidateNested()
|
|
158
|
-
@Type(() => CustomDatasourceTemplateImpl, {
|
|
159
|
-
discriminator: {
|
|
160
|
-
property: 'kind',
|
|
161
|
-
subTypes: [{value: RuntimeDatasourceTemplateImpl, name: 'substrate/Runtime'}],
|
|
162
|
-
},
|
|
163
|
-
keepDiscriminatorProperty: true,
|
|
164
|
-
})
|
|
165
|
-
templates?: (RuntimeDatasourceTemplate | CustomDatasourceTemplate)[];
|
|
166
|
-
@IsObject()
|
|
167
|
-
@ValidateNested()
|
|
168
|
-
@Type(() => SubstrateRunnerSpecsImpl)
|
|
169
|
-
runner!: RunnerSpecs;
|
|
170
|
-
|
|
171
|
-
@IsOptional()
|
|
172
|
-
@IsObject()
|
|
173
|
-
@Type(() => ParentProjectModel)
|
|
174
|
-
parent?: ParentProject;
|
|
175
|
-
}
|
package/test/project_1.0.0.yaml
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
specVersion: 1.0.0
|
|
2
|
-
name: subquery-query-registry-project
|
|
3
|
-
version: 1.0.0
|
|
4
|
-
description: ''
|
|
5
|
-
repository: ''
|
|
6
|
-
runner:
|
|
7
|
-
node:
|
|
8
|
-
name: '@subql/node'
|
|
9
|
-
version: '0.28.0'
|
|
10
|
-
query:
|
|
11
|
-
name: '@subql/query'
|
|
12
|
-
version: '^0.12.0'
|
|
13
|
-
schema:
|
|
14
|
-
file: ./schema.graphql
|
|
15
|
-
network:
|
|
16
|
-
# genesisHash: '0x956876d5b80e47e523a6629b3c3ac3e42f2850ad12e236d87a0aaac87c9f6bc9' # Moonriver
|
|
17
|
-
genesisHash: '0x91bc6e169807aaa54802737e1c504b2577d4fafedd5a02c10293b1cd60e39527' # Moonbase Alpha
|
|
18
|
-
endpoint: wss://moonbeam-alpha.api.onfinality.io/public-ws
|
|
19
|
-
dictionary: https://api.subquery.network/sq/subquery/moonbase-alpha-dictionary
|
|
20
|
-
|
|
21
|
-
chaintypes:
|
|
22
|
-
file: './types.yaml'
|
|
23
|
-
dataSources:
|
|
24
|
-
- kind: substrate/Moonbeam
|
|
25
|
-
startBlock: 1358833
|
|
26
|
-
processor:
|
|
27
|
-
file: './node_modules/@subql/contract-processors/dist/moonbeam.js'
|
|
28
|
-
options:
|
|
29
|
-
abi: settings
|
|
30
|
-
address: '0xde030fC2b42AE2438B32506ECf63B2f3c1665579'
|
|
31
|
-
assets:
|
|
32
|
-
settings:
|
|
33
|
-
file: ./src/settings.abi.json
|
|
34
|
-
mapping:
|
|
35
|
-
file: ./dist/index.js
|
|
36
|
-
handlers:
|
|
37
|
-
- handler: handleUpdateSettings
|
|
38
|
-
kind: substrate/MoonbeamCall
|
|
39
|
-
filter:
|
|
40
|
-
function: setAllAddresses(address _sqToken,address _staking,address _indexerRegistry,address _queryRegistry) # add ",address _serviceAgreementRegistry" in later versions
|
|
41
|
-
|
|
42
|
-
templates:
|
|
43
|
-
- name: QueryRegistry
|
|
44
|
-
kind: substrate/Moonbeam
|
|
45
|
-
startBlock: 1358829
|
|
46
|
-
processor:
|
|
47
|
-
file: './node_modules/@subql/contract-processors/dist/moonbeam.js'
|
|
48
|
-
options:
|
|
49
|
-
abi: queryRegistry
|
|
50
|
-
# address: '0xB0b3f6bc7a8E0bCb2aa1Cd2Ae2dE56fbdA3c0651'
|
|
51
|
-
assets:
|
|
52
|
-
queryRegistry:
|
|
53
|
-
file: ./src/queryRegistry.abi.json
|
|
54
|
-
mapping:
|
|
55
|
-
file: ./dist/index.js
|
|
56
|
-
handlers:
|
|
57
|
-
- handler: handleNewQuery
|
|
58
|
-
kind: substrate/MoonbeamEvent
|
|
59
|
-
filter:
|
|
60
|
-
topics:
|
|
61
|
-
- CreateQuery(uint256 queryId, address creator, bytes32 metadata, bytes32 deploymentId, bytes32 version)
|
|
62
|
-
- handler: handleUpdateQueryMetadata
|
|
63
|
-
kind: substrate/MoonbeamEvent
|
|
64
|
-
filter:
|
|
65
|
-
topics:
|
|
66
|
-
- UpdateQueryMetadata(address owner, uint256 queryId, bytes32 metadata)
|
|
67
|
-
- handler: handleUpdateQueryDeployment
|
|
68
|
-
kind: substrate/MoonbeamEvent
|
|
69
|
-
filter:
|
|
70
|
-
topics:
|
|
71
|
-
- UpdateQueryDeployment(address owner, uint256 queryId, bytes32 deploymentId, bytes32 version)
|
|
72
|
-
- handler: handleStartIndexing
|
|
73
|
-
kind: substrate/MoonbeamEvent
|
|
74
|
-
filter:
|
|
75
|
-
topics:
|
|
76
|
-
- StartIndexing(address indexer, bytes32 deploymentId)
|
|
77
|
-
- handler: handleIndexingUpdate
|
|
78
|
-
kind: substrate/MoonbeamEvent
|
|
79
|
-
filter:
|
|
80
|
-
topics:
|
|
81
|
-
- UpdateDeploymentStatus(address indexer, bytes32 deploymentId, uint256 blockheight, bytes32 mmrRoot, uint256 timestamp)
|
|
82
|
-
- handler: handleIndexingReady
|
|
83
|
-
kind: substrate/MoonbeamEvent
|
|
84
|
-
filter:
|
|
85
|
-
topics:
|
|
86
|
-
- UpdateIndexingStatusToReady(address indexer, bytes32 deploymentId, uint256 _timestamp)
|
|
87
|
-
- handler: handleStopIndexing
|
|
88
|
-
kind: substrate/MoonbeamEvent
|
|
89
|
-
filter:
|
|
90
|
-
topics:
|
|
91
|
-
- StopIndexing(address indexer, bytes32 deploymentId)
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
specVersion: 1.0.0
|
|
2
|
-
name: subquery-query-registry-project
|
|
3
|
-
version: 1.0.0
|
|
4
|
-
description: ''
|
|
5
|
-
repository: ''
|
|
6
|
-
runner:
|
|
7
|
-
node:
|
|
8
|
-
name: '@subql/node'
|
|
9
|
-
version: '0.28.0'
|
|
10
|
-
query:
|
|
11
|
-
name: '@subql/query'
|
|
12
|
-
version: '^0.12.0'
|
|
13
|
-
schema:
|
|
14
|
-
file: ./schema.graphql
|
|
15
|
-
network:
|
|
16
|
-
# genesisHash: '0x956876d5b80e47e523a6629b3c3ac3e42f2850ad12e236d87a0aaac87c9f6bc9' # Moonriver
|
|
17
|
-
genesisHash: '0x91bc6e169807aaa54802737e1c504b2577d4fafedd5a02c10293b1cd60e39527' # Moonbase Alpha
|
|
18
|
-
endpoint: wss://moonbeam-alpha.api.onfinality.io/public-ws
|
|
19
|
-
dictionary: https://api.subquery.network/sq/subquery/moonbase-alpha-dictionary
|
|
20
|
-
|
|
21
|
-
chaintypes:
|
|
22
|
-
file: './types.yaml'
|
|
23
|
-
dataSources:
|
|
24
|
-
- kind: substrate/Moonbeam
|
|
25
|
-
startBlock: 1358833
|
|
26
|
-
processor:
|
|
27
|
-
file: './node_modules/@subql/contract-processors/dist/moonbeam.js'
|
|
28
|
-
something:
|
|
29
|
-
unexpected: 'should throw'
|
|
30
|
-
options:
|
|
31
|
-
abi: settings
|
|
32
|
-
address: '0xde030fC2b42AE2438B32506ECf63B2f3c1665579'
|
|
33
|
-
assets:
|
|
34
|
-
settings:
|
|
35
|
-
file: ./src/settings.abi.json
|
|
36
|
-
mapping:
|
|
37
|
-
file: ./dist/index.js
|
|
38
|
-
handlers:
|
|
39
|
-
- handler: handleUpdateSettings
|
|
40
|
-
kind: substrate/MoonbeamCall
|
|
41
|
-
filter:
|
|
42
|
-
function: setAllAddresses(address _sqToken,address _staking,address _indexerRegistry,address _queryRegistry) # add ",address _serviceAgreementRegistry" in later versions
|
|
43
|
-
|
|
44
|
-
templates:
|
|
45
|
-
- name: QueryRegistry
|
|
46
|
-
kind: substrate/Moonbeam
|
|
47
|
-
startBlock: 1358829
|
|
48
|
-
processor:
|
|
49
|
-
file: './node_modules/@subql/contract-processors/dist/moonbeam.js'
|
|
50
|
-
options:
|
|
51
|
-
abi: queryRegistry
|
|
52
|
-
# address: '0xB0b3f6bc7a8E0bCb2aa1Cd2Ae2dE56fbdA3c0651'
|
|
53
|
-
assets:
|
|
54
|
-
queryRegistry:
|
|
55
|
-
file: ./src/queryRegistry.abi.json
|
|
56
|
-
mapping:
|
|
57
|
-
file: ./dist/index.js
|
|
58
|
-
handlers:
|
|
59
|
-
- handler: handleNewQuery
|
|
60
|
-
kind: substrate/MoonbeamEvent
|
|
61
|
-
filter:
|
|
62
|
-
topics:
|
|
63
|
-
- CreateQuery(uint256 queryId, address creator, bytes32 metadata, bytes32 deploymentId, bytes32 version)
|
|
64
|
-
- handler: handleUpdateQueryMetadata
|
|
65
|
-
kind: substrate/MoonbeamEvent
|
|
66
|
-
filter:
|
|
67
|
-
topics:
|
|
68
|
-
- UpdateQueryMetadata(address owner, uint256 queryId, bytes32 metadata)
|
|
69
|
-
- handler: handleUpdateQueryDeployment
|
|
70
|
-
kind: substrate/MoonbeamEvent
|
|
71
|
-
filter:
|
|
72
|
-
topics:
|
|
73
|
-
- UpdateQueryDeployment(address owner, uint256 queryId, bytes32 deploymentId, bytes32 version)
|
|
74
|
-
- handler: handleStartIndexing
|
|
75
|
-
kind: substrate/MoonbeamEvent
|
|
76
|
-
filter:
|
|
77
|
-
topics:
|
|
78
|
-
- StartIndexing(address indexer, bytes32 deploymentId)
|
|
79
|
-
- handler: handleIndexingUpdate
|
|
80
|
-
kind: substrate/MoonbeamEvent
|
|
81
|
-
filter:
|
|
82
|
-
topics:
|
|
83
|
-
- UpdateDeploymentStatus(address indexer, bytes32 deploymentId, uint256 blockheight, bytes32 mmrRoot, uint256 timestamp)
|
|
84
|
-
- handler: handleIndexingReady
|
|
85
|
-
kind: substrate/MoonbeamEvent
|
|
86
|
-
filter:
|
|
87
|
-
topics:
|
|
88
|
-
- UpdateIndexingStatusToReady(address indexer, bytes32 deploymentId, uint256 _timestamp)
|
|
89
|
-
- handler: handleStopIndexing
|
|
90
|
-
kind: substrate/MoonbeamEvent
|
|
91
|
-
filter:
|
|
92
|
-
topics:
|
|
93
|
-
- StopIndexing(address indexer, bytes32 deploymentId)
|