@graphprotocol/graph-cli 0.37.2 → 0.37.3-alpha-20230110163550-d64bef6

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.
Files changed (206) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/babel.config.js +3 -0
  3. package/dist/bin.js +6 -0
  4. package/dist/cli.js +32 -0
  5. package/dist/codegen/schema.js +250 -0
  6. package/dist/codegen/schema.test.js +458 -0
  7. package/dist/codegen/template.js +65 -0
  8. package/dist/codegen/types/conversions.js +359 -0
  9. package/dist/codegen/types/index.js +71 -0
  10. package/dist/codegen/types/index.test.js +563 -0
  11. package/dist/codegen/typescript.js +200 -0
  12. package/dist/codegen/util.js +46 -0
  13. package/dist/codegen/util.test.js +93 -0
  14. package/dist/command-helpers/abi.js +78 -0
  15. package/dist/command-helpers/auth.js +77 -0
  16. package/dist/command-helpers/compiler.js +66 -0
  17. package/dist/command-helpers/data-sources.js +29 -0
  18. package/dist/command-helpers/fs.js +9 -0
  19. package/dist/command-helpers/gluegun.js +49 -0
  20. package/dist/command-helpers/ipfs.js +5 -0
  21. package/dist/command-helpers/jsonrpc.js +29 -0
  22. package/dist/command-helpers/network.js +93 -0
  23. package/dist/command-helpers/network.test.js +86 -0
  24. package/dist/command-helpers/node.js +40 -0
  25. package/dist/command-helpers/scaffold.js +112 -0
  26. package/dist/command-helpers/spinner.js +84 -0
  27. package/dist/command-helpers/studio.js +13 -0
  28. package/dist/command-helpers/studio.test.js +41 -0
  29. package/dist/command-helpers/subgraph.js +24 -0
  30. package/dist/command-helpers/version.js +74 -0
  31. package/dist/command-helpers/version.test.js +179 -0
  32. package/dist/commands/add.js +190 -0
  33. package/dist/commands/auth.js +127 -0
  34. package/dist/commands/build.js +140 -0
  35. package/dist/commands/codegen.js +135 -0
  36. package/dist/commands/create.js +86 -0
  37. package/dist/commands/deploy.js +334 -0
  38. package/dist/commands/init.js +788 -0
  39. package/dist/commands/local.js +387 -0
  40. package/dist/commands/remove.js +86 -0
  41. package/dist/commands/test.js +295 -0
  42. package/dist/compiler/asc.js +83 -0
  43. package/dist/compiler/index.js +474 -0
  44. package/dist/debug.js +16 -0
  45. package/dist/migrations/mapping_api_version_0_0_1.js +78 -0
  46. package/dist/migrations/mapping_api_version_0_0_2.js +76 -0
  47. package/dist/migrations/mapping_api_version_0_0_3.js +78 -0
  48. package/dist/migrations/mapping_api_version_0_0_4.js +80 -0
  49. package/dist/migrations/mapping_api_version_0_0_5.js +80 -0
  50. package/dist/migrations/spec_version_0_0_2.js +49 -0
  51. package/dist/migrations/spec_version_0_0_3.js +54 -0
  52. package/dist/migrations/util/load-manifest.js +18 -0
  53. package/dist/migrations/util/versions.js +29 -0
  54. package/dist/migrations.js +56 -0
  55. package/dist/protocols/arweave/manifest.graphql +57 -0
  56. package/dist/protocols/arweave/scaffold/manifest.js +18 -0
  57. package/dist/protocols/arweave/scaffold/mapping.js +52 -0
  58. package/dist/protocols/arweave/subgraph.js +23 -0
  59. package/dist/protocols/cosmos/manifest.graphql +76 -0
  60. package/dist/protocols/cosmos/scaffold/manifest.js +15 -0
  61. package/dist/protocols/cosmos/scaffold/mapping.js +38 -0
  62. package/dist/protocols/cosmos/subgraph.js +25 -0
  63. package/dist/protocols/ethereum/abi.js +140 -0
  64. package/dist/protocols/ethereum/codegen/abi.js +451 -0
  65. package/dist/protocols/ethereum/codegen/abi.test.js +328 -0
  66. package/dist/protocols/ethereum/codegen/template.js +50 -0
  67. package/dist/protocols/ethereum/contract.js +20 -0
  68. package/dist/protocols/ethereum/manifest.graphql +94 -0
  69. package/dist/protocols/ethereum/scaffold/manifest.js +32 -0
  70. package/dist/protocols/ethereum/scaffold/mapping.js +65 -0
  71. package/dist/protocols/ethereum/subgraph.js +171 -0
  72. package/dist/protocols/ethereum/type-generator.js +125 -0
  73. package/dist/protocols/index.js +268 -0
  74. package/dist/protocols/ipfs/codegen/file_template.js +50 -0
  75. package/dist/protocols/near/contract.js +41 -0
  76. package/dist/protocols/near/manifest.graphql +64 -0
  77. package/dist/protocols/near/scaffold/manifest.js +16 -0
  78. package/dist/protocols/near/scaffold/mapping.js +38 -0
  79. package/dist/protocols/near/subgraph.js +20 -0
  80. package/dist/protocols/subgraph.js +2 -0
  81. package/dist/protocols/substreams/manifest.graphql +45 -0
  82. package/dist/protocols/substreams/scaffold/manifest.js +12 -0
  83. package/dist/protocols/substreams/subgraph.js +23 -0
  84. package/dist/scaffold/cosmos.test.js +83 -0
  85. package/dist/scaffold/ethereum.test.js +505 -0
  86. package/dist/scaffold/index.js +128 -0
  87. package/dist/scaffold/mapping.js +61 -0
  88. package/dist/scaffold/near.test.js +86 -0
  89. package/dist/scaffold/schema.js +83 -0
  90. package/dist/scaffold/tests.js +175 -0
  91. package/dist/schema.js +54 -0
  92. package/dist/subgraph.js +249 -0
  93. package/dist/type-generator.js +224 -0
  94. package/dist/validation/contract.js +46 -0
  95. package/dist/validation/index.js +8 -0
  96. package/dist/validation/manifest.js +271 -0
  97. package/dist/validation/schema.js +796 -0
  98. package/dist/validation/schema.test.js +35 -0
  99. package/dist/watcher.js +79 -0
  100. package/jest.config.js +1 -1
  101. package/package.json +16 -9
  102. package/{bin/graph → src/bin.ts} +2 -1
  103. package/src/cli.ts +36 -0
  104. package/src/codegen/schema.js +23 -22
  105. package/src/codegen/schema.test.js +33 -27
  106. package/src/codegen/{template.js → template.ts} +8 -6
  107. package/src/codegen/types/conversions.ts +382 -0
  108. package/src/codegen/types/index.js +4 -7
  109. package/src/codegen/types/index.test.js +10 -4
  110. package/src/codegen/{typescript.js → typescript.ts} +44 -26
  111. package/src/codegen/util.js +1 -1
  112. package/src/codegen/util.test.js +5 -2
  113. package/src/command-helpers/abi.js +46 -30
  114. package/src/command-helpers/auth.js +6 -9
  115. package/src/command-helpers/compiler.js +4 -6
  116. package/src/command-helpers/data-sources.js +8 -11
  117. package/src/command-helpers/fs.ts +5 -0
  118. package/src/command-helpers/gluegun.js +2 -4
  119. package/src/command-helpers/ipfs.ts +3 -0
  120. package/src/command-helpers/{jsonrpc.js → jsonrpc.ts} +11 -16
  121. package/src/command-helpers/network.js +58 -44
  122. package/src/command-helpers/network.test.js +23 -19
  123. package/src/command-helpers/node.js +3 -7
  124. package/src/command-helpers/scaffold.js +34 -25
  125. package/src/command-helpers/{spinner.js → spinner.ts} +10 -10
  126. package/src/command-helpers/studio.test.js +61 -30
  127. package/src/command-helpers/studio.ts +20 -0
  128. package/src/command-helpers/{subgraph.js → subgraph.ts} +6 -6
  129. package/src/command-helpers/version.js +11 -16
  130. package/src/command-helpers/version.test.js +111 -82
  131. package/src/commands/add.js +49 -35
  132. package/src/commands/auth.js +13 -25
  133. package/src/commands/build.js +9 -9
  134. package/src/commands/codegen.js +12 -12
  135. package/src/commands/create.js +22 -22
  136. package/src/commands/deploy.js +39 -34
  137. package/src/commands/init.js +21 -24
  138. package/src/commands/local.js +15 -14
  139. package/src/commands/remove.js +22 -22
  140. package/src/commands/test.js +86 -70
  141. package/src/compiler/{asc.js → asc.ts} +29 -16
  142. package/src/compiler/index.js +18 -18
  143. package/src/{debug.js → debug.ts} +2 -2
  144. package/src/migrations/mapping_api_version_0_0_1.js +7 -7
  145. package/src/migrations/mapping_api_version_0_0_2.js +5 -5
  146. package/src/migrations/mapping_api_version_0_0_3.js +7 -7
  147. package/src/migrations/mapping_api_version_0_0_4.js +7 -7
  148. package/src/migrations/mapping_api_version_0_0_5.js +7 -7
  149. package/src/migrations/spec_version_0_0_2.js +5 -5
  150. package/src/migrations/spec_version_0_0_3.js +5 -5
  151. package/src/migrations/util/load-manifest.js +6 -9
  152. package/src/migrations/util/versions.js +5 -10
  153. package/src/{migrations.js → migrations.ts} +14 -15
  154. package/src/protocols/arweave/scaffold/manifest.js +1 -4
  155. package/src/protocols/arweave/scaffold/mapping.js +1 -3
  156. package/src/protocols/arweave/subgraph.ts +22 -0
  157. package/src/protocols/cosmos/scaffold/manifest.js +1 -4
  158. package/src/protocols/cosmos/scaffold/mapping.js +1 -3
  159. package/src/protocols/cosmos/subgraph.js +2 -2
  160. package/src/protocols/ethereum/abi.js +7 -13
  161. package/src/protocols/ethereum/codegen/abi.js +219 -222
  162. package/src/protocols/ethereum/codegen/abi.test.js +6 -6
  163. package/src/protocols/ethereum/codegen/template.js +3 -5
  164. package/src/protocols/ethereum/contract.js +3 -2
  165. package/src/protocols/ethereum/scaffold/manifest.js +4 -7
  166. package/src/protocols/ethereum/scaffold/mapping.js +4 -11
  167. package/src/protocols/ethereum/subgraph.js +21 -20
  168. package/src/protocols/ethereum/type-generator.js +24 -30
  169. package/src/protocols/{index.js → index.ts} +65 -46
  170. package/src/protocols/ipfs/codegen/file_template.js +2 -2
  171. package/src/protocols/near/{contract.js → contract.ts} +16 -12
  172. package/src/protocols/near/scaffold/manifest.js +2 -5
  173. package/src/protocols/near/scaffold/mapping.js +1 -3
  174. package/src/protocols/near/subgraph.js +3 -6
  175. package/src/protocols/subgraph.ts +12 -0
  176. package/src/protocols/substreams/scaffold/{manifest.js → manifest.ts} +2 -7
  177. package/src/protocols/substreams/subgraph.ts +22 -0
  178. package/src/scaffold/cosmos.test.js +3 -3
  179. package/src/scaffold/ethereum.test.js +4 -4
  180. package/src/scaffold/index.js +7 -7
  181. package/src/scaffold/mapping.js +3 -3
  182. package/src/scaffold/near.test.js +3 -3
  183. package/src/scaffold/schema.js +4 -4
  184. package/src/scaffold/tests.js +72 -58
  185. package/src/schema.ts +26 -0
  186. package/src/{subgraph.js → subgraph.ts} +80 -60
  187. package/src/type-generator.js +20 -20
  188. package/src/validation/contract.js +2 -6
  189. package/src/validation/index.js +1 -1
  190. package/src/validation/manifest.js +24 -22
  191. package/src/validation/schema.test.js +1 -1
  192. package/src/validation/{schema.js → schema.ts} +268 -221
  193. package/src/{watcher.js → watcher.ts} +23 -12
  194. package/tests/cli/globalSetup.js +2 -2
  195. package/tests/cli/globalTeardown.js +2 -2
  196. package/tests/cli/init.test.js +2 -2
  197. package/tests/cli/util.js +7 -13
  198. package/tsconfig.json +18 -0
  199. package/src/cli.js +0 -38
  200. package/src/codegen/types/conversions.js +0 -329
  201. package/src/command-helpers/fs.js +0 -8
  202. package/src/command-helpers/ipfs.js +0 -6
  203. package/src/command-helpers/studio.js +0 -15
  204. package/src/protocols/arweave/subgraph.js +0 -20
  205. package/src/protocols/substreams/subgraph.js +0 -17
  206. package/src/schema.js +0 -23
@@ -1,15 +1,21 @@
1
- const chalk = require('chalk')
2
- const toolbox = require('gluegun/toolbox')
3
- const immutable = require('immutable')
4
- const { withSpinner } = require('../command-helpers/spinner')
5
- const Subgraph = require('../subgraph')
6
- const Protocol = require('../protocols')
7
- const DataSourcesExtractor = require('../command-helpers/data-sources')
8
- const { generateDataSource, writeABI, writeSchema, writeMapping, writeTestsFiles } = require('../command-helpers/scaffold')
9
- const { loadAbiFromEtherscan, loadAbiFromBlockScout } = require('../command-helpers/abi')
10
- const EthereumABI = require('../protocols/ethereum/abi')
11
- const { fixParameters } = require('../command-helpers/gluegun')
12
- const { updateNetworksFile } = require('../command-helpers/network')
1
+ import chalk from 'chalk'
2
+ import * as toolbox from 'gluegun/toolbox'
3
+ import immutable from 'immutable'
4
+ import { withSpinner } from '../command-helpers/spinner'
5
+ import Subgraph from '../subgraph'
6
+ import Protocol from '../protocols'
7
+ import * as DataSourcesExtractor from '../command-helpers/data-sources'
8
+ import {
9
+ generateDataSource,
10
+ writeABI,
11
+ writeSchema,
12
+ writeMapping,
13
+ writeTestsFiles,
14
+ } from '../command-helpers/scaffold'
15
+ import { loadAbiFromEtherscan, loadAbiFromBlockScout } from '../command-helpers/abi'
16
+ import EthereumABI from '../protocols/ethereum/abi'
17
+ import { fixParameters } from '../command-helpers/gluegun'
18
+ import { updateNetworksFile } from '../command-helpers/network'
13
19
 
14
20
  const HELP = `
15
21
  ${chalk.bold('graph add')} <address> [<subgraph-manifest default: "./subgraph.yaml">]
@@ -23,21 +29,15 @@ ${chalk.dim('Options:')}
23
29
  -h, --help Show usage information
24
30
  `
25
31
 
26
- module.exports = {
32
+ export default {
27
33
  description: 'Adds a new datasource to a subgraph',
28
34
  run: async toolbox => {
29
35
  // Obtain tools
30
36
  let { print, system } = toolbox
31
37
 
32
38
  // Read CLI parameters
33
- let {
34
- abi,
35
- contractName,
36
- h,
37
- help,
38
- mergeEntities,
39
- networkFile
40
- } = toolbox.parameters.options
39
+ let { abi, contractName, h, help, mergeEntities, networkFile } =
40
+ toolbox.parameters.options
41
41
 
42
42
  contractName = contractName || 'Contract'
43
43
 
@@ -54,7 +54,8 @@ module.exports = {
54
54
  }
55
55
 
56
56
  let address = toolbox.parameters.first || toolbox.parameters.array[0]
57
- let manifestPath = toolbox.parameters.second || toolbox.parameters.array[1] || './subgraph.yaml'
57
+ let manifestPath =
58
+ toolbox.parameters.second || toolbox.parameters.array[1] || './subgraph.yaml'
58
59
 
59
60
  // Show help text if requested
60
61
  if (help || h) {
@@ -96,17 +97,32 @@ module.exports = {
96
97
  }
97
98
  }
98
99
 
99
- let { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(ethabi, entities, contractName, mergeEntities)
100
+ let { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(
101
+ ethabi,
102
+ entities,
103
+ contractName,
104
+ mergeEntities,
105
+ )
100
106
  ethabi.data = abiData
101
107
 
102
108
  await writeABI(ethabi, contractName)
103
- await writeSchema(ethabi, protocol, result.getIn(['schema', 'file']), collisionEntities)
109
+ await writeSchema(
110
+ ethabi,
111
+ protocol,
112
+ result.getIn(['schema', 'file']),
113
+ collisionEntities,
114
+ )
104
115
  await writeMapping(ethabi, protocol, contractName, collisionEntities)
105
116
  await writeTestsFiles(ethabi, protocol, contractName)
106
117
 
107
118
  let dataSources = result.get('dataSources')
108
- let dataSource = await generateDataSource(protocol,
109
- contractName, network, address, ethabi)
119
+ let dataSource = await generateDataSource(
120
+ protocol,
121
+ contractName,
122
+ network,
123
+ address,
124
+ ethabi,
125
+ )
110
126
 
111
127
  // Handle the collisions edge case by copying another data source yaml data
112
128
  if (mergeEntities && onlyCollisions) {
@@ -126,7 +142,7 @@ module.exports = {
126
142
  await Subgraph.write(result, manifestPath)
127
143
 
128
144
  // Update networks.json
129
- const networksFile = networkFile || "./networks.json"
145
+ const networksFile = networkFile || './networks.json'
130
146
  await updateNetworksFile(toolbox, network, contractName, address, networksFile)
131
147
 
132
148
  // Detect Yarn and/or NPM
@@ -146,12 +162,12 @@ module.exports = {
146
162
  'Warning during codegen',
147
163
  async spinner => {
148
164
  await system.run(yarn ? 'yarn codegen' : 'npm run codegen')
149
- }
165
+ },
150
166
  )
151
- }
167
+ },
152
168
  }
153
169
 
154
- const getEntities = (manifest) => {
170
+ const getEntities = manifest => {
155
171
  let dataSources = manifest.result.get('dataSources', immutable.List())
156
172
  let templates = manifest.result.get('templates', immutable.List())
157
173
 
@@ -161,13 +177,11 @@ const getEntities = (manifest) => {
161
177
  .flatten()
162
178
  }
163
179
 
164
- const getContractNames = (manifest) => {
180
+ const getContractNames = manifest => {
165
181
  let dataSources = manifest.result.get('dataSources', immutable.List())
166
182
  let templates = manifest.result.get('templates', immutable.List())
167
183
 
168
- return dataSources
169
- .concat(templates)
170
- .map(dataSource => dataSource.get('name'))
184
+ return dataSources.concat(templates).map(dataSource => dataSource.get('name'))
171
185
  }
172
186
 
173
187
  const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntities) => {
@@ -179,7 +193,7 @@ const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntiti
179
193
  for (let i = 0; i < abiData.size; i++) {
180
194
  let dataRow = abiData.get(i).asMutable()
181
195
 
182
- if (dataRow.get('type') === 'event'){
196
+ if (dataRow.get('type') === 'event') {
183
197
  if (entities.indexOf(dataRow.get('name')) !== -1) {
184
198
  if (entities.indexOf(`${contractName}${dataRow.get('name')}`) !== -1) {
185
199
  print.error(`Contract name ('${contractName}')
@@ -1,11 +1,11 @@
1
- const chalk = require('chalk')
2
- const { saveDeployKey } = require('../command-helpers/auth')
3
- const { chooseNodeUrl } = require('../command-helpers/node')
4
- const { fixParameters } = require('../command-helpers/gluegun')
1
+ import chalk from 'chalk'
2
+ import { saveDeployKey } from '../command-helpers/auth'
3
+ import { chooseNodeUrl } from '../command-helpers/node'
4
+ import { fixParameters } from '../command-helpers/gluegun'
5
5
 
6
6
  const HELP = `
7
7
  ${chalk.bold('graph auth')} [options] ${chalk.bold('<node>')} ${chalk.bold(
8
- '<deploy-key>'
8
+ '<deploy-key>',
9
9
  )}
10
10
 
11
11
  ${chalk.dim('Options:')}
@@ -16,25 +16,18 @@ ${chalk.dim('Options:')}
16
16
  -h, --help Show usage information
17
17
  `
18
18
 
19
- const processForm = async (
20
- toolbox,
21
- {
22
- product,
23
- studio,
24
- node,
25
- deployKey,
26
- },
27
- ) => {
19
+ const processForm = async (toolbox, { product, studio, node, deployKey }) => {
28
20
  const questions = [
29
21
  {
30
22
  type: 'select',
31
23
  name: 'product',
32
24
  message: 'Product for which to initialize',
33
25
  choices: ['subgraph-studio', 'hosted-service'],
34
- skip:
26
+ skip:
35
27
  product === 'subgraph-studio' ||
36
28
  product === 'hosted-service' ||
37
- studio !== undefined || node !== undefined,
29
+ studio !== undefined ||
30
+ node !== undefined,
38
31
  },
39
32
  {
40
33
  type: 'password',
@@ -52,19 +45,14 @@ const processForm = async (
52
45
  }
53
46
  }
54
47
 
55
- module.exports = {
48
+ export default {
56
49
  description: 'Sets the deploy key to use when deploying to a Graph node',
57
50
  run: async toolbox => {
58
51
  // Obtain tools
59
52
  let { filesystem, print, system } = toolbox
60
53
 
61
54
  // Read CLI parameters
62
- let {
63
- product,
64
- studio,
65
- h,
66
- help,
67
- } = toolbox.parameters.options
55
+ let { product, studio, h, help } = toolbox.parameters.options
68
56
 
69
57
  // Show help text if requested
70
58
  if (help || h) {
@@ -77,7 +65,7 @@ module.exports = {
77
65
  ;[firstParam, secondParam] = fixParameters(toolbox.parameters, {
78
66
  h,
79
67
  help,
80
- studio
68
+ studio,
81
69
  })
82
70
  } catch (e) {
83
71
  print.error(e.message)
@@ -101,7 +89,7 @@ module.exports = {
101
89
  product,
102
90
  studio,
103
91
  node,
104
- deployKey
92
+ deployKey,
105
93
  })
106
94
  if (inputs === undefined) {
107
95
  process.exit(1)
@@ -1,12 +1,12 @@
1
- const chalk = require('chalk')
1
+ import chalk from 'chalk'
2
+ import { createCompiler } from '../command-helpers/compiler'
3
+ import { fixParameters } from '../command-helpers/gluegun'
4
+ import { updateSubgraphNetwork } from '../command-helpers/network'
5
+ import * as DataSourcesExtractor from '../command-helpers/data-sources'
6
+ import Protocol from '../protocols'
7
+ import debug from '../debug'
2
8
 
3
- const { createCompiler } = require('../command-helpers/compiler')
4
- const { fixParameters } = require('../command-helpers/gluegun')
5
- const { updateSubgraphNetwork } = require('../command-helpers/network')
6
- const DataSourcesExtractor = require('../command-helpers/data-sources')
7
- const Protocol = require('../protocols')
8
-
9
- let buildDebug = require('../debug')('graph-cli:build')
9
+ let buildDebug = debug('graph-cli:build')
10
10
 
11
11
  const HELP = `
12
12
  ${chalk.bold('graph build')} [options] ${chalk.bold('[<subgraph-manifest>]')}
@@ -23,7 +23,7 @@ Options:
23
23
  --network-file <path> Networks config file path (default: "./networks.json")
24
24
  `
25
25
 
26
- module.exports = {
26
+ export default {
27
27
  description: 'Builds a subgraph and (optionally) uploads it to IPFS',
28
28
  run: async toolbox => {
29
29
  // Obtain tools
@@ -1,14 +1,14 @@
1
- const chalk = require('chalk')
2
- const path = require('path')
3
-
4
- const TypeGenerator = require('../type-generator')
5
- const Protocol = require('../protocols')
6
- const { fixParameters } = require('../command-helpers/gluegun')
7
- const DataSourcesExtractor = require('../command-helpers/data-sources')
8
- const {
1
+ import chalk from 'chalk'
2
+ import path from 'path'
3
+ import TypeGenerator from '../type-generator'
4
+ import Protocol from '../protocols'
5
+ import { fixParameters } from '../command-helpers/gluegun'
6
+ import * as DataSourcesExtractor from '../command-helpers/data-sources'
7
+ import debug from '../debug'
8
+ import {
9
9
  assertManifestApiVersion,
10
10
  assertGraphTsVersion,
11
- } = require('../command-helpers/version')
11
+ } from '../command-helpers/version'
12
12
 
13
13
  const HELP = `
14
14
  ${chalk.bold('graph codegen')} [options] ${chalk.bold('[<subgraph-manifest>]')}
@@ -21,9 +21,9 @@ Options:
21
21
  -uc, --uncrashable-config <path> Directory for uncrashable config (default: ./uncrashable-config.yaml)
22
22
  `
23
23
 
24
- let codegenDebug = require('../debug')('graph-cli:codegen')
24
+ let codegenDebug = debug('graph-cli:codegen')
25
25
 
26
- module.exports = {
26
+ export default {
27
27
  description: 'Generates AssemblyScript types for a subgraph',
28
28
  run: async toolbox => {
29
29
  // Obtain tools
@@ -49,7 +49,7 @@ module.exports = {
49
49
  outputDir = outputDir || o
50
50
  watch = watch || w
51
51
  uncrashable = uncrashable || u
52
- uncrashable_config = uncrashableConfig || uc
52
+ let uncrashable_config = uncrashableConfig || uc
53
53
 
54
54
  let manifest
55
55
  try {
@@ -1,8 +1,8 @@
1
- const URL = require('url').URL
2
- const chalk = require('chalk')
3
- const { validateNodeUrl } = require('../command-helpers/node')
4
- const { identifyDeployKey: identifyAccessToken } = require('../command-helpers/auth')
5
- const { createJsonRpcClient } = require('../command-helpers/jsonrpc')
1
+ import { URL } from 'url'
2
+ import chalk from 'chalk'
3
+ import { validateNodeUrl } from '../command-helpers/node'
4
+ import { identifyDeployKey as identifyAccessToken } from '../command-helpers/auth'
5
+ import { createJsonRpcClient } from '../command-helpers/jsonrpc'
6
6
 
7
7
  const HELP = `
8
8
  ${chalk.bold('graph create')} ${chalk.dim('[options]')} ${chalk.bold('<subgraph-name>')}
@@ -14,7 +14,7 @@ ${chalk.dim('Options:')}
14
14
  -g, --node <url> Graph node to create the subgraph in
15
15
  `
16
16
 
17
- module.exports = {
17
+ export default {
18
18
  description: 'Registers a subgraph name',
19
19
  run: async toolbox => {
20
20
  // Obtain tools
@@ -73,21 +73,21 @@ module.exports = {
73
73
  }
74
74
 
75
75
  let spinner = print.spin(`Creating subgraph in Graph node: ${requestUrl}`)
76
- client.request('subgraph_create', { name: subgraphName }, function(
77
- requestError,
78
- jsonRpcError,
79
- res
80
- ) {
81
- if (jsonRpcError) {
82
- spinner.fail(`Error creating the subgraph: ${jsonRpcError.message}`)
83
- process.exitCode = 1
84
- } else if (requestError) {
85
- spinner.fail(`HTTP error creating the subgraph: ${requestError.code}`)
86
- process.exitCode = 1
87
- } else {
88
- spinner.stop()
89
- print.success(`Created subgraph: ${subgraphName}`)
90
- }
91
- })
76
+ client.request(
77
+ 'subgraph_create',
78
+ { name: subgraphName },
79
+ function (requestError, jsonRpcError, res) {
80
+ if (jsonRpcError) {
81
+ spinner.fail(`Error creating the subgraph: ${jsonRpcError.message}`)
82
+ process.exitCode = 1
83
+ } else if (requestError) {
84
+ spinner.fail(`HTTP error creating the subgraph: ${requestError.code}`)
85
+ process.exitCode = 1
86
+ } else {
87
+ spinner.stop()
88
+ print.success(`Created subgraph: ${subgraphName}`)
89
+ }
90
+ },
91
+ )
92
92
  },
93
93
  }
@@ -1,20 +1,23 @@
1
1
  const URL = require('url').URL
2
- const chalk = require('chalk')
3
- const path = require('path')
4
-
5
- const { identifyDeployKey } = require('../command-helpers/auth')
6
- const { createCompiler } = require('../command-helpers/compiler')
7
- const { fixParameters } = require('../command-helpers/gluegun')
8
- const { createJsonRpcClient } = require('../command-helpers/jsonrpc')
9
- const { chooseNodeUrl } = require('../command-helpers/node')
10
- const { withSpinner } = require('../command-helpers/spinner')
11
- const { validateSubgraphName } = require('../command-helpers/subgraph')
12
- const { DEFAULT_IPFS_URL } = require('../command-helpers/ipfs')
13
- const { assertManifestApiVersion, assertGraphTsVersion } = require('../command-helpers/version')
14
- const DataSourcesExtractor = require('../command-helpers/data-sources')
15
- const { validateStudioNetwork } = require('../command-helpers/studio')
16
- const Protocol = require('../protocols')
17
- const { updateSubgraphNetwork } = require('../command-helpers/network')
2
+ import chalk from 'chalk'
3
+ import path from 'path'
4
+
5
+ import { identifyDeployKey } from '../command-helpers/auth'
6
+ import { createCompiler } from '../command-helpers/compiler'
7
+ import { fixParameters } from '../command-helpers/gluegun'
8
+ import { createJsonRpcClient } from '../command-helpers/jsonrpc'
9
+ import { chooseNodeUrl } from '../command-helpers/node'
10
+ import { withSpinner } from '../command-helpers/spinner'
11
+ import { validateSubgraphName } from '../command-helpers/subgraph'
12
+ import { DEFAULT_IPFS_URL } from '../command-helpers/ipfs'
13
+ import {
14
+ assertManifestApiVersion,
15
+ assertGraphTsVersion,
16
+ } from '../command-helpers/version'
17
+ import * as DataSourcesExtractor from '../command-helpers/data-sources'
18
+ import { validateStudioNetwork } from '../command-helpers/studio'
19
+ import Protocol from '../protocols'
20
+ import { updateSubgraphNetwork } from '../command-helpers/network'
18
21
 
19
22
  const HELP = `
20
23
  ${chalk.bold('graph deploy')} [options] ${chalk.bold('<subgraph-name>')} ${chalk.bold(
@@ -40,15 +43,7 @@ Options:
40
43
  --network-file <path> Networks config file path (default: "./networks.json")
41
44
  `
42
45
 
43
- const processForm = async (
44
- toolbox,
45
- {
46
- product,
47
- studio,
48
- node,
49
- versionLabel,
50
- },
51
- ) => {
46
+ const processForm = async (toolbox, { product, studio, node, versionLabel }) => {
52
47
  const questions = [
53
48
  {
54
49
  type: 'select',
@@ -58,7 +53,8 @@ const processForm = async (
58
53
  skip:
59
54
  product === 'subgraph-studio' ||
60
55
  product === 'hosted-service' ||
61
- studio !== undefined || node !== undefined,
56
+ studio !== undefined ||
57
+ node !== undefined,
62
58
  },
63
59
  {
64
60
  type: 'input',
@@ -76,7 +72,7 @@ const processForm = async (
76
72
  }
77
73
  }
78
74
 
79
- module.exports = {
75
+ export default {
80
76
  description: 'Deploys the subgraph to a Graph node',
81
77
  run: async toolbox => {
82
78
  // Obtain tools
@@ -111,7 +107,7 @@ module.exports = {
111
107
  // Support both long and short option variants
112
108
  help = help || h
113
109
  ipfs = ipfs || i || DEFAULT_IPFS_URL
114
- headers = headers || hdr || "{}"
110
+ headers = headers || hdr || '{}'
115
111
  node = node || g
116
112
  outputDir = outputDir || o
117
113
  watch = watch || w
@@ -120,7 +116,7 @@ module.exports = {
120
116
  try {
121
117
  headers = JSON.parse(headers)
122
118
  } catch (e) {
123
- print.error("Please make sure headers is a valid JSON value")
119
+ print.error('Please make sure headers is a valid JSON value')
124
120
  process.exitCode = 1
125
121
  return
126
122
  }
@@ -132,7 +128,7 @@ module.exports = {
132
128
  help,
133
129
  w,
134
130
  watch,
135
- studio
131
+ studio,
136
132
  })
137
133
  } catch (e) {
138
134
  print.error(e.message)
@@ -149,7 +145,7 @@ module.exports = {
149
145
  networkFile =
150
146
  networkFile !== undefined && networkFile !== ''
151
147
  ? networkFile
152
- : filesystem.resolve("networks.json")
148
+ : filesystem.resolve('networks.json')
153
149
 
154
150
  try {
155
151
  const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest)
@@ -190,7 +186,11 @@ module.exports = {
190
186
 
191
187
  // Validate the subgraph name
192
188
  if (!subgraphName) {
193
- print.error(`No subgraph ${product == 'subgraph-studio' || studio ? 'slug' : 'name'} provided`)
189
+ print.error(
190
+ `No subgraph ${
191
+ product == 'subgraph-studio' || studio ? 'slug' : 'name'
192
+ } provided`,
193
+ )
194
194
  print.info(HELP)
195
195
  process.exitCode = 1
196
196
  return
@@ -246,7 +246,7 @@ module.exports = {
246
246
  outputDir,
247
247
  outputFormat: 'wasm',
248
248
  skipMigrations,
249
- blockIpfsMethods: isStudio, // Network does not support publishing subgraphs with IPFS methods
249
+ blockIpfsMethods: isStudio, // Network does not support publishing subgraphs with IPFS methods
250
250
  protocol,
251
251
  })
252
252
 
@@ -293,7 +293,12 @@ module.exports = {
293
293
  // `Failed to deploy to Graph node ${requestUrl}`,
294
294
  client.request(
295
295
  'subgraph_deploy',
296
- { name: subgraphName, ipfs_hash: ipfsHash, version_label: versionLabel, debug_fork: debugFork },
296
+ {
297
+ name: subgraphName,
298
+ ipfs_hash: ipfsHash,
299
+ version_label: versionLabel,
300
+ debug_fork: debugFork,
301
+ },
297
302
  async (requestError, jsonRpcError, res) => {
298
303
  if (jsonRpcError) {
299
304
  spinner.fail(
@@ -1,32 +1,29 @@
1
- const chalk = require('chalk')
2
- const os = require('os')
3
- const path = require('path')
4
- const toolbox = require('gluegun/toolbox')
5
- const fs = require('fs')
6
- const graphCli = require('../cli')
7
-
8
- const {
9
- getSubgraphBasename,
10
- validateSubgraphName,
11
- } = require('../command-helpers/subgraph')
12
- const DataSourcesExtractor = require('../command-helpers/data-sources')
13
- const { validateStudioNetwork } = require('../command-helpers/studio')
14
- const { initNetworksConfig } = require('../command-helpers/network')
15
- const { withSpinner, step } = require('../command-helpers/spinner')
16
- const { fixParameters } = require('../command-helpers/gluegun')
17
- const { chooseNodeUrl } = require('../command-helpers/node')
18
- const { loadAbiFromEtherscan, loadAbiFromBlockScout } = require('../command-helpers/abi')
19
- const { generateScaffold, writeScaffold } = require('../command-helpers/scaffold')
20
- const { abiEvents } = require('../scaffold/schema')
21
- const { validateContract } = require('../validation')
22
- const Protocol = require('../protocols')
1
+ import chalk from 'chalk'
2
+ import os from 'os'
3
+ import path from 'path'
4
+ import * as toolbox from 'gluegun/toolbox'
5
+ import fs from 'fs'
6
+ import graphCli from '../cli'
7
+ import { getSubgraphBasename, validateSubgraphName } from '../command-helpers/subgraph'
8
+ import * as DataSourcesExtractor from '../command-helpers/data-sources'
9
+ import { validateStudioNetwork } from '../command-helpers/studio'
10
+ import { initNetworksConfig } from '../command-helpers/network'
11
+ import { withSpinner, step } from '../command-helpers/spinner'
12
+ import { fixParameters } from '../command-helpers/gluegun'
13
+ import { chooseNodeUrl } from '../command-helpers/node'
14
+ import { loadAbiFromEtherscan, loadAbiFromBlockScout } from '../command-helpers/abi'
15
+ import { generateScaffold, writeScaffold } from '../command-helpers/scaffold'
16
+ import { abiEvents } from '../scaffold/schema'
17
+ import { validateContract } from '../validation'
18
+ import Protocol from '../protocols'
19
+ import debug from '../debug'
23
20
 
24
21
  const protocolChoices = Array.from(Protocol.availableProtocols().keys())
25
22
  const availableNetworks = Protocol.availableNetworks()
26
23
 
27
24
  const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum/gravatar'
28
25
 
29
- let initDebug = require('../debug')('graph-cli:init')
26
+ let initDebug = debug('graph-cli:init')
30
27
 
31
28
  const HELP = `
32
29
  ${chalk.bold('graph init')} [options] [subgraph-name] [directory]
@@ -303,7 +300,7 @@ const loadAbiFromFile = async (ABI, filename) => {
303
300
  }
304
301
  }
305
302
 
306
- module.exports = {
303
+ export default {
307
304
  description: 'Creates a new subgraph with basic scaffolding',
308
305
  run: async toolbox => {
309
306
  // Obtain tools
@@ -1,15 +1,15 @@
1
- const chalk = require('chalk')
2
- const compose = require('docker-compose')
3
- const http = require('http')
4
- const net = require('net')
5
- const tmp = require('tmp-promise')
6
- const Docker = require('dockerode')
7
- const path = require('path')
8
- const stripAnsi = require('strip-ansi')
1
+ import chalk from 'chalk'
2
+ import compose from 'docker-compose'
3
+ import http from 'http'
4
+ import net from 'net'
5
+ import tmp from 'tmp-promise'
6
+ import Docker from 'dockerode'
7
+ import path from 'path'
8
+ import stripAnsi from 'strip-ansi'
9
9
  const spawn = require('child_process').spawn
10
10
 
11
- const { fixParameters } = require('../command-helpers/gluegun')
12
- const { step, withSpinner } = require('../command-helpers/spinner')
11
+ import { fixParameters } from '../command-helpers/gluegun'
12
+ import { step, withSpinner } from '../command-helpers/spinner'
13
13
 
14
14
  // Clean up temporary files even when an uncaught exception occurs
15
15
  tmp.setGracefulCleanup()
@@ -32,8 +32,9 @@ Options:
32
32
  --timeout Time to wait for service containers. (optional, defaults to 120000 milliseconds)
33
33
  `
34
34
 
35
- module.exports = {
36
- description: 'Runs local tests against a Graph Node environment (using Ganache by default)',
35
+ export default {
36
+ description:
37
+ 'Runs local tests against a Graph Node environment (using Ganache by default)',
37
38
  run: async toolbox => {
38
39
  // Obtain tools
39
40
  let { filesystem, print } = toolbox
@@ -130,7 +131,7 @@ module.exports = {
130
131
  skipWaitForEthereum,
131
132
  skipWaitForIpfs,
132
133
  skipWaitForPostgres,
133
- timeout,
134
+ timeout,
134
135
  })
135
136
  } catch (e) {
136
137
  await stopTestEnvironment(tempdir)
@@ -454,7 +455,7 @@ const startGraphNode = async (standaloneNode, standaloneNodeArgs, nodeOutputChun
454
455
  },
455
456
  )
456
457
 
457
- const waitForGraphNode = async ( timeout ) =>
458
+ const waitForGraphNode = async timeout =>
458
459
  await withSpinner(
459
460
  `Wait for Graph node`,
460
461
  `Failed to wait for Graph node`,