@graphprotocol/graph-cli 0.45.0-alpha-20230330173033-57c7de2 → 0.45.0-alpha-20230330181701-7b433c5

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-20230330173033-57c7de2
3
+ ## 0.45.0-alpha-20230330181701-7b433c5
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable */
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
28
  };
28
29
  Object.defineProperty(exports, "__esModule", { value: true });
29
- /* eslint-disable */
30
30
  const toolbox = __importStar(require("gluegun"));
31
31
  const semver_1 = __importDefault(require("semver"));
32
32
  const load_manifest_1 = require("./util/load-manifest");
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable */
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
28
  };
28
29
  Object.defineProperty(exports, "__esModule", { value: true });
29
- /* eslint-disable */
30
30
  const toolbox = __importStar(require("gluegun"));
31
31
  const semver_1 = __importDefault(require("semver"));
32
32
  const load_manifest_1 = require("./util/load-manifest");
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable */
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
28
  };
28
29
  Object.defineProperty(exports, "__esModule", { value: true });
29
- /* eslint-disable */
30
30
  const toolbox = __importStar(require("gluegun"));
31
31
  const semver_1 = __importDefault(require("semver"));
32
32
  const load_manifest_1 = require("./util/load-manifest");
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable */
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
28
  };
28
29
  Object.defineProperty(exports, "__esModule", { value: true });
29
- /* eslint-disable */
30
30
  const toolbox = __importStar(require("gluegun"));
31
31
  const semver_1 = __importDefault(require("semver"));
32
32
  const load_manifest_1 = require("./util/load-manifest");
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable */
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
28
  };
28
29
  Object.defineProperty(exports, "__esModule", { value: true });
29
- /* eslint-disable */
30
30
  const toolbox = __importStar(require("gluegun"));
31
31
  const semver_1 = __importDefault(require("semver"));
32
32
  const load_manifest_1 = require("./util/load-manifest");
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable */
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -23,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
24
  return result;
24
25
  };
25
26
  Object.defineProperty(exports, "__esModule", { value: true });
26
- /* eslint-disable */
27
27
  const toolbox = __importStar(require("gluegun"));
28
28
  const load_manifest_1 = require("./util/load-manifest");
29
29
  // Spec version to 0.0.2 uses top level templates. graph-cli no longer supports
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable */
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -23,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
24
  return result;
24
25
  };
25
26
  Object.defineProperty(exports, "__esModule", { value: true });
26
- /* eslint-disable */
27
27
  const toolbox = __importStar(require("gluegun"));
28
28
  const load_manifest_1 = require("./util/load-manifest");
29
29
  // Spec version 0.0.4 uses feature management, but features are
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.generateEventIndexingHandlers = exports.generateEventFieldAssignments = exports.generateFieldAssignments = exports.generateFieldAssignment = void 0;
26
+ exports.generateEventIndexingHandlers = exports.generateEventFieldAssignments = exports.renameInput = exports.INPUT_NAMES_BLACKLIST = exports.generateFieldAssignments = exports.generateFieldAssignment = void 0;
27
27
  const util = __importStar(require("../codegen/util"));
28
28
  const generateFieldAssignment = (key, value) => `entity.${key.join('_')} = event.params.${value.join('.')}`;
29
29
  exports.generateFieldAssignment = generateFieldAssignment;
@@ -33,16 +33,24 @@ const generateFieldAssignments = ({ index, input }) => input.type === 'tuple'
33
33
  .map(({ path }) => (0, exports.generateFieldAssignment)(path, path))
34
34
  : (0, exports.generateFieldAssignment)([(input.mappedName ?? input.name) || `param${index}`], [input.name || `param${index}`]);
35
35
  exports.generateFieldAssignments = generateFieldAssignments;
36
+ /**
37
+ * Map of input names that are reserved so we do not use them as field names to avoid conflicts
38
+ */
39
+ exports.INPUT_NAMES_BLACKLIST = {
40
+ /** Related to https://github.com/graphprotocol/graph-tooling/issues/710 */
41
+ id: 'id',
42
+ };
36
43
  const renameInput = (name, subgraphName) => {
37
44
  const inputMap = {
38
- id: `${subgraphName}_id`,
45
+ [exports.INPUT_NAMES_BLACKLIST.id]: `${subgraphName}_id`,
39
46
  };
40
- return inputMap[name] ?? name;
47
+ return inputMap?.[name] ?? name;
41
48
  };
49
+ exports.renameInput = renameInput;
42
50
  const generateEventFieldAssignments = (event, contractName) => event.inputs.reduce((acc, input, index) => {
43
- const inputNamesBlacklist = ['id'];
44
- if (inputNamesBlacklist.includes(input.name)) {
45
- input.mappedName = renameInput(input.name, contractName ?? 'contract');
51
+ console.log({ blacklist: Object.values(exports.INPUT_NAMES_BLACKLIST), input: input.name });
52
+ if (Object.values(exports.INPUT_NAMES_BLACKLIST).includes(input.name)) {
53
+ input.mappedName = (0, exports.renameInput)(input.name, contractName ?? 'contract');
46
54
  }
47
55
  return acc.concat((0, exports.generateFieldAssignments)({ input, index }));
48
56
  }, []);
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.generateExampleEntityType = exports.generateEventType = exports.generateEventFields = exports.generateField = exports.protocolTypeToGraphQL = exports.abiEvents = void 0;
27
27
  const types_1 = require("../codegen/types");
28
28
  const util = __importStar(require("../codegen/util"));
29
+ const mapping_1 = require("./mapping");
29
30
  function abiEvents(abi) {
30
31
  return util.disambiguateNames({
31
32
  // @ts-expect-error improve typings of disambiguateNames to handle iterables
@@ -62,20 +63,13 @@ const generateEventFields = ({ index, input, protocolName, }) => input.type == '
62
63
  }),
63
64
  ];
64
65
  exports.generateEventFields = generateEventFields;
65
- const renameInput = (name, subgraphName) => {
66
- const inputMap = {
67
- id: `${subgraphName}_id`,
68
- };
69
- return inputMap[name] ?? name;
70
- };
71
66
  const generateEventType = (event, protocolName, subgraphName) => {
72
- const inputNamesBlacklist = ['id'];
73
67
  return `type ${event._alias} @entity(immutable: true) {
74
68
  id: Bytes!
75
69
  ${event.inputs
76
70
  .reduce((acc, input, index) => {
77
- if (inputNamesBlacklist.includes(input.name)) {
78
- input.name = renameInput(input.name, subgraphName ?? 'contract');
71
+ if (Object.values(mapping_1.INPUT_NAMES_BLACKLIST).includes(input.name)) {
72
+ input.name = (0, mapping_1.renameInput)(input.name, subgraphName ?? 'contract');
79
73
  }
80
74
  return acc.concat((0, exports.generateEventFields)({ input, index, protocolName }));
81
75
  }, [])
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.45.0-alpha-20230330173033-57c7de2",
2
+ "version": "0.45.0-alpha-20230330181701-7b433c5",
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-20230330173033-57c7de2",
3
+ "version": "0.45.0-alpha-20230330181701-7b433c5",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "engines": {