@subql/common-substrate 4.5.3 → 4.5.4
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 +4 -1
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/project/index.d.ts +7 -0
- package/dist/project/index.js +27 -0
- package/dist/project/index.js.map +1 -0
- package/dist/project/load.d.ts +4 -0
- package/dist/project/load.js +35 -0
- package/dist/project/load.js.map +1 -0
- package/dist/project/models.d.ts +63 -0
- package/dist/project/models.js +264 -0
- package/dist/project/models.js.map +1 -0
- package/dist/project/types.d.ts +4 -0
- package/dist/project/types.js +10 -0
- package/dist/project/types.js.map +1 -0
- package/dist/project/utils.d.ts +7 -0
- package/dist/project/utils.js +26 -0
- package/dist/project/utils.js.map +1 -0
- package/dist/project/versioned/ProjectManifestVersioned.d.ts +27 -0
- package/dist/project/versioned/ProjectManifestVersioned.js +57 -0
- package/dist/project/versioned/ProjectManifestVersioned.js.map +1 -0
- package/dist/project/versioned/index.d.ts +2 -0
- package/dist/project/versioned/index.js +21 -0
- package/dist/project/versioned/index.js.map +1 -0
- package/dist/project/versioned/v1_0_0/index.d.ts +1 -0
- package/dist/project/versioned/v1_0_0/index.js +20 -0
- package/dist/project/versioned/v1_0_0/index.js.map +1 -0
- package/dist/project/versioned/v1_0_0/model.d.ts +49 -0
- package/dist/project/versioned/v1_0_0/model.js +227 -0
- package/dist/project/versioned/v1_0_0/model.js.map +1 -0
- package/package.json +3 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './project';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
__exportStar(require("./project"), exports);
|
|
42
|
+
const p = __importStar(require("./project"));
|
|
43
|
+
// This provides a compiled time check to ensure that the correct exports are provided
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
|
+
const _ = {
|
|
46
|
+
...p,
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnC,4CAA0B;AAI1B,6CAA+B;AAE/B,sFAAsF;AACtF,6DAA6D;AAC7D,MAAM,CAAC,GAAG;IACR,GAAG,CAAC;CACsG,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nexport * from './project';\n\nimport {SubstrateCustomDatasource, SubstrateDatasource, SubstrateRuntimeDatasource} from '@subql/types';\nimport {INetworkCommonModule} from '@subql/types-core';\nimport * as p from './project';\n\n// This provides a compiled time check to ensure that the correct exports are provided\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst _ = {\n ...p,\n} satisfies INetworkCommonModule<SubstrateDatasource, SubstrateRuntimeDatasource, SubstrateCustomDatasource>;\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.parseProjectManifest = void 0;
|
|
20
|
+
__exportStar(require("./load"), exports);
|
|
21
|
+
__exportStar(require("./models"), exports);
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
23
|
+
__exportStar(require("./utils"), exports);
|
|
24
|
+
__exportStar(require("./versioned"), exports);
|
|
25
|
+
const load_1 = require("./load");
|
|
26
|
+
Object.defineProperty(exports, "parseProjectManifest", { enumerable: true, get: function () { return load_1.parseSubstrateProjectManifest; } });
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;;AAEnC,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB;AACxB,8CAA4B;AAE5B,iCAAqD;AACZ,qGADjC,oCAA6B,OACwB","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nexport * from './load';\nexport * from './models';\nexport * from './types';\nexport * from './utils';\nexport * from './versioned';\n\nimport {parseSubstrateProjectManifest} from './load';\nexport {parseSubstrateProjectManifest as parseProjectManifest};\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChainTypes } from './models';
|
|
2
|
+
import { SubstrateProjectManifestVersioned } from './versioned';
|
|
3
|
+
export declare function parseSubstrateProjectManifest(raw: unknown): SubstrateProjectManifestVersioned;
|
|
4
|
+
export declare function parseChainTypes(raw: unknown): ChainTypes;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.parseSubstrateProjectManifest = parseSubstrateProjectManifest;
|
|
6
|
+
exports.parseChainTypes = parseChainTypes;
|
|
7
|
+
const class_transformer_1 = require("class-transformer");
|
|
8
|
+
const class_validator_1 = require("class-validator");
|
|
9
|
+
const models_1 = require("./models");
|
|
10
|
+
const versioned_1 = require("./versioned");
|
|
11
|
+
function parseSubstrateProjectManifest(raw) {
|
|
12
|
+
const projectManifest = new versioned_1.SubstrateProjectManifestVersioned(raw);
|
|
13
|
+
projectManifest.validate();
|
|
14
|
+
return projectManifest;
|
|
15
|
+
}
|
|
16
|
+
function parseChainTypes(raw) {
|
|
17
|
+
const chainTypes = (0, class_transformer_1.plainToClass)(models_1.ChainTypes, raw);
|
|
18
|
+
if (!!chainTypes.types ||
|
|
19
|
+
!!chainTypes.typesChain ||
|
|
20
|
+
!!chainTypes.typesBundle ||
|
|
21
|
+
!!chainTypes.typesAlias ||
|
|
22
|
+
!!chainTypes.typesSpec) {
|
|
23
|
+
const errors = (0, class_validator_1.validateSync)(chainTypes, { whitelist: true, forbidNonWhitelisted: true });
|
|
24
|
+
if (errors?.length) {
|
|
25
|
+
// TODO: print error details
|
|
26
|
+
const errorMsgs = errors.map((e) => e.toString()).join('\n');
|
|
27
|
+
throw new Error(`failed to parse chain types.\n${errorMsgs}`);
|
|
28
|
+
}
|
|
29
|
+
return chainTypes;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new Error(`chainTypes is not valid`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=load.js.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right 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {plainToClass} from 'class-transformer';\nimport {validateSync} from 'class-validator';\nimport {ChainTypes} from './models';\nimport {SubstrateProjectManifestVersioned, VersionedProjectManifest} from './versioned';\n\nexport function parseSubstrateProjectManifest(raw: unknown): SubstrateProjectManifestVersioned {\n const projectManifest = new SubstrateProjectManifestVersioned(raw as VersionedProjectManifest);\n projectManifest.validate();\n return projectManifest;\n}\n\nexport function parseChainTypes(raw: unknown): ChainTypes {\n const chainTypes = plainToClass(ChainTypes, raw);\n if (\n !!chainTypes.types ||\n !!chainTypes.typesChain ||\n !!chainTypes.typesBundle ||\n !!chainTypes.typesAlias ||\n !!chainTypes.typesSpec\n ) {\n const errors = validateSync(chainTypes, {whitelist: true, forbidNonWhitelisted: true});\n if (errors?.length) {\n // TODO: print error details\n const errorMsgs = errors.map((e) => e.toString()).join('\\n');\n throw new Error(`failed to parse chain types.\\n${errorMsgs}`);\n }\n return chainTypes;\n } else {\n throw new Error(`chainTypes is not valid`);\n }\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { RegisteredTypes, RegistryTypes, OverrideModuleType, OverrideBundleType } from '@polkadot/types/types';
|
|
2
|
+
import { BaseDataSource, BlockFilterImpl } from '@subql/common';
|
|
3
|
+
import { SubstrateBlockFilter, SubstrateBlockHandler, SubstrateCallFilter, SubstrateCallHandler, SubstrateCustomHandler, SubstrateDatasourceKind, SubstrateEventFilter, SubstrateEventHandler, SubstrateHandlerKind, SubstrateRuntimeDatasource, SubstrateRuntimeHandler, SubstrateCustomDatasource } from '@subql/types';
|
|
4
|
+
import { BaseMapping, FileReference, Processor } from '@subql/types-core';
|
|
5
|
+
export declare class BlockFilter extends BlockFilterImpl implements SubstrateBlockFilter {
|
|
6
|
+
specVersion?: [number, number];
|
|
7
|
+
}
|
|
8
|
+
export declare class EventFilter implements SubstrateEventFilter {
|
|
9
|
+
module?: string;
|
|
10
|
+
method?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class ChainTypes implements RegisteredTypes {
|
|
13
|
+
types?: RegistryTypes;
|
|
14
|
+
typesAlias?: Record<string, OverrideModuleType>;
|
|
15
|
+
typesBundle?: OverrideBundleType;
|
|
16
|
+
typesChain?: Record<string, RegistryTypes>;
|
|
17
|
+
typesSpec?: Record<string, RegistryTypes>;
|
|
18
|
+
}
|
|
19
|
+
export declare class CallFilter extends EventFilter implements SubstrateCallFilter {
|
|
20
|
+
success?: boolean;
|
|
21
|
+
isSigned?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare class BlockHandler implements SubstrateBlockHandler {
|
|
24
|
+
filter?: SubstrateBlockFilter;
|
|
25
|
+
kind: SubstrateHandlerKind.Block;
|
|
26
|
+
handler: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class CallHandler implements SubstrateCallHandler {
|
|
29
|
+
filter?: SubstrateCallFilter;
|
|
30
|
+
kind: SubstrateHandlerKind.Call;
|
|
31
|
+
handler: string;
|
|
32
|
+
}
|
|
33
|
+
export declare class EventHandler implements SubstrateEventHandler {
|
|
34
|
+
filter?: SubstrateEventFilter;
|
|
35
|
+
kind: SubstrateHandlerKind.Event;
|
|
36
|
+
handler: string;
|
|
37
|
+
}
|
|
38
|
+
export declare class CustomHandler implements SubstrateCustomHandler {
|
|
39
|
+
kind: string;
|
|
40
|
+
handler: string;
|
|
41
|
+
filter?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export declare class RuntimeMapping implements BaseMapping<SubstrateRuntimeHandler> {
|
|
44
|
+
handlers: SubstrateRuntimeHandler[];
|
|
45
|
+
file: string;
|
|
46
|
+
}
|
|
47
|
+
export declare class CustomMapping implements BaseMapping<SubstrateCustomHandler> {
|
|
48
|
+
handlers: CustomHandler[];
|
|
49
|
+
file: string;
|
|
50
|
+
}
|
|
51
|
+
export declare class RuntimeDataSourceBase extends BaseDataSource implements SubstrateRuntimeDatasource {
|
|
52
|
+
kind: SubstrateDatasourceKind.Runtime;
|
|
53
|
+
mapping: RuntimeMapping;
|
|
54
|
+
}
|
|
55
|
+
export declare class FileReferenceImpl implements FileReference {
|
|
56
|
+
file: string;
|
|
57
|
+
}
|
|
58
|
+
export declare class CustomDataSourceBase<K extends string, M extends CustomMapping, O = any> extends BaseDataSource implements SubstrateCustomDatasource<K, M, O> {
|
|
59
|
+
kind: K;
|
|
60
|
+
mapping: M;
|
|
61
|
+
assets: Map<string, FileReference>;
|
|
62
|
+
processor: Processor<O>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
5
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
+
};
|
|
10
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.CustomDataSourceBase = exports.FileReferenceImpl = exports.RuntimeDataSourceBase = exports.CustomMapping = exports.RuntimeMapping = exports.CustomHandler = exports.EventHandler = exports.CallHandler = exports.BlockHandler = exports.CallFilter = exports.ChainTypes = exports.EventFilter = exports.BlockFilter = void 0;
|
|
15
|
+
const common_1 = require("@subql/common");
|
|
16
|
+
const types_1 = require("@subql/types");
|
|
17
|
+
const class_transformer_1 = require("class-transformer");
|
|
18
|
+
const class_validator_1 = require("class-validator");
|
|
19
|
+
class BlockFilter extends common_1.BlockFilterImpl {
|
|
20
|
+
specVersion;
|
|
21
|
+
}
|
|
22
|
+
exports.BlockFilter = BlockFilter;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, class_validator_1.IsOptional)(),
|
|
25
|
+
(0, class_validator_1.IsArray)(),
|
|
26
|
+
(0, class_validator_1.ArrayMaxSize)(2),
|
|
27
|
+
__metadata("design:type", Array)
|
|
28
|
+
], BlockFilter.prototype, "specVersion", void 0);
|
|
29
|
+
class EventFilter {
|
|
30
|
+
module;
|
|
31
|
+
method;
|
|
32
|
+
}
|
|
33
|
+
exports.EventFilter = EventFilter;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, class_validator_1.IsOptional)(),
|
|
36
|
+
(0, class_validator_1.IsString)(),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], EventFilter.prototype, "module", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, class_validator_1.IsOptional)(),
|
|
41
|
+
(0, class_validator_1.IsString)(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], EventFilter.prototype, "method", void 0);
|
|
44
|
+
class ChainTypes {
|
|
45
|
+
types;
|
|
46
|
+
typesAlias;
|
|
47
|
+
typesBundle;
|
|
48
|
+
typesChain;
|
|
49
|
+
typesSpec;
|
|
50
|
+
}
|
|
51
|
+
exports.ChainTypes = ChainTypes;
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, class_validator_1.IsObject)(),
|
|
54
|
+
(0, class_validator_1.IsOptional)(),
|
|
55
|
+
__metadata("design:type", Object)
|
|
56
|
+
], ChainTypes.prototype, "types", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, class_validator_1.IsObject)(),
|
|
59
|
+
(0, class_validator_1.IsOptional)(),
|
|
60
|
+
__metadata("design:type", Object)
|
|
61
|
+
], ChainTypes.prototype, "typesAlias", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, class_validator_1.IsObject)(),
|
|
64
|
+
(0, class_validator_1.IsOptional)(),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], ChainTypes.prototype, "typesBundle", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, class_validator_1.IsObject)(),
|
|
69
|
+
(0, class_validator_1.IsOptional)(),
|
|
70
|
+
__metadata("design:type", Object)
|
|
71
|
+
], ChainTypes.prototype, "typesChain", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, class_validator_1.IsObject)(),
|
|
74
|
+
(0, class_validator_1.IsOptional)(),
|
|
75
|
+
__metadata("design:type", Object)
|
|
76
|
+
], ChainTypes.prototype, "typesSpec", void 0);
|
|
77
|
+
class CallFilter extends EventFilter {
|
|
78
|
+
success;
|
|
79
|
+
isSigned;
|
|
80
|
+
}
|
|
81
|
+
exports.CallFilter = CallFilter;
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, class_validator_1.IsOptional)(),
|
|
84
|
+
(0, class_validator_1.IsBoolean)(),
|
|
85
|
+
__metadata("design:type", Boolean)
|
|
86
|
+
], CallFilter.prototype, "success", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, class_validator_1.IsOptional)(),
|
|
89
|
+
(0, class_validator_1.IsBoolean)(),
|
|
90
|
+
__metadata("design:type", Boolean)
|
|
91
|
+
], CallFilter.prototype, "isSigned", void 0);
|
|
92
|
+
class BlockHandler {
|
|
93
|
+
filter;
|
|
94
|
+
kind;
|
|
95
|
+
handler;
|
|
96
|
+
}
|
|
97
|
+
exports.BlockHandler = BlockHandler;
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, class_validator_1.IsOptional)(),
|
|
100
|
+
(0, class_validator_1.ValidateNested)(),
|
|
101
|
+
(0, class_transformer_1.Type)(() => BlockFilter),
|
|
102
|
+
__metadata("design:type", Object)
|
|
103
|
+
], BlockHandler.prototype, "filter", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, class_validator_1.IsEnum)(types_1.SubstrateHandlerKind, { groups: [types_1.SubstrateHandlerKind.Block] }),
|
|
106
|
+
__metadata("design:type", String)
|
|
107
|
+
], BlockHandler.prototype, "kind", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, class_validator_1.IsString)(),
|
|
110
|
+
__metadata("design:type", String)
|
|
111
|
+
], BlockHandler.prototype, "handler", void 0);
|
|
112
|
+
class CallHandler {
|
|
113
|
+
filter;
|
|
114
|
+
kind;
|
|
115
|
+
handler;
|
|
116
|
+
}
|
|
117
|
+
exports.CallHandler = CallHandler;
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, class_validator_1.IsOptional)(),
|
|
120
|
+
(0, class_validator_1.ValidateNested)(),
|
|
121
|
+
(0, class_transformer_1.Type)(() => CallFilter),
|
|
122
|
+
__metadata("design:type", Object)
|
|
123
|
+
], CallHandler.prototype, "filter", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, class_validator_1.IsEnum)(types_1.SubstrateHandlerKind, { groups: [types_1.SubstrateHandlerKind.Call] }),
|
|
126
|
+
__metadata("design:type", String)
|
|
127
|
+
], CallHandler.prototype, "kind", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, class_validator_1.IsString)(),
|
|
130
|
+
__metadata("design:type", String)
|
|
131
|
+
], CallHandler.prototype, "handler", void 0);
|
|
132
|
+
class EventHandler {
|
|
133
|
+
filter;
|
|
134
|
+
kind;
|
|
135
|
+
handler;
|
|
136
|
+
}
|
|
137
|
+
exports.EventHandler = EventHandler;
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, class_validator_1.IsOptional)(),
|
|
140
|
+
(0, class_validator_1.ValidateNested)(),
|
|
141
|
+
(0, class_transformer_1.Type)(() => EventFilter),
|
|
142
|
+
__metadata("design:type", Object)
|
|
143
|
+
], EventHandler.prototype, "filter", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, class_validator_1.IsEnum)(types_1.SubstrateHandlerKind, { groups: [types_1.SubstrateHandlerKind.Event] }),
|
|
146
|
+
__metadata("design:type", String)
|
|
147
|
+
], EventHandler.prototype, "kind", void 0);
|
|
148
|
+
__decorate([
|
|
149
|
+
(0, class_validator_1.IsString)(),
|
|
150
|
+
__metadata("design:type", String)
|
|
151
|
+
], EventHandler.prototype, "handler", void 0);
|
|
152
|
+
class CustomHandler {
|
|
153
|
+
kind;
|
|
154
|
+
handler;
|
|
155
|
+
filter;
|
|
156
|
+
}
|
|
157
|
+
exports.CustomHandler = CustomHandler;
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, class_validator_1.IsString)(),
|
|
160
|
+
__metadata("design:type", String)
|
|
161
|
+
], CustomHandler.prototype, "kind", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, class_validator_1.IsString)(),
|
|
164
|
+
__metadata("design:type", String)
|
|
165
|
+
], CustomHandler.prototype, "handler", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
(0, class_validator_1.IsObject)(),
|
|
168
|
+
(0, class_validator_1.IsOptional)(),
|
|
169
|
+
__metadata("design:type", Object)
|
|
170
|
+
], CustomHandler.prototype, "filter", void 0);
|
|
171
|
+
class RuntimeMapping {
|
|
172
|
+
handlers;
|
|
173
|
+
file;
|
|
174
|
+
}
|
|
175
|
+
exports.RuntimeMapping = RuntimeMapping;
|
|
176
|
+
__decorate([
|
|
177
|
+
(0, class_transformer_1.Transform)((params) => {
|
|
178
|
+
const handlers = params.value;
|
|
179
|
+
return handlers.map((handler) => {
|
|
180
|
+
switch (handler.kind) {
|
|
181
|
+
case types_1.SubstrateHandlerKind.Event:
|
|
182
|
+
return (0, class_transformer_1.plainToClass)(EventHandler, handler);
|
|
183
|
+
case types_1.SubstrateHandlerKind.Call:
|
|
184
|
+
return (0, class_transformer_1.plainToClass)(CallHandler, handler);
|
|
185
|
+
case types_1.SubstrateHandlerKind.Block:
|
|
186
|
+
return (0, class_transformer_1.plainToClass)(BlockHandler, handler);
|
|
187
|
+
default:
|
|
188
|
+
throw new Error(`handler ${handler.kind} not supported`);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}),
|
|
192
|
+
(0, class_validator_1.IsArray)(),
|
|
193
|
+
(0, class_validator_1.ValidateNested)(),
|
|
194
|
+
__metadata("design:type", Array)
|
|
195
|
+
], RuntimeMapping.prototype, "handlers", void 0);
|
|
196
|
+
__decorate([
|
|
197
|
+
(0, class_validator_1.IsString)(),
|
|
198
|
+
__metadata("design:type", String)
|
|
199
|
+
], RuntimeMapping.prototype, "file", void 0);
|
|
200
|
+
class CustomMapping {
|
|
201
|
+
handlers;
|
|
202
|
+
file;
|
|
203
|
+
}
|
|
204
|
+
exports.CustomMapping = CustomMapping;
|
|
205
|
+
__decorate([
|
|
206
|
+
(0, class_validator_1.IsArray)(),
|
|
207
|
+
(0, class_transformer_1.Type)(() => CustomHandler),
|
|
208
|
+
(0, class_validator_1.ValidateNested)(),
|
|
209
|
+
__metadata("design:type", Array)
|
|
210
|
+
], CustomMapping.prototype, "handlers", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
(0, class_validator_1.IsString)(),
|
|
213
|
+
__metadata("design:type", String)
|
|
214
|
+
], CustomMapping.prototype, "file", void 0);
|
|
215
|
+
class RuntimeDataSourceBase extends common_1.BaseDataSource {
|
|
216
|
+
kind;
|
|
217
|
+
mapping;
|
|
218
|
+
}
|
|
219
|
+
exports.RuntimeDataSourceBase = RuntimeDataSourceBase;
|
|
220
|
+
__decorate([
|
|
221
|
+
(0, class_validator_1.IsEnum)(types_1.SubstrateDatasourceKind, { groups: [types_1.SubstrateDatasourceKind.Runtime] }),
|
|
222
|
+
__metadata("design:type", String)
|
|
223
|
+
], RuntimeDataSourceBase.prototype, "kind", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
(0, class_transformer_1.Type)(() => RuntimeMapping),
|
|
226
|
+
(0, class_validator_1.ValidateNested)(),
|
|
227
|
+
__metadata("design:type", RuntimeMapping)
|
|
228
|
+
], RuntimeDataSourceBase.prototype, "mapping", void 0);
|
|
229
|
+
class FileReferenceImpl {
|
|
230
|
+
file;
|
|
231
|
+
}
|
|
232
|
+
exports.FileReferenceImpl = FileReferenceImpl;
|
|
233
|
+
__decorate([
|
|
234
|
+
(0, class_validator_1.IsString)(),
|
|
235
|
+
__metadata("design:type", String)
|
|
236
|
+
], FileReferenceImpl.prototype, "file", void 0);
|
|
237
|
+
class CustomDataSourceBase extends common_1.BaseDataSource {
|
|
238
|
+
kind;
|
|
239
|
+
mapping;
|
|
240
|
+
assets;
|
|
241
|
+
processor;
|
|
242
|
+
}
|
|
243
|
+
exports.CustomDataSourceBase = CustomDataSourceBase;
|
|
244
|
+
__decorate([
|
|
245
|
+
(0, class_validator_1.IsString)(),
|
|
246
|
+
__metadata("design:type", String)
|
|
247
|
+
], CustomDataSourceBase.prototype, "kind", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
(0, class_transformer_1.Type)(() => CustomMapping),
|
|
250
|
+
(0, class_validator_1.ValidateNested)(),
|
|
251
|
+
__metadata("design:type", Object)
|
|
252
|
+
], CustomDataSourceBase.prototype, "mapping", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
(0, class_transformer_1.Type)(() => FileReferenceImpl),
|
|
255
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
256
|
+
__metadata("design:type", Map)
|
|
257
|
+
], CustomDataSourceBase.prototype, "assets", void 0);
|
|
258
|
+
__decorate([
|
|
259
|
+
(0, class_transformer_1.Type)(() => common_1.ProcessorImpl),
|
|
260
|
+
(0, class_validator_1.IsObject)(),
|
|
261
|
+
(0, class_validator_1.ValidateNested)(),
|
|
262
|
+
__metadata("design:type", Object)
|
|
263
|
+
], CustomDataSourceBase.prototype, "processor", void 0);
|
|
264
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/project/models.ts"],"names":[],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M,EAAC,+BAAuB,EAAE,EAAC,MAAM,EAAE,CAAC,+BAAuB,CAAC,OAAO,CAAC,EAAC,CAAC;;mDACtC;AAGvC;IAFC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,cAAc,CAAC;IAC1B,IAAA,gCAAc,GAAE;8BACP,cAAc;sDAAC;AAG3B,MAAa,iBAAiB;IAE5B,IAAI,CAAU;CACf;AAHD,8CAGC;AADC;IADC,IAAA,0BAAQ,GAAE;;+CACG;AAGhB,MAAa,oBACX,SAAQ,uBAAc;IAItB,IAAI,CAAK;IAGT,OAAO,CAAK;IAGZ,MAAM,CAA8B;IAIpC,SAAS,CAAgB;CAC1B;AAhBD,oDAgBC;AAXC;IADC,IAAA,0BAAQ,GAAE;;kDACF;AAGT;IAFC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,aAAa,CAAC;IACzB,IAAA,gCAAc,GAAE;;qDACL;AAGZ;IAFC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC;IAC7B,IAAA,gCAAc,EAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC;8BACpB,GAAG;oDAAwB;AAIpC;IAHC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC;IACzB,IAAA,0BAAQ,GAAE;IACV,IAAA,gCAAc,GAAE;;uDACQ","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {RegisteredTypes, RegistryTypes, OverrideModuleType, OverrideBundleType} from '@polkadot/types/types';\nimport {BaseDataSource, BlockFilterImpl, ProcessorImpl} from '@subql/common';\nimport {\n SubstrateBlockFilter,\n SubstrateBlockHandler,\n SubstrateCallFilter,\n SubstrateCallHandler,\n SubstrateCustomHandler,\n SubstrateDatasourceKind,\n SubstrateEventFilter,\n SubstrateEventHandler,\n SubstrateHandlerKind,\n SubstrateRuntimeDatasource,\n SubstrateRuntimeHandler,\n SubstrateCustomDatasource,\n} from '@subql/types';\nimport {BaseMapping, FileReference, Processor} from '@subql/types-core';\nimport {plainToClass, Transform, Type} from 'class-transformer';\nimport {\n ArrayMaxSize,\n IsArray,\n IsBoolean,\n IsEnum,\n IsOptional,\n IsString,\n IsObject,\n ValidateNested,\n} from 'class-validator';\n\nexport class BlockFilter extends BlockFilterImpl implements SubstrateBlockFilter {\n @IsOptional()\n @IsArray()\n @ArrayMaxSize(2)\n specVersion?: [number, number];\n}\n\nexport class EventFilter implements SubstrateEventFilter {\n @IsOptional()\n @IsString()\n module?: string;\n @IsOptional()\n @IsString()\n method?: string;\n}\n\nexport class ChainTypes implements RegisteredTypes {\n @IsObject()\n @IsOptional()\n types?: RegistryTypes;\n @IsObject()\n @IsOptional()\n typesAlias?: Record<string, OverrideModuleType>;\n @IsObject()\n @IsOptional()\n typesBundle?: OverrideBundleType;\n @IsObject()\n @IsOptional()\n typesChain?: Record<string, RegistryTypes>;\n @IsObject()\n @IsOptional()\n typesSpec?: Record<string, RegistryTypes>;\n}\n\nexport class CallFilter extends EventFilter implements SubstrateCallFilter {\n @IsOptional()\n @IsBoolean()\n success?: boolean;\n @IsOptional()\n @IsBoolean()\n isSigned?: boolean;\n}\n\nexport class BlockHandler implements SubstrateBlockHandler {\n @IsOptional()\n @ValidateNested()\n @Type(() => BlockFilter)\n filter?: SubstrateBlockFilter;\n @IsEnum(SubstrateHandlerKind, {groups: [SubstrateHandlerKind.Block]})\n kind!: SubstrateHandlerKind.Block;\n @IsString()\n handler!: string;\n}\n\nexport class CallHandler implements SubstrateCallHandler {\n @IsOptional()\n @ValidateNested()\n @Type(() => CallFilter)\n filter?: SubstrateCallFilter;\n @IsEnum(SubstrateHandlerKind, {groups: [SubstrateHandlerKind.Call]})\n kind!: SubstrateHandlerKind.Call;\n @IsString()\n handler!: string;\n}\n\nexport class EventHandler implements SubstrateEventHandler {\n @IsOptional()\n @ValidateNested()\n @Type(() => EventFilter)\n filter?: SubstrateEventFilter;\n @IsEnum(SubstrateHandlerKind, {groups: [SubstrateHandlerKind.Event]})\n kind!: SubstrateHandlerKind.Event;\n @IsString()\n handler!: string;\n}\n\nexport class CustomHandler implements SubstrateCustomHandler {\n @IsString()\n kind!: string;\n @IsString()\n handler!: string;\n @IsObject()\n @IsOptional()\n filter?: Record<string, unknown>;\n}\n\nexport class RuntimeMapping implements BaseMapping<SubstrateRuntimeHandler> {\n @Transform((params) => {\n const handlers: SubstrateRuntimeHandler[] = params.value;\n return handlers.map((handler) => {\n switch (handler.kind) {\n case SubstrateHandlerKind.Event:\n return plainToClass(EventHandler, handler);\n case SubstrateHandlerKind.Call:\n return plainToClass(CallHandler, handler);\n case SubstrateHandlerKind.Block:\n return plainToClass(BlockHandler, handler);\n default:\n throw new Error(`handler ${(handler as any).kind} not supported`);\n }\n });\n })\n @IsArray()\n @ValidateNested()\n handlers!: SubstrateRuntimeHandler[];\n @IsString()\n file!: string;\n}\n\nexport class CustomMapping implements BaseMapping<SubstrateCustomHandler> {\n @IsArray()\n @Type(() => CustomHandler)\n @ValidateNested()\n handlers!: CustomHandler[];\n @IsString()\n file!: string;\n}\n\nexport class RuntimeDataSourceBase extends BaseDataSource implements SubstrateRuntimeDatasource {\n @IsEnum(SubstrateDatasourceKind, {groups: [SubstrateDatasourceKind.Runtime]})\n kind!: SubstrateDatasourceKind.Runtime;\n @Type(() => RuntimeMapping)\n @ValidateNested()\n mapping!: RuntimeMapping;\n}\n\nexport class FileReferenceImpl implements FileReference {\n @IsString()\n file!: string;\n}\n\nexport class CustomDataSourceBase<K extends string, M extends CustomMapping, O = any>\n extends BaseDataSource\n implements SubstrateCustomDatasource<K, M, O>\n{\n @IsString()\n kind!: K;\n @Type(() => CustomMapping)\n @ValidateNested()\n mapping!: M;\n @Type(() => FileReferenceImpl)\n @ValidateNested({each: true})\n assets!: Map<string, FileReference>;\n @Type(() => ProcessorImpl)\n @IsObject()\n @ValidateNested()\n processor!: Processor<O>;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SubstrateDatasource } from '@subql/types';
|
|
2
|
+
import { IProjectManifest } from '@subql/types-core';
|
|
3
|
+
export { SubstrateRuntimeHandler, SubstrateCustomHandler, SubstrateHandler, SubstrateHandlerKind, SubstrateDatasource as SubstrateDataSource, SubstrateCustomDatasource as SubstrateCustomDataSource, SubstrateBlockFilter, SubstrateCallFilter, SubstrateEventFilter, SubstrateDatasourceProcessor, SubstrateRuntimeHandlerFilter, SubstrateDatasourceKind, RuntimeHandlerInputMap as SubstrateRuntimeHandlerInputMap, } from '@subql/types';
|
|
4
|
+
export type ISubstrateProjectManifest = IProjectManifest<SubstrateDatasource>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.SubstrateDatasourceKind = exports.SubstrateHandlerKind = void 0;
|
|
6
|
+
// All of these used to be redefined in this file, re-exporting for simplicity
|
|
7
|
+
var types_1 = require("@subql/types");
|
|
8
|
+
Object.defineProperty(exports, "SubstrateHandlerKind", { enumerable: true, get: function () { return types_1.SubstrateHandlerKind; } });
|
|
9
|
+
Object.defineProperty(exports, "SubstrateDatasourceKind", { enumerable: true, get: function () { return types_1.SubstrateDatasourceKind; } });
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/project/types.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAKnC,8EAA8E;AAC9E,sCAcsB;AAVpB,6GAAA,oBAAoB,OAAA;AAQpB,gHAAA,uBAAuB,OAAA","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {SubstrateDatasource} from '@subql/types';\nimport {IProjectManifest} from '@subql/types-core';\n\n// All of these used to be redefined in this file, re-exporting for simplicity\nexport {\n SubstrateRuntimeHandler,\n SubstrateCustomHandler,\n SubstrateHandler,\n SubstrateHandlerKind,\n SubstrateDatasource as SubstrateDataSource,\n SubstrateCustomDatasource as SubstrateCustomDataSource,\n SubstrateBlockFilter,\n SubstrateCallFilter,\n SubstrateEventFilter,\n SubstrateDatasourceProcessor,\n SubstrateRuntimeHandlerFilter,\n SubstrateDatasourceKind,\n RuntimeHandlerInputMap as SubstrateRuntimeHandlerInputMap,\n} from '@subql/types';\n\n//make exception for runtime datasource 0.0.1\nexport type ISubstrateProjectManifest = IProjectManifest<SubstrateDatasource>;\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SecondLayerHandlerProcessor, SubstrateCustomDatasource, SubstrateDatasource, SubstrateHandlerKind, SubstrateRuntimeDatasource, SubstrateMapping, SubstrateCustomHandler, SecondLayerHandlerProcessorArray } from '@subql/types';
|
|
2
|
+
import { BaseTemplateDataSource } from '@subql/types-core';
|
|
3
|
+
export declare function isBlockHandlerProcessor<F extends Record<string, unknown>, E>(hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Block, F, E>;
|
|
4
|
+
export declare function isEventHandlerProcessor<F extends Record<string, unknown>, E>(hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Event, F, E>;
|
|
5
|
+
export declare function isCallHandlerProcessor<F extends Record<string, unknown>, E>(hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Call, F, E>;
|
|
6
|
+
export declare function isCustomDs<F extends SubstrateMapping<SubstrateCustomHandler>>(ds: SubstrateDatasource | BaseTemplateDataSource<SubstrateDatasource>): ds is SubstrateCustomDatasource<string, F>;
|
|
7
|
+
export declare function isRuntimeDs(ds: SubstrateDatasource | BaseTemplateDataSource<SubstrateDatasource>): ds is SubstrateRuntimeDatasource;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.isBlockHandlerProcessor = isBlockHandlerProcessor;
|
|
6
|
+
exports.isEventHandlerProcessor = isEventHandlerProcessor;
|
|
7
|
+
exports.isCallHandlerProcessor = isCallHandlerProcessor;
|
|
8
|
+
exports.isCustomDs = isCustomDs;
|
|
9
|
+
exports.isRuntimeDs = isRuntimeDs;
|
|
10
|
+
const types_1 = require("@subql/types");
|
|
11
|
+
function isBlockHandlerProcessor(hp) {
|
|
12
|
+
return hp.baseHandlerKind === types_1.SubstrateHandlerKind.Block;
|
|
13
|
+
}
|
|
14
|
+
function isEventHandlerProcessor(hp) {
|
|
15
|
+
return hp.baseHandlerKind === types_1.SubstrateHandlerKind.Event;
|
|
16
|
+
}
|
|
17
|
+
function isCallHandlerProcessor(hp) {
|
|
18
|
+
return hp.baseHandlerKind === types_1.SubstrateHandlerKind.Call;
|
|
19
|
+
}
|
|
20
|
+
function isCustomDs(ds) {
|
|
21
|
+
return ds.kind !== types_1.SubstrateDatasourceKind.Runtime && !!ds.processor;
|
|
22
|
+
}
|
|
23
|
+
function isRuntimeDs(ds) {
|
|
24
|
+
return ds.kind === types_1.SubstrateDatasourceKind.Runtime;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/project/utils.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAenC,0DAIC;AAED,0DAIC;AAED,wDAIC;AAED,gCAIC;AAED,kCAIC;AAzCD,wCAUsB;AAGtB,SAAgB,uBAAuB,CACrC,EAAsE;IAEtE,OAAO,EAAE,CAAC,eAAe,KAAK,4BAAoB,CAAC,KAAK,CAAC;AAC3D,CAAC;AAED,SAAgB,uBAAuB,CACrC,EAAsE;IAEtE,OAAO,EAAE,CAAC,eAAe,KAAK,4BAAoB,CAAC,KAAK,CAAC;AAC3D,CAAC;AAED,SAAgB,sBAAsB,CACpC,EAAsE;IAEtE,OAAO,EAAE,CAAC,eAAe,KAAK,4BAAoB,CAAC,IAAI,CAAC;AAC1D,CAAC;AAED,SAAgB,UAAU,CACxB,EAAqE;IAErE,OAAO,EAAE,CAAC,IAAI,KAAK,+BAAuB,CAAC,OAAO,IAAI,CAAC,CAAE,EAA2C,CAAC,SAAS,CAAC;AACjH,CAAC;AAED,SAAgB,WAAW,CACzB,EAAqE;IAErE,OAAO,EAAE,CAAC,IAAI,KAAK,+BAAuB,CAAC,OAAO,CAAC;AACrD,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n SecondLayerHandlerProcessor,\n SubstrateCustomDatasource,\n SubstrateDatasource,\n SubstrateDatasourceKind,\n SubstrateHandlerKind,\n SubstrateRuntimeDatasource,\n SubstrateMapping,\n SubstrateCustomHandler,\n SecondLayerHandlerProcessorArray,\n} from '@subql/types';\nimport {BaseTemplateDataSource} from '@subql/types-core';\n\nexport function isBlockHandlerProcessor<F extends Record<string, unknown>, E>(\n hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>\n): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Block, F, E> {\n return hp.baseHandlerKind === SubstrateHandlerKind.Block;\n}\n\nexport function isEventHandlerProcessor<F extends Record<string, unknown>, E>(\n hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>\n): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Event, F, E> {\n return hp.baseHandlerKind === SubstrateHandlerKind.Event;\n}\n\nexport function isCallHandlerProcessor<F extends Record<string, unknown>, E>(\n hp: SecondLayerHandlerProcessorArray<SubstrateHandlerKind, F, unknown>\n): hp is SecondLayerHandlerProcessor<SubstrateHandlerKind.Call, F, E> {\n return hp.baseHandlerKind === SubstrateHandlerKind.Call;\n}\n\nexport function isCustomDs<F extends SubstrateMapping<SubstrateCustomHandler>>(\n ds: SubstrateDatasource | BaseTemplateDataSource<SubstrateDatasource>\n): ds is SubstrateCustomDatasource<string, F> {\n return ds.kind !== SubstrateDatasourceKind.Runtime && !!(ds as SubstrateCustomDatasource<string, F>).processor;\n}\n\nexport function isRuntimeDs(\n ds: SubstrateDatasource | BaseTemplateDataSource<SubstrateDatasource>\n): ds is SubstrateRuntimeDatasource {\n return ds.kind === SubstrateDatasourceKind.Runtime;\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SubstrateDatasource } from '@subql/types';
|
|
2
|
+
import { ISubstrateProjectManifest } from '../types';
|
|
3
|
+
import { ProjectManifestV1_0_0Impl } from './v1_0_0';
|
|
4
|
+
export type VersionedProjectManifest = {
|
|
5
|
+
specVersion: string;
|
|
6
|
+
};
|
|
7
|
+
declare const SUBSTRATE_SUPPORTED_VERSIONS: {
|
|
8
|
+
'1.0.0': typeof ProjectManifestV1_0_0Impl;
|
|
9
|
+
};
|
|
10
|
+
type Versions = keyof typeof SUBSTRATE_SUPPORTED_VERSIONS;
|
|
11
|
+
export type ProjectManifestImpls = InstanceType<(typeof SUBSTRATE_SUPPORTED_VERSIONS)[Versions]>;
|
|
12
|
+
export declare function manifestIsV1_0_0(manifest: ISubstrateProjectManifest): manifest is ProjectManifestV1_0_0Impl;
|
|
13
|
+
export declare class SubstrateProjectManifestVersioned implements ISubstrateProjectManifest {
|
|
14
|
+
private _impl;
|
|
15
|
+
constructor(projectManifest: VersionedProjectManifest);
|
|
16
|
+
get asImpl(): ProjectManifestImpls;
|
|
17
|
+
get isV1_0_0(): boolean;
|
|
18
|
+
get asV1_0_0(): ProjectManifestV1_0_0Impl;
|
|
19
|
+
toDeployment(): string;
|
|
20
|
+
validate(): void;
|
|
21
|
+
get dataSources(): SubstrateDatasource[];
|
|
22
|
+
get schema(): string;
|
|
23
|
+
get specVersion(): string;
|
|
24
|
+
get description(): string | undefined;
|
|
25
|
+
get repository(): string | undefined;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.SubstrateProjectManifestVersioned = void 0;
|
|
6
|
+
exports.manifestIsV1_0_0 = manifestIsV1_0_0;
|
|
7
|
+
const class_transformer_1 = require("class-transformer");
|
|
8
|
+
const v1_0_0_1 = require("./v1_0_0");
|
|
9
|
+
/* Retain support for all versions here to continue support for migrations */
|
|
10
|
+
const SUBSTRATE_SUPPORTED_VERSIONS = {
|
|
11
|
+
'1.0.0': v1_0_0_1.ProjectManifestV1_0_0Impl,
|
|
12
|
+
};
|
|
13
|
+
function manifestIsV1_0_0(manifest) {
|
|
14
|
+
return manifest.specVersion === '1.0.0';
|
|
15
|
+
}
|
|
16
|
+
class SubstrateProjectManifestVersioned {
|
|
17
|
+
_impl;
|
|
18
|
+
constructor(projectManifest) {
|
|
19
|
+
const klass = SUBSTRATE_SUPPORTED_VERSIONS[projectManifest.specVersion];
|
|
20
|
+
if (!klass) {
|
|
21
|
+
throw new Error('specVersion not supported for project manifest file');
|
|
22
|
+
}
|
|
23
|
+
this._impl = (0, class_transformer_1.plainToClass)(klass, projectManifest);
|
|
24
|
+
}
|
|
25
|
+
get asImpl() {
|
|
26
|
+
return this._impl;
|
|
27
|
+
}
|
|
28
|
+
get isV1_0_0() {
|
|
29
|
+
return this.specVersion === '1.0.0';
|
|
30
|
+
}
|
|
31
|
+
get asV1_0_0() {
|
|
32
|
+
return this._impl;
|
|
33
|
+
}
|
|
34
|
+
toDeployment() {
|
|
35
|
+
return this._impl.deployment.toYaml();
|
|
36
|
+
}
|
|
37
|
+
validate() {
|
|
38
|
+
return this._impl.validate();
|
|
39
|
+
}
|
|
40
|
+
get dataSources() {
|
|
41
|
+
return this._impl.dataSources;
|
|
42
|
+
}
|
|
43
|
+
get schema() {
|
|
44
|
+
return this._impl.schema.file;
|
|
45
|
+
}
|
|
46
|
+
get specVersion() {
|
|
47
|
+
return this._impl.specVersion;
|
|
48
|
+
}
|
|
49
|
+
get description() {
|
|
50
|
+
return this._impl.description;
|
|
51
|
+
}
|
|
52
|
+
get repository() {
|
|
53
|
+
return this._impl.repository;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.SubstrateProjectManifestVersioned = SubstrateProjectManifestVersioned;
|
|
57
|
+
//# sourceMappingURL=ProjectManifestVersioned.js.map
|