@graphprotocol/graph-cli 0.36.1 → 0.37.1-alpha-20221207192322-dd39b34

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 (64) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +6 -3
  3. package/src/command-helpers/abi.js +2 -0
  4. package/src/command-helpers/compiler.js +1 -1
  5. package/src/command-helpers/network.test.js +13 -10
  6. package/src/commands/build.js +7 -3
  7. package/src/commands/codegen.js +5 -0
  8. package/src/commands/init.js +12 -3
  9. package/src/compiler/index.js +128 -73
  10. package/src/debug.js +15 -0
  11. package/src/protocols/index.js +140 -128
  12. package/src/protocols/substreams/manifest.graphql +45 -0
  13. package/src/protocols/substreams/scaffold/manifest.js +13 -0
  14. package/src/protocols/substreams/subgraph.js +17 -0
  15. package/src/scaffold/index.js +7 -2
  16. package/src/subgraph.js +14 -3
  17. package/tests/cli/validation/call-handler-with-tuple/generated/schema.ts +44 -0
  18. package/tests/cli/validation/example-values-found/generated/ExampleSubgraph/ExampleContract.ts +35 -0
  19. package/tests/cli/validation/example-values-found/generated/schema.ts +44 -0
  20. package/tests/cli/validation/source-without-address-is-valid/generated/ExampleSubgraph/ExampleContract.ts +35 -0
  21. package/.eslintrc +0 -10
  22. package/.prettierrc.json +0 -6
  23. package/.travis.yml +0 -37
  24. package/CONTRIBUTING.md +0 -16
  25. package/LICENSE-APACHE +0 -190
  26. package/LICENSE-MIT +0 -21
  27. package/NEWS.md +0 -80
  28. package/README.md +0 -146
  29. package/examples/basic-event-handlers/LICENSE +0 -21
  30. package/examples/basic-event-handlers/README.md +0 -3
  31. package/examples/basic-event-handlers/abis/Gravity.json +0 -1
  32. package/examples/basic-event-handlers/bin/Counter.bin +0 -1
  33. package/examples/basic-event-handlers/build/Gravity/Gravity.wasm +0 -0
  34. package/examples/basic-event-handlers/build/Gravity/abis/Gravity.json +0 -199
  35. package/examples/basic-event-handlers/build/schema.graphql +0 -13
  36. package/examples/basic-event-handlers/build/subgraph.yaml +0 -27
  37. package/examples/basic-event-handlers/contracts/Gravity.sol +0 -62
  38. package/examples/basic-event-handlers/contracts/Migrations.sol +0 -23
  39. package/examples/basic-event-handlers/generated/Gravity/Gravity.ts +0 -343
  40. package/examples/basic-event-handlers/generated/schema.ts +0 -133
  41. package/examples/basic-event-handlers/migrations/1_initial_migration.js +0 -5
  42. package/examples/basic-event-handlers/migrations/2_deploy_contract.js +0 -5
  43. package/examples/basic-event-handlers/migrations/3_create_gravatars.js +0 -14
  44. package/examples/basic-event-handlers/migrations/4_update_gravatars.js +0 -9
  45. package/examples/basic-event-handlers/package.json +0 -24
  46. package/examples/basic-event-handlers/schema.graphql +0 -13
  47. package/examples/basic-event-handlers/src/mapping.ts +0 -21
  48. package/examples/basic-event-handlers/subgraph.yaml +0 -27
  49. package/examples/basic-event-handlers/test/handlers.js +0 -110
  50. package/examples/basic-event-handlers/truffle.js +0 -34
  51. package/examples/basic-event-handlers/yarn.lock +0 -1027
  52. package/examples/example-subgraph/abis/ExampleContract.json +0 -2388
  53. package/examples/example-subgraph/dist/ExampleSubgraph/ExampleSubgraph.wasm +0 -0
  54. package/examples/example-subgraph/dist/ExampleSubgraph/abis/ExampleContract.json +0 -2394
  55. package/examples/example-subgraph/dist/abis/ExampleContract.json +0 -2388
  56. package/examples/example-subgraph/dist/schema.graphql +0 -37
  57. package/examples/example-subgraph/dist/subgraph.yaml +0 -26
  58. package/examples/example-subgraph/package.json +0 -15
  59. package/examples/example-subgraph/schema.graphql +0 -37
  60. package/examples/example-subgraph/src/mapping.ts +0 -286
  61. package/examples/example-subgraph/subgraph.yaml +0 -26
  62. package/examples/example-subgraph/yarn.lock +0 -28
  63. package/resources/test/docker-compose-standalone-node.yml +0 -20
  64. package/resources/test/docker-compose.yml +0 -43
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @graphprotocol/graph-cli
2
+
3
+ ## 0.37.1-alpha-20221207192322-dd39b34
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1015](https://github.com/graphprotocol/graph-cli/pull/1015) [`0153cb5`](https://github.com/graphprotocol/graph-cli/commit/0153cb5be26d4334360218a9e9964398f9015882) Thanks [@saihaj](https://github.com/saihaj)! - fix fantom network init URLs
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.36.1",
3
+ "version": "0.37.1-alpha-20221207192322-dd39b34",
4
4
  "license": "(Apache-2.0 OR MIT)",
5
5
  "description": "CLI for building for and deploying to The Graph",
6
6
  "dependencies": {
7
- "assemblyscript": "0.19.10",
7
+ "assemblyscript": "0.19.23",
8
8
  "binary-install-raw": "0.0.13",
9
9
  "chalk": "3.0.0",
10
10
  "chokidar": "3.5.1",
@@ -41,9 +41,12 @@
41
41
  "strip-ansi": "6.0.0",
42
42
  "tern": "0.24.3"
43
43
  },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
44
47
  "scripts": {
45
48
  "test": "jest --verbose",
46
49
  "test:init": "jest tests/cli/init.test.js --verbose",
47
50
  "test:validation": "jest tests/cli/validation.test.js --verbose"
48
51
  }
49
- }
52
+ }
@@ -66,6 +66,8 @@ const getEtherscanLikeAPIUrl = (network) => {
66
66
  case "avalanche": return `https://api.snowtrace.io/api`;
67
67
  case "fuji": return `https://api-testnet.snowtrace.io/api`;
68
68
  case "gnosis": return `https://api.gnosisscan.io/api`;
69
+ case "fantom": return `https://api.ftmscan.com/api`;
70
+ case "fantom-testnet": return `https://api-testnet.ftmscan.com/api`;
69
71
  default: return `https://api-${network}.etherscan.io/api`
70
72
  }
71
73
  }
@@ -6,7 +6,7 @@ const Compiler = require('../compiler')
6
6
  // Helper function to construct a subgraph compiler
7
7
  const createCompiler = (
8
8
  manifest,
9
- { ipfs, headers, outputDir, outputFormat, skipMigrations, blockIpfsMethods, protocol }
9
+ { ipfs, headers, outputDir, outputFormat, skipMigrations, blockIpfsMethods, protocol },
10
10
  ) => {
11
11
  // Parse the IPFS URL
12
12
  let url
@@ -1,21 +1,24 @@
1
1
  const { initNetworksConfig, updateSubgraphNetwork } = require('../command-helpers/network')
2
2
  const toolbox = require('gluegun/toolbox')
3
3
  const yaml = require('yaml')
4
+ const path = require('path')
5
+
6
+ const SUBGRAPH_PATH_BASE = path.join(__dirname,'..','..','..','..','examples','example-subgraph')
4
7
 
5
8
  describe('initNetworksConfig', () => {
6
9
  beforeAll(async () => {
7
- await initNetworksConfig(toolbox, './examples/example-subgraph', 'address')
10
+ await initNetworksConfig(toolbox, SUBGRAPH_PATH_BASE, 'address')
8
11
  })
9
12
  afterAll(async () => {
10
- await toolbox.filesystem.remove('./examples/example-subgraph/networks.json')
13
+ await toolbox.filesystem.remove(`${SUBGRAPH_PATH_BASE}/networks.json`)
11
14
  })
12
15
 
13
16
  test('generates networks.json from subgraph.yaml', () => {
14
- expect(toolbox.filesystem.exists('./examples/example-subgraph/networks.json')).toBe('file')
17
+ expect(toolbox.filesystem.exists(`${SUBGRAPH_PATH_BASE}/networks.json`)).toBe('file')
15
18
  })
16
19
 
17
20
  test('Populates the networks.json file with the data from subgraph.yaml', async () => {
18
- let networksStr = await toolbox.filesystem.read('./examples/example-subgraph/networks.json')
21
+ let networksStr = await toolbox.filesystem.read(`${SUBGRAPH_PATH_BASE}/networks.json`)
19
22
  let networks = JSON.parse(networksStr)
20
23
 
21
24
  let expected = {
@@ -36,18 +39,18 @@ describe('updateSubgraphNetwork', () => {
36
39
  }
37
40
  }
38
41
 
39
- await toolbox.filesystem.write('./examples/example-subgraph/networks.json', content)
40
- await toolbox.filesystem.copy('./examples/example-subgraph/subgraph.yaml', './examples/example-subgraph/subgraph_copy.yaml')
42
+ await toolbox.filesystem.write(`${SUBGRAPH_PATH_BASE}/networks.json`, content)
43
+ await toolbox.filesystem.copy(`${SUBGRAPH_PATH_BASE}/subgraph.yaml`, `${SUBGRAPH_PATH_BASE}/subgraph_copy.yaml`)
41
44
  })
42
45
 
43
46
  afterAll(async () => {
44
- await toolbox.filesystem.remove('./examples/example-subgraph/networks.json')
45
- await toolbox.filesystem.remove('./examples/example-subgraph/subgraph_copy.yaml')
47
+ await toolbox.filesystem.remove(`${SUBGRAPH_PATH_BASE}/networks.json`)
48
+ await toolbox.filesystem.remove(`${SUBGRAPH_PATH_BASE}/subgraph_copy.yaml`)
46
49
  })
47
50
 
48
51
  test('Updates subgraph.yaml', async () => {
49
- let manifest = './examples/example-subgraph/subgraph_copy.yaml'
50
- let networksFie = './examples/example-subgraph/networks.json'
52
+ let manifest = `${SUBGRAPH_PATH_BASE}/subgraph_copy.yaml`
53
+ let networksFie = `${SUBGRAPH_PATH_BASE}/networks.json`
51
54
  let subgraph = await toolbox.filesystem.read(manifest)
52
55
  let subgraphObj = yaml.parse(subgraph)
53
56
 
@@ -6,6 +6,8 @@ const { updateSubgraphNetwork } = require('../command-helpers/network')
6
6
  const DataSourcesExtractor = require('../command-helpers/data-sources')
7
7
  const Protocol = require('../protocols')
8
8
 
9
+ let buildDebug = require('../debug')('graph-cli:build')
10
+
9
11
  const HELP = `
10
12
  ${chalk.bold('graph build')} [options] ${chalk.bold('[<subgraph-manifest>]')}
11
13
 
@@ -41,7 +43,7 @@ module.exports = {
41
43
  w,
42
44
  watch,
43
45
  network,
44
- networkFile
46
+ networkFile,
45
47
  } = toolbox.parameters.options
46
48
 
47
49
  // Support both short and long option variants
@@ -76,7 +78,7 @@ module.exports = {
76
78
  networkFile =
77
79
  networkFile !== undefined && networkFile !== ''
78
80
  ? networkFile
79
- : filesystem.resolve("networks.json")
81
+ : filesystem.resolve('networks.json')
80
82
 
81
83
  // Show help text if requested
82
84
  if (help) {
@@ -95,7 +97,9 @@ module.exports = {
95
97
  return
96
98
  }
97
99
 
98
- if (network && filesystem.exists(networkFile) !== "file") {
100
+ buildDebug('Detected protocol "%s" (%o)', protocol.name, protocol)
101
+
102
+ if (network && filesystem.exists(networkFile) !== 'file') {
99
103
  print.error(`Network file '${networkFile}' does not exists or is not a file!`)
100
104
  process.exitCode = 1
101
105
  return
@@ -21,6 +21,8 @@ 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')
25
+
24
26
  module.exports = {
25
27
  description: 'Generates AssemblyScript types for a subgraph',
26
28
  run: async toolbox => {
@@ -54,6 +56,7 @@ module.exports = {
54
56
  ;[manifest] = fixParameters(toolbox.parameters, {
55
57
  h,
56
58
  help,
59
+ skipMigrations,
57
60
  w,
58
61
  watch,
59
62
  u,
@@ -65,6 +68,8 @@ module.exports = {
65
68
  return
66
69
  }
67
70
 
71
+ codegenDebug('Initialized codegen manifest: %o', manifest)
72
+
68
73
  // Fall back to default values for options / parameters
69
74
  outputDir =
70
75
  outputDir !== undefined && outputDir !== ''
@@ -26,6 +26,8 @@ const availableNetworks = Protocol.availableNetworks()
26
26
 
27
27
  const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum/gravatar'
28
28
 
29
+ let initDebug = require('../debug')('graph-cli:init')
30
+
29
31
  const HELP = `
30
32
  ${chalk.bold('graph init')} [options] [subgraph-name] [directory]
31
33
 
@@ -170,10 +172,17 @@ const processInitForm = async (
170
172
  type: 'select',
171
173
  name: 'network',
172
174
  message: () => `${protocolInstance.displayName()} network`,
173
- choices: () =>
174
- availableNetworks
175
+ choices: () => {
176
+ initDebug(
177
+ 'Generating list of available networks for protocol "%s" (%M)',
178
+ protocol,
179
+ availableNetworks.get(protocol),
180
+ )
181
+ return availableNetworks
175
182
  .get(protocol) // Get networks related to the chosen protocol.
176
- .toArray(), // Needed because of gluegun. It can't even receive a JS iterable.
183
+ .toArray() // Needed because of gluegun. It can't even receive a JS iterable.
184
+ },
185
+
177
186
  skip: fromExample !== undefined,
178
187
  initial: network || 'mainnet',
179
188
  result: value => {
@@ -11,6 +11,9 @@ const Subgraph = require('../subgraph')
11
11
  const Watcher = require('../watcher')
12
12
  const { applyMigrations } = require('../migrations')
13
13
  const asc = require('./asc')
14
+ const SubstreamsSubgraph = require('../protocols/substreams/subgraph')
15
+
16
+ let compilerDebug = require('../debug')('graph-cli:compiler')
14
17
 
15
18
  class Compiler {
16
19
  constructor(options) {
@@ -20,36 +23,38 @@ class Compiler {
20
23
  this.blockIpfsMethods = options.blockIpfsMethods
21
24
  this.libsDirs = []
22
25
 
23
- for (
24
- let dir = path.resolve(this.sourceDir);
25
- // Terminate after the root dir or when we have found node_modules
26
- dir !== undefined;
27
- // Continue with the parent directory, terminate after the root dir
28
- dir = path.dirname(dir) === dir ? undefined : path.dirname(dir)
29
- ) {
30
- if (fs.existsSync(path.join(dir, 'node_modules'))) {
31
- this.libsDirs.push(path.join(dir, 'node_modules'))
26
+ if (options.protocol.name !== 'substreams') {
27
+ for (
28
+ let dir = path.resolve(this.sourceDir);
29
+ // Terminate after the root dir or when we have found node_modules
30
+ dir !== undefined;
31
+ // Continue with the parent directory, terminate after the root dir
32
+ dir = path.dirname(dir) === dir ? undefined : path.dirname(dir)
33
+ ) {
34
+ if (fs.existsSync(path.join(dir, 'node_modules'))) {
35
+ this.libsDirs.push(path.join(dir, 'node_modules'))
36
+ }
32
37
  }
33
- }
34
38
 
35
- if (this.libsDirs.length === 0) {
36
- throw Error(
37
- `could not locate \`node_modules\` in parent directories of subgraph manifest`,
38
- )
39
- }
39
+ if (this.libsDirs.length === 0) {
40
+ throw Error(
41
+ `could not locate \`node_modules\` in parent directories of subgraph manifest`,
42
+ )
43
+ }
40
44
 
41
- const globalsFile = path.join('@graphprotocol', 'graph-ts', 'global', 'global.ts')
42
- const globalsLib = this.libsDirs.find(item => {
43
- return fs.existsSync(path.join(item, globalsFile))
44
- })
45
+ const globalsFile = path.join('@graphprotocol', 'graph-ts', 'global', 'global.ts')
46
+ const globalsLib = this.libsDirs.find(item => {
47
+ return fs.existsSync(path.join(item, globalsFile))
48
+ })
45
49
 
46
- if (!globalsLib) {
47
- throw Error(
48
- 'Could not locate `@graphprotocol/graph-ts` package in parent directories of subgraph manifest.',
49
- )
50
- }
50
+ if (!globalsLib) {
51
+ throw Error(
52
+ 'Could not locate `@graphprotocol/graph-ts` package in parent directories of subgraph manifest.',
53
+ )
54
+ }
51
55
 
52
- this.globalsFile = path.join(globalsLib, globalsFile)
56
+ this.globalsFile = path.join(globalsLib, globalsFile)
57
+ }
53
58
 
54
59
  this.protocol = this.options.protocol
55
60
  this.ABI = this.protocol.getABI()
@@ -83,7 +88,10 @@ class Compiler {
83
88
  }
84
89
  let subgraph = await this.loadSubgraph()
85
90
  let compiledSubgraph = await this.compileSubgraph(subgraph)
86
- let localSubgraph = await this.writeSubgraphToOutputDirectory(compiledSubgraph)
91
+ let localSubgraph = await this.writeSubgraphToOutputDirectory(
92
+ this.options.protocol,
93
+ compiledSubgraph,
94
+ )
87
95
 
88
96
  if (this.ipfs !== undefined) {
89
97
  let ipfsHash = await this.uploadSubgraphToIPFS(localSubgraph)
@@ -214,6 +222,7 @@ class Compiler {
214
222
  dataSources.map(dataSource =>
215
223
  dataSource.updateIn(['mapping', 'file'], mappingPath =>
216
224
  this._compileDataSourceMapping(
225
+ this.protocol,
217
226
  dataSource,
218
227
  mappingPath,
219
228
  compiledFiles,
@@ -243,7 +252,11 @@ class Compiler {
243
252
  )
244
253
  }
245
254
 
246
- _compileDataSourceMapping(dataSource, mappingPath, compiledFiles, spinner) {
255
+ _compileDataSourceMapping(protocol, dataSource, mappingPath, compiledFiles, spinner) {
256
+ if (protocol.name == 'substreams') {
257
+ return
258
+ }
259
+
247
260
  try {
248
261
  let dataSourceName = dataSource.getIn(['name'])
249
262
 
@@ -378,7 +391,7 @@ class Compiler {
378
391
  _validateMappingContent(filePath) {
379
392
  const data = fs.readFileSync(filePath)
380
393
  if (
381
- this.blockIpfsMethods &&
394
+ this.blockIpfsMethods &&
382
395
  (data.includes('ipfs.cat') || data.includes('ipfs.map'))
383
396
  ) {
384
397
  throw Error(`
@@ -389,7 +402,7 @@ class Compiler {
389
402
  }
390
403
  }
391
404
 
392
- async writeSubgraphToOutputDirectory(subgraph) {
405
+ async writeSubgraphToOutputDirectory(protocol, subgraph) {
393
406
  const displayDir = `${this.displayPath(this.options.outputDir)}${
394
407
  toolbox.filesystem.separator
395
408
  }`
@@ -437,6 +450,30 @@ class Compiler {
437
450
  )
438
451
  }
439
452
 
453
+ if (protocol.name == 'substreams') {
454
+ updatedDataSource = updatedDataSource
455
+ // Write data source ABIs to the output directory
456
+ .updateIn(['source', 'package'], substreamsPackage =>
457
+ substreamsPackage.update('file', packageFile => {
458
+ packageFile = path.resolve(this.sourceDir, packageFile)
459
+ let packageContent = fs.readFileSync(packageFile)
460
+
461
+ return path.relative(
462
+ this.options.outputDir,
463
+ this._writeSubgraphFile(
464
+ packageFile,
465
+ packageContent,
466
+ this.sourceDir,
467
+ this.subgraphDir(this.options.outputDir, dataSource),
468
+ spinner,
469
+ ),
470
+ )
471
+ }),
472
+ )
473
+
474
+ return updatedDataSource
475
+ }
476
+
440
477
  // The mapping file is already being written to the output
441
478
  // directory by the AssemblyScript compiler
442
479
  return updatedDataSource.updateIn(['mapping', 'file'], mappingFile =>
@@ -445,7 +482,7 @@ class Compiler {
445
482
  path.resolve(this.sourceDir, mappingFile),
446
483
  ),
447
484
  )
448
- })
485
+ }),
449
486
  )
450
487
 
451
488
  // Copy template files and update their paths
@@ -453,40 +490,40 @@ class Compiler {
453
490
  templates === undefined
454
491
  ? templates
455
492
  : templates.map(template => {
456
- let updatedTemplate = template
457
-
458
- if (this.protocol.hasABIs()) {
459
- updatedTemplate = updatedTemplate
460
- // Write template ABIs to the output directory
461
- .updateIn(['mapping', 'abis'], abis =>
462
- abis.map(abi =>
463
- abi.update('file', abiFile => {
464
- abiFile = path.resolve(this.sourceDir, abiFile)
465
- let abiData = this.ABI.load(abi.get('name'), abiFile)
466
- return path.relative(
467
- this.options.outputDir,
468
- this._writeSubgraphFile(
469
- abiFile,
470
- JSON.stringify(abiData.data.toJS(), null, 2),
471
- this.sourceDir,
472
- this.subgraphDir(this.options.outputDir, template),
473
- spinner,
474
- ),
475
- )
476
- }),
477
- ),
478
- )
479
- }
480
-
481
- // The mapping file is already being written to the output
482
- // directory by the AssemblyScript compiler
483
- return updatedTemplate.updateIn(['mapping', 'file'], mappingFile =>
484
- path.relative(
485
- this.options.outputDir,
486
- path.resolve(this.sourceDir, mappingFile),
487
- ),
488
- )
489
- })
493
+ let updatedTemplate = template
494
+
495
+ if (this.protocol.hasABIs()) {
496
+ updatedTemplate = updatedTemplate
497
+ // Write template ABIs to the output directory
498
+ .updateIn(['mapping', 'abis'], abis =>
499
+ abis.map(abi =>
500
+ abi.update('file', abiFile => {
501
+ abiFile = path.resolve(this.sourceDir, abiFile)
502
+ let abiData = this.ABI.load(abi.get('name'), abiFile)
503
+ return path.relative(
504
+ this.options.outputDir,
505
+ this._writeSubgraphFile(
506
+ abiFile,
507
+ JSON.stringify(abiData.data.toJS(), null, 2),
508
+ this.sourceDir,
509
+ this.subgraphDir(this.options.outputDir, template),
510
+ spinner,
511
+ ),
512
+ )
513
+ }),
514
+ ),
515
+ )
516
+ }
517
+
518
+ // The mapping file is already being written to the output
519
+ // directory by the AssemblyScript compiler
520
+ return updatedTemplate.updateIn(['mapping', 'file'], mappingFile =>
521
+ path.relative(
522
+ this.options.outputDir,
523
+ path.resolve(this.sourceDir, mappingFile),
524
+ ),
525
+ )
526
+ }),
490
527
  )
491
528
 
492
529
  // Write the subgraph manifest itself
@@ -537,15 +574,28 @@ class Compiler {
537
574
  }
538
575
 
539
576
  // Upload all mappings
540
- for (let [i, dataSource] of subgraph.get('dataSources').entries()) {
541
- updates.push({
542
- keyPath: ['dataSources', i, 'mapping', 'file'],
543
- value: await this._uploadFileToIPFS(
544
- dataSource.getIn(['mapping', 'file']),
545
- uploadedFiles,
546
- spinner,
547
- ),
548
- })
577
+ if (this.protocol.name !== 'substreams') {
578
+ for (let [i, dataSource] of subgraph.get('dataSources').entries()) {
579
+ updates.push({
580
+ keyPath: ['dataSources', i, 'mapping', 'file'],
581
+ value: await this._uploadFileToIPFS(
582
+ dataSource.getIn(['mapping', 'file']),
583
+ uploadedFiles,
584
+ spinner,
585
+ ),
586
+ })
587
+ }
588
+ } else {
589
+ for (let [i, dataSource] of subgraph.get('dataSources').entries()) {
590
+ updates.push({
591
+ keyPath: ['dataSources', i, 'source', 'package', 'file'],
592
+ value: await this._uploadFileToIPFS(
593
+ dataSource.getIn(['source', 'package', 'file']),
594
+ uploadedFiles,
595
+ spinner,
596
+ ),
597
+ })
598
+ }
549
599
  }
550
600
 
551
601
  for (let [i, template] of subgraph.get('templates', immutable.List()).entries()) {
@@ -584,6 +634,11 @@ class Compiler {
584
634
  }
585
635
 
586
636
  async _uploadFileToIPFS(maybeRelativeFile, uploadedFiles, spinner) {
637
+ compilerDebug(
638
+ 'Resolving IPFS file "%s" from output dir "%s"',
639
+ maybeRelativeFile,
640
+ this.options.outputDir,
641
+ )
587
642
  let absoluteFile = path.resolve(this.options.outputDir, maybeRelativeFile)
588
643
  step(spinner, 'Add file to IPFS', this.displayPath(absoluteFile))
589
644
 
package/src/debug.js ADDED
@@ -0,0 +1,15 @@
1
+ const debugFactory = require('debug')
2
+
3
+ debugFactory.formatters.L = immutableList => {
4
+ return JSON.stringify(immutableList)
5
+ }
6
+
7
+ debugFactory.formatters.M = immutableMap => {
8
+ if (immutableMap.toMap != null) {
9
+ return JSON.stringify(immutableMap.toMap())
10
+ }
11
+
12
+ return immutableMap
13
+ }
14
+
15
+ module.exports = debugFactory