@graphprotocol/graph-cli 0.22.0-alpha.3 → 0.22.0

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-ts",
3
3
  "description": "TypeScript/AssemblyScript library for writing subgraph mappings for The Graph",
4
- "version": "0.22.0-alpha.3",
4
+ "version": "0.22.0",
5
5
  "module": "index.ts",
6
6
  "types": "index.ts",
7
7
  "main": "index.ts",
@@ -9,7 +9,7 @@
9
9
  "deploy-test": "../../bin/graph deploy test/basic-event-handlers --version-label v0.0.1 --ipfs http://localhost:15001 --node http://127.0.0.1:18020"
10
10
  },
11
11
  "devDependencies": {
12
- "@graphprotocol/graph-ts": "0.22.0-alpha.3",
12
+ "@graphprotocol/graph-ts": "0.22.0",
13
13
  "apollo-fetch": "^0.7.0"
14
14
  },
15
15
  "dependencies": {
@@ -2,10 +2,10 @@
2
2
  # yarn lockfile v1
3
3
 
4
4
 
5
- "@graphprotocol/graph-ts@0.22.0-alpha.3":
6
- version "0.22.0-alpha.3"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.22.0-alpha.3.tgz#925e564adf65b512aad2809a3c49e10f4fe03a8e"
8
- integrity sha512-pYYwMbWxshyKgWswAxBh0ebLSzeBYp0OEREZJy7M9yuTTKTNJNeSYoC3KZOhZnh3D5otre2LLQOd5cL8oaVylQ==
5
+ "@graphprotocol/graph-ts@0.22.0":
6
+ version "0.22.0"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.22.0.tgz#5280513d1c8a162077f82ce7f9a492bb5783d6f4"
8
+ integrity sha512-kJIBL73xBxj0+NJdRABukAtcrc3Mb8jt31s0tCLPe6c57rQXEf7KR9oYrFdzE1ZsJCP6j+MX+A2+sj1Pj3aJtQ==
9
9
  dependencies:
10
10
  assemblyscript "0.19.10"
11
11
 
@@ -7,7 +7,7 @@
7
7
  "build-wast": "../../bin/graph build -t wast subgraph.yaml"
8
8
  },
9
9
  "devDependencies": {
10
- "@graphprotocol/graph-ts": "0.22.0-alpha.3"
10
+ "@graphprotocol/graph-ts": "0.22.0"
11
11
  },
12
12
  "resolutions": {
13
13
  "assemblyscript": "0.19.10"
@@ -2,10 +2,10 @@
2
2
  # yarn lockfile v1
3
3
 
4
4
 
5
- "@graphprotocol/graph-ts@0.22.0-alpha.3":
6
- version "0.22.0-alpha.3"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.22.0-alpha.3.tgz#925e564adf65b512aad2809a3c49e10f4fe03a8e"
8
- integrity sha512-pYYwMbWxshyKgWswAxBh0ebLSzeBYp0OEREZJy7M9yuTTKTNJNeSYoC3KZOhZnh3D5otre2LLQOd5cL8oaVylQ==
5
+ "@graphprotocol/graph-ts@0.22.0":
6
+ version "0.22.0"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.22.0.tgz#5280513d1c8a162077f82ce7f9a492bb5783d6f4"
8
+ integrity sha512-kJIBL73xBxj0+NJdRABukAtcrc3Mb8jt31s0tCLPe6c57rQXEf7KR9oYrFdzE1ZsJCP6j+MX+A2+sj1Pj3aJtQ==
9
9
  dependencies:
10
10
  assemblyscript "0.19.10"
11
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.22.0-alpha.3",
3
+ "version": "0.22.0",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "dependencies": {
6
6
  "assemblyscript": "0.19.10",
@@ -0,0 +1,12 @@
1
+ const validateStudioNetwork = ({ studio, product, network }) => {
2
+ let isStudio = studio || product === 'subgraph-studio'
3
+ let isEthereumMainnet = network === 'mainnet'
4
+
5
+ if (isStudio && !isEthereumMainnet) {
6
+ throw new Error(`Non Ethereum mainnet subgraphs should not be deployed to the studio`)
7
+ }
8
+ }
9
+
10
+ module.exports = {
11
+ validateStudioNetwork,
12
+ }
@@ -0,0 +1,44 @@
1
+ const { validateStudioNetwork } = require('./studio')
2
+
3
+ describe('Version Command Helpers', () => {
4
+ describe('validateStudioNetwork', () => {
5
+ describe("When it's studio", () => {
6
+ test("And it's Ethereum mainnet", () => {
7
+ expect(() => validateStudioNetwork({
8
+ studio: true,
9
+ network: 'mainnet',
10
+ }))
11
+ .not
12
+ .toThrow(new Error('Non Ethereum mainnet subgraphs should not be deployed to the studio'))
13
+ })
14
+
15
+ test("And it's NOT Ethereum mainnet", () => {
16
+ expect(() => validateStudioNetwork({
17
+ product: 'subgraph-studio',
18
+ network: 'xdai',
19
+ }))
20
+ .toThrow(new Error('Non Ethereum mainnet subgraphs should not be deployed to the studio'))
21
+ })
22
+ })
23
+
24
+ describe("When it's NOT studio", () => {
25
+ test("And it's Ethereum mainnet", () => {
26
+ expect(() => validateStudioNetwork({
27
+ studio: false,
28
+ network: 'mainnet',
29
+ }))
30
+ .not
31
+ .toThrow(new Error('Non Ethereum mainnet subgraphs should not be deployed to the studio'))
32
+ })
33
+
34
+ test("And it's NOT Ethereum mainnet", () => {
35
+ expect(() => validateStudioNetwork({
36
+ product: 'hosted-service',
37
+ network: 'xdai',
38
+ }))
39
+ .not
40
+ .toThrow(new Error('Non Ethereum mainnet subgraphs should not be deployed to the studio'))
41
+ })
42
+ })
43
+ })
44
+ })
@@ -11,6 +11,8 @@ const { withSpinner } = require('../command-helpers/spinner')
11
11
  const { validateSubgraphName } = require('../command-helpers/subgraph')
12
12
  const { DEFAULT_IPFS_URL } = require('../command-helpers/ipfs')
13
13
  const { assertManifestApiVersion, assertGraphTsVersion } = require('../command-helpers/version')
14
+ const { validateStudioNetwork } = require('../command-helpers/studio')
15
+ const { loadManifest } = require('../migrations/util/load-manifest')
14
16
 
15
17
  const HELP = `
16
18
  ${chalk.bold('graph deploy')} [options] ${chalk.bold('<subgraph-name>')} ${chalk.bold(
@@ -125,6 +127,22 @@ module.exports = {
125
127
  ? manifest
126
128
  : filesystem.resolve('subgraph.yaml')
127
129
 
130
+ try {
131
+ let manifestFile = await loadManifest(manifest)
132
+
133
+ for (const { network } of manifestFile.dataSources || []) {
134
+ validateStudioNetwork({ studio, product, network })
135
+ }
136
+
137
+ for (const { network } of manifestFile.templates || []) {
138
+ validateStudioNetwork({ studio, product, network })
139
+ }
140
+ } catch (e) {
141
+ print.error(e.message)
142
+ process.exitCode = 1
143
+ return
144
+ }
145
+
128
146
  // Show help text if requested
129
147
  if (help) {
130
148
  print.info(HELP)
@@ -9,9 +9,11 @@ const {
9
9
  getSubgraphBasename,
10
10
  validateSubgraphName,
11
11
  } = require('../command-helpers/subgraph')
12
+ const { validateStudioNetwork } = require('../command-helpers/studio')
12
13
  const { withSpinner, step } = require('../command-helpers/spinner')
13
14
  const { fixParameters } = require('../command-helpers/gluegun')
14
15
  const { chooseNodeUrl } = require('../command-helpers/node')
16
+ const { loadManifest } = require('../migrations/util/load-manifest')
15
17
  const { abiEvents, generateScaffold, writeScaffold } = require('../scaffold')
16
18
  const ABI = require('../abi')
17
19
 
@@ -381,7 +383,7 @@ module.exports = {
381
383
  if (fromExample && subgraphName && directory) {
382
384
  return await initSubgraphFromExample(
383
385
  toolbox,
384
- { allowSimpleName, directory, subgraphName },
386
+ { allowSimpleName, directory, subgraphName, studio, product },
385
387
  { commands },
386
388
  )
387
389
  }
@@ -421,7 +423,9 @@ module.exports = {
421
423
  network,
422
424
  subgraphName,
423
425
  contractName,
424
- node
426
+ node,
427
+ studio,
428
+ product,
425
429
  },
426
430
  { commands },
427
431
  )
@@ -455,6 +459,8 @@ module.exports = {
455
459
  {
456
460
  subgraphName: inputs.subgraphName,
457
461
  directory: inputs.directory,
462
+ studio: inputs.studio,
463
+ product: inputs.product,
458
464
  },
459
465
  { commands },
460
466
  )
@@ -476,7 +482,9 @@ module.exports = {
476
482
  address: inputs.address,
477
483
  indexEvents,
478
484
  contractName: inputs.contractName,
479
- node
485
+ node,
486
+ studio: inputs.studio,
487
+ product: inputs.product,
480
488
  },
481
489
  { commands },
482
490
  )
@@ -567,7 +575,7 @@ Make sure to visit the documentation on https://thegraph.com/docs/ for further i
567
575
 
568
576
  const initSubgraphFromExample = async (
569
577
  toolbox,
570
- { allowSimpleName, subgraphName, directory },
578
+ { allowSimpleName, subgraphName, directory, studio, product },
571
579
  { commands },
572
580
  ) => {
573
581
  let { filesystem, print, system } = toolbox
@@ -602,6 +610,24 @@ const initSubgraphFromExample = async (
602
610
  return
603
611
  }
604
612
 
613
+ try {
614
+ // It doesn't matter if we changed the URL we clone the YAML,
615
+ // we'll check it's network anyway. If it's a studio subgraph we're dealing with.
616
+ let manifestFile = await loadManifest(path.join(directory, 'subgraph.yaml'))
617
+
618
+ for (const { network } of manifestFile.dataSources || []) {
619
+ validateStudioNetwork({ studio, product, network })
620
+ }
621
+
622
+ for (const { network } of manifestFile.templates || []) {
623
+ validateStudioNetwork({ studio, product, network })
624
+ }
625
+ } catch (e) {
626
+ print.error(e.message)
627
+ process.exitCode = 1
628
+ return
629
+ }
630
+
605
631
  // Update package.json to match the subgraph name
606
632
  let prepared = await withSpinner(
607
633
  `Update subgraph name and commands in package.json`,
@@ -661,7 +687,19 @@ const initSubgraphFromExample = async (
661
687
 
662
688
  const initSubgraphFromContract = async (
663
689
  toolbox,
664
- {allowSimpleName, subgraphName, directory, abi, network, address, indexEvents, contractName, node},
690
+ {
691
+ allowSimpleName,
692
+ subgraphName,
693
+ directory,
694
+ abi,
695
+ network,
696
+ address,
697
+ indexEvents,
698
+ contractName,
699
+ node,
700
+ studio,
701
+ product,
702
+ },
665
703
  { commands },
666
704
  ) => {
667
705
  let { print } = toolbox
@@ -686,6 +724,17 @@ const initSubgraphFromContract = async (
686
724
  return
687
725
  }
688
726
 
727
+ // We can validate this before the scaffold because we receive
728
+ // the network from the form or via command line argument.
729
+ // We don't need to read the manifest in this case.
730
+ try {
731
+ validateStudioNetwork({ studio, product, network })
732
+ } catch (e) {
733
+ print.error(e.message)
734
+ process.exitCode = 1
735
+ return
736
+ }
737
+
689
738
  // Scaffold subgraph from ABI
690
739
  let scaffold = await withSpinner(
691
740
  `Create subgraph scaffold`,
package/src/scaffold.js CHANGED
@@ -41,7 +41,7 @@ const generatePackageJson = ({ subgraphName, node }) =>
41
41
  },
42
42
  dependencies: {
43
43
  '@graphprotocol/graph-cli': `${module.exports.version}`,
44
- '@graphprotocol/graph-ts': `0.22.0-alpha.3`,
44
+ '@graphprotocol/graph-ts': `0.22.0`,
45
45
  },
46
46
  }),
47
47
  { parser: 'json' },