@graphprotocol/graph-cli 0.28.0 → 0.30.0-alpha.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.
Files changed (37) hide show
  1. package/README.md +6 -6
  2. package/examples/basic-event-handlers/node_modules/keccak/build/Makefile +1 -1
  3. package/examples/basic-event-handlers/node_modules/keccak/build/Release/.deps/Release/obj.target/keccak/src/addon.o.d.raw +16 -16
  4. package/examples/basic-event-handlers/node_modules/keccak/build/config.gypi +4 -4
  5. package/examples/basic-event-handlers/node_modules/keccak/build/keccak.target.mk +14 -14
  6. package/examples/basic-event-handlers/node_modules/websocket/build/Makefile +1 -1
  7. package/examples/basic-event-handlers/node_modules/websocket/build/Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw +16 -16
  8. package/examples/basic-event-handlers/node_modules/websocket/build/bufferutil.target.mk +14 -14
  9. package/examples/basic-event-handlers/node_modules/websocket/build/config.gypi +1 -1
  10. package/examples/basic-event-handlers/node_modules/websocket/build/validation.target.mk +14 -14
  11. package/examples/basic-event-handlers/package.json +1 -1
  12. package/examples/basic-event-handlers/yarn.lock +4 -4
  13. package/examples/example-subgraph/package.json +1 -1
  14. package/examples/example-subgraph/yarn.lock +4 -4
  15. package/package.json +1 -1
  16. package/src/command-helpers/network.js +113 -0
  17. package/src/command-helpers/network.test.js +78 -0
  18. package/src/commands/build.js +21 -1
  19. package/src/commands/codegen.js +1 -1
  20. package/src/commands/deploy.js +1 -6
  21. package/src/commands/init.js +19 -3
  22. package/src/migrations/mapping_api_version_0_0_5.js +1 -1
  23. package/src/migrations/mapping_api_version_0_0_6.js +74 -0
  24. package/src/migrations/spec_version_0_0_4.js +25 -0
  25. package/src/migrations.js +2 -0
  26. package/src/protocols/ethereum/manifest.graphql +2 -0
  27. package/src/protocols/index.js +12 -2
  28. package/src/scaffold/index.js +1 -1
  29. package/src/subgraph.js +4 -0
  30. package/src/validation/manifest.js +12 -0
  31. package/tests/cli/init/ethereum/from-contract-with-abi-and-structs.stderr +2 -0
  32. package/tests/cli/init/ethereum/from-contract-with-abi.stderr +2 -0
  33. package/tests/cli/init/ethereum/from-contract-with-overloaded-elements.stderr +2 -0
  34. package/tests/cli/init/ethereum/from-contract.stderr +2 -0
  35. package/tests/cli/init/ethereum/from-example.stderr +2 -0
  36. package/tests/cli/init/near/from-contract.stderr +2 -0
  37. package/src/protocols/tendermint/contract.js +0 -12
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # The Graph CLI (graph-cli)
2
2
 
3
3
  [![npm (scoped)](https://img.shields.io/npm/v/@graphprotocol/graph-cli.svg)](https://www.npmjs.com/package/@graphprotocol/graph-cli)
4
- [![Build Status](https://travis-ci.org/graphprotocol/graph-cli.svg?branch=master)](https://travis-ci.org/graphprotocol/graph-cli)
4
+ [![Build Status](https://travis-ci.org/graphprotocol/graph-cli.svg?branch=main)](https://travis-ci.org/graphprotocol/graph-cli)
5
5
 
6
6
  ## The Graph Command Line Interface
7
7
 
@@ -57,9 +57,9 @@ If you are ready to dive into the details of building a subgraph from scratch, t
57
57
 
58
58
  The steps to create a new version of the `graph-cli` are:
59
59
 
60
- 1. Decide which version number you'll be rolling out. You can check the differences between the current `master` branch and the latest release.
60
+ 1. Decide which version number you'll be rolling out. You can check the differences between the current `main` branch and the latest release.
61
61
  2. Create a PR with the commit generated by `npm version <VERSION> [<PREID>]`.
62
- 3. Once that's approved and merged to `master`, you can publish it to `npm` and push the git tags as well.
62
+ 3. Once that's approved and merged to `main`, you can publish it to `npm` and push the git tags as well.
63
63
  4. Last but not least, create a Github Release refering to the pushed git tag, linking to the PRs involved.
64
64
 
65
65
  Helpful links:
@@ -84,7 +84,7 @@ npm version minor
84
84
  git push --set-upstream <REMOTE> <BRANCH>
85
85
  ```
86
86
 
87
- Once that's approved and merged, you can update your local `master` and:
87
+ Once that's approved and merged, you can update your local `main` and:
88
88
 
89
89
  ```
90
90
  npm publish
@@ -106,7 +106,7 @@ npm version preminor --preid alpha
106
106
  git push --set-upstream <REMOTE> <BRANCH>
107
107
  ```
108
108
 
109
- Once that's approved and merged, you can update your local `master` and:
109
+ Once that's approved and merged, you can update your local `main` and:
110
110
 
111
111
  ```
112
112
  npm publish --tag alpha
@@ -128,7 +128,7 @@ npm version prerelease --preid alpha
128
128
  git push --set-upstream <REMOTE> <BRANCH>
129
129
  ```
130
130
 
131
- Once that's approved and merged, you can update your local `master` and:
131
+ Once that's approved and merged, you can update your local `main` and:
132
132
 
133
133
  ```
134
134
  npm publish --tag alpha
@@ -326,7 +326,7 @@ ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
326
326
  endif
327
327
 
328
328
  quiet_cmd_regen_makefile = ACTION Regenerating $@
329
- cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/otaviopace/graph-cli/examples/basic-event-handlers/node_modules/keccak/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/otaviopace/Library/Caches/node-gyp/14.16.0" "-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/Users/otaviopace/Library/Caches/node-gyp/14.16.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/Users/otaviopace/graph-cli/examples/basic-event-handlers/node_modules/keccak" "-Dnode_engine=v8" binding.gyp
329
+ cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/eva/graph-cli/examples/basic-event-handlers/node_modules/keccak/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/eva/Library/Caches/node-gyp/14.16.0/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/eva/Library/Caches/node-gyp/14.16.0" "-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/Users/eva/Library/Caches/node-gyp/14.16.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/Users/eva/graph-cli/examples/basic-event-handlers/node_modules/keccak" "-Dnode_engine=v8" binding.gyp
330
330
  Makefile: $(srcdir)/../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../../Library/Caches/node-gyp/14.16.0/include/node/common.gypi
331
331
  $(call do_cmd,regen_makefile)
332
332
 
@@ -1,21 +1,21 @@
1
1
  Release/obj.target/keccak/src/addon.o: ../src/addon.cc \
2
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/node.h \
3
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8.h \
4
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/cppgc/common.h \
5
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8config.h \
6
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8-internal.h \
7
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8-version.h \
8
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8-platform.h \
9
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/node_version.h \
2
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/node.h \
3
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8.h \
4
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/cppgc/common.h \
5
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8config.h \
6
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8-internal.h \
7
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8-version.h \
8
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8-platform.h \
9
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/node_version.h \
10
10
  ../../nan/nan.h \
11
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv.h \
12
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/errno.h \
13
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/version.h \
14
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/unix.h \
15
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/threadpool.h \
16
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/darwin.h \
17
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/node_buffer.h \
18
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/node_object_wrap.h \
11
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv.h \
12
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/errno.h \
13
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/version.h \
14
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/unix.h \
15
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/threadpool.h \
16
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/darwin.h \
17
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/node_buffer.h \
18
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/node_object_wrap.h \
19
19
  ../../nan/nan_callbacks.h ../../nan/nan_callbacks_12_inl.h \
20
20
  ../../nan/nan_maybe_43_inl.h ../../nan/nan_converters.h \
21
21
  ../../nan/nan_converters_43_inl.h ../../nan/nan_new.h \
@@ -76,7 +76,7 @@
76
76
  "v8_use_siphash": 1,
77
77
  "want_separate_host_toolset": 0,
78
78
  "xcode_version": "11.0",
79
- "nodedir": "/Users/otaviopace/Library/Caches/node-gyp/14.16.0",
79
+ "nodedir": "/Users/eva/Library/Caches/node-gyp/14.16.0",
80
80
  "standalone_static_library": 1,
81
81
  "save_dev": "",
82
82
  "legacy_bundling": "",
@@ -133,8 +133,8 @@
133
133
  "https_proxy": "",
134
134
  "engine_strict": "",
135
135
  "description": "true",
136
- "userconfig": "/Users/otaviopace/.npmrc",
137
- "init_module": "/Users/otaviopace/.npm-init.js",
136
+ "userconfig": "/Users/eva/.npmrc",
137
+ "init_module": "/Users/eva/.npm-init.js",
138
138
  "cidr": "",
139
139
  "user": "",
140
140
  "node_version": "14.16.0",
@@ -178,7 +178,7 @@
178
178
  "otp": "",
179
179
  "cache_min": "10",
180
180
  "searchexclude": "",
181
- "cache": "/Users/otaviopace/.npm",
181
+ "cache": "/Users/eva/.npm",
182
182
  "color": "true",
183
183
  "package_lock": "true",
184
184
  "package_lock_only": "",
@@ -52,13 +52,13 @@ CFLAGS_OBJC_Debug :=
52
52
  CFLAGS_OBJCC_Debug :=
53
53
 
54
54
  INCS_Debug := \
55
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node \
56
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/src \
57
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
58
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
59
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/uv/include \
60
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/zlib \
61
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/v8/include \
55
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/include/node \
56
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/src \
57
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
58
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
59
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/uv/include \
60
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/zlib \
61
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/v8/include \
62
62
  -I$(srcdir)/../nan
63
63
 
64
64
  DEFS_Release := \
@@ -108,13 +108,13 @@ CFLAGS_OBJC_Release :=
108
108
  CFLAGS_OBJCC_Release :=
109
109
 
110
110
  INCS_Release := \
111
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node \
112
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/src \
113
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
114
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
115
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/uv/include \
116
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/zlib \
117
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/v8/include \
111
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/include/node \
112
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/src \
113
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
114
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
115
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/uv/include \
116
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/zlib \
117
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/v8/include \
118
118
  -I$(srcdir)/../nan
119
119
 
120
120
  OBJS := \
@@ -331,7 +331,7 @@ ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
331
331
  endif
332
332
 
333
333
  quiet_cmd_regen_makefile = ACTION Regenerating $@
334
- cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/otaviopace/graph-cli/examples/basic-event-handlers/node_modules/websocket/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/otaviopace/Library/Caches/node-gyp/14.16.0" "-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/Users/otaviopace/Library/Caches/node-gyp/14.16.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/Users/otaviopace/graph-cli/examples/basic-event-handlers/node_modules/websocket" "-Dnode_engine=v8" binding.gyp
334
+ cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/eva/graph-cli/examples/basic-event-handlers/node_modules/websocket/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/eva/Library/Caches/node-gyp/14.16.0/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/eva/Library/Caches/node-gyp/14.16.0" "-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/Users/eva/Library/Caches/node-gyp/14.16.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/Users/eva/graph-cli/examples/basic-event-handlers/node_modules/websocket" "-Dnode_engine=v8" binding.gyp
335
335
  Makefile: $(srcdir)/../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../../Library/Caches/node-gyp/14.16.0/include/node/common.gypi
336
336
  $(call do_cmd,regen_makefile)
337
337
 
@@ -1,21 +1,21 @@
1
1
  Release/obj.target/bufferutil/src/bufferutil.o: ../src/bufferutil.cc \
2
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8.h \
3
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/cppgc/common.h \
4
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8config.h \
5
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8-internal.h \
6
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8-version.h \
7
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/node.h \
8
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/v8-platform.h \
9
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/node_version.h \
10
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/node_buffer.h \
11
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/node_object_wrap.h \
2
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8.h \
3
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/cppgc/common.h \
4
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8config.h \
5
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8-internal.h \
6
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8-version.h \
7
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/node.h \
8
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/v8-platform.h \
9
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/node_version.h \
10
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/node_buffer.h \
11
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/node_object_wrap.h \
12
12
  ../../nan/nan.h \
13
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv.h \
14
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/errno.h \
15
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/version.h \
16
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/unix.h \
17
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/threadpool.h \
18
- /Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node/uv/darwin.h \
13
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv.h \
14
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/errno.h \
15
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/version.h \
16
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/unix.h \
17
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/threadpool.h \
18
+ /Users/eva/Library/Caches/node-gyp/14.16.0/include/node/uv/darwin.h \
19
19
  ../../nan/nan_callbacks.h ../../nan/nan_callbacks_12_inl.h \
20
20
  ../../nan/nan_maybe_43_inl.h ../../nan/nan_converters.h \
21
21
  ../../nan/nan_converters_43_inl.h ../../nan/nan_new.h \
@@ -49,13 +49,13 @@ CFLAGS_OBJC_Debug :=
49
49
  CFLAGS_OBJCC_Debug :=
50
50
 
51
51
  INCS_Debug := \
52
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node \
53
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/src \
54
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
55
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
56
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/uv/include \
57
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/zlib \
58
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/v8/include \
52
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/include/node \
53
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/src \
54
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
55
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
56
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/uv/include \
57
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/zlib \
58
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/v8/include \
59
59
  -I$(srcdir)/../nan
60
60
 
61
61
  DEFS_Release := \
@@ -102,13 +102,13 @@ CFLAGS_OBJC_Release :=
102
102
  CFLAGS_OBJCC_Release :=
103
103
 
104
104
  INCS_Release := \
105
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node \
106
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/src \
107
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
108
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
109
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/uv/include \
110
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/zlib \
111
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/v8/include \
105
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/include/node \
106
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/src \
107
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
108
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
109
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/uv/include \
110
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/zlib \
111
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/v8/include \
112
112
  -I$(srcdir)/../nan
113
113
 
114
114
  OBJS := \
@@ -76,7 +76,7 @@
76
76
  "v8_use_siphash": 1,
77
77
  "want_separate_host_toolset": 0,
78
78
  "xcode_version": "11.0",
79
- "nodedir": "/Users/otaviopace/Library/Caches/node-gyp/14.16.0",
79
+ "nodedir": "/Users/eva/Library/Caches/node-gyp/14.16.0",
80
80
  "standalone_static_library": 1,
81
81
  "version_git_tag": "true",
82
82
  "init_license": "MIT",
@@ -49,13 +49,13 @@ CFLAGS_OBJC_Debug :=
49
49
  CFLAGS_OBJCC_Debug :=
50
50
 
51
51
  INCS_Debug := \
52
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node \
53
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/src \
54
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
55
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
56
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/uv/include \
57
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/zlib \
58
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/v8/include \
52
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/include/node \
53
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/src \
54
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
55
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
56
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/uv/include \
57
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/zlib \
58
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/v8/include \
59
59
  -I$(srcdir)/../nan
60
60
 
61
61
  DEFS_Release := \
@@ -102,13 +102,13 @@ CFLAGS_OBJC_Release :=
102
102
  CFLAGS_OBJCC_Release :=
103
103
 
104
104
  INCS_Release := \
105
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/include/node \
106
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/src \
107
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
108
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
109
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/uv/include \
110
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/zlib \
111
- -I/Users/otaviopace/Library/Caches/node-gyp/14.16.0/deps/v8/include \
105
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/include/node \
106
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/src \
107
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/config \
108
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/openssl/openssl/include \
109
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/uv/include \
110
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/zlib \
111
+ -I/Users/eva/Library/Caches/node-gyp/14.16.0/deps/v8/include \
112
112
  -I$(srcdir)/../nan
113
113
 
114
114
  OBJS := \
@@ -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.26.0",
12
+ "@graphprotocol/graph-ts": "0.27.0-alpha.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.26.0":
6
- version "0.26.0"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.26.0.tgz#576f995531eebaca4374901aeaff499219e382e8"
8
- integrity sha512-GW/emOJl+35MXgmIxTnUK7dJtPCaB9u5aAwoLVqJ8swogC794O92UrXMVrAJsherUriu+yI9bLMGmNPOIi60jw==
5
+ "@graphprotocol/graph-ts@0.27.0-alpha.0":
6
+ version "0.27.0-alpha.0"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.27.0-alpha.0.tgz#1d50fc3fe7e574b09f206d60a5d9889d5e95beba"
8
+ integrity sha512-aS1VQUgj3dSvodDMJSBoyYfHjBA8UsUc/JUIrz+R5DjpxFx7wq5yzzB6GGlwEhuBV93UEh4UdmRDPWT/SKD5sg==
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.26.0"
10
+ "@graphprotocol/graph-ts": "0.27.0-alpha.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.26.0":
6
- version "0.26.0"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.26.0.tgz#576f995531eebaca4374901aeaff499219e382e8"
8
- integrity sha512-GW/emOJl+35MXgmIxTnUK7dJtPCaB9u5aAwoLVqJ8swogC794O92UrXMVrAJsherUriu+yI9bLMGmNPOIi60jw==
5
+ "@graphprotocol/graph-ts@0.27.0-alpha.0":
6
+ version "0.27.0-alpha.0"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.27.0-alpha.0.tgz#1d50fc3fe7e574b09f206d60a5d9889d5e95beba"
8
+ integrity sha512-aS1VQUgj3dSvodDMJSBoyYfHjBA8UsUc/JUIrz+R5DjpxFx7wq5yzzB6GGlwEhuBV93UEh4UdmRDPWT/SKD5sg==
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.28.0",
3
+ "version": "0.30.0-alpha.0",
4
4
  "license": "(Apache-2.0 OR MIT)",
5
5
  "description": "CLI for building for and deploying to The Graph",
6
6
  "dependencies": {
@@ -0,0 +1,113 @@
1
+ const path = require('path')
2
+ const yaml = require('yaml')
3
+ const { step, withSpinner } = require('../command-helpers/spinner')
4
+
5
+ const updateSubgraphNetwork = async (toolbox, manifest, network, networksFile, identifierName) =>
6
+ await withSpinner(
7
+ `Update sources network`,
8
+ `Failed to update sources network`,
9
+ `Warnings while updating sources network`,
10
+ async spinner => {
11
+ let allNetworks
12
+
13
+ step(spinner, `Reading networks config`)
14
+ allNetworks = await toolbox.filesystem.read(networksFile, "json")
15
+ let networkConfig = allNetworks[network]
16
+
17
+ // Exit if the network passed with --network does not exits in networks.json
18
+ if(!networkConfig) {
19
+ throw new Error(`Network '${network}' was not found in '${networksFile}'`)
20
+ }
21
+
22
+ await toolbox.patching.update(manifest, content => {
23
+ let subgraph = yaml.parse(content)
24
+ let networkSources = Object.keys(networkConfig)
25
+ let subgraphSources = subgraph.dataSources.map(value => value.name);
26
+
27
+ // Update the dataSources network config
28
+ subgraph.dataSources = subgraph.dataSources.map(source => {
29
+ if (!networkSources.includes(source.name)) {
30
+ throw new Error(`'${source.name}' was not found in the '${network}' configuration, please update!`)
31
+ }
32
+
33
+ if (hasChanges(identifierName, network, networkConfig[source.name], source)) {
34
+ step(spinner, `Update '${source.name}' network configuration`)
35
+ source.network = network
36
+ source.source = source.source.abi ? { abi: source.source.abi } : {}
37
+ Object.assign(source.source, networkConfig[source.name])
38
+ } else {
39
+ step(spinner, `Skip '${source.name}': No changes to network configuration`)
40
+ }
41
+
42
+ return source
43
+ }
44
+ )
45
+
46
+ // All data sources shoud be on the same network,
47
+ // so we have to update the network of all templates too.
48
+ if(subgraph.templates) {
49
+ subgraph.templates = subgraph.templates.map(template => ({
50
+ ...template,
51
+ network,
52
+ }))
53
+ }
54
+
55
+ let unsusedSources = networkSources.filter(x => !subgraphSources.includes(x))
56
+
57
+ unsusedSources.forEach(source => {
58
+ step(spinner, `dataSource '${source}' from '${networksFile}' not found in ${manifest}`)
59
+ })
60
+
61
+ let yaml_doc = new yaml.Document()
62
+ yaml_doc.contents = subgraph
63
+ return yaml_doc.toString()
64
+ })
65
+ })
66
+
67
+ const initNetworksConfig = async(toolbox, directory, identifierName) =>
68
+ await withSpinner(
69
+ `Initialize networks config`,
70
+ `Failed to initialize networks config`,
71
+ `Warnings while initializing networks config`,
72
+ async spinner => {
73
+ let subgraphStr = await toolbox.filesystem.read(path.join(directory, 'subgraph.yaml'))
74
+ let subgraph = yaml.parse(subgraphStr)
75
+
76
+ const networks = subgraph.dataSources.reduce((acc, source) =>
77
+ Object.assign(
78
+ acc,
79
+ {
80
+ [source.network]: {
81
+ [source.name]: {
82
+ [identifierName]: source.source.address,
83
+ startBlock: source.source.startBlock,
84
+ },
85
+ },
86
+ }
87
+ )
88
+ , {})
89
+
90
+ await toolbox.filesystem.write(`${directory}/networks.json`, networks)
91
+
92
+ return true
93
+ },
94
+ )
95
+
96
+ // Checks if any network attribute has been changed
97
+ function hasChanges(identifierName, network, networkConfig, dataSource) {
98
+ let networkChanged = dataSource.network !== network
99
+
100
+ // Return directly if the network is different
101
+ if (networkChanged) return networkChanged
102
+
103
+ let addressChanged = networkConfig[identifierName] !== dataSource.source[identifierName]
104
+
105
+ let startBlockChanged = networkConfig.startBlock !== dataSource.source.startBlock
106
+
107
+ return networkChanged || addressChanged || startBlockChanged
108
+ }
109
+
110
+ module.exports = {
111
+ updateSubgraphNetwork,
112
+ initNetworksConfig
113
+ }
@@ -0,0 +1,78 @@
1
+ const { initNetworksConfig, updateSubgraphNetwork } = require('../command-helpers/network')
2
+ const toolbox = require('gluegun/toolbox')
3
+ const yaml = require('yaml')
4
+
5
+ describe('initNetworksConfig', () => {
6
+ beforeAll(async () => {
7
+ await initNetworksConfig(toolbox, './examples/example-subgraph', 'address')
8
+ })
9
+ afterAll(async () => {
10
+ await toolbox.filesystem.remove('./examples/example-subgraph/networks.json')
11
+ })
12
+
13
+ test('generates networks.json from subgraph.yaml', () => {
14
+ expect(toolbox.filesystem.exists('./examples/example-subgraph/networks.json')).toBe('file')
15
+ })
16
+
17
+ 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')
19
+ let networks = JSON.parse(networksStr)
20
+
21
+ let expected = {
22
+ mainnet: {
23
+ ExampleSubgraph: { address: '0x22843e74c59580b3eaf6c233fa67d8b7c561a835' }
24
+ }
25
+ }
26
+
27
+ expect(networks).toStrictEqual(expected)
28
+ })
29
+ })
30
+
31
+ describe('updateSubgraphNetwork', () => {
32
+ beforeAll(async () => {
33
+ let content = {
34
+ optimism: {
35
+ ExampleSubgraph: { address: '0x12345...' }
36
+ }
37
+ }
38
+
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')
41
+ })
42
+
43
+ afterAll(async () => {
44
+ await toolbox.filesystem.remove('./examples/example-subgraph/networks.json')
45
+ await toolbox.filesystem.remove('./examples/example-subgraph/subgraph_copy.yaml')
46
+ })
47
+
48
+ test('Updates subgraph.yaml', async () => {
49
+ let manifest = './examples/example-subgraph/subgraph_copy.yaml'
50
+ let networksFie = './examples/example-subgraph/networks.json'
51
+ let subgraph = await toolbox.filesystem.read(manifest)
52
+ let subgraphObj = yaml.parse(subgraph)
53
+
54
+ let network = subgraphObj.dataSources[0].network
55
+ let address = subgraphObj.dataSources[0].source.address
56
+
57
+ expect(network).toBe('mainnet')
58
+ expect(address).toBe('0x22843e74c59580b3eaf6c233fa67d8b7c561a835')
59
+
60
+ await updateSubgraphNetwork(
61
+ toolbox,
62
+ manifest,
63
+ 'optimism',
64
+ networksFie,
65
+ 'address'
66
+ )
67
+
68
+ subgraph = await toolbox.filesystem.read(manifest)
69
+ subgraphObj = yaml.parse(subgraph)
70
+
71
+ network = subgraphObj.dataSources[0].network
72
+ address = subgraphObj.dataSources[0].source.address
73
+
74
+ expect(network).toBe('optimism')
75
+ expect(address).toBe('0x12345...')
76
+ })
77
+
78
+ })
@@ -2,6 +2,7 @@ const chalk = require('chalk')
2
2
 
3
3
  const { createCompiler } = require('../command-helpers/compiler')
4
4
  const { fixParameters } = require('../command-helpers/gluegun')
5
+ const { updateSubgraphNetwork } = require('../command-helpers/network')
5
6
  const DataSourcesExtractor = require('../command-helpers/data-sources')
6
7
  const Protocol = require('../protocols')
7
8
 
@@ -16,13 +17,15 @@ Options:
16
17
  -t, --output-format <format> Output format for mappings (wasm, wast) (default: wasm)
17
18
  --skip-migrations Skip subgraph migrations (default: false)
18
19
  -w, --watch Regenerate types when subgraph files change (default: false)
20
+ --network <name> Network to use from networks.json
21
+ --network-file <path> Networks file (default: "./networks.json")
19
22
  `
20
23
 
21
24
  module.exports = {
22
25
  description: 'Builds a subgraph and (optionally) uploads it to IPFS',
23
26
  run: async toolbox => {
24
27
  // Obtain tools
25
- let { filesystem, print, system } = toolbox
28
+ let { filesystem, patching, print, system } = toolbox
26
29
 
27
30
  // Parse CLI parameters
28
31
  let {
@@ -37,6 +40,8 @@ module.exports = {
37
40
  t,
38
41
  w,
39
42
  watch,
43
+ network,
44
+ networkFile
40
45
  } = toolbox.parameters.options
41
46
 
42
47
  // Support both short and long option variants
@@ -68,6 +73,10 @@ module.exports = {
68
73
  manifest !== undefined && manifest !== ''
69
74
  ? manifest
70
75
  : filesystem.resolve('subgraph.yaml')
76
+ networkFile =
77
+ networkFile !== undefined && networkFile !== ''
78
+ ? networkFile
79
+ : filesystem.resolve("networks.json")
71
80
 
72
81
  // Show help text if requested
73
82
  if (help) {
@@ -86,6 +95,17 @@ module.exports = {
86
95
  return
87
96
  }
88
97
 
98
+ if (network && filesystem.exists(networkFile) !== "file") {
99
+ print.error(`Network file '${networkFile}' does not exists or is not a file!`)
100
+ process.exitCode = 1
101
+ return
102
+ }
103
+
104
+ if (network) {
105
+ let identifierName = protocol.getContract().identifierName()
106
+ await updateSubgraphNetwork(toolbox, manifest, network, networkFile, identifierName)
107
+ }
108
+
89
109
  let compiler = createCompiler(manifest, {
90
110
  ipfs,
91
111
  outputDir,
@@ -71,7 +71,7 @@ module.exports = {
71
71
  // because that would mean the CLI would generate code to
72
72
  // the wrong AssemblyScript version.
73
73
  await assertManifestApiVersion(manifest, '0.0.5')
74
- await assertGraphTsVersion(path.dirname(manifest), '0.22.0')
74
+ await assertGraphTsVersion(path.dirname(manifest), '0.25.0')
75
75
 
76
76
  const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest)
77
77
 
@@ -200,7 +200,7 @@ module.exports = {
200
200
  // because that would mean the CLI would try to compile code
201
201
  // using the wrong AssemblyScript compiler.
202
202
  await assertManifestApiVersion(manifest, '0.0.5')
203
- await assertGraphTsVersion(path.dirname(manifest), '0.22.0')
203
+ await assertGraphTsVersion(path.dirname(manifest), '0.25.0')
204
204
 
205
205
  const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest)
206
206
 
@@ -294,7 +294,6 @@ $ graph create --node ${node} ${subgraphName}`)
294
294
  const base = requestUrl.protocol + '//' + requestUrl.hostname
295
295
  let playground = res.playground
296
296
  let queries = res.queries
297
- let subscriptions = res.subscriptions
298
297
 
299
298
  // Add a base URL if graph-node did not return the full URL
300
299
  if (playground.charAt(0) === ':') {
@@ -303,9 +302,6 @@ $ graph create --node ${node} ${subgraphName}`)
303
302
  if (queries.charAt(0) === ':') {
304
303
  queries = base + queries
305
304
  }
306
- if (subscriptions.charAt(0) === ':') {
307
- subscriptions = base + subscriptions
308
- }
309
305
 
310
306
  if (isHostedService) {
311
307
  print.success(
@@ -318,7 +314,6 @@ $ graph create --node ${node} ${subgraphName}`)
318
314
  }
319
315
  print.info('\nSubgraph endpoints:')
320
316
  print.info(`Queries (HTTP): ${queries}`)
321
- print.info(`Subscriptions (WS): ${subscriptions}`)
322
317
  print.info(``)
323
318
  }
324
319
  },
@@ -4,6 +4,7 @@ const immutable = require('immutable')
4
4
  const os = require('os')
5
5
  const path = require('path')
6
6
  const toolbox = require('gluegun/toolbox')
7
+ const yaml = require('yaml')
7
8
 
8
9
  const {
9
10
  getSubgraphBasename,
@@ -11,6 +12,7 @@ const {
11
12
  } = require('../command-helpers/subgraph')
12
13
  const DataSourcesExtractor = require('../command-helpers/data-sources')
13
14
  const { validateStudioNetwork } = require('../command-helpers/studio')
15
+ const { initNetworksConfig } = require('../command-helpers/network')
14
16
  const { withSpinner, step } = require('../command-helpers/spinner')
15
17
  const { fixParameters } = require('../command-helpers/gluegun')
16
18
  const { chooseNodeUrl } = require('../command-helpers/node')
@@ -132,7 +134,7 @@ const processInitForm = async (
132
134
  return `${e.message}
133
135
 
134
136
  Examples:
135
-
137
+
136
138
  $ graph init ${os.userInfo().username}/${name}
137
139
  $ graph init ${name} --allow-simple-name`
138
140
  }
@@ -285,9 +287,10 @@ const getEtherscanLikeAPIUrl = (network) => {
285
287
  case "mumbai": return `https://api-testnet.polygonscan.com/api`;
286
288
  case "aurora": return `https://api.aurorascan.dev/api`;
287
289
  case "aurora-testnet": return `https://api-testnet.aurorascan.dev/api`;
290
+ case "optimism-kovan": return `https://api-kovan-optimistic.etherscan.io/api`;
288
291
  default: return `https://api-${network}.etherscan.io/api`;
289
292
  }
290
- }
293
+ }
291
294
 
292
295
  const loadAbiFromEtherscan = async (ABI, network, address) =>
293
296
  await withSpinner(
@@ -355,7 +358,7 @@ module.exports = {
355
358
 
356
359
  node = node || g
357
360
  ;({ node, allowSimpleName } = chooseNodeUrl({ product, studio, node, allowSimpleName }))
358
-
361
+
359
362
  if (fromContract && fromExample) {
360
363
  print.error(`Only one of --from-example and --from-contract can be used at a time.`)
361
364
  process.exitCode = 1
@@ -685,6 +688,12 @@ const initSubgraphFromExample = async (
685
688
  return
686
689
  }
687
690
 
691
+ let networkConf = await initNetworksConfig(toolbox, directory, "address")
692
+ if (networkConf !== true) {
693
+ process.exitCode = 1
694
+ return
695
+ }
696
+
688
697
  // Update package.json to match the subgraph name
689
698
  let prepared = await withSpinner(
690
699
  `Update subgraph name and commands in package.json`,
@@ -826,6 +835,13 @@ const initSubgraphFromContract = async (
826
835
  return
827
836
  }
828
837
 
838
+ let identifierName = protocolInstance.getContract().identifierName()
839
+ let networkConf = await initNetworksConfig(toolbox, directory, identifierName)
840
+ if (networkConf !== true) {
841
+ process.exitCode = 1
842
+ return
843
+ }
844
+
829
845
  // Initialize a fresh Git repository
830
846
  let repo = await initRepository(toolbox, directory)
831
847
  if (repo !== true) {
@@ -21,7 +21,7 @@ module.exports = {
21
21
 
22
22
  let manifest = loadManifest(manifestFile)
23
23
  return (
24
- // Only migrate if the graph-ts version is >= 0.23.0...
24
+ // Only migrate if the graph-ts version is >= 0.24.0...
25
25
  // Coerce needed because we may be dealing with an alpha version
26
26
  // and in the `semver` library this would not return true on equality.
27
27
  semver.gte(semver.coerce(graphTsVersion), '0.24.0') &&
@@ -0,0 +1,74 @@
1
+ const fs = require('fs-extra')
2
+ const semver = require('semver')
3
+ const toolbox = require('gluegun/toolbox')
4
+ const yaml = require('js-yaml')
5
+ const { loadManifest } = require('./util/load-manifest')
6
+ const { getGraphTsVersion } = require('./util/versions')
7
+
8
+ // If any of the manifest apiVersions are 0.0.6, replace them with 0.0.7
9
+ module.exports = {
10
+ name: 'Bump mapping apiVersion from 0.0.6 to 0.0.7',
11
+ predicate: async ({ sourceDir, manifestFile }) => {
12
+ // Obtain the graph-ts version, if possible
13
+ let graphTsVersion
14
+ try {
15
+ graphTsVersion = await getGraphTsVersion(sourceDir)
16
+ } catch (_) {
17
+ // If we cannot obtain the version, return a hint that the graph-ts
18
+ // hasn't been installed yet
19
+ return 'graph-ts dependency not installed yet'
20
+ }
21
+
22
+ let manifest = loadManifest(manifestFile)
23
+ return (
24
+ // Only migrate if the graph-ts version is >= 0.27.0...
25
+ // Coerce needed because we may be dealing with an alpha version
26
+ // and in the `semver` library this would not return true on equality.
27
+ semver.gte(semver.coerce(graphTsVersion), '0.27.0') &&
28
+ // ...and we have a manifest with mapping > apiVersion = 0.0.6
29
+ manifest &&
30
+ typeof manifest === 'object' &&
31
+ Array.isArray(manifest.dataSources) &&
32
+ (manifest.dataSources.reduce(
33
+ (hasOldMappings, dataSource) =>
34
+ hasOldMappings ||
35
+ (typeof dataSource === 'object' &&
36
+ dataSource.mapping &&
37
+ typeof dataSource.mapping === 'object' &&
38
+ dataSource.mapping.apiVersion === '0.0.6'),
39
+ false,
40
+ ) ||
41
+ (Array.isArray(manifest.templates) &&
42
+ manifest.templates.reduce(
43
+ (hasOldMappings, template) =>
44
+ hasOldMappings ||
45
+ (typeof template === 'object' &&
46
+ template.mapping &&
47
+ typeof template.mapping === 'object' &&
48
+ template.mapping.apiVersion === '0.0.6'),
49
+ false,
50
+ )))
51
+ )
52
+ },
53
+ apply: async ({ manifestFile }) => {
54
+ // Make sure we catch all variants; we could load the manifest
55
+ // and replace the values in the data structures here; unfortunately
56
+ // writing that back to the file messes with the formatting more than
57
+ // we'd like; that's why for now, we use a simple patching approach
58
+ await toolbox.patching.replace(
59
+ manifestFile,
60
+ new RegExp('apiVersion: 0.0.6', 'g'),
61
+ 'apiVersion: 0.0.7',
62
+ )
63
+ await toolbox.patching.replace(
64
+ manifestFile,
65
+ new RegExp("apiVersion: '0.0.6'", 'g'),
66
+ "apiVersion: '0.0.7'",
67
+ )
68
+ await toolbox.patching.replace(
69
+ manifestFile,
70
+ new RegExp('apiVersion: "0.0.6"', 'g'),
71
+ 'apiVersion: "0.0.7"',
72
+ )
73
+ },
74
+ }
@@ -0,0 +1,25 @@
1
+ const fs = require('fs-extra')
2
+ const toolbox = require('gluegun/toolbox')
3
+ const yaml = require('js-yaml')
4
+ const { loadManifest } = require('./util/load-manifest')
5
+
6
+ // Spec version 0.0.5 let event handlers require transaction receipt
7
+ // data to be accessed in the runtime.
8
+ module.exports = {
9
+ name: 'Bump manifest specVersion from 0.0.4 to 0.0.5',
10
+ predicate: async ({ sourceDir, manifestFile }) => {
11
+ let manifest = await loadManifest(manifestFile)
12
+ return (
13
+ manifest &&
14
+ typeof manifest === 'object' &&
15
+ manifest.specVersion &&
16
+ manifest.specVersion === '0.0.4'
17
+ )
18
+ },
19
+ apply: async ({ manifestFile }) => {
20
+ await toolbox.patching.patch(manifestFile, {
21
+ insert: 'specVersion: 0.0.5',
22
+ replace: new RegExp(`specVersion: ['"]?0.0.4['"]?`),
23
+ })
24
+ },
25
+ }
package/src/migrations.js CHANGED
@@ -5,7 +5,9 @@ const MIGRATIONS = [
5
5
  require('./migrations/mapping_api_version_0_0_2'),
6
6
  require('./migrations/mapping_api_version_0_0_3'),
7
7
  require('./migrations/mapping_api_version_0_0_4'),
8
+ require('./migrations/mapping_api_version_0_0_5'),
8
9
  require('./migrations/spec_version_0_0_2'),
10
+ require('./migrations/spec_version_0_0_4'),
9
11
  ]
10
12
 
11
13
  const applyMigrations = async options =>
@@ -7,6 +7,7 @@
7
7
  scalar String
8
8
  scalar File
9
9
  scalar BigInt
10
+ scalar Boolean
10
11
 
11
12
  type SubgraphManifest {
12
13
  specVersion: String!
@@ -72,6 +73,7 @@ type ContractEventHandler {
72
73
  event: String!
73
74
  topic0: String
74
75
  handler: String!
76
+ receipt: Boolean
75
77
  }
76
78
 
77
79
  type Graft {
@@ -7,7 +7,6 @@ const NearSubgraph = require('./near/subgraph')
7
7
  const TendermintSubgraph = require('./tendermint/subgraph')
8
8
  const EthereumContract = require('./ethereum/contract')
9
9
  const NearContract = require('./near/contract')
10
- const TendermintContract = require('./tendermint/contract')
11
10
  const EthereumManifestScaffold = require('./ethereum/scaffold/manifest')
12
11
  const NearManifestScaffold = require('./near/scaffold/manifest')
13
12
  const EthereumMappingScaffold = require('./ethereum/scaffold/mapping')
@@ -104,6 +103,17 @@ module.exports = class Protocol {
104
103
  }
105
104
  }
106
105
 
106
+ hasContract() {
107
+ switch (this.name) {
108
+ case 'ethereum':
109
+ return true
110
+ case 'near':
111
+ return true
112
+ case 'tendermint':
113
+ return false
114
+ }
115
+ }
116
+
107
117
  hasEvents() {
108
118
  switch (this.name) {
109
119
  case 'ethereum':
@@ -185,7 +195,7 @@ module.exports = class Protocol {
185
195
  case 'near':
186
196
  return NearContract
187
197
  case 'tendermint':
188
- return TendermintContract
198
+ return null
189
199
  }
190
200
  }
191
201
 
@@ -50,7 +50,7 @@ module.exports = class Scaffold {
50
50
  },
51
51
  dependencies: {
52
52
  '@graphprotocol/graph-cli': GRAPH_CLI_VERSION,
53
- '@graphprotocol/graph-ts': `0.26.0`,
53
+ '@graphprotocol/graph-ts': `0.27.0-alpha.0`,
54
54
  },
55
55
  }),
56
56
  { parser: 'json' },
package/src/subgraph.js CHANGED
@@ -158,6 +158,10 @@ At least one such handler must be defined.`,
158
158
  }
159
159
 
160
160
  static validateContractValues(manifest, protocol) {
161
+ if (!protocol.hasContract()){
162
+ return immutable.List()
163
+ }
164
+
161
165
  return validation.validateContractValues(manifest, protocol)
162
166
  }
163
167
 
@@ -204,6 +204,18 @@ const validators = immutable.fromJS({
204
204
  message: `Expected filename, found ${typeName(value)}:\n${value}`,
205
205
  },
206
206
  ]),
207
+
208
+ Boolean: (value, ctx) =>
209
+ typeof value === 'boolean'
210
+ ? List()
211
+ : immutable.fromJS([
212
+ {
213
+ path: ctx.get('path'),
214
+ message: `Expected true or false, found ${typeName(value)}:\n${toYAML(
215
+ value,
216
+ )}`,
217
+ },
218
+ ]),
207
219
  })
208
220
 
209
221
  const validateValue = (value, ctx) => {
@@ -4,6 +4,8 @@
4
4
  Write subgraph to directory
5
5
  - Create subgraph scaffold
6
6
  ✔ Create subgraph scaffold
7
+ - Initialize networks config
8
+ ✔ Initialize networks config
7
9
  - Initialize subgraph repository
8
10
  ✔ Initialize subgraph repository
9
11
  - Install dependencies with yarn
@@ -4,6 +4,8 @@
4
4
  Write subgraph to directory
5
5
  - Create subgraph scaffold
6
6
  ✔ Create subgraph scaffold
7
+ - Initialize networks config
8
+ ✔ Initialize networks config
7
9
  - Initialize subgraph repository
8
10
  ✔ Initialize subgraph repository
9
11
  - Install dependencies with yarn
@@ -4,6 +4,8 @@
4
4
  Write subgraph to directory
5
5
  - Create subgraph scaffold
6
6
  ✔ Create subgraph scaffold
7
+ - Initialize networks config
8
+ ✔ Initialize networks config
7
9
  - Initialize subgraph repository
8
10
  ✔ Initialize subgraph repository
9
11
  - Install dependencies with yarn
@@ -6,6 +6,8 @@
6
6
  Write subgraph to directory
7
7
  - Create subgraph scaffold
8
8
  ✔ Create subgraph scaffold
9
+ - Initialize networks config
10
+ ✔ Initialize networks config
9
11
  - Initialize subgraph repository
10
12
  ✔ Initialize subgraph repository
11
13
  - Install dependencies with yarn
@@ -1,5 +1,7 @@
1
1
  - Cloning example subgraph
2
2
  ✔ Cloning example subgraph
3
+ - Initialize networks config
4
+ ✔ Initialize networks config
3
5
  - Update subgraph name and commands in package.json
4
6
  ✔ Update subgraph name and commands in package.json
5
7
  - Initialize subgraph repository
@@ -4,6 +4,8 @@
4
4
  Write subgraph to directory
5
5
  - Create subgraph scaffold
6
6
  ✔ Create subgraph scaffold
7
+ - Initialize networks config
8
+ ✔ Initialize networks config
7
9
  - Initialize subgraph repository
8
10
  ✔ Initialize subgraph repository
9
11
  - Install dependencies with yarn
@@ -1,12 +0,0 @@
1
- module.exports = class TendermintContract {
2
- static identifierName() {
3
- return 'address'
4
- }
5
-
6
- validate() {
7
- return {
8
- valid: true,
9
- error: null,
10
- }
11
- }
12
- }