@graphprotocol/graph-cli 0.45.0-alpha-20230403193800-82c814f → 0.45.0-alpha-20230403195400-e8bdaff

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
- ## 0.45.0-alpha-20230403193800-82c814f
3
+ ## 0.45.0-alpha-20230403195400-e8bdaff
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -15,6 +15,13 @@
15
15
 
16
16
  ### Patch Changes
17
17
 
18
+ - [#1216](https://github.com/graphprotocol/graph-tooling/pull/1216)
19
+ [`f088870`](https://github.com/graphprotocol/graph-tooling/commit/f088870123c03619a17dd07f5bbc8640fc1dba3b)
20
+ Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
21
+
22
+ - Updated dependency [`yaml@1.10.2` ↗︎](https://www.npmjs.com/package/yaml/v/1.10.2) (from
23
+ `1.9.2`, in `dependencies`)
24
+
18
25
  - [#1218](https://github.com/graphprotocol/graph-tooling/pull/1218)
19
26
  [`01046d9`](https://github.com/graphprotocol/graph-tooling/commit/01046d946f42f436fb10d54c5c959012cd6fef67)
20
27
  Thanks [@saihaj](https://github.com/saihaj)! - dependencies updates:
@@ -53,13 +60,6 @@
53
60
  - Updated dependency [`fs-extra@9.1.0` ↗︎](https://www.npmjs.com/package/fs-extra/v/9.1.0) (from
54
61
  `9.0.0`, in `dependencies`)
55
62
 
56
- - [#1239](https://github.com/graphprotocol/graph-tooling/pull/1239)
57
- [`82c814f`](https://github.com/graphprotocol/graph-tooling/commit/82c814f7d2a197d206fecca35552f9b30b0aa752)
58
- Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
59
-
60
- - Updated dependency [`jayson@3.7.0` ↗︎](https://www.npmjs.com/package/jayson/v/3.7.0) (from
61
- `3.6.6`, in `dependencies`)
62
-
63
63
  - [#1240](https://github.com/graphprotocol/graph-tooling/pull/1240)
64
64
  [`ef99d62`](https://github.com/graphprotocol/graph-tooling/commit/ef99d6234de249a04e9d5f09d1f0909f9261d413)
65
65
  Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
@@ -67,13 +67,6 @@
67
67
  - Updated dependency [`js-yaml@3.14.1` ↗︎](https://www.npmjs.com/package/js-yaml/v/3.14.1) (from
68
68
  `3.13.1`, in `dependencies`)
69
69
 
70
- - [#1243](https://github.com/graphprotocol/graph-tooling/pull/1243)
71
- [`5682ab5`](https://github.com/graphprotocol/graph-tooling/commit/5682ab5aab38013aa68936d70458962f2927db75)
72
- Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
73
-
74
- - Updated dependency [`yaml@1.10.2` ↗︎](https://www.npmjs.com/package/yaml/v/1.10.2) (from
75
- `1.9.2`, in `dependencies`)
76
-
77
70
  - [#1207](https://github.com/graphprotocol/graph-tooling/pull/1207)
78
71
  [`ad275b3`](https://github.com/graphprotocol/graph-tooling/commit/ad275b31e635dab03cfefda00617ef9f612b01c0)
79
72
  Thanks [@saihaj](https://github.com/saihaj)! - bring back short hand for version and help
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ /* eslint-disable unicorn/no-array-for-each */
29
30
  const immutable_1 = __importDefault(require("immutable"));
30
31
  const typesCodegen = __importStar(require("./types"));
31
32
  const tsCodegen = __importStar(require("./typescript"));
@@ -43,6 +43,7 @@ const testEntity = (generatedTypes, expectedEntity) => {
43
43
  expect(members).toStrictEqual(expectedEntity.members);
44
44
  for (const expectedMethod of expectedEntity.methods) {
45
45
  const method = methods.find((method) => method.name === expectedMethod.name);
46
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
46
47
  expectedMethod.static
47
48
  ? expect(method instanceof typescript_1.StaticMethod).toBe(true)
48
49
  : expect(method instanceof typescript_1.Method).toBe(true);
@@ -44,10 +44,10 @@ const updateSubgraphNetwork = async (manifest, network, networksFile, identifier
44
44
  ...template,
45
45
  network,
46
46
  })));
47
- const unsusedSources = networkSources.filter(x => !subgraphSources.includes(x));
48
- unsusedSources.forEach(source => {
47
+ const unusedSources = networkSources.filter(x => !subgraphSources.includes(x));
48
+ for (const source of unusedSources) {
49
49
  (0, spinner_1.step)(spinner, `dataSource '${source}' from '${networksFile}' not found in ${manifest}`);
50
- });
50
+ }
51
51
  const yaml_doc = new yaml_1.default.Document();
52
52
  yaml_doc.contents = subgraph;
53
53
  return yaml_doc.toString();
@@ -622,9 +622,9 @@ async function initSubgraphFromExample({ fromExample, allowSimpleName, subgraphN
622
622
  const pkgJsonFilename = gluegun_1.filesystem.path(directory, 'package.json');
623
623
  const pkgJson = await gluegun_1.filesystem.read(pkgJsonFilename, 'json');
624
624
  pkgJson.name = (0, subgraph_1.getSubgraphBasename)(subgraphName);
625
- Object.keys(pkgJson.scripts).forEach(name => {
625
+ for (const name of Object.keys(pkgJson.scripts)) {
626
626
  pkgJson.scripts[name] = pkgJson.scripts[name].replace('example', subgraphName);
627
- });
627
+ }
628
628
  delete pkgJson['license'];
629
629
  delete pkgJson['repository'];
630
630
  // Remove example's cli in favor of the local one (added via `npm link`)
@@ -125,6 +125,7 @@ async function runBinary(datasource, opts) {
125
125
  this.log(`Download link: ${url}`);
126
126
  }
127
127
  const binary = new binary_install_raw_1.Binary(platform, url, versionOpt || latestVersion);
128
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
128
129
  forceOpt ? await binary.install(true) : await binary.install(false);
129
130
  const args = [];
130
131
  if (coverageOpt)
@@ -133,6 +134,7 @@ async function runBinary(datasource, opts) {
133
134
  args.push('-r');
134
135
  if (datasource)
135
136
  args.push(datasource);
137
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
136
138
  args.length > 0 ? binary.run(...args) : binary.run();
137
139
  }
138
140
  async function getPlatform(logsOpt) {
@@ -179,9 +181,9 @@ async function getLinuxInfo() {
179
181
  .split('\n')
180
182
  .map(p => p.split('='));
181
183
  const linuxInfo = {};
182
- infoArray.forEach(val => {
184
+ for (const val of infoArray) {
183
185
  linuxInfo[val[0].toLowerCase()] = val[1];
184
- });
186
+ }
185
187
  return linuxInfo;
186
188
  }
187
189
  catch (error) {
@@ -385,19 +385,19 @@ class Compiler {
385
385
  }
386
386
  }
387
387
  // Upload all mappings
388
- if (this.protocol.name !== 'substreams') {
388
+ if (this.protocol.name === 'substreams') {
389
389
  for (const [i, dataSource] of subgraph.get('dataSources').entries()) {
390
390
  updates.push({
391
- keyPath: ['dataSources', i, 'mapping', 'file'],
392
- value: await this._uploadFileToIPFS(dataSource.getIn(['mapping', 'file']), uploadedFiles, spinner),
391
+ keyPath: ['dataSources', i, 'source', 'package', 'file'],
392
+ value: await this._uploadFileToIPFS(dataSource.getIn(['source', 'package', 'file']), uploadedFiles, spinner),
393
393
  });
394
394
  }
395
395
  }
396
396
  else {
397
397
  for (const [i, dataSource] of subgraph.get('dataSources').entries()) {
398
398
  updates.push({
399
- keyPath: ['dataSources', i, 'source', 'package', 'file'],
400
- value: await this._uploadFileToIPFS(dataSource.getIn(['source', 'package', 'file']), uploadedFiles, spinner),
399
+ keyPath: ['dataSources', i, 'mapping', 'file'],
400
+ value: await this._uploadFileToIPFS(dataSource.getIn(['mapping', 'file']), uploadedFiles, spinner),
401
401
  });
402
402
  }
403
403
  }
@@ -29,7 +29,7 @@ const buildSignatureParameter = (input) => {
29
29
  return `(${input.get('indexed') ? 'indexed ' : ''}${input
30
30
  .get('components')
31
31
  .map((component) => buildSignatureParameter(component))
32
- .join(',')})[${length ? length : ''}]`;
32
+ .join(',')})[${length || ''}]`;
33
33
  }
34
34
  if (input.get('type').match(TUPLE_MATRIX_PATTERN)) {
35
35
  const length1 = input.get('type').match(TUPLE_MATRIX_PATTERN)[1];
@@ -37,7 +37,7 @@ const buildSignatureParameter = (input) => {
37
37
  return `(${input.get('indexed') ? 'indexed ' : ''}${input
38
38
  .get('components')
39
39
  .map((component) => buildSignatureParameter(component))
40
- .join(',')})[${length1 ? length1 : ''}][${length2 ? length2 : ''}]`;
40
+ .join(',')})[${length1 || ''}][${length2 || ''}]`;
41
41
  }
42
42
  return `${input.get('indexed') ? 'indexed ' : ''}${input.get('type')}`;
43
43
  };
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ /* eslint-disable unicorn/no-array-for-each */
29
30
  const fs_1 = __importDefault(require("fs"));
30
31
  const immutable_1 = __importDefault(require("immutable"));
31
32
  const sync_request_1 = __importDefault(require("sync-request"));
@@ -159,7 +160,7 @@ class AbiCodeGenerator {
159
160
  setName: (input, name) => input.set('name', name),
160
161
  });
161
162
  const namesAndTypes = [];
162
- inputs.forEach((input, index) => {
163
+ for (const [index, input] of inputs.entries()) {
163
164
  // Generate getters and classes for event params
164
165
  const paramObject = this._generateInputOrOutput(input, index, eventClassName, `event`, `parameters`);
165
166
  paramsClass.addMethod(paramObject.getter);
@@ -172,7 +173,7 @@ class AbiCodeGenerator {
172
173
  namesAndTypes.push({ name: paramObject.getter.name.slice(4), type: ethType });
173
174
  }
174
175
  tupleClasses.push(...paramObject.classes);
175
- });
176
+ }
176
177
  // Then, generate the event class itself
177
178
  const klass = tsCodegen.klass(eventClassName, {
178
179
  export: true,
@@ -304,7 +305,7 @@ class AbiCodeGenerator {
304
305
  // @ts-expect-error improve typings of disambiguateNames to handle iterables
305
306
  setName: (fn, name) => fn.set('_alias', name),
306
307
  });
307
- functions.forEach(member => {
308
+ for (const member of functions) {
308
309
  const fnName = member.get('name');
309
310
  const fnAlias = member.get('_alias');
310
311
  const fnSignature = this.abi.functionSignature(member);
@@ -436,7 +437,7 @@ class AbiCodeGenerator {
436
437
  // Generate method with an without `try_`.
437
438
  klass.addMethod(tsCodegen.method(fnAlias, params, returnType, methodCallBody(false)));
438
439
  klass.addMethod(tsCodegen.method('try_' + fnAlias, params, 'ethereum.CallResult<' + returnType + '>', methodCallBody(true)));
439
- });
440
+ }
440
441
  return [...types, klass];
441
442
  }
442
443
  _getTupleParamType(inputOrOutput, index, tupleParentType) {
@@ -135,6 +135,7 @@ class Protocol {
135
135
  substreams: ['mainnet'],
136
136
  });
137
137
  const allNetworks = [];
138
+ // eslint-disable-next-line unicorn/no-array-for-each
138
139
  networks.forEach(value => {
139
140
  allNetworks.push(...value);
140
141
  });
@@ -64,7 +64,7 @@ const assignValue = (type) => {
64
64
  }
65
65
  default: {
66
66
  const value = VARIABLES_VALUES[type];
67
- return value ? value : `"${type} Not implemented"`;
67
+ return value || `"${type} Not implemented"`;
68
68
  }
69
69
  }
70
70
  };
@@ -95,7 +95,7 @@ const expectedValue = (type) => {
95
95
  }
96
96
  default: {
97
97
  const value = VARIABLES_VALUES[type];
98
- return value ? value : `${type} Not implemented`;
98
+ return value || `${type} Not implemented`;
99
99
  }
100
100
  }
101
101
  };
@@ -102,15 +102,12 @@ class TypeGenerator {
102
102
  async loadSubgraph({ quiet } = { quiet: false }) {
103
103
  const subgraphLoadOptions = { protocol: this.protocol, skipValidation: false };
104
104
  if (quiet) {
105
- return this.options.subgraph
106
- ? this.options.subgraph
107
- : (await subgraph_1.default.load(this.options.subgraphManifest, subgraphLoadOptions)).result;
105
+ return (this.options.subgraph ||
106
+ (await subgraph_1.default.load(this.options.subgraphManifest, subgraphLoadOptions)).result);
108
107
  }
109
108
  const manifestPath = (0, fs_1.displayPath)(this.options.subgraphManifest);
110
109
  return await (0, spinner_1.withSpinner)(`Load subgraph from ${manifestPath}`, `Failed to load subgraph from ${manifestPath}`, `Warnings while loading subgraph from ${manifestPath}`, async (_spinner) => {
111
- return this.options.subgraph
112
- ? this.options.subgraph
113
- : subgraph_1.default.load(this.options.subgraphManifest, subgraphLoadOptions);
110
+ return (this.options.subgraph || subgraph_1.default.load(this.options.subgraphManifest, subgraphLoadOptions));
114
111
  });
115
112
  }
116
113
  async loadSchema(subgraph) {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateSchema = exports.validateManifest = exports.validateContractValues = exports.validateContract = void 0;
4
- const contract_1 = require("./contract");
4
+ var contract_1 = require("./contract");
5
5
  Object.defineProperty(exports, "validateContract", { enumerable: true, get: function () { return contract_1.validateContract; } });
6
6
  Object.defineProperty(exports, "validateContractValues", { enumerable: true, get: function () { return contract_1.validateContractValues; } });
7
- const manifest_1 = require("./manifest");
7
+ var manifest_1 = require("./manifest");
8
8
  Object.defineProperty(exports, "validateManifest", { enumerable: true, get: function () { return manifest_1.validateManifest; } });
9
- const schema_1 = require("./schema");
9
+ var schema_1 = require("./schema");
10
10
  Object.defineProperty(exports, "validateSchema", { enumerable: true, get: function () { return schema_1.validateSchema; } });
@@ -30,7 +30,9 @@ const getFieldType = (type, fieldName) => {
30
30
  const fieldDef = type
31
31
  .get('fields')
32
32
  .find((field) => field.getIn(['name', 'value']) === fieldName);
33
- return fieldDef !== undefined ? fieldDef.get('type') : undefined;
33
+ if (fieldDef) {
34
+ return fieldDef.get('type');
35
+ }
34
36
  };
35
37
  /**
36
38
  * Resolves a type in the GraphQL schema.
@@ -188,7 +188,10 @@ def.directives
188
188
  ? type.fields.find((field) => field.name.value == 'as').value.value
189
189
  : undefined)))
190
190
  .reduce((flattened, types_args) => flattened.concat(types_args.reduce((flattened, types_arg) => {
191
- types_arg.forEach(type => (type ? flattened.push(type) : undefined));
191
+ for (const type in types_arg) {
192
+ if (type)
193
+ flattened.push(type);
194
+ }
192
195
  return flattened;
193
196
  }, [])), []);
194
197
  const entityTypeByName = (defs, name) => defs
@@ -215,7 +218,7 @@ const validateInnerFieldType = (defs, def, field) => {
215
218
  entity: def.name.value,
216
219
  message: `\
217
220
  Field '${field.name.value}': \
218
- Unknown type '${typeName}'.${suggestion !== undefined ? ` Did you mean '${suggestion}'?` : ''}`,
221
+ Unknown type '${typeName}'.${suggestion === undefined ? '' : ` Did you mean '${suggestion}'?`}`,
219
222
  },
220
223
  ]);
221
224
  };
@@ -352,16 +355,16 @@ const validateFulltextName = (def, directive) => {
352
355
  ]);
353
356
  };
354
357
  const validateFulltextArgumentName = (def, directive, argument) => {
355
- return argument.value.kind != 'StringValue'
356
- ? List([
358
+ return argument.value.kind == 'StringValue'
359
+ ? List([])
360
+ : List([
357
361
  immutable_1.default.fromJS({
358
362
  loc: directive.name.loc,
359
363
  entity: def.name.value,
360
364
  directive: fulltextDirectiveName(directive),
361
365
  message: `@fulltext argument 'name' must be a string`,
362
366
  }),
363
- ])
364
- : List([]);
367
+ ]);
365
368
  };
366
369
  const fulltextDirectiveName = (directive) => {
367
370
  const arg = directive.arguments.find((argument) => argument.name.value == 'name');
@@ -737,9 +740,9 @@ const typeDefinitionValidators = {
737
740
  : List.of(...validateEntityDirective(def), ...validateEntityID(def), ...validateEntityFields(defs, def), ...validateNoImportDirective(def), ...validateNoFulltext(def)),
738
741
  ObjectTypeExtension: (_defs, def) => validateAtLeastOneExtensionField(def),
739
742
  };
740
- const validateTypeDefinition = (defs, def) => typeDefinitionValidators[def.kind] !== undefined
741
- ? typeDefinitionValidators[def.kind](defs, def)
742
- : List();
743
+ const validateTypeDefinition = (defs, def) => typeDefinitionValidators[def.kind] === undefined
744
+ ? List()
745
+ : typeDefinitionValidators[def.kind](defs, def);
743
746
  const validateTypeDefinitions = (defs) => defs.reduce((errors, def) => errors.concat(validateTypeDefinition(defs, def)), List());
744
747
  const validateNamingCollisionsInTypes = (types) => {
745
748
  let seen = Set();
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.45.0-alpha-20230403193800-82c814f",
2
+ "version": "0.45.0-alpha-20230403195400-e8bdaff",
3
3
  "commands": {
4
4
  "add": {
5
5
  "id": "add",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.45.0-alpha-20230403193800-82c814f",
3
+ "version": "0.45.0-alpha-20230403195400-e8bdaff",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "engines": {
@@ -33,7 +33,7 @@
33
33
  "graphql": "15.5.0",
34
34
  "immutable": "4.2.1",
35
35
  "ipfs-http-client": "34.0.0",
36
- "jayson": "3.7.0",
36
+ "jayson": "3.6.6",
37
37
  "js-yaml": "3.14.1",
38
38
  "prettier": "1.19.1",
39
39
  "request": "2.88.2",
@@ -42,7 +42,7 @@
42
42
  "tmp-promise": "3.0.2",
43
43
  "web3-eth-abi": "1.7.0",
44
44
  "which": "2.0.2",
45
- "yaml": "1.10.2"
45
+ "yaml": "1.9.2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/debug": "^4.1.7",