@graphprotocol/graph-cli 0.49.0-alpha-20230505181403-af18bf2 → 0.49.0-alpha-20230530184045-63696ac
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 +10 -40
- package/dist/codegen/schema.d.ts +7 -0
- package/dist/codegen/schema.js +96 -0
- package/dist/codegen/schema.test.js +2 -7
- package/dist/command-helpers/scaffold.d.ts +0 -8
- package/dist/commands/init.js +212 -261
- package/dist/protocols/index.js +8 -1
- package/dist/scaffold/index.d.ts +0 -9
- package/dist/scaffold/index.js +0 -27
- package/dist/type-generator.js +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
-
## 0.49.0-alpha-
|
|
3
|
+
## 0.49.0-alpha-20230530184045-63696ac
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -9,53 +9,23 @@
|
|
|
9
9
|
Thanks [@saihaj](https://github.com/saihaj)! - do not generate types, instead show a message to
|
|
10
10
|
user to use substreams CLI for codegen.
|
|
11
11
|
|
|
12
|
-
- [#
|
|
13
|
-
[`
|
|
14
|
-
Thanks [@
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
.
|
|
19
|
-
├── package.json
|
|
20
|
-
├── schema.graphql
|
|
21
|
-
└── subgraph.yaml
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
In the `package.json` we only depend on the CLI since that is what developer will use to deploy
|
|
25
|
-
the subgraph. The `schema.graphql` is the schema of the subgraph and the `subgraph.yaml` is the
|
|
26
|
-
manifest file for the subgraph.
|
|
27
|
-
|
|
28
|
-
- [#1335](https://github.com/graphprotocol/graph-tooling/pull/1335)
|
|
29
|
-
[`affcb14`](https://github.com/graphprotocol/graph-tooling/commit/affcb1492f29affdb2426e57a154f132362f24ef)
|
|
30
|
-
Thanks [@saihaj](https://github.com/saihaj)! - respect --abi flag instead of loading from
|
|
31
|
-
etherscan
|
|
32
|
-
|
|
33
|
-
- [#1335](https://github.com/graphprotocol/graph-tooling/pull/1335)
|
|
34
|
-
[`f90dd75`](https://github.com/graphprotocol/graph-tooling/commit/f90dd757a558f4e66cc46780f13612309f45646a)
|
|
35
|
-
Thanks [@saihaj](https://github.com/saihaj)! - remove index events as entities for substreams
|
|
12
|
+
- [#1340](https://github.com/graphprotocol/graph-tooling/pull/1340)
|
|
13
|
+
[`72ffd3d`](https://github.com/graphprotocol/graph-tooling/commit/72ffd3def132ccf4d50a18e0e6fd1b377da6cd48)
|
|
14
|
+
Thanks [@incrypto32](https://github.com/incrypto32)! - Add support for codegen for derived field
|
|
15
|
+
loaders, This adds getters for derived fields defined in the schema for entities.
|
|
36
16
|
|
|
37
17
|
- [#1306](https://github.com/graphprotocol/graph-tooling/pull/1306)
|
|
38
18
|
[`f5e4b58`](https://github.com/graphprotocol/graph-tooling/commit/f5e4b58989edc5f3bb8211f1b912449e77832de8)
|
|
39
19
|
Thanks [@saihaj](https://github.com/saihaj)! - Add loadInBlock function for entities as part of
|
|
40
20
|
codegen
|
|
41
21
|
|
|
42
|
-
- [#1335](https://github.com/graphprotocol/graph-tooling/pull/1335)
|
|
43
|
-
[`f90dd75`](https://github.com/graphprotocol/graph-tooling/commit/f90dd757a558f4e66cc46780f13612309f45646a)
|
|
44
|
-
Thanks [@saihaj](https://github.com/saihaj)! - remove start block selection for substreams
|
|
45
|
-
|
|
46
22
|
### Patch Changes
|
|
47
23
|
|
|
48
|
-
- [#
|
|
49
|
-
[`
|
|
50
|
-
Thanks [@
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
`https://github.com/edgeandnode/gluegun#v4.3.1-pin-colors-dep`, in `dependencies`)
|
|
54
|
-
|
|
55
|
-
- [#1331](https://github.com/graphprotocol/graph-tooling/pull/1331)
|
|
56
|
-
[`b2c8dec`](https://github.com/graphprotocol/graph-tooling/commit/b2c8decb7806d25df6ca4e07f6dfdf7941516435)
|
|
57
|
-
Thanks [@saihaj](https://github.com/saihaj)! - only allow mainnet for substreams in network
|
|
58
|
-
selection for init
|
|
24
|
+
- [#1340](https://github.com/graphprotocol/graph-tooling/pull/1340)
|
|
25
|
+
[`dd5d0b2`](https://github.com/graphprotocol/graph-tooling/commit/dd5d0b29355b62b7671e25da38d434a2de7f4b47)
|
|
26
|
+
Thanks [@incrypto32](https://github.com/incrypto32)! - dependencies updates:
|
|
27
|
+
- Updated dependency [`@oclif/core@2.8.4` ↗︎](https://www.npmjs.com/package/@oclif/core/v/2.8.4)
|
|
28
|
+
(from `2.8.2`, in `dependencies`)
|
|
59
29
|
|
|
60
30
|
## 0.48.0
|
|
61
31
|
|
package/dist/codegen/schema.d.ts
CHANGED
|
@@ -21,13 +21,20 @@ export default class SchemaCodeGenerator {
|
|
|
21
21
|
constructor(schema: Schema);
|
|
22
22
|
generateModuleImports(): tsCodegen.ModuleImports[];
|
|
23
23
|
generateTypes(): Array<tsCodegen.Class>;
|
|
24
|
+
generateDerivedLoaders(): any[];
|
|
24
25
|
_isEntityTypeDefinition(def: DefinitionNode): def is ObjectTypeDefinitionNode;
|
|
26
|
+
_isDerivedField(field: FieldDefinitionNode | undefined): boolean;
|
|
25
27
|
_isInterfaceDefinition(def: DefinitionNode): def is InterfaceTypeDefinitionNode;
|
|
26
28
|
_generateEntityType(def: ObjectTypeDefinitionNode): tsCodegen.Class;
|
|
29
|
+
_generateDerivedLoader(typeName: string): any;
|
|
30
|
+
_getTypeNameForField(gqlType: TypeNode): string;
|
|
27
31
|
_generateConstructor(_entityName: string, fields: readonly FieldDefinitionNode[] | undefined): tsCodegen.Method;
|
|
28
32
|
_generateStoreMethods(entityName: string, idField: IdField): Array<tsCodegen.Method | tsCodegen.StaticMethod>;
|
|
29
33
|
_generateEntityFieldMethods(entityDef: ObjectTypeDefinitionNode, fieldDef: FieldDefinitionNode): Array<tsCodegen.Method>;
|
|
30
34
|
_generateEntityFieldGetter(_entityDef: ObjectTypeDefinitionNode, fieldDef: FieldDefinitionNode): tsCodegen.Method;
|
|
35
|
+
_generateDerivedFieldGetter(entityDef: ObjectTypeDefinitionNode, fieldDef: FieldDefinitionNode): tsCodegen.Method;
|
|
36
|
+
_returnTypeForDervied(gqlType: TypeNode): tsCodegen.NamedType;
|
|
37
|
+
_generatedEntityDerivedFieldGetter(_entityDef: ObjectTypeDefinitionNode, fieldDef: FieldDefinitionNode): tsCodegen.Method;
|
|
31
38
|
_generateEntityFieldSetter(_entityDef: ObjectTypeDefinitionNode, fieldDef: FieldDefinitionNode): tsCodegen.Method | null;
|
|
32
39
|
_resolveFieldType(gqlType: NamedTypeNode): string;
|
|
33
40
|
/** Return the type that values for this field must have. For scalar
|
package/dist/codegen/schema.js
CHANGED
|
@@ -22,7 +22,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
/* eslint-disable unicorn/no-array-for-each */
|
|
30
|
+
const debug_1 = __importDefault(require("debug"));
|
|
26
31
|
const typesCodegen = __importStar(require("./types"));
|
|
27
32
|
const tsCodegen = __importStar(require("./typescript"));
|
|
28
33
|
class IdField {
|
|
@@ -98,10 +103,23 @@ class SchemaCodeGenerator {
|
|
|
98
103
|
})
|
|
99
104
|
.filter(Boolean);
|
|
100
105
|
}
|
|
106
|
+
generateDerivedLoaders() {
|
|
107
|
+
const fields = this.schema.ast.definitions.filter(def => this._isEntityTypeDefinition(def))
|
|
108
|
+
.flatMap((def) => def.fields)
|
|
109
|
+
.filter(def => this._isDerivedField(def))
|
|
110
|
+
.filter(def => def?.type !== undefined).map(def => this._getTypeNameForField(def.type));
|
|
111
|
+
return [...new Set(fields)].map(typeName => {
|
|
112
|
+
return this._generateDerivedLoader(typeName);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
101
115
|
_isEntityTypeDefinition(def) {
|
|
102
116
|
return (def.kind === 'ObjectTypeDefinition' &&
|
|
103
117
|
def.directives?.find(directive => directive.name.value === 'entity') !== undefined);
|
|
104
118
|
}
|
|
119
|
+
_isDerivedField(field) {
|
|
120
|
+
return (field?.directives?.find((directive) => directive.name.value === 'derivedFrom') !==
|
|
121
|
+
undefined);
|
|
122
|
+
}
|
|
105
123
|
_isInterfaceDefinition(def) {
|
|
106
124
|
return def.kind === 'InterfaceTypeDefinition';
|
|
107
125
|
}
|
|
@@ -120,6 +138,42 @@ class SchemaCodeGenerator {
|
|
|
120
138
|
.forEach((method) => klass.addMethod(method));
|
|
121
139
|
return klass;
|
|
122
140
|
}
|
|
141
|
+
_generateDerivedLoader(typeName) {
|
|
142
|
+
// <field>Loader
|
|
143
|
+
const klass = tsCodegen.klass(`${typeName}Loader`, { export: true, extends: 'Entity' });
|
|
144
|
+
klass.addMember(tsCodegen.klassMember('_entity', 'string'));
|
|
145
|
+
klass.addMember(tsCodegen.klassMember('_field', 'string'));
|
|
146
|
+
klass.addMember(tsCodegen.klassMember('_id', 'string'));
|
|
147
|
+
// Generate and add a constructor
|
|
148
|
+
klass.addMethod(tsCodegen.method('constructor', [
|
|
149
|
+
tsCodegen.param('entity', 'string'),
|
|
150
|
+
tsCodegen.param('id', 'string'),
|
|
151
|
+
tsCodegen.param('field', 'string'),
|
|
152
|
+
], undefined, `
|
|
153
|
+
super();
|
|
154
|
+
this._entity = entity;
|
|
155
|
+
this._id = id;
|
|
156
|
+
this._field = field;
|
|
157
|
+
`));
|
|
158
|
+
// Generate load() method for the Loader
|
|
159
|
+
klass.addMethod(tsCodegen.method('load', [], `${typeName}[]`, `
|
|
160
|
+
let value = store.loadRelated(this._entity, this._id, this._field);
|
|
161
|
+
return changetype<${typeName}[]>(value);
|
|
162
|
+
`));
|
|
163
|
+
return klass;
|
|
164
|
+
}
|
|
165
|
+
_getTypeNameForField(gqlType) {
|
|
166
|
+
if (gqlType.kind === 'NonNullType') {
|
|
167
|
+
return this._getTypeNameForField(gqlType.type);
|
|
168
|
+
}
|
|
169
|
+
if (gqlType.kind === 'ListType') {
|
|
170
|
+
return this._getTypeNameForField(gqlType.type);
|
|
171
|
+
}
|
|
172
|
+
if (gqlType.kind === 'NamedType') {
|
|
173
|
+
return gqlType.name.value;
|
|
174
|
+
}
|
|
175
|
+
throw new Error(`Unknown type kind: ${gqlType}`);
|
|
176
|
+
}
|
|
123
177
|
_generateConstructor(_entityName, fields) {
|
|
124
178
|
const idField = IdField.fromFields(fields);
|
|
125
179
|
return tsCodegen.method('constructor', [tsCodegen.param('id', idField.tsNamedType())], undefined, `
|
|
@@ -156,6 +210,12 @@ class SchemaCodeGenerator {
|
|
|
156
210
|
.filter(Boolean);
|
|
157
211
|
}
|
|
158
212
|
_generateEntityFieldGetter(_entityDef, fieldDef) {
|
|
213
|
+
const isDerivedField = this._isDerivedField(fieldDef);
|
|
214
|
+
const codegenDebug = (0, debug_1.default)('codegen');
|
|
215
|
+
if (isDerivedField) {
|
|
216
|
+
codegenDebug(`Generating derived field getter for ${fieldDef.name.value}`);
|
|
217
|
+
return this._generateDerivedFieldGetter(_entityDef, fieldDef);
|
|
218
|
+
}
|
|
159
219
|
const name = fieldDef.name.value;
|
|
160
220
|
const gqlType = fieldDef.type;
|
|
161
221
|
const fieldValueType = this._valueTypeFromGraphQl(gqlType);
|
|
@@ -179,6 +239,42 @@ class SchemaCodeGenerator {
|
|
|
179
239
|
${isNullable ? getNullable : getNonNullable}
|
|
180
240
|
`);
|
|
181
241
|
}
|
|
242
|
+
_generateDerivedFieldGetter(entityDef, fieldDef) {
|
|
243
|
+
const entityName = entityDef.name.value;
|
|
244
|
+
const name = fieldDef.name.value;
|
|
245
|
+
const gqlType = fieldDef.type;
|
|
246
|
+
const returnType = this._returnTypeForDervied(gqlType);
|
|
247
|
+
return tsCodegen.method(`get ${name}`, [], returnType, `
|
|
248
|
+
return new ${returnType}('${entityName}', this.get('id')!.toString(), '${name}')
|
|
249
|
+
`);
|
|
250
|
+
}
|
|
251
|
+
_returnTypeForDervied(gqlType) {
|
|
252
|
+
if (gqlType.kind === 'NonNullType') {
|
|
253
|
+
return this._returnTypeForDervied(gqlType.type);
|
|
254
|
+
}
|
|
255
|
+
if (gqlType.kind === 'ListType') {
|
|
256
|
+
return this._returnTypeForDervied(gqlType.type);
|
|
257
|
+
}
|
|
258
|
+
const type = tsCodegen.namedType(gqlType.name.value + 'Loader');
|
|
259
|
+
return type;
|
|
260
|
+
}
|
|
261
|
+
_generatedEntityDerivedFieldGetter(_entityDef, fieldDef) {
|
|
262
|
+
const name = fieldDef.name.value;
|
|
263
|
+
const gqlType = fieldDef.type;
|
|
264
|
+
const fieldValueType = this._valueTypeFromGraphQl(gqlType);
|
|
265
|
+
const returnType = this._typeFromGraphQl(gqlType);
|
|
266
|
+
const isNullable = returnType instanceof tsCodegen.NullableType;
|
|
267
|
+
const getNonNullable = `return ${typesCodegen.valueToAsc('value!', fieldValueType)}`;
|
|
268
|
+
const getNullable = `if (!value || value.kind == ValueKind.NULL) {
|
|
269
|
+
return null
|
|
270
|
+
} else {
|
|
271
|
+
return ${typesCodegen.valueToAsc('value', fieldValueType)}
|
|
272
|
+
}`;
|
|
273
|
+
return tsCodegen.method(`get ${name}`, [], returnType, `
|
|
274
|
+
let value = this.get('${name}')
|
|
275
|
+
${isNullable ? getNullable : getNonNullable}
|
|
276
|
+
`);
|
|
277
|
+
}
|
|
182
278
|
_generateEntityFieldSetter(_entityDef, fieldDef) {
|
|
183
279
|
const name = fieldDef.name.value;
|
|
184
280
|
const isDerivedField = !!fieldDef.directives?.find(directive => directive.name.value === 'derivedFrom');
|
|
@@ -276,14 +276,9 @@ describe('Schema code generator', () => {
|
|
|
276
276
|
{
|
|
277
277
|
name: 'get wallets',
|
|
278
278
|
params: [],
|
|
279
|
-
returnType: new typescript_1.
|
|
279
|
+
returnType: new typescript_1.NamedType('WalletLoader'),
|
|
280
280
|
body: `
|
|
281
|
-
|
|
282
|
-
if (!value || value.kind == ValueKind.NULL) {
|
|
283
|
-
return null
|
|
284
|
-
} else {
|
|
285
|
-
return value.toStringArray()
|
|
286
|
-
}
|
|
281
|
+
return new WalletLoader("Account", this.get('id')!.toString(), "wallets")
|
|
287
282
|
`,
|
|
288
283
|
},
|
|
289
284
|
],
|
|
@@ -14,14 +14,6 @@ export declare const generateScaffold: ({ protocolInstance, abi, contract, netwo
|
|
|
14
14
|
startBlock?: string | undefined;
|
|
15
15
|
node?: string | undefined;
|
|
16
16
|
}, spinner: Spinner) => Promise<{
|
|
17
|
-
'subgraph.yaml': string;
|
|
18
|
-
'schema.graphql': string;
|
|
19
|
-
'package.json': string;
|
|
20
|
-
'tsconfig.json'?: undefined;
|
|
21
|
-
src?: undefined;
|
|
22
|
-
abis?: undefined;
|
|
23
|
-
tests?: undefined;
|
|
24
|
-
} | {
|
|
25
17
|
'package.json': string;
|
|
26
18
|
'subgraph.yaml': string;
|
|
27
19
|
'schema.graphql': string;
|
package/dist/commands/init.js
CHANGED
|
@@ -39,10 +39,12 @@ const scaffold_1 = require("../command-helpers/scaffold");
|
|
|
39
39
|
const spinner_1 = require("../command-helpers/spinner");
|
|
40
40
|
const studio_1 = require("../command-helpers/studio");
|
|
41
41
|
const subgraph_1 = require("../command-helpers/subgraph");
|
|
42
|
+
const debug_1 = __importDefault(require("../debug"));
|
|
42
43
|
const protocols_1 = __importDefault(require("../protocols"));
|
|
43
44
|
const schema_1 = require("../scaffold/schema");
|
|
44
45
|
const validation_1 = require("../validation");
|
|
45
46
|
const add_1 = __importDefault(require("./add"));
|
|
47
|
+
const initDebug = (0, debug_1.default)('graph-cli:init');
|
|
46
48
|
const protocolChoices = Array.from(protocols_1.default.availableProtocols().keys());
|
|
47
49
|
const availableNetworks = protocols_1.default.availableNetworks();
|
|
48
50
|
const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum/gravatar';
|
|
@@ -83,18 +85,8 @@ class InitCommand extends core_1.Command {
|
|
|
83
85
|
};
|
|
84
86
|
// If all parameters are provided from the command-line,
|
|
85
87
|
// go straight to creating the subgraph from the example
|
|
86
|
-
if (fromExample && subgraphName && directory
|
|
87
|
-
await initSubgraphFromExample.bind(this)({
|
|
88
|
-
fromExample,
|
|
89
|
-
allowSimpleName,
|
|
90
|
-
directory,
|
|
91
|
-
subgraphName,
|
|
92
|
-
studio,
|
|
93
|
-
product,
|
|
94
|
-
protocolInstance: new protocols_1.default(protocol),
|
|
95
|
-
}, { commands });
|
|
96
|
-
// Exit with success
|
|
97
|
-
return this.exit(0);
|
|
88
|
+
if (fromExample && subgraphName && directory) {
|
|
89
|
+
return await initSubgraphFromExample.bind(this)({ fromExample, allowSimpleName, directory, subgraphName, studio, product }, { commands });
|
|
98
90
|
}
|
|
99
91
|
// Will be assigned below if ethereum
|
|
100
92
|
let abi;
|
|
@@ -130,7 +122,7 @@ class InitCommand extends core_1.Command {
|
|
|
130
122
|
}
|
|
131
123
|
}
|
|
132
124
|
}
|
|
133
|
-
await initSubgraphFromContract.bind(this)({
|
|
125
|
+
return await initSubgraphFromContract.bind(this)({
|
|
134
126
|
protocolInstance,
|
|
135
127
|
abi,
|
|
136
128
|
allowSimpleName,
|
|
@@ -145,8 +137,6 @@ class InitCommand extends core_1.Command {
|
|
|
145
137
|
product,
|
|
146
138
|
startBlock,
|
|
147
139
|
}, { commands, addContract: false });
|
|
148
|
-
// Exit with success
|
|
149
|
-
return this.exit(0);
|
|
150
140
|
}
|
|
151
141
|
// Otherwise, take the user through the interactive form
|
|
152
142
|
const answers = await processInitForm.bind(this)({
|
|
@@ -155,7 +145,6 @@ class InitCommand extends core_1.Command {
|
|
|
155
145
|
studio,
|
|
156
146
|
node,
|
|
157
147
|
abi,
|
|
158
|
-
abiPath,
|
|
159
148
|
allowSimpleName,
|
|
160
149
|
directory,
|
|
161
150
|
contract: fromContract,
|
|
@@ -177,7 +166,6 @@ class InitCommand extends core_1.Command {
|
|
|
177
166
|
directory: answers.directory,
|
|
178
167
|
studio: answers.studio,
|
|
179
168
|
product: answers.product,
|
|
180
|
-
protocolInstance: answers.protocolInstance,
|
|
181
169
|
}, { commands });
|
|
182
170
|
}
|
|
183
171
|
else {
|
|
@@ -203,8 +191,6 @@ class InitCommand extends core_1.Command {
|
|
|
203
191
|
startBlock: answers.startBlock,
|
|
204
192
|
}, { commands, addContract: true });
|
|
205
193
|
}
|
|
206
|
-
// Exit with success
|
|
207
|
-
this.exit(0);
|
|
208
194
|
}
|
|
209
195
|
}
|
|
210
196
|
InitCommand.description = 'Creates a new subgraph with basic scaffolding.';
|
|
@@ -279,255 +265,227 @@ InitCommand.flags = {
|
|
|
279
265
|
}),
|
|
280
266
|
};
|
|
281
267
|
exports.default = InitCommand;
|
|
282
|
-
async function processInitForm({ protocol
|
|
268
|
+
async function processInitForm({ protocol, product, studio, node, abi, allowSimpleName, directory, contract, indexEvents, fromExample, network, subgraphName, contractName, startBlock, }) {
|
|
283
269
|
let abiFromEtherscan = undefined;
|
|
284
|
-
|
|
285
|
-
|
|
270
|
+
let abiFromFile = undefined;
|
|
271
|
+
let protocolInstance;
|
|
272
|
+
let ProtocolContract;
|
|
273
|
+
let ABI;
|
|
274
|
+
const questions = [
|
|
275
|
+
{
|
|
286
276
|
type: 'select',
|
|
287
277
|
name: 'protocol',
|
|
288
278
|
message: 'Protocol',
|
|
289
279
|
choices: protocolChoices,
|
|
290
|
-
skip: protocolChoices.includes(String(
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
type: 'select',
|
|
297
|
-
name: 'product',
|
|
298
|
-
message: 'Product for which to initialize',
|
|
299
|
-
choices: ['subgraph-studio', 'hosted-service'],
|
|
300
|
-
skip: protocol === 'arweave' ||
|
|
301
|
-
protocol === 'cosmos' ||
|
|
302
|
-
protocol === 'near' ||
|
|
303
|
-
initProduct === 'subgraph-studio' ||
|
|
304
|
-
initProduct === 'hosted-service' ||
|
|
305
|
-
initStudio !== undefined ||
|
|
306
|
-
initNode !== undefined,
|
|
307
|
-
result: value => {
|
|
308
|
-
if (initProduct)
|
|
309
|
-
return initProduct;
|
|
310
|
-
if (initStudio)
|
|
311
|
-
return 'subgraph-studio';
|
|
312
|
-
// For now we only support NEAR subgraphs in the Hosted Service
|
|
313
|
-
if (protocol === 'near') {
|
|
314
|
-
return 'hosted-service';
|
|
315
|
-
}
|
|
316
|
-
if (value == 'subgraph-studio') {
|
|
317
|
-
initAllowSimpleName = true;
|
|
318
|
-
}
|
|
319
|
-
return value;
|
|
320
|
-
},
|
|
280
|
+
skip: protocolChoices.includes(String(protocol)),
|
|
281
|
+
result: (value) => {
|
|
282
|
+
// eslint-disable-next-line -- prettier has problems with ||=
|
|
283
|
+
protocol = protocol || value;
|
|
284
|
+
protocolInstance = new protocols_1.default(protocol);
|
|
285
|
+
return protocol;
|
|
321
286
|
},
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: 'select',
|
|
290
|
+
name: 'product',
|
|
291
|
+
message: 'Product for which to initialize',
|
|
292
|
+
choices: ['subgraph-studio', 'hosted-service'],
|
|
293
|
+
skip: () => protocol === 'arweave' ||
|
|
294
|
+
protocol === 'cosmos' ||
|
|
295
|
+
protocol === 'near' ||
|
|
296
|
+
product === 'subgraph-studio' ||
|
|
297
|
+
product === 'hosted-service' ||
|
|
298
|
+
studio !== undefined ||
|
|
299
|
+
node !== undefined,
|
|
300
|
+
result: (value) => {
|
|
301
|
+
// For now we only support NEAR subgraphs in the Hosted Service
|
|
302
|
+
if (protocol === 'near') {
|
|
303
|
+
// Can be overwritten because the question will be skipped (product === undefined)
|
|
304
|
+
product = 'hosted-service';
|
|
305
|
+
return product;
|
|
306
|
+
}
|
|
307
|
+
if (value == 'subgraph-studio') {
|
|
308
|
+
allowSimpleName = true;
|
|
309
|
+
}
|
|
310
|
+
product = value;
|
|
311
|
+
return value;
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
type: 'input',
|
|
316
|
+
name: 'subgraphName',
|
|
317
|
+
message: () => (product == 'subgraph-studio' || studio ? 'Subgraph slug' : 'Subgraph name'),
|
|
318
|
+
initial: subgraphName,
|
|
319
|
+
validate: (name) => {
|
|
320
|
+
try {
|
|
321
|
+
(0, subgraph_1.validateSubgraphName)(name, { allowSimpleName });
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
catch (e) {
|
|
325
|
+
return `${e.message}
|
|
336
326
|
|
|
337
|
-
|
|
327
|
+
Examples:
|
|
338
328
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
},
|
|
329
|
+
$ graph init ${os_1.default.userInfo().username}/${name}
|
|
330
|
+
$ graph init ${name} --allow-simple-name`;
|
|
331
|
+
}
|
|
343
332
|
},
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
type: 'input',
|
|
348
|
-
name: 'directory',
|
|
349
|
-
message: 'Directory to create the subgraph in',
|
|
350
|
-
initial: () => initDirectory || (0, subgraph_1.getSubgraphBasename)(subgraphName),
|
|
351
|
-
validate: value => gluegun_1.filesystem.exists(value || initDirectory || (0, subgraph_1.getSubgraphBasename)(subgraphName))
|
|
352
|
-
? 'Directory already exists'
|
|
353
|
-
: true,
|
|
333
|
+
result: (value) => {
|
|
334
|
+
subgraphName = value;
|
|
335
|
+
return value;
|
|
354
336
|
},
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
type: 'input',
|
|
340
|
+
name: 'directory',
|
|
341
|
+
message: 'Directory to create the subgraph in',
|
|
342
|
+
initial: () => directory ||
|
|
343
|
+
(0, subgraph_1.getSubgraphBasename)(
|
|
344
|
+
// @ts-expect-error will be set by previous question
|
|
345
|
+
subgraphName),
|
|
346
|
+
validate: (value) => gluegun_1.filesystem.exists(value ||
|
|
347
|
+
directory ||
|
|
348
|
+
(0, subgraph_1.getSubgraphBasename)(
|
|
349
|
+
// @ts-expect-error will be set by previous question
|
|
350
|
+
subgraphName))
|
|
351
|
+
? 'Directory already exists'
|
|
352
|
+
: true,
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
type: 'select',
|
|
356
|
+
name: 'network',
|
|
357
|
+
message: () => `${protocolInstance.displayName()} network`,
|
|
358
|
+
choices: () => {
|
|
359
|
+
initDebug('Generating list of available networks for protocol "%s" (%M)', protocol, availableNetworks.get(protocol));
|
|
360
|
+
return (
|
|
361
|
+
// @ts-expect-error TODO: wait what?
|
|
362
|
+
availableNetworks
|
|
362
363
|
.get(protocol) // Get networks related to the chosen protocol.
|
|
363
|
-
|
|
364
|
-
skip: initFromExample !== undefined,
|
|
365
|
-
result: value => {
|
|
366
|
-
if (initNetwork)
|
|
367
|
-
return initNetwork;
|
|
368
|
-
return value;
|
|
369
|
-
},
|
|
364
|
+
.toArray()); // Needed because of gluegun. It can't even receive a JS iterable.
|
|
370
365
|
},
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
// - cosmos
|
|
377
|
-
{
|
|
378
|
-
type: 'input',
|
|
379
|
-
name: 'contract',
|
|
380
|
-
message: `Contract ${protocolInstance.getContract()?.identifierName()}`,
|
|
381
|
-
skip: () => initFromExample !== undefined || !protocolInstance.hasContract() || isSubstreams,
|
|
382
|
-
initial: initContract,
|
|
383
|
-
validate: async (value) => {
|
|
384
|
-
if (initFromExample !== undefined || !protocolInstance.hasContract()) {
|
|
385
|
-
return true;
|
|
386
|
-
}
|
|
387
|
-
const protocolContract = protocolInstance.getContract();
|
|
388
|
-
if (!protocolContract) {
|
|
389
|
-
return 'Contract not found.';
|
|
390
|
-
}
|
|
391
|
-
// Validate whether the contract is valid
|
|
392
|
-
const { valid, error } = (0, validation_1.validateContract)(value, protocolContract);
|
|
393
|
-
return valid ? true : error;
|
|
394
|
-
},
|
|
395
|
-
result: async (value) => {
|
|
396
|
-
if (initFromExample !== undefined || isSubstreams || initAbiPath) {
|
|
397
|
-
return value;
|
|
398
|
-
}
|
|
399
|
-
const ABI = protocolInstance.getABI();
|
|
400
|
-
// Try loading the ABI from Etherscan, if none was provided
|
|
401
|
-
if (protocolInstance.hasABIs() && !initAbi) {
|
|
402
|
-
try {
|
|
403
|
-
if (network === 'poa-core') {
|
|
404
|
-
// TODO: this variable is never used anywhere, what happens?
|
|
405
|
-
// abiFromBlockScout = await loadAbiFromBlockScout(ABI, network, value)
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
abiFromEtherscan = await (0, abi_1.loadAbiFromEtherscan)(ABI, network, value);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
catch (e) {
|
|
412
|
-
// noop
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
// If startBlock is not set, try to load it.
|
|
416
|
-
if (!initStartBlock) {
|
|
417
|
-
try {
|
|
418
|
-
// Load startBlock for this contract
|
|
419
|
-
initStartBlock = Number(await (0, abi_1.loadStartBlockForContract)(network, value)).toString();
|
|
420
|
-
}
|
|
421
|
-
catch (error) {
|
|
422
|
-
// noop
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
return value;
|
|
426
|
-
},
|
|
366
|
+
skip: fromExample !== undefined,
|
|
367
|
+
initial: network || 'mainnet',
|
|
368
|
+
result: (value) => {
|
|
369
|
+
network = value;
|
|
370
|
+
return value;
|
|
427
371
|
},
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
372
|
+
},
|
|
373
|
+
// TODO:
|
|
374
|
+
//
|
|
375
|
+
// protocols that don't support contract
|
|
376
|
+
// - arweave
|
|
377
|
+
// - cosmos
|
|
378
|
+
{
|
|
379
|
+
type: 'input',
|
|
380
|
+
name: 'contract',
|
|
381
|
+
message: () => {
|
|
382
|
+
ProtocolContract = protocolInstance.getContract();
|
|
383
|
+
return `Contract ${ProtocolContract.identifierName()}`;
|
|
384
|
+
},
|
|
385
|
+
skip: () => fromExample !== undefined || !protocolInstance.hasContract(),
|
|
386
|
+
initial: contract,
|
|
387
|
+
validate: async (value) => {
|
|
388
|
+
if (fromExample !== undefined || !protocolInstance.hasContract()) {
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
// Validate whether the contract is valid
|
|
392
|
+
const { valid, error } = (0, validation_1.validateContract)(value, ProtocolContract);
|
|
393
|
+
return valid ? true : error;
|
|
394
|
+
},
|
|
395
|
+
result: async (value) => {
|
|
396
|
+
if (fromExample !== undefined) {
|
|
397
|
+
return value;
|
|
398
|
+
}
|
|
399
|
+
ABI = protocolInstance.getABI();
|
|
400
|
+
// Try loading the ABI from Etherscan, if none was provided
|
|
401
|
+
if (protocolInstance.hasABIs() && !abi) {
|
|
402
|
+
try {
|
|
403
|
+
if (network === 'poa-core') {
|
|
404
|
+
// TODO: this variable is never used anywhere, what happens?
|
|
405
|
+
// abiFromBlockScout = await loadAbiFromBlockScout(ABI, network, value)
|
|
449
406
|
}
|
|
450
|
-
|
|
451
|
-
|
|
407
|
+
else {
|
|
408
|
+
abiFromEtherscan = await (0, abi_1.loadAbiFromEtherscan)(ABI, network, value);
|
|
452
409
|
}
|
|
453
410
|
}
|
|
454
|
-
try {
|
|
455
|
-
loadAbiFromFile(ABI, value);
|
|
456
|
-
return true;
|
|
457
|
-
}
|
|
458
411
|
catch (e) {
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
result: async (value) => {
|
|
463
|
-
if (initFromExample || abiFromEtherscan || !protocolInstance.hasABIs()) {
|
|
464
|
-
return null;
|
|
465
|
-
}
|
|
466
|
-
const ABI = protocolInstance.getABI();
|
|
467
|
-
if (initAbiPath) {
|
|
468
|
-
try {
|
|
469
|
-
return loadAbiFromFile(ABI, initAbiPath);
|
|
470
|
-
}
|
|
471
|
-
catch (e) {
|
|
472
|
-
return e.message;
|
|
473
|
-
}
|
|
412
|
+
// noop
|
|
474
413
|
}
|
|
414
|
+
}
|
|
415
|
+
// If startBlock is not set, try to load it.
|
|
416
|
+
if (!startBlock) {
|
|
475
417
|
try {
|
|
476
|
-
|
|
418
|
+
// Load startBlock for this contract
|
|
419
|
+
startBlock = Number(await (0, abi_1.loadStartBlockForContract)(network, value)).toString();
|
|
477
420
|
}
|
|
478
|
-
catch (
|
|
479
|
-
|
|
421
|
+
catch (error) {
|
|
422
|
+
// noop
|
|
480
423
|
}
|
|
481
|
-
}
|
|
424
|
+
}
|
|
425
|
+
return value;
|
|
482
426
|
},
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
type: 'input',
|
|
430
|
+
name: 'abi',
|
|
431
|
+
message: 'ABI file (path)',
|
|
432
|
+
initial: abi,
|
|
433
|
+
skip: () => !protocolInstance.hasABIs() || fromExample !== undefined || abiFromEtherscan !== undefined,
|
|
434
|
+
validate: async (value) => {
|
|
435
|
+
if (fromExample || abiFromEtherscan || !protocolInstance.hasABIs()) {
|
|
436
|
+
return true;
|
|
437
|
+
}
|
|
438
|
+
try {
|
|
439
|
+
abiFromFile = loadAbiFromFile(ABI, value);
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
catch (e) {
|
|
443
|
+
return e.message;
|
|
444
|
+
}
|
|
497
445
|
},
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
type: 'input',
|
|
449
|
+
name: 'startBlock',
|
|
450
|
+
message: 'Start Block',
|
|
451
|
+
initial: () => startBlock || '0',
|
|
452
|
+
skip: () => fromExample !== undefined,
|
|
453
|
+
validate: (value) => parseInt(value) >= 0,
|
|
454
|
+
result: (value) => {
|
|
455
|
+
startBlock = value;
|
|
456
|
+
return value;
|
|
507
457
|
},
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
type: 'input',
|
|
461
|
+
name: 'contractName',
|
|
462
|
+
message: 'Contract Name',
|
|
463
|
+
initial: contractName || 'Contract',
|
|
464
|
+
skip: () => fromExample !== undefined || !protocolInstance.hasContract(),
|
|
465
|
+
validate: (value) => value && value.length > 0,
|
|
466
|
+
result: (value) => {
|
|
467
|
+
contractName = value;
|
|
468
|
+
return value;
|
|
516
469
|
},
|
|
517
|
-
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
type: 'confirm',
|
|
473
|
+
name: 'indexEvents',
|
|
474
|
+
message: 'Index contract events as entities',
|
|
475
|
+
initial: true,
|
|
476
|
+
skip: () => !!indexEvents,
|
|
477
|
+
result: (value) => {
|
|
478
|
+
indexEvents = value;
|
|
479
|
+
return value;
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
];
|
|
483
|
+
try {
|
|
484
|
+
const answers = await gluegun_1.prompt.ask(questions);
|
|
518
485
|
return {
|
|
486
|
+
...answers,
|
|
519
487
|
abi: abiFromEtherscan || abiFromFile,
|
|
520
488
|
protocolInstance,
|
|
521
|
-
subgraphName,
|
|
522
|
-
directory,
|
|
523
|
-
studio: product === 'subgraph-studio',
|
|
524
|
-
startBlock,
|
|
525
|
-
fromExample: !!initFromExample,
|
|
526
|
-
product,
|
|
527
|
-
network,
|
|
528
|
-
contractName,
|
|
529
|
-
contract,
|
|
530
|
-
indexEvents,
|
|
531
489
|
};
|
|
532
490
|
}
|
|
533
491
|
catch (e) {
|
|
@@ -605,8 +563,7 @@ Subgraph ${subgraphName} created in ${relativeDir}
|
|
|
605
563
|
|
|
606
564
|
Make sure to visit the documentation on https://thegraph.com/docs/ for further information.`);
|
|
607
565
|
}
|
|
608
|
-
async function initSubgraphFromExample({
|
|
609
|
-
const isSubstreams = protocolInstance.name === 'substreams';
|
|
566
|
+
async function initSubgraphFromExample({ fromExample, allowSimpleName, subgraphName, directory, studio, product, }, { commands, }) {
|
|
610
567
|
// Fail if the subgraph name is invalid
|
|
611
568
|
if (!revalidateSubgraphName.bind(this)(subgraphName, { allowSimpleName })) {
|
|
612
569
|
process.exitCode = 1;
|
|
@@ -699,18 +656,15 @@ async function initSubgraphFromExample({ protocolInstance, fromExample, allowSim
|
|
|
699
656
|
this.exit(1);
|
|
700
657
|
return;
|
|
701
658
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
659
|
+
// Run code-generation
|
|
660
|
+
const codegen = await runCodegen(directory, commands.codegen);
|
|
661
|
+
if (codegen !== true) {
|
|
662
|
+
this.exit(1);
|
|
663
|
+
return;
|
|
709
664
|
}
|
|
710
665
|
printNextSteps.bind(this)({ subgraphName, directory }, { commands });
|
|
711
666
|
}
|
|
712
667
|
async function initSubgraphFromContract({ protocolInstance, allowSimpleName, subgraphName, directory, abi, network, contract, indexEvents, contractName, node, studio, product, startBlock, }, { commands, addContract, }) {
|
|
713
|
-
const isSubstreams = protocolInstance.name === 'substreams';
|
|
714
668
|
// Fail if the subgraph name is invalid
|
|
715
669
|
if (!revalidateSubgraphName.bind(this)(subgraphName, { allowSimpleName })) {
|
|
716
670
|
this.exit(1);
|
|
@@ -776,17 +730,14 @@ async function initSubgraphFromContract({ protocolInstance, allowSimpleName, sub
|
|
|
776
730
|
this.exit(1);
|
|
777
731
|
return;
|
|
778
732
|
}
|
|
779
|
-
//
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
787
|
-
while (addContract) {
|
|
788
|
-
addContract = await addAnotherContract.bind(this)({ protocolInstance, directory });
|
|
789
|
-
}
|
|
733
|
+
// Run code-generation
|
|
734
|
+
const codegen = await runCodegen(directory, commands.codegen);
|
|
735
|
+
if (codegen !== true) {
|
|
736
|
+
this.exit(1);
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
while (addContract) {
|
|
740
|
+
addContract = await addAnotherContract.bind(this)({ protocolInstance, directory });
|
|
790
741
|
}
|
|
791
742
|
printNextSteps.bind(this)({ subgraphName, directory }, { commands });
|
|
792
743
|
}
|
package/dist/protocols/index.js
CHANGED
|
@@ -88,7 +88,7 @@ class Protocol {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
static availableNetworks() {
|
|
91
|
-
|
|
91
|
+
let networks = immutable_1.default.fromJS({
|
|
92
92
|
arweave: ['arweave-mainnet'],
|
|
93
93
|
ethereum: [
|
|
94
94
|
'mainnet',
|
|
@@ -135,6 +135,13 @@ class Protocol {
|
|
|
135
135
|
],
|
|
136
136
|
substreams: ['mainnet'],
|
|
137
137
|
});
|
|
138
|
+
const allNetworks = [];
|
|
139
|
+
// eslint-disable-next-line unicorn/no-array-for-each
|
|
140
|
+
networks.forEach(value => {
|
|
141
|
+
allNetworks.push(...value);
|
|
142
|
+
});
|
|
143
|
+
networks = networks.set('substreams', immutable_1.default.List(allNetworks));
|
|
144
|
+
return networks;
|
|
138
145
|
}
|
|
139
146
|
static normalizeName(name) {
|
|
140
147
|
return Protocol.availableProtocols().findKey(possibleNames => {
|
package/dist/scaffold/index.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export default class Scaffold {
|
|
|
23
23
|
startBlock?: string;
|
|
24
24
|
constructor(options: ScaffoldOptions);
|
|
25
25
|
generatePackageJson(): string;
|
|
26
|
-
generatePackageJsonForSubstreams(): string;
|
|
27
26
|
generateManifest(): string;
|
|
28
27
|
generateSchema(): string;
|
|
29
28
|
generateTsConfig(): string;
|
|
@@ -38,14 +37,6 @@ export default class Scaffold {
|
|
|
38
37
|
[x: string]: string;
|
|
39
38
|
} | undefined;
|
|
40
39
|
generate(): {
|
|
41
|
-
'subgraph.yaml': string;
|
|
42
|
-
'schema.graphql': string;
|
|
43
|
-
'package.json': string;
|
|
44
|
-
'tsconfig.json'?: undefined;
|
|
45
|
-
src?: undefined;
|
|
46
|
-
abis?: undefined;
|
|
47
|
-
tests?: undefined;
|
|
48
|
-
} | {
|
|
49
40
|
'package.json': string;
|
|
50
41
|
'subgraph.yaml': string;
|
|
51
42
|
'schema.graphql': string;
|
package/dist/scaffold/index.js
CHANGED
|
@@ -51,26 +51,6 @@ class Scaffold {
|
|
|
51
51
|
devDependencies: this.protocol.hasEvents() ? { 'matchstick-as': `0.5.0` } : undefined,
|
|
52
52
|
}), { parser: 'json' });
|
|
53
53
|
}
|
|
54
|
-
generatePackageJsonForSubstreams() {
|
|
55
|
-
return prettier_1.default.format(JSON.stringify({
|
|
56
|
-
name: (0, subgraph_1.getSubgraphBasename)(String(this.subgraphName)),
|
|
57
|
-
license: 'UNLICENSED',
|
|
58
|
-
scripts: {
|
|
59
|
-
build: 'graph build',
|
|
60
|
-
deploy: `graph deploy ` + `--node ${this.node} ` + this.subgraphName,
|
|
61
|
-
'create-local': `graph create --node http://localhost:8020/ ${this.subgraphName}`,
|
|
62
|
-
'remove-local': `graph remove --node http://localhost:8020/ ${this.subgraphName}`,
|
|
63
|
-
'deploy-local': `graph deploy ` +
|
|
64
|
-
`--node http://localhost:8020/ ` +
|
|
65
|
-
`--ipfs http://localhost:5001 ` +
|
|
66
|
-
this.subgraphName,
|
|
67
|
-
test: 'graph test',
|
|
68
|
-
},
|
|
69
|
-
dependencies: {
|
|
70
|
-
'@graphprotocol/graph-cli': GRAPH_CLI_VERSION,
|
|
71
|
-
},
|
|
72
|
-
}), { parser: 'json' });
|
|
73
|
-
}
|
|
74
54
|
generateManifest() {
|
|
75
55
|
const protocolManifest = this.protocol.getManifestScaffold();
|
|
76
56
|
return prettier_1.default.format(`
|
|
@@ -135,13 +115,6 @@ dataSources:
|
|
|
135
115
|
: undefined;
|
|
136
116
|
}
|
|
137
117
|
generate() {
|
|
138
|
-
if (this.protocol.name === 'substreams') {
|
|
139
|
-
return {
|
|
140
|
-
'subgraph.yaml': this.generateManifest(),
|
|
141
|
-
'schema.graphql': this.generateSchema(),
|
|
142
|
-
'package.json': this.generatePackageJsonForSubstreams(),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
118
|
return {
|
|
146
119
|
'package.json': this.generatePackageJson(),
|
|
147
120
|
'subgraph.yaml': this.generateManifest(),
|
package/dist/type-generator.js
CHANGED
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphprotocol/graph-cli",
|
|
3
|
-
"version": "0.49.0-alpha-
|
|
3
|
+
"version": "0.49.0-alpha-20230530184045-63696ac",
|
|
4
4
|
"description": "CLI for building for and deploying to The Graph",
|
|
5
5
|
"license": "(Apache-2.0 OR MIT)",
|
|
6
6
|
"engines": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dockerode": "2.5.8",
|
|
32
32
|
"fs-extra": "9.1.0",
|
|
33
33
|
"glob": "9.3.5",
|
|
34
|
-
"gluegun": "
|
|
34
|
+
"gluegun": "https://github.com/edgeandnode/gluegun#v4.3.1-pin-colors-dep",
|
|
35
35
|
"graphql": "15.5.0",
|
|
36
36
|
"immutable": "4.2.1",
|
|
37
37
|
"ipfs-http-client": "55.0.0",
|