@graphprotocol/graph-cli 0.37.3-alpha-20230112211157-1ff22ed → 0.37.3-alpha-20230112213511-df1c6b2

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.37.3-alpha-20230112211157-1ff22ed
3
+ ## 0.37.3-alpha-20230112213511-df1c6b2
4
4
 
5
5
  ### Patch Changes
6
6
 
package/dist/cli.js CHANGED
@@ -7,9 +7,7 @@ exports.run = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const gluegun_1 = require("gluegun");
9
9
  const run = async (argv) => {
10
- let builder = (0, gluegun_1.build)()
11
- .brand('graph')
12
- .src(__dirname);
10
+ let builder = (0, gluegun_1.build)().brand('graph').src(__dirname);
13
11
  const pluginDirs = [];
14
12
  await Promise.all(['npm root -g', 'npm root', 'yarn global dir'].map(async (cmd) => {
15
13
  try {
@@ -22,11 +20,7 @@ const run = async (argv) => {
22
20
  }));
23
21
  // Inject potential plugin directories
24
22
  builder = pluginDirs.reduce((cli, dir) => cli.plugin(path_1.default.join(dir, '@graphprotocol', 'indexer-cli', 'dist')), builder);
25
- const cli = builder
26
- .help()
27
- .version()
28
- .defaultCommand()
29
- .create();
23
+ const cli = builder.help().version().defaultCommand().create();
30
24
  return await cli.run(argv);
31
25
  };
32
26
  exports.run = run;
@@ -54,7 +54,7 @@ exports.default = {
54
54
  // Obtain tools
55
55
  let { print, system } = toolbox;
56
56
  // Read CLI parameters
57
- let { abi, contractName, h, help, mergeEntities, networkFile, } = toolbox.parameters.options;
57
+ let { abi, contractName, h, help, mergeEntities, networkFile } = toolbox.parameters.options;
58
58
  contractName = contractName || 'Contract';
59
59
  try {
60
60
  (0, gluegun_1.fixParameters)(toolbox.parameters, {
@@ -29,7 +29,7 @@ exports.default = {
29
29
  description: 'Runs rust binary for subgraph testing',
30
30
  run: async (toolbox) => {
31
31
  // Read CLI parameters
32
- let { c, coverage, d, docker, f, force, h, help, l, logs, r, recompile, v, version, } = toolbox.parameters.options;
32
+ let { c, coverage, d, docker, f, force, h, help, l, logs, r, recompile, v, version } = toolbox.parameters.options;
33
33
  const testsFolder = './tests';
34
34
  let opts = {
35
35
  testsFolder,
@@ -129,8 +129,7 @@ async function runBinary(datasource, opts) {
129
129
  let latestVersion = opts.latestVersion;
130
130
  let recompileOpt = opts.recompile;
131
131
  const platform = await getPlatform(logsOpt);
132
- const url = `https://github.com/LimeChain/matchstick/releases/download/${versionOpt ||
133
- latestVersion}/${platform}`;
132
+ const url = `https://github.com/LimeChain/matchstick/releases/download/${versionOpt || latestVersion}/${platform}`;
134
133
  if (logsOpt) {
135
134
  gluegun_1.print.info(`Download link: ${url}`);
136
135
  }
@@ -155,8 +154,7 @@ async function getPlatform(logsOpt) {
155
154
  const release = linuxInfo.version || os_1.default.release();
156
155
  const majorVersion = parseInt(linuxInfo.version || '', 10) || semver_1.default.major(release);
157
156
  if (logsOpt) {
158
- gluegun_1.print.info(`OS type: ${linuxDistro ||
159
- type}\nOS arch: ${arch}\nOS release: ${release}\nOS major version: ${majorVersion}\nCPU model: ${cpuCore.model}`);
157
+ gluegun_1.print.info(`OS type: ${linuxDistro || type}\nOS arch: ${arch}\nOS release: ${release}\nOS major version: ${majorVersion}\nCPU model: ${cpuCore.model}`);
160
158
  }
161
159
  if (arch === 'x64' || isAppleSilicon) {
162
160
  if (type === 'Darwin') {
@@ -83,14 +83,8 @@ class ABI {
83
83
  * - Multiple inputs and outputs: `example(uint256,(string,bytes32)):(bool,uint256)`
84
84
  */
85
85
  functionSignature(fn) {
86
- let inputs = fn
87
- .get('inputs', [])
88
- .map(buildSignatureParameter)
89
- .join(',');
90
- let outputs = fn
91
- .get('outputs', [])
92
- .map(buildSignatureParameter)
93
- .join(',');
86
+ let inputs = fn.get('inputs', []).map(buildSignatureParameter).join(',');
87
+ let outputs = fn.get('outputs', []).map(buildSignatureParameter).join(',');
94
88
  return `${fn.get('name')}(${inputs})${outputs.length > 0 ? `:(${outputs})` : ''}`;
95
89
  }
96
90
  oldEventSignatures() {
@@ -29,9 +29,7 @@ const generatePlaceholderHandlers = ({ abi, events, contractName, }) => `
29
29
  entity.count = entity.count + BigInt.fromI32(1)
30
30
 
31
31
  // Entity fields can be set based on event parameters
32
- ${(0, mapping_1.generateEventFieldAssignments)(event)
33
- .slice(0, 2)
34
- .join('\n')}
32
+ ${(0, mapping_1.generateEventFieldAssignments)(event).slice(0, 2).join('\n')}
35
33
 
36
34
  // Entities can be written to the store with \`.save()\`
37
35
  entity.save()
@@ -51,10 +49,7 @@ const generatePlaceholderHandlers = ({ abi, events, contractName, }) => `
51
49
  // The following functions can then be called on this contract to access
52
50
  // state variables and other data:
53
51
  //
54
- // ${abi
55
- .codeGenerator()
56
- .callableFunctions()
57
- .isEmpty()
52
+ // ${abi.codeGenerator().callableFunctions().isEmpty()
58
53
  ? 'None'
59
54
  : abi
60
55
  .codeGenerator()
@@ -150,9 +150,7 @@ class Protocol {
150
150
  // Receives a data source kind, and checks if it's valid
151
151
  // for the given protocol instance (this).
152
152
  isValidKindName(kind) {
153
- return Protocol.availableProtocols()
154
- .get(this.name, immutable_1.default.List())
155
- .includes(kind);
153
+ return Protocol.availableProtocols().get(this.name, immutable_1.default.List()).includes(kind);
156
154
  }
157
155
  hasABIs() {
158
156
  return this.config.abi != null;
@@ -160,8 +160,7 @@ const generateMockedEvents = (events) => events.reduce((acc, event) => acc.conca
160
160
  const generateMockedEvent = (event) => {
161
161
  const varName = `${gluegun_1.strings.camelCase(event._alias)}Event`;
162
162
  const fnArgs = event.inputs.map((input, index) => `${input.name || `param${index}`}: ${(0, types_1.ascTypeForEthereum)(input.type)}`);
163
- const ascToEth = event.inputs.map((input, index) => `${varName}.parameters.push(new ethereum.EventParam("${input.name ||
164
- `param${index}`}", ${(0, types_1.ethereumFromAsc)(input.name || `param${index}`, input.type)}))`);
163
+ const ascToEth = event.inputs.map((input, index) => `${varName}.parameters.push(new ethereum.EventParam("${input.name || `param${index}`}", ${(0, types_1.ethereumFromAsc)(input.name || `param${index}`, input.type)}))`);
165
164
  return `
166
165
  export function create${event._alias}Event(${fnArgs.join(', ')}): ${event._alias} {
167
166
  let ${varName} = changetype<${event._alias}>(newMockEvent());
package/dist/subgraph.js CHANGED
@@ -39,19 +39,13 @@ const throwCombinedError = (filename, errors) => {
39
39
  throw new Error(errors.reduce((msg, e) => `${msg}
40
40
 
41
41
  Path: ${e.get('path').size === 0 ? '/' : e.get('path').join(' > ')}
42
- ${e
43
- .get('message')
44
- .split('\n')
45
- .join('\n ')}`, `Error in ${path_1.default.relative(process.cwd(), filename)}:`));
42
+ ${e.get('message').split('\n').join('\n ')}`, `Error in ${path_1.default.relative(process.cwd(), filename)}:`));
46
43
  };
47
44
  const buildCombinedWarning = (filename, warnings) => warnings.size > 0
48
45
  ? warnings.reduce((msg, w) => `${msg}
49
46
 
50
47
  Path: ${w.get('path').size === 0 ? '/' : w.get('path').join(' > ')}
51
- ${w
52
- .get('message')
53
- .split('\n')
54
- .join('\n ')}`, `Warnings in ${path_1.default.relative(process.cwd(), filename)}:`) + '\n'
48
+ ${w.get('message').split('\n').join('\n ')}`, `Warnings in ${path_1.default.relative(process.cwd(), filename)}:`) + '\n'
55
49
  : null;
56
50
  class Subgraph {
57
51
  static async validate(data, protocol, { resolveFile }) {
@@ -88,10 +82,7 @@ class Subgraph {
88
82
  ${directive}:`
89
83
  : ''}
90
84
  ${errors
91
- .map(error => error
92
- .get('message')
93
- .split('\n')
94
- .join('\n '))
85
+ .map(error => error.get('message').split('\n').join('\n '))
95
86
  .map(msg => `${directive ? ' ' : ''}- ${msg}`)
96
87
  .join('\n ')}`;
97
88
  }, ``);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.37.3-alpha-20230112211157-1ff22ed",
3
+ "version": "0.37.3-alpha-20230112213511-df1c6b2",
4
4
  "license": "(Apache-2.0 OR MIT)",
5
5
  "description": "CLI for building for and deploying to The Graph",
6
6
  "main": "dist/cli.js",
package/src/cli.ts CHANGED
@@ -2,9 +2,7 @@ import path from 'path'
2
2
  import { build, system } from 'gluegun'
3
3
 
4
4
  const run = async (argv: string[]) => {
5
- let builder = build()
6
- .brand('graph')
7
- .src(__dirname)
5
+ let builder = build().brand('graph').src(__dirname)
8
6
 
9
7
  const pluginDirs: string[] = []
10
8
  await Promise.all(
@@ -24,11 +22,7 @@ const run = async (argv: string[]) => {
24
22
  builder,
25
23
  )
26
24
 
27
- const cli = builder
28
- .help()
29
- .version()
30
- .defaultCommand()
31
- .create()
25
+ const cli = builder.help().version().defaultCommand().create()
32
26
 
33
27
  return await cli.run(argv)
34
28
  }
@@ -44,14 +44,8 @@ export default {
44
44
  let { print, system } = toolbox
45
45
 
46
46
  // Read CLI parameters
47
- let {
48
- abi,
49
- contractName,
50
- h,
51
- help,
52
- mergeEntities,
53
- networkFile,
54
- } = toolbox.parameters.options
47
+ let { abi, contractName, h, help, mergeEntities, networkFile } =
48
+ toolbox.parameters.options
55
49
 
56
50
  contractName = contractName || 'Contract'
57
51
 
@@ -81,26 +81,30 @@ export default {
81
81
  }
82
82
 
83
83
  let spinner = print.spin(`Creating subgraph in Graph node: ${requestUrl}`)
84
- client.request('subgraph_create', { name: subgraphName }, function(
85
- // @ts-expect-error TODO: why are the arguments not typed?
86
- requestError,
87
- // @ts-expect-error TODO: why are the arguments not typed?
88
- jsonRpcError,
89
- // TODO: why are the arguments not typed?
90
- // TODO: this argument is unused, but removing it fails the basic-event-handlers tests
91
- // @ts-expect-error
92
- res,
93
- ) {
94
- if (jsonRpcError) {
95
- spinner.fail(`Error creating the subgraph: ${jsonRpcError.message}`)
96
- process.exitCode = 1
97
- } else if (requestError) {
98
- spinner.fail(`HTTP error creating the subgraph: ${requestError.code}`)
99
- process.exitCode = 1
100
- } else {
101
- spinner.stop()
102
- print.success(`Created subgraph: ${subgraphName}`)
103
- }
104
- })
84
+ client.request(
85
+ 'subgraph_create',
86
+ { name: subgraphName },
87
+ function (
88
+ // @ts-expect-error TODO: why are the arguments not typed?
89
+ requestError,
90
+ // @ts-expect-error TODO: why are the arguments not typed?
91
+ jsonRpcError,
92
+ // TODO: why are the arguments not typed?
93
+ // TODO: this argument is unused, but removing it fails the basic-event-handlers tests
94
+ // @ts-expect-error
95
+ res,
96
+ ) {
97
+ if (jsonRpcError) {
98
+ spinner.fail(`Error creating the subgraph: ${jsonRpcError.message}`)
99
+ process.exitCode = 1
100
+ } else if (requestError) {
101
+ spinner.fail(`HTTP error creating the subgraph: ${requestError.code}`)
102
+ process.exitCode = 1
103
+ } else {
104
+ spinner.stop()
105
+ print.success(`Created subgraph: ${subgraphName}`)
106
+ }
107
+ },
108
+ )
105
109
  },
106
110
  }
@@ -81,27 +81,31 @@ export default {
81
81
  }
82
82
 
83
83
  let spinner = print.spin(`Creating subgraph in Graph node: ${requestUrl}`)
84
- client.request('subgraph_remove', { name: subgraphName }, function(
85
- // @ts-expect-error TODO: why are the arguments not typed?
86
- requestError,
87
- // @ts-expect-error TODO: why are the arguments not typed?
88
- jsonRpcError,
89
- // TODO: why are the arguments not typed?
90
- // TODO: this argument is unused, but removing it from the commands/create.ts fails the basic-event-handlers tests.
91
- // I'll therefore leave it in here too until we figure out the weirdness
92
- // @ts-expect-error
93
- res,
94
- ) {
95
- if (jsonRpcError) {
96
- spinner.fail(`Error removing the subgraph: ${jsonRpcError.message}`)
97
- process.exitCode = 1
98
- } else if (requestError) {
99
- spinner.fail(`HTTP error removing the subgraph: ${requestError.code}`)
100
- process.exitCode = 1
101
- } else {
102
- spinner.stop()
103
- print.success(`Removed subgraph: ${subgraphName}`)
104
- }
105
- })
84
+ client.request(
85
+ 'subgraph_remove',
86
+ { name: subgraphName },
87
+ function (
88
+ // @ts-expect-error TODO: why are the arguments not typed?
89
+ requestError,
90
+ // @ts-expect-error TODO: why are the arguments not typed?
91
+ jsonRpcError,
92
+ // TODO: why are the arguments not typed?
93
+ // TODO: this argument is unused, but removing it from the commands/create.ts fails the basic-event-handlers tests.
94
+ // I'll therefore leave it in here too until we figure out the weirdness
95
+ // @ts-expect-error
96
+ res,
97
+ ) {
98
+ if (jsonRpcError) {
99
+ spinner.fail(`Error removing the subgraph: ${jsonRpcError.message}`)
100
+ process.exitCode = 1
101
+ } else if (requestError) {
102
+ spinner.fail(`HTTP error removing the subgraph: ${requestError.code}`)
103
+ process.exitCode = 1
104
+ } else {
105
+ spinner.stop()
106
+ print.success(`Removed subgraph: ${subgraphName}`)
107
+ }
108
+ },
109
+ )
106
110
  },
107
111
  }
@@ -40,22 +40,8 @@ export default {
40
40
  description: 'Runs rust binary for subgraph testing',
41
41
  run: async (toolbox: GluegunToolbox) => {
42
42
  // Read CLI parameters
43
- let {
44
- c,
45
- coverage,
46
- d,
47
- docker,
48
- f,
49
- force,
50
- h,
51
- help,
52
- l,
53
- logs,
54
- r,
55
- recompile,
56
- v,
57
- version,
58
- } = toolbox.parameters.options
43
+ let { c, coverage, d, docker, f, force, h, help, l, logs, r, recompile, v, version } =
44
+ toolbox.parameters.options
59
45
 
60
46
  const testsFolder = './tests'
61
47
  let opts: TestOptions = {
@@ -168,8 +154,9 @@ async function runBinary(datasource: string | undefined, opts: TestOptions) {
168
154
 
169
155
  const platform = await getPlatform(logsOpt)
170
156
 
171
- const url = `https://github.com/LimeChain/matchstick/releases/download/${versionOpt ||
172
- latestVersion}/${platform}`
157
+ const url = `https://github.com/LimeChain/matchstick/releases/download/${
158
+ versionOpt || latestVersion
159
+ }/${platform}`
173
160
 
174
161
  if (logsOpt) {
175
162
  print.info(`Download link: ${url}`)
@@ -197,8 +184,9 @@ async function getPlatform(logsOpt: boolean | undefined) {
197
184
 
198
185
  if (logsOpt) {
199
186
  print.info(
200
- `OS type: ${linuxDistro ||
201
- type}\nOS arch: ${arch}\nOS release: ${release}\nOS major version: ${majorVersion}\nCPU model: ${
187
+ `OS type: ${
188
+ linuxDistro || type
189
+ }\nOS arch: ${arch}\nOS release: ${release}\nOS major version: ${majorVersion}\nCPU model: ${
202
190
  cpuCore.model
203
191
  }`,
204
192
  )
@@ -82,7 +82,7 @@ export default class Compiler {
82
82
  this.protocol = this.options.protocol
83
83
  this.ABI = this.protocol.getABI()
84
84
 
85
- process.on('uncaughtException', function(e) {
85
+ process.on('uncaughtException', function (e) {
86
86
  toolbox.print.error(`UNCAUGHT EXCEPTION: ${e}`)
87
87
  })
88
88
  }
@@ -82,14 +82,8 @@ export default class ABI {
82
82
  * - Multiple inputs and outputs: `example(uint256,(string,bytes32)):(bool,uint256)`
83
83
  */
84
84
  functionSignature(fn: immutable.Map<any, any>) {
85
- let inputs = fn
86
- .get('inputs', [])
87
- .map(buildSignatureParameter)
88
- .join(',')
89
- let outputs = fn
90
- .get('outputs', [])
91
- .map(buildSignatureParameter)
92
- .join(',')
85
+ let inputs = fn.get('inputs', []).map(buildSignatureParameter).join(',')
86
+ let outputs = fn.get('outputs', []).map(buildSignatureParameter).join(',')
93
87
  return `${fn.get('name')}(${inputs})${outputs.length > 0 ? `:(${outputs})` : ''}`
94
88
  }
95
89
 
@@ -442,9 +442,9 @@ export default class AbiCodeGenerator {
442
442
  tsCodegen.staticMethod(
443
443
  'bind',
444
444
  // TODO: add support for iterable staticMethod params
445
- (immutable.List([
445
+ immutable.List([
446
446
  tsCodegen.param('address', typesCodegen.ascTypeForEthereum('address')),
447
- ]) as unknown) as tsCodegen.Param[],
447
+ ]) as unknown as tsCodegen.Param[],
448
448
  tsCodegen.namedType(this.abi.name),
449
449
  `
450
450
  return new ${this.abi.name}('${this.abi.name}', address);
@@ -38,9 +38,7 @@ export const generatePlaceholderHandlers = ({
38
38
  entity.count = entity.count + BigInt.fromI32(1)
39
39
 
40
40
  // Entity fields can be set based on event parameters
41
- ${generateEventFieldAssignments(event)
42
- .slice(0, 2)
43
- .join('\n')}
41
+ ${generateEventFieldAssignments(event).slice(0, 2).join('\n')}
44
42
 
45
43
  // Entities can be written to the store with \`.save()\`
46
44
  entity.save()
@@ -61,10 +59,7 @@ export const generatePlaceholderHandlers = ({
61
59
  // state variables and other data:
62
60
  //
63
61
  // ${
64
- abi
65
- .codeGenerator()
66
- .callableFunctions()
67
- .isEmpty()
62
+ abi.codeGenerator().callableFunctions().isEmpty()
68
63
  ? 'None'
69
64
  : abi
70
65
  .codeGenerator()
@@ -142,9 +142,7 @@ export default class Protocol {
142
142
  // Receives a data source kind, and checks if it's valid
143
143
  // for the given protocol instance (this).
144
144
  isValidKindName(kind: string) {
145
- return Protocol.availableProtocols()
146
- .get(this.name, immutable.List())
147
- .includes(kind)
145
+ return Protocol.availableProtocols().get(this.name, immutable.List()).includes(kind)
148
146
  }
149
147
 
150
148
  hasABIs() {
@@ -4,14 +4,14 @@ import * as util from '../codegen/util'
4
4
  import Protocol from '../protocols'
5
5
 
6
6
  export function abiEvents(abi: { data: immutable.Collection<any, any> }) {
7
- return (util.disambiguateNames({
7
+ return util.disambiguateNames({
8
8
  // @ts-expect-error improve typings of disambiguateNames to handle iterables
9
9
  values: abi.data.filter(item => item.get('type') === 'event'),
10
10
  // @ts-expect-error improve typings of disambiguateNames to handle iterables
11
11
  getName: event => event.get('name'),
12
12
  // @ts-expect-error improve typings of disambiguateNames to handle iterables
13
13
  setName: (event, name) => event.set('_alias', name),
14
- }) as unknown) as immutable.List<any>
14
+ }) as unknown as immutable.List<any>
15
15
  }
16
16
 
17
17
  export const protocolTypeToGraphQL = (protocol: string, name: string) => {
@@ -202,11 +202,9 @@ const generateMockedEvent = (event: any) => {
202
202
  )
203
203
  const ascToEth = event.inputs.map(
204
204
  (input: any, index: number) =>
205
- `${varName}.parameters.push(new ethereum.EventParam("${input.name ||
206
- `param${index}`}", ${ethereumFromAsc(
207
- input.name || `param${index}`,
208
- input.type,
209
- )}))`,
205
+ `${varName}.parameters.push(new ethereum.EventParam("${
206
+ input.name || `param${index}`
207
+ }", ${ethereumFromAsc(input.name || `param${index}`, input.type)}))`,
210
208
  )
211
209
 
212
210
  return `
package/src/subgraph.ts CHANGED
@@ -17,10 +17,7 @@ const throwCombinedError = (filename: string, errors: immutable.List<any>) => {
17
17
  `${msg}
18
18
 
19
19
  Path: ${e.get('path').size === 0 ? '/' : e.get('path').join(' > ')}
20
- ${e
21
- .get('message')
22
- .split('\n')
23
- .join('\n ')}`,
20
+ ${e.get('message').split('\n').join('\n ')}`,
24
21
  `Error in ${path.relative(process.cwd(), filename)}:`,
25
22
  ),
26
23
  )
@@ -33,10 +30,7 @@ const buildCombinedWarning = (filename: string, warnings: immutable.List<any>) =
33
30
  `${msg}
34
31
 
35
32
  Path: ${w.get('path').size === 0 ? '/' : w.get('path').join(' > ')}
36
- ${w
37
- .get('message')
38
- .split('\n')
39
- .join('\n ')}`,
33
+ ${w.get('message').split('\n').join('\n ')}`,
40
34
  `Warnings in ${path.relative(process.cwd(), filename)}:`,
41
35
  ) + '\n'
42
36
  : null
@@ -95,12 +89,7 @@ export default class Subgraph {
95
89
  : ''
96
90
  }
97
91
  ${errors
98
- .map(error =>
99
- error
100
- .get('message')
101
- .split('\n')
102
- .join('\n '),
103
- )
92
+ .map(error => error.get('message').split('\n').join('\n '))
104
93
  .map(msg => `${directive ? ' ' : ''}- ${msg}`)
105
94
  .join('\n ')}`
106
95
  },
@@ -47,7 +47,7 @@ export default class TypeGenerator {
47
47
  outputDir: this.options.outputDir,
48
48
  })
49
49
 
50
- process.on('uncaughtException', function(e) {
50
+ process.on('uncaughtException', function (e) {
51
51
  toolbox.print.error(`UNCAUGHT EXCEPTION: ${e}`)
52
52
  })
53
53
  }