@graphprotocol/graph-cli 0.54.0-alpha-20230724180700-d5ce4e2 → 0.54.0-alpha-20230801202859-9fcb823
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 +8 -6
- package/dist/codegen/template.js +8 -2
- package/dist/command-helpers/abi.js +1 -1
- package/dist/commands/add.js +19 -17
- package/dist/subgraph.d.ts +10 -90
- package/dist/subgraph.js +53 -71
- package/dist/validation/contract.d.ts +2 -2
- package/dist/validation/contract.js +12 -9
- package/oclif.manifest.json +1 -1
- package/package.json +4 -7
- package/dist/manifest.d.ts +0 -511
- package/dist/manifest.js +0 -128
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
-
## 0.54.0-alpha-
|
|
3
|
+
## 0.54.0-alpha-20230801202859-9fcb823
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
+
- [#1411](https://github.com/graphprotocol/graph-tooling/pull/1411)
|
|
8
|
+
[`9fcb823`](https://github.com/graphprotocol/graph-tooling/commit/9fcb823b86862c52b55c92c28fb4ef5e2b249417)
|
|
9
|
+
Thanks [@saihaj](https://github.com/saihaj)! - add support for arweave file datasource
|
|
10
|
+
|
|
7
11
|
- [#1407](https://github.com/graphprotocol/graph-tooling/pull/1407)
|
|
8
12
|
[`d388127`](https://github.com/graphprotocol/graph-tooling/commit/d388127aa46a47feaab5024d0a2f2da49c9cabac)
|
|
9
13
|
Thanks [@saihaj](https://github.com/saihaj)! - add skipInstall flag for init
|
|
10
14
|
|
|
11
15
|
### Patch Changes
|
|
12
16
|
|
|
13
|
-
- [#
|
|
14
|
-
[`
|
|
15
|
-
Thanks [@
|
|
16
|
-
- Added dependency [`zod@^3.21.4` ↗︎](https://www.npmjs.com/package/zod/v/3.21.4) (to
|
|
17
|
-
`dependencies`)
|
|
17
|
+
- [#1410](https://github.com/graphprotocol/graph-tooling/pull/1410)
|
|
18
|
+
[`c1eed12`](https://github.com/graphprotocol/graph-tooling/commit/c1eed1219b015145bd428c201577659c61ab64bc)
|
|
19
|
+
Thanks [@uF4No](https://github.com/uF4No)! - fix ABI api endpoint zksync mainnet
|
|
18
20
|
|
|
19
21
|
## 0.53.0
|
|
20
22
|
|
package/dist/codegen/template.js
CHANGED
|
@@ -37,9 +37,12 @@ class DataSourceTemplateCodeGenerator {
|
|
|
37
37
|
if (kind.split('/')[0] == protocol.name) {
|
|
38
38
|
this.protocolTemplateCodeGen = protocol.getTemplateCodeGen(template);
|
|
39
39
|
}
|
|
40
|
-
else if (kind == 'file/ipfs') {
|
|
40
|
+
else if (kind == 'file/ipfs' || kind == 'file/arweave') {
|
|
41
41
|
this.protocolTemplateCodeGen = new file_template_1.default(template);
|
|
42
42
|
}
|
|
43
|
+
else {
|
|
44
|
+
throw new Error(`DataSourceTemplate kind not supported: ${kind}`);
|
|
45
|
+
}
|
|
43
46
|
}
|
|
44
47
|
generateModuleImports() {
|
|
45
48
|
return [
|
|
@@ -55,7 +58,10 @@ class DataSourceTemplateCodeGenerator {
|
|
|
55
58
|
}
|
|
56
59
|
_generateTemplateType() {
|
|
57
60
|
const name = this.template.get('name');
|
|
58
|
-
const klass = tsCodegen.klass(name, {
|
|
61
|
+
const klass = tsCodegen.klass(name, {
|
|
62
|
+
export: true,
|
|
63
|
+
extends: 'DataSourceTemplate',
|
|
64
|
+
});
|
|
59
65
|
klass.addMethod(this.protocolTemplateCodeGen.generateCreateMethod());
|
|
60
66
|
klass.addMethod(this.protocolTemplateCodeGen.generateCreateWithContextMethod());
|
|
61
67
|
return klass;
|
|
@@ -149,7 +149,7 @@ const getEtherscanLikeAPIUrl = (network) => {
|
|
|
149
149
|
case 'fantom-testnet':
|
|
150
150
|
return `https://api-testnet.ftmscan.com/api`;
|
|
151
151
|
case 'zksync-era':
|
|
152
|
-
return `https://explorer.zksync.io/api`;
|
|
152
|
+
return `https://block-explorer-api.mainnet.zksync.io/api`;
|
|
153
153
|
case 'polygon-zkevm-testnet':
|
|
154
154
|
return `https://testnet-zkevm.polygonscan.com/api`;
|
|
155
155
|
case 'polygon-zkevm':
|
package/dist/commands/add.js
CHANGED
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const core_1 = require("@oclif/core");
|
|
30
30
|
const errors_1 = require("@oclif/core/lib/errors");
|
|
31
31
|
const gluegun_1 = require("gluegun");
|
|
32
|
+
const immutable_1 = __importDefault(require("immutable"));
|
|
32
33
|
const abi_1 = require("../command-helpers/abi");
|
|
33
34
|
const DataSourcesExtractor = __importStar(require("../command-helpers/data-sources"));
|
|
34
35
|
const network_1 = require("../command-helpers/network");
|
|
@@ -43,8 +44,8 @@ class AddCommand extends core_1.Command {
|
|
|
43
44
|
const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifestPath);
|
|
44
45
|
const protocol = protocols_1.default.fromDataSources(dataSourcesAndTemplates);
|
|
45
46
|
const manifest = await subgraph_1.default.load(manifestPath, { protocol });
|
|
46
|
-
const network = manifest.result.dataSources
|
|
47
|
-
const result = manifest.result;
|
|
47
|
+
const network = manifest.result.getIn(['dataSources', 0, 'network']);
|
|
48
|
+
const result = manifest.result.asMutable();
|
|
48
49
|
let startBlock = startBlockFlag;
|
|
49
50
|
const entities = getEntities(manifest);
|
|
50
51
|
const contractNames = getContractNames(manifest);
|
|
@@ -86,22 +87,23 @@ class AddCommand extends core_1.Command {
|
|
|
86
87
|
await (0, scaffold_1.writeABI)(ethabi, contractName);
|
|
87
88
|
const { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(ethabi, entities, contractName, mergeEntities);
|
|
88
89
|
ethabi.data = abiData;
|
|
89
|
-
await (0, scaffold_1.writeSchema)(ethabi, protocol, result.schema
|
|
90
|
+
await (0, scaffold_1.writeSchema)(ethabi, protocol, result.getIn(['schema', 'file']), collisionEntities, contractName);
|
|
90
91
|
await (0, scaffold_1.writeMapping)(ethabi, protocol, contractName, collisionEntities);
|
|
91
92
|
await (0, scaffold_1.writeTestsFiles)(ethabi, protocol, contractName);
|
|
92
|
-
const dataSources = result.dataSources;
|
|
93
|
+
const dataSources = result.get('dataSources');
|
|
93
94
|
const dataSource = await (0, scaffold_1.generateDataSource)(protocol, contractName, network, address, ethabi, startBlock);
|
|
94
95
|
// Handle the collisions edge case by copying another data source yaml data
|
|
95
96
|
if (mergeEntities && onlyCollisions) {
|
|
96
|
-
const firstDataSource = dataSources
|
|
97
|
+
const firstDataSource = dataSources.get(0);
|
|
97
98
|
const source = dataSource.get('source');
|
|
98
|
-
const mapping = firstDataSource.mapping;
|
|
99
|
+
const mapping = firstDataSource.get('mapping').asMutable();
|
|
99
100
|
// Save the address of the new data source
|
|
100
|
-
source.abi = firstDataSource.source.abi;
|
|
101
|
+
source.abi = firstDataSource.get('source').get('abi');
|
|
101
102
|
dataSource.set('mapping', mapping);
|
|
102
103
|
dataSource.set('source', source);
|
|
103
104
|
}
|
|
104
|
-
|
|
105
|
+
result.set('dataSources', dataSources.push(dataSource));
|
|
106
|
+
await subgraph_1.default.write(result, manifestPath);
|
|
105
107
|
// Update networks.json
|
|
106
108
|
if (gluegun_1.filesystem.exists(networksFile)) {
|
|
107
109
|
await (0, network_1.updateNetworksFile)(network, contractName, address, networksFile);
|
|
@@ -153,17 +155,17 @@ AddCommand.flags = {
|
|
|
153
155
|
};
|
|
154
156
|
exports.default = AddCommand;
|
|
155
157
|
const getEntities = (manifest) => {
|
|
156
|
-
const dataSources = manifest.result
|
|
157
|
-
const templates = manifest.result
|
|
158
|
-
return
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
const dataSources = manifest.result.get('dataSources', immutable_1.default.List());
|
|
159
|
+
const templates = manifest.result.get('templates', immutable_1.default.List());
|
|
160
|
+
return dataSources
|
|
161
|
+
.concat(templates)
|
|
162
|
+
.map((dataSource) => dataSource.getIn(['mapping', 'entities']))
|
|
163
|
+
.flatten();
|
|
162
164
|
};
|
|
163
165
|
const getContractNames = (manifest) => {
|
|
164
|
-
const dataSources = manifest.result
|
|
165
|
-
const templates = manifest.result
|
|
166
|
-
return
|
|
166
|
+
const dataSources = manifest.result.get('dataSources', immutable_1.default.List());
|
|
167
|
+
const templates = manifest.result.get('templates', immutable_1.default.List());
|
|
168
|
+
return dataSources.concat(templates).map((dataSource) => dataSource.get('name'));
|
|
167
169
|
};
|
|
168
170
|
const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntities) => {
|
|
169
171
|
let abiData = ethabi.data;
|
package/dist/subgraph.d.ts
CHANGED
|
@@ -1,105 +1,25 @@
|
|
|
1
|
+
import immutable from 'immutable';
|
|
1
2
|
import { Subgraph as ISubgraph } from './protocols/subgraph';
|
|
2
|
-
import { ManifestZodSchema } from './manifest';
|
|
3
3
|
type ResolveFile = (path: string) => string;
|
|
4
4
|
export default class Subgraph {
|
|
5
5
|
static validate(data: any, protocol: any, { resolveFile }: {
|
|
6
6
|
resolveFile: ResolveFile;
|
|
7
7
|
}): Promise<any>;
|
|
8
|
-
static validateSchema(manifest:
|
|
8
|
+
static validateSchema(manifest: any, { resolveFile }: {
|
|
9
9
|
resolveFile: ResolveFile;
|
|
10
10
|
}): void;
|
|
11
|
-
static validateRepository(manifest:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
static
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}[];
|
|
19
|
-
static validateHandlers(manifest: ManifestZodSchema, protocol: any, protocolSubgraph: ISubgraph): any;
|
|
20
|
-
static validateContractValues(manifest: ManifestZodSchema, protocol: any): any;
|
|
21
|
-
static validateUniqueDataSourceNames(manifest: ManifestZodSchema): any;
|
|
22
|
-
static validateUniqueTemplateNames(manifest: ManifestZodSchema): any;
|
|
23
|
-
static dump(manifest: ManifestZodSchema): string;
|
|
11
|
+
static validateRepository(manifest: immutable.Collection<any, any>): immutable.List<unknown>;
|
|
12
|
+
static validateDescription(manifest: immutable.Collection<any, any>): immutable.List<unknown>;
|
|
13
|
+
static validateHandlers(manifest: immutable.Collection<any, any>, protocol: any, protocolSubgraph: ISubgraph): any;
|
|
14
|
+
static validateContractValues(manifest: any, protocol: any): any;
|
|
15
|
+
static validateUniqueDataSourceNames(manifest: any): any;
|
|
16
|
+
static validateUniqueTemplateNames(manifest: any): any;
|
|
17
|
+
static dump(manifest: any): string;
|
|
24
18
|
static load(filename: string, { protocol, skipValidation }?: {
|
|
25
19
|
protocol?: any;
|
|
26
20
|
skipValidation?: boolean;
|
|
27
21
|
}): Promise<{
|
|
28
|
-
result:
|
|
29
|
-
specVersion: string;
|
|
30
|
-
schema: {
|
|
31
|
-
file: string;
|
|
32
|
-
};
|
|
33
|
-
dataSources: {
|
|
34
|
-
kind: string;
|
|
35
|
-
name: string;
|
|
36
|
-
network: string;
|
|
37
|
-
source: {
|
|
38
|
-
address: string;
|
|
39
|
-
abi: string;
|
|
40
|
-
startBlock?: number | bigint | undefined;
|
|
41
|
-
};
|
|
42
|
-
mapping: {
|
|
43
|
-
file: string;
|
|
44
|
-
kind: "ethereum/events";
|
|
45
|
-
apiVersion: string;
|
|
46
|
-
language: "wasm/assemblyscript";
|
|
47
|
-
entities: string[];
|
|
48
|
-
eventHandlers?: {
|
|
49
|
-
event: string;
|
|
50
|
-
handler: string;
|
|
51
|
-
topic0?: string | undefined;
|
|
52
|
-
}[] | undefined;
|
|
53
|
-
callHandlers?: {
|
|
54
|
-
function: string;
|
|
55
|
-
handler: string;
|
|
56
|
-
}[] | undefined;
|
|
57
|
-
blockHandlers?: {
|
|
58
|
-
handler: string;
|
|
59
|
-
filter?: {
|
|
60
|
-
kind: "call";
|
|
61
|
-
} | undefined;
|
|
62
|
-
}[] | undefined;
|
|
63
|
-
};
|
|
64
|
-
}[];
|
|
65
|
-
description?: string | undefined;
|
|
66
|
-
repository?: string | undefined;
|
|
67
|
-
graft?: {
|
|
68
|
-
base: string;
|
|
69
|
-
block: bigint;
|
|
70
|
-
} | undefined;
|
|
71
|
-
templates?: {
|
|
72
|
-
kind: string;
|
|
73
|
-
name: string;
|
|
74
|
-
network: string;
|
|
75
|
-
source: {
|
|
76
|
-
abi: string;
|
|
77
|
-
startBlock?: number | bigint | undefined;
|
|
78
|
-
};
|
|
79
|
-
mapping: {
|
|
80
|
-
file: string;
|
|
81
|
-
kind: "ethereum/events";
|
|
82
|
-
apiVersion: string;
|
|
83
|
-
language: "wasm/assemblyscript";
|
|
84
|
-
entities: string[];
|
|
85
|
-
eventHandlers?: {
|
|
86
|
-
event: string;
|
|
87
|
-
handler: string;
|
|
88
|
-
topic0?: string | undefined;
|
|
89
|
-
}[] | undefined;
|
|
90
|
-
callHandlers?: {
|
|
91
|
-
function: string;
|
|
92
|
-
handler: string;
|
|
93
|
-
}[] | undefined;
|
|
94
|
-
blockHandlers?: {
|
|
95
|
-
handler: string;
|
|
96
|
-
filter?: {
|
|
97
|
-
kind: "call";
|
|
98
|
-
} | undefined;
|
|
99
|
-
}[] | undefined;
|
|
100
|
-
};
|
|
101
|
-
}[] | undefined;
|
|
102
|
-
};
|
|
22
|
+
result: immutable.Map<any, any>;
|
|
103
23
|
warning: string | null;
|
|
104
24
|
}>;
|
|
105
25
|
static write(manifest: any, filename: string): Promise<void>;
|
package/dist/subgraph.js
CHANGED
|
@@ -34,19 +34,18 @@ const yaml_1 = __importDefault(require("yaml"));
|
|
|
34
34
|
const types_1 = require("yaml/types");
|
|
35
35
|
const debug_1 = __importDefault(require("./debug"));
|
|
36
36
|
const validation = __importStar(require("./validation"));
|
|
37
|
-
const manifest_1 = require("./manifest");
|
|
38
37
|
const subgraphDebug = (0, debug_1.default)('graph-cli:subgraph');
|
|
39
38
|
const throwCombinedError = (filename, errors) => {
|
|
40
39
|
throw new Error(errors.reduce((msg, e) => `${msg}
|
|
41
40
|
|
|
42
|
-
Path: ${e.path.
|
|
43
|
-
${e.message.split('\n').join('\n ')}`, `Error in ${path_1.default.relative(process.cwd(), filename)}:`));
|
|
41
|
+
Path: ${e.get('path').size === 0 ? '/' : e.get('path').join(' > ')}
|
|
42
|
+
${e.get('message').split('\n').join('\n ')}`, `Error in ${path_1.default.relative(process.cwd(), filename)}:`));
|
|
44
43
|
};
|
|
45
|
-
const buildCombinedWarning = (filename, warnings) => warnings.
|
|
44
|
+
const buildCombinedWarning = (filename, warnings) => warnings.size > 0
|
|
46
45
|
? warnings.reduce((msg, w) => `${msg}
|
|
47
46
|
|
|
48
|
-
Path: ${w.path.
|
|
49
|
-
${w.message.split('\n').join('\n ')}`, `Warnings in ${path_1.default.relative(process.cwd(), filename)}:`) + '\n'
|
|
47
|
+
Path: ${w.get('path').size === 0 ? '/' : w.get('path').join(' > ')}
|
|
48
|
+
${w.get('message').split('\n').join('\n ')}`, `Warnings in ${path_1.default.relative(process.cwd(), filename)}:`) + '\n'
|
|
50
49
|
: null;
|
|
51
50
|
class Subgraph {
|
|
52
51
|
static async validate(data, protocol, { resolveFile }) {
|
|
@@ -67,12 +66,10 @@ class Subgraph {
|
|
|
67
66
|
return definition.name.value === 'SubgraphManifest';
|
|
68
67
|
});
|
|
69
68
|
// Validate the subgraph manifest using this schema
|
|
70
|
-
return validation.validateManifest(data, rootType, schema, protocol, {
|
|
71
|
-
resolveFile,
|
|
72
|
-
});
|
|
69
|
+
return validation.validateManifest(data, rootType, schema, protocol, { resolveFile });
|
|
73
70
|
}
|
|
74
71
|
static validateSchema(manifest, { resolveFile }) {
|
|
75
|
-
const filename = resolveFile(manifest.schema
|
|
72
|
+
const filename = resolveFile(manifest.getIn(['schema', 'file']));
|
|
76
73
|
const validationErrors = validation.validateSchema(filename);
|
|
77
74
|
let errors;
|
|
78
75
|
if (validationErrors.size > 0) {
|
|
@@ -97,106 +94,103 @@ class Subgraph {
|
|
|
97
94
|
}
|
|
98
95
|
}
|
|
99
96
|
static validateRepository(manifest) {
|
|
100
|
-
const repository = manifest.repository;
|
|
101
|
-
// repository is optional, so no need to throw error if it's not set
|
|
102
|
-
if (!repository)
|
|
103
|
-
return [];
|
|
97
|
+
const repository = manifest.get('repository');
|
|
104
98
|
return /^https:\/\/github\.com\/graphprotocol\/graph-tooling?$/.test(repository) ||
|
|
105
99
|
// For legacy reasons, we should error on example subgraphs
|
|
106
100
|
/^https:\/\/github\.com\/graphprotocol\/example-subgraphs?$/.test(repository)
|
|
107
|
-
?
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
message: `\
|
|
101
|
+
? immutable_1.default.List().push(immutable_1.default.fromJS({
|
|
102
|
+
path: ['repository'],
|
|
103
|
+
message: `\
|
|
111
104
|
The repository is still set to ${repository}.
|
|
112
105
|
Please replace it with a link to your subgraph source code.`,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
: [];
|
|
106
|
+
}))
|
|
107
|
+
: immutable_1.default.List();
|
|
116
108
|
}
|
|
117
109
|
static validateDescription(manifest) {
|
|
118
110
|
// TODO: Maybe implement this in the future for each protocol example description
|
|
119
|
-
return (
|
|
120
|
-
?
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
message: `\
|
|
111
|
+
return manifest.get('description', '').startsWith('Gravatar for ')
|
|
112
|
+
? immutable_1.default.List().push(immutable_1.default.fromJS({
|
|
113
|
+
path: ['description'],
|
|
114
|
+
message: `\
|
|
124
115
|
The description is still the one from the example subgraph.
|
|
125
116
|
Please update it to tell users more about your subgraph.`,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
: [];
|
|
117
|
+
}))
|
|
118
|
+
: immutable_1.default.List();
|
|
129
119
|
}
|
|
130
120
|
static validateHandlers(manifest, protocol, protocolSubgraph) {
|
|
131
|
-
return manifest
|
|
132
|
-
.
|
|
121
|
+
return manifest
|
|
122
|
+
.get('dataSources')
|
|
123
|
+
.filter((dataSource) => protocol.isValidKindName(dataSource.get('kind')))
|
|
133
124
|
.reduce((errors, dataSource, dataSourceIndex) => {
|
|
134
125
|
const path = ['dataSources', dataSourceIndex, 'mapping'];
|
|
135
|
-
const mapping = dataSource.mapping;
|
|
126
|
+
const mapping = dataSource.get('mapping');
|
|
136
127
|
const handlerTypes = protocolSubgraph.handlerTypes();
|
|
137
|
-
subgraphDebug('Validating dataSource "%s" handlers with %d handlers types defined for protocol', dataSource.name, handlerTypes.size);
|
|
128
|
+
subgraphDebug('Validating dataSource "%s" handlers with %d handlers types defined for protocol', dataSource.get('name'), handlerTypes.size);
|
|
138
129
|
if (handlerTypes.size == 0) {
|
|
139
130
|
return errors;
|
|
140
131
|
}
|
|
141
132
|
const areAllHandlersEmpty = handlerTypes
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
.every(handlers => handlers.length === 0);
|
|
133
|
+
.map((handlerType) => mapping.get(handlerType, immutable_1.default.List()))
|
|
134
|
+
.every((handlers) => handlers.isEmpty());
|
|
145
135
|
const handlerNamesWithoutLast = handlerTypes.pop().join(', ');
|
|
146
136
|
return areAllHandlersEmpty
|
|
147
|
-
? errors.push({
|
|
137
|
+
? errors.push(immutable_1.default.fromJS({
|
|
148
138
|
path,
|
|
149
139
|
message: `\
|
|
150
140
|
Mapping has no ${handlerNamesWithoutLast} or ${handlerTypes.get(-1)}.
|
|
151
141
|
At least one such handler must be defined.`,
|
|
152
|
-
})
|
|
142
|
+
}))
|
|
153
143
|
: errors;
|
|
154
|
-
},
|
|
144
|
+
}, immutable_1.default.List());
|
|
155
145
|
}
|
|
156
146
|
static validateContractValues(manifest, protocol) {
|
|
157
147
|
if (!protocol.hasContract()) {
|
|
158
|
-
return
|
|
148
|
+
return immutable_1.default.List();
|
|
159
149
|
}
|
|
160
150
|
return validation.validateContractValues(manifest, protocol);
|
|
161
151
|
}
|
|
162
152
|
// Validate that data source names are unique, so they don't overwrite each other.
|
|
163
153
|
static validateUniqueDataSourceNames(manifest) {
|
|
164
154
|
const names = [];
|
|
165
|
-
return manifest
|
|
155
|
+
return manifest
|
|
156
|
+
.get('dataSources')
|
|
157
|
+
.reduce((errors, dataSource, dataSourceIndex) => {
|
|
166
158
|
const path = ['dataSources', dataSourceIndex, 'name'];
|
|
167
|
-
const name = dataSource.name;
|
|
159
|
+
const name = dataSource.get('name');
|
|
168
160
|
if (names.includes(name)) {
|
|
169
|
-
errors = errors.push({
|
|
161
|
+
errors = errors.push(immutable_1.default.fromJS({
|
|
170
162
|
path,
|
|
171
163
|
message: `\
|
|
172
164
|
More than one data source named '${name}', data source names must be unique.`,
|
|
173
|
-
});
|
|
165
|
+
}));
|
|
174
166
|
}
|
|
175
167
|
names.push(name);
|
|
176
168
|
return errors;
|
|
177
|
-
},
|
|
169
|
+
}, immutable_1.default.List());
|
|
178
170
|
}
|
|
179
171
|
static validateUniqueTemplateNames(manifest) {
|
|
180
172
|
const names = [];
|
|
181
|
-
return
|
|
173
|
+
return manifest
|
|
174
|
+
.get('templates', immutable_1.default.List())
|
|
175
|
+
.reduce((errors, template, templateIndex) => {
|
|
182
176
|
const path = ['templates', templateIndex, 'name'];
|
|
183
|
-
const name = template.name;
|
|
177
|
+
const name = template.get('name');
|
|
184
178
|
if (names.includes(name)) {
|
|
185
|
-
errors = errors.push({
|
|
179
|
+
errors = errors.push(immutable_1.default.fromJS({
|
|
186
180
|
path,
|
|
187
181
|
message: `\
|
|
188
182
|
More than one template named '${name}', template names must be unique.`,
|
|
189
|
-
});
|
|
183
|
+
}));
|
|
190
184
|
}
|
|
191
185
|
names.push(name);
|
|
192
186
|
return errors;
|
|
193
|
-
},
|
|
187
|
+
}, immutable_1.default.List());
|
|
194
188
|
}
|
|
195
189
|
static dump(manifest) {
|
|
196
190
|
types_1.strOptions.fold.lineWidth = 90;
|
|
197
191
|
// @ts-expect-error TODO: plain is the value behind the TS constant
|
|
198
192
|
types_1.strOptions.defaultType = 'PLAIN';
|
|
199
|
-
return yaml_1.default.stringify(manifest);
|
|
193
|
+
return yaml_1.default.stringify(manifest.toJS());
|
|
200
194
|
}
|
|
201
195
|
static async load(filename, { protocol, skipValidation } = {
|
|
202
196
|
skipValidation: false,
|
|
@@ -216,18 +210,12 @@ More than one template named '${name}', template names must be unique.`,
|
|
|
216
210
|
const resolveFile = maybeRelativeFile => path_1.default.resolve(path_1.default.dirname(filename), maybeRelativeFile);
|
|
217
211
|
// TODO: Validation for file data sources
|
|
218
212
|
if (!has_file_data_sources) {
|
|
219
|
-
const manifestErrors = await Subgraph.validate(data, protocol, {
|
|
220
|
-
resolveFile,
|
|
221
|
-
});
|
|
213
|
+
const manifestErrors = await Subgraph.validate(data, protocol, { resolveFile });
|
|
222
214
|
if (manifestErrors.size > 0) {
|
|
223
215
|
throwCombinedError(filename, manifestErrors);
|
|
224
216
|
}
|
|
225
217
|
}
|
|
226
|
-
const
|
|
227
|
-
if (!manifestSchema.success) {
|
|
228
|
-
throw new Error(manifestSchema.error.message);
|
|
229
|
-
}
|
|
230
|
-
const manifest = manifestSchema.data;
|
|
218
|
+
const manifest = immutable_1.default.fromJS(data);
|
|
231
219
|
// Validate the schema
|
|
232
220
|
Subgraph.validateSchema(manifest, { resolveFile });
|
|
233
221
|
// Perform other validations
|
|
@@ -236,24 +224,18 @@ More than one template named '${name}', template names must be unique.`,
|
|
|
236
224
|
resolveFile,
|
|
237
225
|
});
|
|
238
226
|
const errors = skipValidation
|
|
239
|
-
?
|
|
240
|
-
:
|
|
241
|
-
|
|
242
|
-
...Subgraph.validateContractValues(manifest, protocol),
|
|
243
|
-
...Subgraph.validateUniqueDataSourceNames(manifest),
|
|
244
|
-
...Subgraph.validateUniqueTemplateNames(manifest),
|
|
245
|
-
...Subgraph.validateHandlers(manifest, protocol, protocolSubgraph),
|
|
246
|
-
];
|
|
247
|
-
if (errors.length > 0) {
|
|
227
|
+
? immutable_1.default.List()
|
|
228
|
+
: immutable_1.default.List.of(...protocolSubgraph.validateManifest(), ...Subgraph.validateContractValues(manifest, protocol), ...Subgraph.validateUniqueDataSourceNames(manifest), ...Subgraph.validateUniqueTemplateNames(manifest), ...Subgraph.validateHandlers(manifest, protocol, protocolSubgraph));
|
|
229
|
+
if (errors.size > 0) {
|
|
248
230
|
throwCombinedError(filename, errors);
|
|
249
231
|
}
|
|
250
232
|
// Perform warning validations
|
|
251
233
|
const warnings = skipValidation
|
|
252
|
-
?
|
|
253
|
-
:
|
|
234
|
+
? immutable_1.default.List()
|
|
235
|
+
: immutable_1.default.List.of(...Subgraph.validateRepository(manifest), ...Subgraph.validateDescription(manifest));
|
|
254
236
|
return {
|
|
255
237
|
result: manifest,
|
|
256
|
-
warning: warnings.
|
|
238
|
+
warning: warnings.size > 0 ? buildCombinedWarning(filename, warnings) : null,
|
|
257
239
|
};
|
|
258
240
|
}
|
|
259
241
|
static async write(manifest, filename) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import immutable from 'immutable';
|
|
1
2
|
import Protocol from '../protocols';
|
|
2
3
|
import { ContractCtor } from '../protocols/contract';
|
|
3
|
-
import { ManifestZodSchema } from '../manifest';
|
|
4
4
|
export declare const validateContract: (value: string, ProtocolContract: ContractCtor) => {
|
|
5
5
|
valid: false;
|
|
6
6
|
error: string;
|
|
@@ -8,4 +8,4 @@ export declare const validateContract: (value: string, ProtocolContract: Contrac
|
|
|
8
8
|
valid: true;
|
|
9
9
|
error: string | null;
|
|
10
10
|
};
|
|
11
|
-
export declare const validateContractValues: (manifest:
|
|
11
|
+
export declare const validateContractValues: (manifest: immutable.Map<any, any>, protocol: Protocol) => any;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.validateContractValues = exports.validateContract = void 0;
|
|
7
|
+
const immutable_1 = __importDefault(require("immutable"));
|
|
4
8
|
const validateContract = (value, ProtocolContract) => {
|
|
5
9
|
const contract = new ProtocolContract(value);
|
|
6
10
|
const { valid, error } = contract.validate();
|
|
@@ -16,26 +20,25 @@ exports.validateContract = validateContract;
|
|
|
16
20
|
const validateContractValues = (manifest, protocol) => {
|
|
17
21
|
const ProtocolContract = protocol.getContract();
|
|
18
22
|
const fieldName = ProtocolContract.identifierName();
|
|
19
|
-
return manifest
|
|
20
|
-
.
|
|
23
|
+
return manifest
|
|
24
|
+
.get('dataSources')
|
|
25
|
+
.filter((dataSource) => protocol.isValidKindName(dataSource.get('kind')))
|
|
21
26
|
.reduce((errors, dataSource, dataSourceIndex) => {
|
|
22
27
|
const path = ['dataSources', dataSourceIndex, 'source', fieldName];
|
|
23
28
|
// No need to validate if the source has no contract field
|
|
24
|
-
|
|
25
|
-
if (!dataSource.source[fieldName]) {
|
|
29
|
+
if (!dataSource.get('source').has(fieldName)) {
|
|
26
30
|
return errors;
|
|
27
31
|
}
|
|
28
|
-
|
|
29
|
-
const contractValue = dataSource.source[fieldName];
|
|
32
|
+
const contractValue = dataSource.getIn(['source', fieldName]);
|
|
30
33
|
const { valid, error } = (0, exports.validateContract)(contractValue, ProtocolContract);
|
|
31
34
|
// Validate whether the contract is valid for the protocol
|
|
32
35
|
if (valid) {
|
|
33
36
|
return errors;
|
|
34
37
|
}
|
|
35
|
-
return errors.push({
|
|
38
|
+
return errors.push(immutable_1.default.fromJS({
|
|
36
39
|
path,
|
|
37
40
|
message: error,
|
|
38
|
-
});
|
|
39
|
-
},
|
|
41
|
+
}));
|
|
42
|
+
}, immutable_1.default.List());
|
|
40
43
|
};
|
|
41
44
|
exports.validateContractValues = validateContractValues;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphprotocol/graph-cli",
|
|
3
|
-
"version": "0.54.0-alpha-
|
|
3
|
+
"version": "0.54.0-alpha-20230801202859-9fcb823",
|
|
4
4
|
"description": "CLI for building for and deploying to The Graph",
|
|
5
5
|
"license": "(Apache-2.0 OR MIT)",
|
|
6
6
|
"engines": {
|
|
@@ -44,15 +44,13 @@
|
|
|
44
44
|
"tmp-promise": "3.0.3",
|
|
45
45
|
"web3-eth-abi": "1.7.0",
|
|
46
46
|
"which": "2.0.2",
|
|
47
|
-
"yaml": "1.10.2"
|
|
48
|
-
"zod": "^3.21.4"
|
|
47
|
+
"yaml": "1.10.2"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
50
|
"@types/debug": "^4.1.7",
|
|
52
51
|
"@types/fs-extra": "^9.0.13",
|
|
53
52
|
"@types/jest": "^29.0.0",
|
|
54
53
|
"@types/js-yaml": "^3.12.7",
|
|
55
|
-
"@types/node": "^20.3.2",
|
|
56
54
|
"@types/semver": "^7.3.13",
|
|
57
55
|
"@types/which": "^2.0.1",
|
|
58
56
|
"copyfiles": "^2.4.1",
|
|
@@ -61,8 +59,7 @@
|
|
|
61
59
|
"spawn-command": "0.0.2-1",
|
|
62
60
|
"strip-ansi": "6.0.1",
|
|
63
61
|
"tern": "0.24.3",
|
|
64
|
-
"typescript": "^5.0.0"
|
|
65
|
-
"zod-to-json-schema": "^3.21.3"
|
|
62
|
+
"typescript": "^5.0.0"
|
|
66
63
|
},
|
|
67
64
|
"publishConfig": {
|
|
68
65
|
"access": "public"
|
|
@@ -78,7 +75,7 @@
|
|
|
78
75
|
]
|
|
79
76
|
},
|
|
80
77
|
"scripts": {
|
|
81
|
-
"build": "tsc -b tsconfig.build.json && oclif manifest && oclif readme && copyfiles -u 1 src/**/*.graphql dist/
|
|
78
|
+
"build": "tsc -b tsconfig.build.json && oclif manifest && oclif readme && copyfiles -u 1 src/**/*.graphql dist/",
|
|
82
79
|
"oclif:pack": "npm pack && pnpm oclif pack tarballs --no-xz && node scripts/rename-tarballs.mjs",
|
|
83
80
|
"test": "jest --verbose",
|
|
84
81
|
"test:add": "jest tests/cli/add.test.ts --verbose",
|
package/dist/manifest.d.ts
DELETED
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const Manifest: z.ZodObject<{
|
|
3
|
-
specVersion: z.ZodString;
|
|
4
|
-
schema: z.ZodObject<{
|
|
5
|
-
file: z.ZodString;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
file: string;
|
|
8
|
-
}, {
|
|
9
|
-
file: string;
|
|
10
|
-
}>;
|
|
11
|
-
description: z.ZodOptional<z.ZodString>;
|
|
12
|
-
repository: z.ZodOptional<z.ZodString>;
|
|
13
|
-
graft: z.ZodOptional<z.ZodObject<{
|
|
14
|
-
base: z.ZodString;
|
|
15
|
-
block: z.ZodBigInt;
|
|
16
|
-
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
base: string;
|
|
18
|
-
block: bigint;
|
|
19
|
-
}, {
|
|
20
|
-
base: string;
|
|
21
|
-
block: bigint;
|
|
22
|
-
}>>;
|
|
23
|
-
dataSources: z.ZodArray<z.ZodObject<{
|
|
24
|
-
kind: z.ZodString;
|
|
25
|
-
name: z.ZodString;
|
|
26
|
-
network: z.ZodString;
|
|
27
|
-
source: z.ZodObject<{
|
|
28
|
-
address: z.ZodString;
|
|
29
|
-
abi: z.ZodString;
|
|
30
|
-
startBlock: z.ZodOptional<z.ZodUnion<[z.ZodBigInt, z.ZodNumber]>>;
|
|
31
|
-
}, "strip", z.ZodTypeAny, {
|
|
32
|
-
address: string;
|
|
33
|
-
abi: string;
|
|
34
|
-
startBlock?: number | bigint | undefined;
|
|
35
|
-
}, {
|
|
36
|
-
address: string;
|
|
37
|
-
abi: string;
|
|
38
|
-
startBlock?: number | bigint | undefined;
|
|
39
|
-
}>;
|
|
40
|
-
mapping: z.ZodObject<{
|
|
41
|
-
kind: z.ZodLiteral<"ethereum/events">;
|
|
42
|
-
apiVersion: z.ZodString;
|
|
43
|
-
language: z.ZodLiteral<"wasm/assemblyscript">;
|
|
44
|
-
entities: z.ZodArray<z.ZodString, "many">;
|
|
45
|
-
eventHandlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
46
|
-
event: z.ZodString;
|
|
47
|
-
handler: z.ZodString;
|
|
48
|
-
topic0: z.ZodOptional<z.ZodString>;
|
|
49
|
-
}, "strip", z.ZodTypeAny, {
|
|
50
|
-
event: string;
|
|
51
|
-
handler: string;
|
|
52
|
-
topic0?: string | undefined;
|
|
53
|
-
}, {
|
|
54
|
-
event: string;
|
|
55
|
-
handler: string;
|
|
56
|
-
topic0?: string | undefined;
|
|
57
|
-
}>, "many">>;
|
|
58
|
-
callHandlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
59
|
-
function: z.ZodString;
|
|
60
|
-
handler: z.ZodString;
|
|
61
|
-
}, "strip", z.ZodTypeAny, {
|
|
62
|
-
function: string;
|
|
63
|
-
handler: string;
|
|
64
|
-
}, {
|
|
65
|
-
function: string;
|
|
66
|
-
handler: string;
|
|
67
|
-
}>, "many">>;
|
|
68
|
-
blockHandlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
69
|
-
handler: z.ZodString;
|
|
70
|
-
filter: z.ZodOptional<z.ZodObject<{
|
|
71
|
-
kind: z.ZodLiteral<"call">;
|
|
72
|
-
}, "strip", z.ZodTypeAny, {
|
|
73
|
-
kind: "call";
|
|
74
|
-
}, {
|
|
75
|
-
kind: "call";
|
|
76
|
-
}>>;
|
|
77
|
-
}, "strip", z.ZodTypeAny, {
|
|
78
|
-
handler: string;
|
|
79
|
-
filter?: {
|
|
80
|
-
kind: "call";
|
|
81
|
-
} | undefined;
|
|
82
|
-
}, {
|
|
83
|
-
handler: string;
|
|
84
|
-
filter?: {
|
|
85
|
-
kind: "call";
|
|
86
|
-
} | undefined;
|
|
87
|
-
}>, "many">>;
|
|
88
|
-
file: z.ZodString;
|
|
89
|
-
}, "strip", z.ZodTypeAny, {
|
|
90
|
-
file: string;
|
|
91
|
-
kind: "ethereum/events";
|
|
92
|
-
apiVersion: string;
|
|
93
|
-
language: "wasm/assemblyscript";
|
|
94
|
-
entities: string[];
|
|
95
|
-
eventHandlers?: {
|
|
96
|
-
event: string;
|
|
97
|
-
handler: string;
|
|
98
|
-
topic0?: string | undefined;
|
|
99
|
-
}[] | undefined;
|
|
100
|
-
callHandlers?: {
|
|
101
|
-
function: string;
|
|
102
|
-
handler: string;
|
|
103
|
-
}[] | undefined;
|
|
104
|
-
blockHandlers?: {
|
|
105
|
-
handler: string;
|
|
106
|
-
filter?: {
|
|
107
|
-
kind: "call";
|
|
108
|
-
} | undefined;
|
|
109
|
-
}[] | undefined;
|
|
110
|
-
}, {
|
|
111
|
-
file: string;
|
|
112
|
-
kind: "ethereum/events";
|
|
113
|
-
apiVersion: string;
|
|
114
|
-
language: "wasm/assemblyscript";
|
|
115
|
-
entities: string[];
|
|
116
|
-
eventHandlers?: {
|
|
117
|
-
event: string;
|
|
118
|
-
handler: string;
|
|
119
|
-
topic0?: string | undefined;
|
|
120
|
-
}[] | undefined;
|
|
121
|
-
callHandlers?: {
|
|
122
|
-
function: string;
|
|
123
|
-
handler: string;
|
|
124
|
-
}[] | undefined;
|
|
125
|
-
blockHandlers?: {
|
|
126
|
-
handler: string;
|
|
127
|
-
filter?: {
|
|
128
|
-
kind: "call";
|
|
129
|
-
} | undefined;
|
|
130
|
-
}[] | undefined;
|
|
131
|
-
}>;
|
|
132
|
-
}, "strip", z.ZodTypeAny, {
|
|
133
|
-
kind: string;
|
|
134
|
-
name: string;
|
|
135
|
-
network: string;
|
|
136
|
-
source: {
|
|
137
|
-
address: string;
|
|
138
|
-
abi: string;
|
|
139
|
-
startBlock?: number | bigint | undefined;
|
|
140
|
-
};
|
|
141
|
-
mapping: {
|
|
142
|
-
file: string;
|
|
143
|
-
kind: "ethereum/events";
|
|
144
|
-
apiVersion: string;
|
|
145
|
-
language: "wasm/assemblyscript";
|
|
146
|
-
entities: string[];
|
|
147
|
-
eventHandlers?: {
|
|
148
|
-
event: string;
|
|
149
|
-
handler: string;
|
|
150
|
-
topic0?: string | undefined;
|
|
151
|
-
}[] | undefined;
|
|
152
|
-
callHandlers?: {
|
|
153
|
-
function: string;
|
|
154
|
-
handler: string;
|
|
155
|
-
}[] | undefined;
|
|
156
|
-
blockHandlers?: {
|
|
157
|
-
handler: string;
|
|
158
|
-
filter?: {
|
|
159
|
-
kind: "call";
|
|
160
|
-
} | undefined;
|
|
161
|
-
}[] | undefined;
|
|
162
|
-
};
|
|
163
|
-
}, {
|
|
164
|
-
kind: string;
|
|
165
|
-
name: string;
|
|
166
|
-
network: string;
|
|
167
|
-
source: {
|
|
168
|
-
address: string;
|
|
169
|
-
abi: string;
|
|
170
|
-
startBlock?: number | bigint | undefined;
|
|
171
|
-
};
|
|
172
|
-
mapping: {
|
|
173
|
-
file: string;
|
|
174
|
-
kind: "ethereum/events";
|
|
175
|
-
apiVersion: string;
|
|
176
|
-
language: "wasm/assemblyscript";
|
|
177
|
-
entities: string[];
|
|
178
|
-
eventHandlers?: {
|
|
179
|
-
event: string;
|
|
180
|
-
handler: string;
|
|
181
|
-
topic0?: string | undefined;
|
|
182
|
-
}[] | undefined;
|
|
183
|
-
callHandlers?: {
|
|
184
|
-
function: string;
|
|
185
|
-
handler: string;
|
|
186
|
-
}[] | undefined;
|
|
187
|
-
blockHandlers?: {
|
|
188
|
-
handler: string;
|
|
189
|
-
filter?: {
|
|
190
|
-
kind: "call";
|
|
191
|
-
} | undefined;
|
|
192
|
-
}[] | undefined;
|
|
193
|
-
};
|
|
194
|
-
}>, "many">;
|
|
195
|
-
templates: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
196
|
-
kind: z.ZodString;
|
|
197
|
-
name: z.ZodString;
|
|
198
|
-
network: z.ZodString;
|
|
199
|
-
source: z.ZodObject<{
|
|
200
|
-
abi: z.ZodString;
|
|
201
|
-
startBlock: z.ZodOptional<z.ZodUnion<[z.ZodBigInt, z.ZodNumber]>>;
|
|
202
|
-
}, "strip", z.ZodTypeAny, {
|
|
203
|
-
abi: string;
|
|
204
|
-
startBlock?: number | bigint | undefined;
|
|
205
|
-
}, {
|
|
206
|
-
abi: string;
|
|
207
|
-
startBlock?: number | bigint | undefined;
|
|
208
|
-
}>;
|
|
209
|
-
mapping: z.ZodObject<{
|
|
210
|
-
kind: z.ZodLiteral<"ethereum/events">;
|
|
211
|
-
apiVersion: z.ZodString;
|
|
212
|
-
language: z.ZodLiteral<"wasm/assemblyscript">;
|
|
213
|
-
entities: z.ZodArray<z.ZodString, "many">;
|
|
214
|
-
eventHandlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
215
|
-
event: z.ZodString;
|
|
216
|
-
handler: z.ZodString;
|
|
217
|
-
topic0: z.ZodOptional<z.ZodString>;
|
|
218
|
-
}, "strip", z.ZodTypeAny, {
|
|
219
|
-
event: string;
|
|
220
|
-
handler: string;
|
|
221
|
-
topic0?: string | undefined;
|
|
222
|
-
}, {
|
|
223
|
-
event: string;
|
|
224
|
-
handler: string;
|
|
225
|
-
topic0?: string | undefined;
|
|
226
|
-
}>, "many">>;
|
|
227
|
-
callHandlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
228
|
-
function: z.ZodString;
|
|
229
|
-
handler: z.ZodString;
|
|
230
|
-
}, "strip", z.ZodTypeAny, {
|
|
231
|
-
function: string;
|
|
232
|
-
handler: string;
|
|
233
|
-
}, {
|
|
234
|
-
function: string;
|
|
235
|
-
handler: string;
|
|
236
|
-
}>, "many">>;
|
|
237
|
-
blockHandlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
238
|
-
handler: z.ZodString;
|
|
239
|
-
filter: z.ZodOptional<z.ZodObject<{
|
|
240
|
-
kind: z.ZodLiteral<"call">;
|
|
241
|
-
}, "strip", z.ZodTypeAny, {
|
|
242
|
-
kind: "call";
|
|
243
|
-
}, {
|
|
244
|
-
kind: "call";
|
|
245
|
-
}>>;
|
|
246
|
-
}, "strip", z.ZodTypeAny, {
|
|
247
|
-
handler: string;
|
|
248
|
-
filter?: {
|
|
249
|
-
kind: "call";
|
|
250
|
-
} | undefined;
|
|
251
|
-
}, {
|
|
252
|
-
handler: string;
|
|
253
|
-
filter?: {
|
|
254
|
-
kind: "call";
|
|
255
|
-
} | undefined;
|
|
256
|
-
}>, "many">>;
|
|
257
|
-
file: z.ZodString;
|
|
258
|
-
}, "strip", z.ZodTypeAny, {
|
|
259
|
-
file: string;
|
|
260
|
-
kind: "ethereum/events";
|
|
261
|
-
apiVersion: string;
|
|
262
|
-
language: "wasm/assemblyscript";
|
|
263
|
-
entities: string[];
|
|
264
|
-
eventHandlers?: {
|
|
265
|
-
event: string;
|
|
266
|
-
handler: string;
|
|
267
|
-
topic0?: string | undefined;
|
|
268
|
-
}[] | undefined;
|
|
269
|
-
callHandlers?: {
|
|
270
|
-
function: string;
|
|
271
|
-
handler: string;
|
|
272
|
-
}[] | undefined;
|
|
273
|
-
blockHandlers?: {
|
|
274
|
-
handler: string;
|
|
275
|
-
filter?: {
|
|
276
|
-
kind: "call";
|
|
277
|
-
} | undefined;
|
|
278
|
-
}[] | undefined;
|
|
279
|
-
}, {
|
|
280
|
-
file: string;
|
|
281
|
-
kind: "ethereum/events";
|
|
282
|
-
apiVersion: string;
|
|
283
|
-
language: "wasm/assemblyscript";
|
|
284
|
-
entities: string[];
|
|
285
|
-
eventHandlers?: {
|
|
286
|
-
event: string;
|
|
287
|
-
handler: string;
|
|
288
|
-
topic0?: string | undefined;
|
|
289
|
-
}[] | undefined;
|
|
290
|
-
callHandlers?: {
|
|
291
|
-
function: string;
|
|
292
|
-
handler: string;
|
|
293
|
-
}[] | undefined;
|
|
294
|
-
blockHandlers?: {
|
|
295
|
-
handler: string;
|
|
296
|
-
filter?: {
|
|
297
|
-
kind: "call";
|
|
298
|
-
} | undefined;
|
|
299
|
-
}[] | undefined;
|
|
300
|
-
}>;
|
|
301
|
-
}, "strip", z.ZodTypeAny, {
|
|
302
|
-
kind: string;
|
|
303
|
-
name: string;
|
|
304
|
-
network: string;
|
|
305
|
-
source: {
|
|
306
|
-
abi: string;
|
|
307
|
-
startBlock?: number | bigint | undefined;
|
|
308
|
-
};
|
|
309
|
-
mapping: {
|
|
310
|
-
file: string;
|
|
311
|
-
kind: "ethereum/events";
|
|
312
|
-
apiVersion: string;
|
|
313
|
-
language: "wasm/assemblyscript";
|
|
314
|
-
entities: string[];
|
|
315
|
-
eventHandlers?: {
|
|
316
|
-
event: string;
|
|
317
|
-
handler: string;
|
|
318
|
-
topic0?: string | undefined;
|
|
319
|
-
}[] | undefined;
|
|
320
|
-
callHandlers?: {
|
|
321
|
-
function: string;
|
|
322
|
-
handler: string;
|
|
323
|
-
}[] | undefined;
|
|
324
|
-
blockHandlers?: {
|
|
325
|
-
handler: string;
|
|
326
|
-
filter?: {
|
|
327
|
-
kind: "call";
|
|
328
|
-
} | undefined;
|
|
329
|
-
}[] | undefined;
|
|
330
|
-
};
|
|
331
|
-
}, {
|
|
332
|
-
kind: string;
|
|
333
|
-
name: string;
|
|
334
|
-
network: string;
|
|
335
|
-
source: {
|
|
336
|
-
abi: string;
|
|
337
|
-
startBlock?: number | bigint | undefined;
|
|
338
|
-
};
|
|
339
|
-
mapping: {
|
|
340
|
-
file: string;
|
|
341
|
-
kind: "ethereum/events";
|
|
342
|
-
apiVersion: string;
|
|
343
|
-
language: "wasm/assemblyscript";
|
|
344
|
-
entities: string[];
|
|
345
|
-
eventHandlers?: {
|
|
346
|
-
event: string;
|
|
347
|
-
handler: string;
|
|
348
|
-
topic0?: string | undefined;
|
|
349
|
-
}[] | undefined;
|
|
350
|
-
callHandlers?: {
|
|
351
|
-
function: string;
|
|
352
|
-
handler: string;
|
|
353
|
-
}[] | undefined;
|
|
354
|
-
blockHandlers?: {
|
|
355
|
-
handler: string;
|
|
356
|
-
filter?: {
|
|
357
|
-
kind: "call";
|
|
358
|
-
} | undefined;
|
|
359
|
-
}[] | undefined;
|
|
360
|
-
};
|
|
361
|
-
}>, "many">>;
|
|
362
|
-
}, "strip", z.ZodTypeAny, {
|
|
363
|
-
specVersion: string;
|
|
364
|
-
schema: {
|
|
365
|
-
file: string;
|
|
366
|
-
};
|
|
367
|
-
dataSources: {
|
|
368
|
-
kind: string;
|
|
369
|
-
name: string;
|
|
370
|
-
network: string;
|
|
371
|
-
source: {
|
|
372
|
-
address: string;
|
|
373
|
-
abi: string;
|
|
374
|
-
startBlock?: number | bigint | undefined;
|
|
375
|
-
};
|
|
376
|
-
mapping: {
|
|
377
|
-
file: string;
|
|
378
|
-
kind: "ethereum/events";
|
|
379
|
-
apiVersion: string;
|
|
380
|
-
language: "wasm/assemblyscript";
|
|
381
|
-
entities: string[];
|
|
382
|
-
eventHandlers?: {
|
|
383
|
-
event: string;
|
|
384
|
-
handler: string;
|
|
385
|
-
topic0?: string | undefined;
|
|
386
|
-
}[] | undefined;
|
|
387
|
-
callHandlers?: {
|
|
388
|
-
function: string;
|
|
389
|
-
handler: string;
|
|
390
|
-
}[] | undefined;
|
|
391
|
-
blockHandlers?: {
|
|
392
|
-
handler: string;
|
|
393
|
-
filter?: {
|
|
394
|
-
kind: "call";
|
|
395
|
-
} | undefined;
|
|
396
|
-
}[] | undefined;
|
|
397
|
-
};
|
|
398
|
-
}[];
|
|
399
|
-
description?: string | undefined;
|
|
400
|
-
repository?: string | undefined;
|
|
401
|
-
graft?: {
|
|
402
|
-
base: string;
|
|
403
|
-
block: bigint;
|
|
404
|
-
} | undefined;
|
|
405
|
-
templates?: {
|
|
406
|
-
kind: string;
|
|
407
|
-
name: string;
|
|
408
|
-
network: string;
|
|
409
|
-
source: {
|
|
410
|
-
abi: string;
|
|
411
|
-
startBlock?: number | bigint | undefined;
|
|
412
|
-
};
|
|
413
|
-
mapping: {
|
|
414
|
-
file: string;
|
|
415
|
-
kind: "ethereum/events";
|
|
416
|
-
apiVersion: string;
|
|
417
|
-
language: "wasm/assemblyscript";
|
|
418
|
-
entities: string[];
|
|
419
|
-
eventHandlers?: {
|
|
420
|
-
event: string;
|
|
421
|
-
handler: string;
|
|
422
|
-
topic0?: string | undefined;
|
|
423
|
-
}[] | undefined;
|
|
424
|
-
callHandlers?: {
|
|
425
|
-
function: string;
|
|
426
|
-
handler: string;
|
|
427
|
-
}[] | undefined;
|
|
428
|
-
blockHandlers?: {
|
|
429
|
-
handler: string;
|
|
430
|
-
filter?: {
|
|
431
|
-
kind: "call";
|
|
432
|
-
} | undefined;
|
|
433
|
-
}[] | undefined;
|
|
434
|
-
};
|
|
435
|
-
}[] | undefined;
|
|
436
|
-
}, {
|
|
437
|
-
specVersion: string;
|
|
438
|
-
schema: {
|
|
439
|
-
file: string;
|
|
440
|
-
};
|
|
441
|
-
dataSources: {
|
|
442
|
-
kind: string;
|
|
443
|
-
name: string;
|
|
444
|
-
network: string;
|
|
445
|
-
source: {
|
|
446
|
-
address: string;
|
|
447
|
-
abi: string;
|
|
448
|
-
startBlock?: number | bigint | undefined;
|
|
449
|
-
};
|
|
450
|
-
mapping: {
|
|
451
|
-
file: string;
|
|
452
|
-
kind: "ethereum/events";
|
|
453
|
-
apiVersion: string;
|
|
454
|
-
language: "wasm/assemblyscript";
|
|
455
|
-
entities: string[];
|
|
456
|
-
eventHandlers?: {
|
|
457
|
-
event: string;
|
|
458
|
-
handler: string;
|
|
459
|
-
topic0?: string | undefined;
|
|
460
|
-
}[] | undefined;
|
|
461
|
-
callHandlers?: {
|
|
462
|
-
function: string;
|
|
463
|
-
handler: string;
|
|
464
|
-
}[] | undefined;
|
|
465
|
-
blockHandlers?: {
|
|
466
|
-
handler: string;
|
|
467
|
-
filter?: {
|
|
468
|
-
kind: "call";
|
|
469
|
-
} | undefined;
|
|
470
|
-
}[] | undefined;
|
|
471
|
-
};
|
|
472
|
-
}[];
|
|
473
|
-
description?: string | undefined;
|
|
474
|
-
repository?: string | undefined;
|
|
475
|
-
graft?: {
|
|
476
|
-
base: string;
|
|
477
|
-
block: bigint;
|
|
478
|
-
} | undefined;
|
|
479
|
-
templates?: {
|
|
480
|
-
kind: string;
|
|
481
|
-
name: string;
|
|
482
|
-
network: string;
|
|
483
|
-
source: {
|
|
484
|
-
abi: string;
|
|
485
|
-
startBlock?: number | bigint | undefined;
|
|
486
|
-
};
|
|
487
|
-
mapping: {
|
|
488
|
-
file: string;
|
|
489
|
-
kind: "ethereum/events";
|
|
490
|
-
apiVersion: string;
|
|
491
|
-
language: "wasm/assemblyscript";
|
|
492
|
-
entities: string[];
|
|
493
|
-
eventHandlers?: {
|
|
494
|
-
event: string;
|
|
495
|
-
handler: string;
|
|
496
|
-
topic0?: string | undefined;
|
|
497
|
-
}[] | undefined;
|
|
498
|
-
callHandlers?: {
|
|
499
|
-
function: string;
|
|
500
|
-
handler: string;
|
|
501
|
-
}[] | undefined;
|
|
502
|
-
blockHandlers?: {
|
|
503
|
-
handler: string;
|
|
504
|
-
filter?: {
|
|
505
|
-
kind: "call";
|
|
506
|
-
} | undefined;
|
|
507
|
-
}[] | undefined;
|
|
508
|
-
};
|
|
509
|
-
}[] | undefined;
|
|
510
|
-
}>;
|
|
511
|
-
export type ManifestZodSchema = z.infer<typeof Manifest>;
|
package/dist/manifest.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Manifest = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#14-schema
|
|
6
|
-
const Schema = zod_1.z.object({
|
|
7
|
-
file: zod_1.z.string().describe('The path of the GraphQL IDL file, either local or on IPFS.'),
|
|
8
|
-
});
|
|
9
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#151-ethereumcontractsource
|
|
10
|
-
const EthereumContractSource = zod_1.z.object({
|
|
11
|
-
address: zod_1.z.string(),
|
|
12
|
-
abi: zod_1.z.string(),
|
|
13
|
-
startBlock: zod_1.z.union([zod_1.z.bigint(), zod_1.z.number()]).optional(),
|
|
14
|
-
});
|
|
15
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#151-ethereumcontractsource
|
|
16
|
-
const EthereumTemplateContractSource = zod_1.z.object({
|
|
17
|
-
abi: zod_1.z.string(),
|
|
18
|
-
startBlock: zod_1.z.union([zod_1.z.bigint(), zod_1.z.number()]).optional(),
|
|
19
|
-
});
|
|
20
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#1522-eventhandler
|
|
21
|
-
const EventHandler = zod_1.z.object({
|
|
22
|
-
event: zod_1.z
|
|
23
|
-
.string()
|
|
24
|
-
.describe('An identifier for an event that will be handled in the mapping script. For Ethereum contracts, this must be the full event signature to distinguish from events that may share the same name. No alias types can be used.'),
|
|
25
|
-
handler: zod_1.z
|
|
26
|
-
.string()
|
|
27
|
-
.describe('The name of an exported function in the mapping script that should handle the specified event.'),
|
|
28
|
-
topic0: zod_1.z
|
|
29
|
-
.string()
|
|
30
|
-
.optional()
|
|
31
|
-
.describe('A 0x prefixed hex string. If provided, events whose topic0 is equal to this value will be processed by the given handler. When topic0 is provided, only the topic0 value will be matched, and not the hash of the event signature. This is useful for processing anonymous events in Solidity, which can have their topic0 set to anything. By default, topic0 is equal to the hash of the event signature.'),
|
|
32
|
-
});
|
|
33
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#1523-callhandler
|
|
34
|
-
const CallHandler = zod_1.z.object({
|
|
35
|
-
function: zod_1.z
|
|
36
|
-
.string()
|
|
37
|
-
.describe('An identifier for a function that will be handled in the mapping script. For Ethereum contracts, this is the normalized function signature to filter calls by.'),
|
|
38
|
-
handler: zod_1.z
|
|
39
|
-
.string()
|
|
40
|
-
.describe('The name of an exported function in the mapping script that should handle the specified event.'),
|
|
41
|
-
});
|
|
42
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#15241-blockhandlerfilter
|
|
43
|
-
const BlockHandlerFilter = zod_1.z.object({
|
|
44
|
-
kind: zod_1.z.literal('call').describe('The selected block handler filter.'),
|
|
45
|
-
});
|
|
46
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#1524-blockhandler
|
|
47
|
-
const BlockHandler = zod_1.z.object({
|
|
48
|
-
handler: zod_1.z
|
|
49
|
-
.string()
|
|
50
|
-
.describe('The name of an exported function in the mapping script that should handle the specified event.'),
|
|
51
|
-
filter: BlockHandlerFilter.optional().describe('Definition of the filter to apply. If none is supplied, the handler will be called on every block.'),
|
|
52
|
-
});
|
|
53
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#1521-ethereum-mapping
|
|
54
|
-
const EthereumMapping = zod_1.z.object({
|
|
55
|
-
kind: zod_1.z
|
|
56
|
-
.literal('ethereum/events')
|
|
57
|
-
.describe('Must be "ethereum/events" for Ethereum Events Mapping.'),
|
|
58
|
-
apiVersion: zod_1.z
|
|
59
|
-
.string()
|
|
60
|
-
.describe('Semver string of the version of the Mappings API that will be used by the mapping script.'),
|
|
61
|
-
language: zod_1.z
|
|
62
|
-
.literal('wasm/assemblyscript')
|
|
63
|
-
.describe('The language of the runtime for the Mapping API.'),
|
|
64
|
-
entities: zod_1.z
|
|
65
|
-
.array(zod_1.z.string())
|
|
66
|
-
.describe('A list of entities that will be ingested as part of this mapping. Must correspond to names of entities in the GraphQL IDL.'),
|
|
67
|
-
eventHandlers: zod_1.z
|
|
68
|
-
.array(EventHandler)
|
|
69
|
-
.optional()
|
|
70
|
-
.describe('Handlers for specific events, which will be defined in the mapping script.'),
|
|
71
|
-
callHandlers: zod_1.z
|
|
72
|
-
.array(CallHandler)
|
|
73
|
-
.optional()
|
|
74
|
-
.describe('A list of functions that will trigger a handler and the name of the corresponding handlers in the mapping.'),
|
|
75
|
-
blockHandlers: zod_1.z
|
|
76
|
-
.array(BlockHandler)
|
|
77
|
-
.optional()
|
|
78
|
-
.describe('Defines block filters and handlers to process matching blocks.'),
|
|
79
|
-
file: zod_1.z.string().describe('The path of the mapping script.'),
|
|
80
|
-
});
|
|
81
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#152-mapping
|
|
82
|
-
const Mapping = EthereumMapping;
|
|
83
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#15-data-source
|
|
84
|
-
const DataSource = zod_1.z.object({
|
|
85
|
-
kind: zod_1.z.string().describe('The type of data source. Possible values: ethereum/contract.'),
|
|
86
|
-
name: zod_1.z
|
|
87
|
-
.string()
|
|
88
|
-
.describe('The name of the source data. Will be used to generate APIs in the mapping and also for self-documentation purposes.'),
|
|
89
|
-
network: zod_1.z
|
|
90
|
-
.string()
|
|
91
|
-
.describe('For blockchains, this describes which network the subgraph targets'),
|
|
92
|
-
source: EthereumContractSource.describe('The source data on a blockchain such as Ethereum.'),
|
|
93
|
-
mapping: Mapping.describe('The mapping that defines how to ingest the data.'),
|
|
94
|
-
});
|
|
95
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#17-data-source-templates
|
|
96
|
-
const TemplateSource = zod_1.z.object({
|
|
97
|
-
kind: zod_1.z.string().describe('The type of data source. Possible values: ethereum/contract.'),
|
|
98
|
-
name: zod_1.z
|
|
99
|
-
.string()
|
|
100
|
-
.describe('The name of the source data. Will be used to generate APIs in the mapping and also for self-documentation purposes.'),
|
|
101
|
-
network: zod_1.z
|
|
102
|
-
.string()
|
|
103
|
-
.describe('For blockchains, this describes which network the subgraph targets'),
|
|
104
|
-
source: EthereumTemplateContractSource.describe('The source data on a blockchain such as Ethereum.'),
|
|
105
|
-
mapping: Mapping.describe('The mapping that defines how to ingest the data.'),
|
|
106
|
-
});
|
|
107
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#18-graft-base
|
|
108
|
-
const GraftBase = zod_1.z.object({
|
|
109
|
-
base: zod_1.z.string().describe('The subgraph ID of the base subgraph'),
|
|
110
|
-
block: zod_1.z.bigint().describe('The block number up to which to use data from the base subgraph'),
|
|
111
|
-
});
|
|
112
|
-
// https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md#13-top-level-api
|
|
113
|
-
exports.Manifest = zod_1.z.object({
|
|
114
|
-
specVersion: zod_1.z
|
|
115
|
-
.string()
|
|
116
|
-
.describe('A Semver version indicating which version of this API is being used.'),
|
|
117
|
-
schema: Schema.describe('The GraphQL schema of this subgraph.'),
|
|
118
|
-
description: zod_1.z.string().describe("An optional description of the subgraph's purpose.").optional(),
|
|
119
|
-
repository: zod_1.z.string().describe('An optional link to where the subgraph lives.').optional(),
|
|
120
|
-
graft: GraftBase.describe('An optional base to graft onto.').optional(),
|
|
121
|
-
dataSources: zod_1.z
|
|
122
|
-
.array(DataSource)
|
|
123
|
-
.describe("Each data source spec defines the data that will be ingested as well as the transformation logic to derive the state of the subgraph's entities based on the source data."),
|
|
124
|
-
templates: zod_1.z
|
|
125
|
-
.array(TemplateSource)
|
|
126
|
-
.optional()
|
|
127
|
-
.describe('Each data source template defines a data source that can be created dynamically from the mappings.'),
|
|
128
|
-
});
|