@graphprotocol/graph-cli 0.28.1 → 0.29.1

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 (25) hide show
  1. package/examples/basic-event-handlers/node_modules/keccak/build/Makefile +1 -1
  2. package/examples/basic-event-handlers/node_modules/keccak/build/Release/.deps/Release/obj.target/keccak/src/addon.o.d.raw +16 -16
  3. package/examples/basic-event-handlers/node_modules/keccak/build/config.gypi +4 -4
  4. package/examples/basic-event-handlers/node_modules/keccak/build/keccak.target.mk +14 -14
  5. package/examples/basic-event-handlers/node_modules/websocket/build/Makefile +1 -1
  6. package/examples/basic-event-handlers/node_modules/websocket/build/Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw +16 -16
  7. package/examples/basic-event-handlers/node_modules/websocket/build/bufferutil.target.mk +14 -14
  8. package/examples/basic-event-handlers/node_modules/websocket/build/config.gypi +1 -1
  9. package/examples/basic-event-handlers/node_modules/websocket/build/validation.target.mk +14 -14
  10. package/package.json +1 -1
  11. package/src/codegen/schema.js +3 -44
  12. package/src/codegen/schema.test.js +0 -6
  13. package/src/codegen/types/conversions.js +19 -19
  14. package/src/codegen/types/index.js +0 -25
  15. package/src/codegen/types/index.test.js +0 -22
  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/init.js +18 -3
  20. package/tests/cli/init/ethereum/from-contract-with-abi-and-structs.stderr +2 -0
  21. package/tests/cli/init/ethereum/from-contract-with-abi.stderr +2 -0
  22. package/tests/cli/init/ethereum/from-contract-with-overloaded-elements.stderr +2 -0
  23. package/tests/cli/init/ethereum/from-contract.stderr +2 -0
  24. package/tests/cli/init/ethereum/from-example.stderr +2 -0
  25. package/tests/cli/init/near/from-contract.stderr +2 -0
@@ -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 := \
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.28.1",
3
+ "version": "0.29.1",
4
4
  "license": "(Apache-2.0 OR MIT)",
5
5
  "description": "CLI for building for and deploying to The Graph",
6
6
  "dependencies": {
@@ -120,41 +120,6 @@ module.exports = class SchemaCodeGenerator {
120
120
  return klass
121
121
  }
122
122
 
123
- // Fields that are non-nullable get an empty/zero value set in the class constructor.
124
- _generateDefaultFieldValues(fields) {
125
- const indexOfIdField = fields.findIndex(field => field.getIn(['name', 'value']) === 'id')
126
- const fieldsWithoutId = fields.remove(indexOfIdField)
127
-
128
- const fieldsSetCalls = fieldsWithoutId
129
- .map(field => {
130
- const name = field.getIn(['name', 'value'])
131
- const type = this._typeFromGraphQl(field.get('type'), true, true)
132
-
133
- const isNullable = type instanceof tsCodegen.NullableType
134
-
135
- const directives = field.get('directives')
136
- const isDerivedFrom = directives.some(directive => directive.getIn(['name', 'value']) === 'derivedFrom')
137
-
138
- return { name, type, isNullable, isDerivedFrom }
139
- })
140
- // We only call the setter with the default value in the constructor for fields that are:
141
- // - Not nullable, so that AS doesn't break when subgraph developers try to access them before a `set`
142
- // - It doesn't matter if it's primitive or not
143
- // - Not tagged as `derivedFrom`, because they only exist in query time
144
- .filter(({
145
- isNullable,
146
- isDerivedFrom,
147
- }) => !isNullable && !isDerivedFrom)
148
- .map(({ name, type, isNullable }) => {
149
- const fieldTypeString = isNullable ? type.inner.toString() : type.toString()
150
-
151
- return `
152
- this.set('${name}', ${typesCodegen.initializedValueFromAsc(fieldTypeString)})`
153
- })
154
-
155
- return fieldsSetCalls.join('')
156
- }
157
-
158
123
  _generateConstructor(entityName, fields) {
159
124
  const idField = IdField.fromFields(fields)
160
125
  return tsCodegen.method(
@@ -164,7 +129,6 @@ module.exports = class SchemaCodeGenerator {
164
129
  `
165
130
  super()
166
131
  this.set('id', ${idField.tsValueFrom()})
167
- ${this._generateDefaultFieldValues(fields)}
168
132
  `,
169
133
  )
170
134
  }
@@ -313,7 +277,7 @@ Suggestion: add an '!' to the member type of the List, change from '[${baseType}
313
277
  }
314
278
  }
315
279
 
316
- _typeFromGraphQl(gqlType, nullable = true, nullablePrimitive = false) {
280
+ _typeFromGraphQl(gqlType, nullable = true) {
317
281
  if (gqlType.get('kind') === 'NonNullType') {
318
282
  return this._typeFromGraphQl(gqlType.get('type'), false)
319
283
  } else if (gqlType.get('kind') === 'ListType') {
@@ -324,13 +288,8 @@ Suggestion: add an '!' to the member type of the List, change from '[${baseType}
324
288
  let type = tsCodegen.namedType(
325
289
  typesCodegen.ascTypeForValue(this._resolveFieldType(gqlType)),
326
290
  )
327
-
328
- // Will not wrap primitives into NullableType by default.
329
- if (!nullablePrimitive && type.isPrimitive()) {
330
- return type
331
- }
332
-
333
- return nullable ? tsCodegen.nullableType(type) : type
291
+ // In AssemblyScript, primitives cannot be nullable.
292
+ return nullable && !type.isPrimitive() ? tsCodegen.nullableType(type) : type
334
293
  }
335
294
  }
336
295
  }
@@ -114,9 +114,6 @@ describe('Schema code generator', () => {
114
114
  body: `
115
115
  super()
116
116
  this.set('id', Value.fromString(id))
117
-
118
- this.set('name', Value.fromString(''))
119
- this.set('count', Value.fromI32(0))
120
117
  `,
121
118
  },
122
119
  {
@@ -277,9 +274,6 @@ describe('Schema code generator', () => {
277
274
  body: `
278
275
  super()
279
276
  this.set('id', Value.fromString(id))
280
-
281
- this.set('amount', Value.fromBigInt(BigInt.zero()))
282
- this.set('account', Value.fromString(''))
283
277
  `,
284
278
  },
285
279
  {
@@ -188,28 +188,28 @@ const VALUE_TO_ASSEMBLYSCRIPT = [
188
188
  const ASSEMBLYSCRIPT_TO_VALUE = [
189
189
  // Arrays
190
190
 
191
- ['Array<Address>', '[Bytes]', code => `Value.fromBytesArray(${code})`, 'new Array(0)'],
192
- ['Array<Bytes>', '[Bytes]', code => `Value.fromBytesArray(${code})`, 'new Array(0)'],
193
- ['Array<boolean>', '[Boolean]', code => `Value.fromBooleanArray(${code})`, 'new Array(0)'],
194
- ['Array<i32>', '[Int]', code => `Value.fromI32Array(${code})`, 'new Array(0)'],
195
- ['Array<BigInt>', '[BigInt]', code => `Value.fromBigIntArray(${code})`, 'new Array(0)'],
196
- ['Array<string>', '[String]', code => `Value.fromStringArray(${code})`, 'new Array(0)'],
197
- ['Array<string>', '[ID]', code => `Value.fromStringArray(${code})`, 'new Array(0)'],
198
- ['Array<BigDecimal>', '[BigDecimal]', code => `Value.fromBigDecimalArray(${code})`, 'new Array(0)'],
199
- ['Array<string>', /\[.*\]/, code => `Value.fromStringArray(${code})`, 'new Array(0)'],
200
- ['Array<string | null>', null, code => `Value.fromStringArray(${code})`, 'new Array(0)'],
191
+ ['Array<Address>', '[Bytes]', code => `Value.fromBytesArray(${code})`],
192
+ ['Array<Bytes>', '[Bytes]', code => `Value.fromBytesArray(${code})`],
193
+ ['Array<boolean>', '[Boolean]', code => `Value.fromBooleanArray(${code})`],
194
+ ['Array<i32>', '[Int]', code => `Value.fromI32Array(${code})`],
195
+ ['Array<BigInt>', '[BigInt]', code => `Value.fromBigIntArray(${code})`],
196
+ ['Array<string>', '[String]', code => `Value.fromStringArray(${code})`],
197
+ ['Array<string>', '[ID]', code => `Value.fromStringArray(${code})`],
198
+ ['Array<BigDecimal>', '[BigDecimal]', code => `Value.fromBigDecimalArray(${code})`],
199
+ ['Array<string>', /\[.*\]/, code => `Value.fromStringArray(${code})`],
200
+ ['Array<string | null>', null, code => `Value.fromStringArray(${code})`],
201
201
 
202
202
  // Scalar values
203
203
 
204
- ['Address', 'Bytes', code => `Value.fromBytes(${code})`, 'Address.zero()'],
205
- ['Bytes', 'Bytes', code => `Value.fromBytes(${code})`, 'Bytes.empty()'],
206
- ['boolean', 'Boolean', code => `Value.fromBoolean(${code})`, 'false'],
207
- ['i32', 'Int', code => `Value.fromI32(${code})`, '0'],
208
- ['BigInt', 'BigInt', code => `Value.fromBigInt(${code})`, 'BigInt.zero()'],
209
- ['string', 'String', code => `Value.fromString(${code})`, "''"],
210
- ['string', 'ID', code => `Value.fromString(${code})`, "''"],
211
- ['BigDecimal', 'BigDecimal', code => `Value.fromBigDecimal(${code})`, 'BigDecimal.zero()'],
212
- ['string', /.*/, code => `Value.fromString(${code})`, "''"],
204
+ ['Address', 'Bytes', code => `Value.fromBytes(${code})`],
205
+ ['Bytes', 'Bytes', code => `Value.fromBytes(${code})`],
206
+ ['boolean', 'Boolean', code => `Value.fromBoolean(${code})`],
207
+ ['i32', 'Int', code => `Value.fromI32(${code})`],
208
+ ['BigInt', 'BigInt', code => `Value.fromBigInt(${code})`],
209
+ ['string', 'String', code => `Value.fromString(${code})`],
210
+ ['string', 'ID', code => `Value.fromString(${code})`],
211
+ ['BigDecimal', 'BigDecimal', code => `Value.fromBigDecimal(${code})`],
212
+ ['string', /.*/, code => `Value.fromString(${code})`],
213
213
  ]
214
214
 
215
215
  /**
@@ -66,27 +66,6 @@ const findConversionToType = (fromTypeSystem, toTypeSystem, toType) => {
66
66
  return objectifyConversion(fromTypeSystem, toTypeSystem, conversion)
67
67
  }
68
68
 
69
- const findInitializationForType = (fromTypeSystem, toTypeSystem, ascType) => {
70
- const conversions = conversionsForTypeSystems(fromTypeSystem, toTypeSystem)
71
-
72
- const conversion = conversions.find(conversion =>
73
- typeof conversion.get(0) === 'string'
74
- ? conversion.get(0) === ascType
75
- : ascType.match(conversion.get(0)),
76
- )
77
-
78
- if (conversion === undefined) {
79
- throw new Error(
80
- `Conversion from '${fromTypeSystem}' to '${toTypeSystem}' for ` +
81
- `target type '${ascType}' is not supported`,
82
- )
83
- }
84
-
85
- const conversionObj = objectifyConversion(fromTypeSystem, toTypeSystem, conversion)
86
-
87
- return conversionObj.get('convert')(conversion.get(3))
88
- }
89
-
90
69
  // High-level type system API
91
70
 
92
71
  const ascTypeForProtocol = (protocol, protocolType) =>
@@ -120,9 +99,6 @@ const valueToAsc = (code, valueType) =>
120
99
  const valueFromAsc = (code, valueType) =>
121
100
  findConversionToType('AssemblyScript', 'Value', valueType).get('convert')(code)
122
101
 
123
- const initializedValueFromAsc = ascType =>
124
- findInitializationForType('AssemblyScript', 'Value', ascType)
125
-
126
102
  module.exports = {
127
103
  // protocol <-> AssemblyScript
128
104
  ascTypeForProtocol,
@@ -138,5 +114,4 @@ module.exports = {
138
114
  valueTypeForAsc,
139
115
  valueToAsc,
140
116
  valueFromAsc,
141
- initializedValueFromAsc,
142
117
  }
@@ -449,26 +449,4 @@ describe('AssemblyScript -> Value', () => {
449
449
  expect(codegen.valueFromAsc('x', '[String]')).toBe('Value.fromStringArray(x)')
450
450
  expect(codegen.valueTypeForAsc('Array<string>')).toBe('[String]')
451
451
  })
452
-
453
- describe('Initialization for zero/empty values', () => {
454
- test('Array<string>', () => {
455
- expect(codegen.initializedValueFromAsc('Array<string>')).toBe('Value.fromStringArray(new Array(0))')
456
- })
457
-
458
- test('Array<string | null>', () => {
459
- expect(codegen.initializedValueFromAsc('Array<string | null>')).toBe('Value.fromStringArray(new Array(0))')
460
- })
461
-
462
- test('i32', () => {
463
- expect(codegen.initializedValueFromAsc('i32')).toBe('Value.fromI32(0)')
464
- })
465
-
466
- test('string', () => {
467
- expect(codegen.initializedValueFromAsc('string')).toBe("Value.fromString('')")
468
- })
469
-
470
- test('BigInt', () => {
471
- expect(codegen.initializedValueFromAsc('BigInt')).toBe('Value.fromBigInt(BigInt.zero())')
472
- })
473
- })
474
452
  })
@@ -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,
@@ -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
  }
@@ -288,7 +290,7 @@ const getEtherscanLikeAPIUrl = (network) => {
288
290
  case "optimism-kovan": return `https://api-kovan-optimistic.etherscan.io/api`;
289
291
  default: return `https://api-${network}.etherscan.io/api`;
290
292
  }
291
- }
293
+ }
292
294
 
293
295
  const loadAbiFromEtherscan = async (ABI, network, address) =>
294
296
  await withSpinner(
@@ -356,7 +358,7 @@ module.exports = {
356
358
 
357
359
  node = node || g
358
360
  ;({ node, allowSimpleName } = chooseNodeUrl({ product, studio, node, allowSimpleName }))
359
-
361
+
360
362
  if (fromContract && fromExample) {
361
363
  print.error(`Only one of --from-example and --from-contract can be used at a time.`)
362
364
  process.exitCode = 1
@@ -686,6 +688,12 @@ const initSubgraphFromExample = async (
686
688
  return
687
689
  }
688
690
 
691
+ let networkConf = await initNetworksConfig(toolbox, directory, "address")
692
+ if (networkConf !== true) {
693
+ process.exitCode = 1
694
+ return
695
+ }
696
+
689
697
  // Update package.json to match the subgraph name
690
698
  let prepared = await withSpinner(
691
699
  `Update subgraph name and commands in package.json`,
@@ -827,6 +835,13 @@ const initSubgraphFromContract = async (
827
835
  return
828
836
  }
829
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
+
830
845
  // Initialize a fresh Git repository
831
846
  let repo = await initRepository(toolbox, directory)
832
847
  if (repo !== true) {
@@ -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