@graphprotocol/graph-cli 0.30.0-alpha.0 → 0.30.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 (66) hide show
  1. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/arweave.ts +76 -0
  2. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/cosmos.ts +341 -0
  3. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/ethereum.ts +39 -0
  4. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/global/global.ts +286 -142
  5. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/index.ts +4 -2
  6. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/package.json +2 -1
  7. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/test.js +4 -2
  8. package/examples/basic-event-handlers/node_modules/keccak/build/config.gypi +300 -125
  9. package/examples/basic-event-handlers/node_modules/websocket/build/config.gypi +292 -15
  10. package/examples/basic-event-handlers/package.json +1 -1
  11. package/examples/basic-event-handlers/yarn.lock +4 -4
  12. package/examples/example-subgraph/package.json +1 -1
  13. package/examples/example-subgraph/yarn.lock +4 -4
  14. package/package.json +1 -1
  15. package/resources/test/docker-compose.yml +4 -2
  16. package/src/codegen/schema.js +8 -45
  17. package/src/codegen/schema.test.js +102 -6
  18. package/src/codegen/types/conversions.js +19 -19
  19. package/src/codegen/types/index.js +0 -25
  20. package/src/codegen/types/index.test.js +0 -22
  21. package/src/command-helpers/abi.js +69 -0
  22. package/src/command-helpers/scaffold.js +67 -0
  23. package/src/commands/add.js +198 -0
  24. package/src/commands/init.js +25 -71
  25. package/src/migrations/spec_version_0_0_2.js +1 -1
  26. package/src/migrations/{spec_version_0_0_4.js → spec_version_0_0_3.js} +10 -6
  27. package/src/migrations.js +1 -1
  28. package/src/protocols/arweave/manifest.graphql +57 -0
  29. package/src/protocols/arweave/scaffold/manifest.js +19 -0
  30. package/src/protocols/arweave/scaffold/mapping.js +53 -0
  31. package/src/protocols/arweave/subgraph.js +20 -0
  32. package/src/protocols/{tendermint → cosmos}/manifest.graphql +6 -0
  33. package/src/protocols/cosmos/scaffold/manifest.js +16 -0
  34. package/src/protocols/cosmos/scaffold/mapping.js +39 -0
  35. package/src/protocols/{tendermint → cosmos}/subgraph.js +2 -1
  36. package/src/protocols/ethereum/codegen/abi.js +21 -4
  37. package/src/protocols/ethereum/scaffold/manifest.js +2 -1
  38. package/src/protocols/index.js +53 -20
  39. package/src/protocols/near/manifest.graphql +1 -0
  40. package/src/protocols/near/scaffold/manifest.js +4 -2
  41. package/src/scaffold/cosmos.test.js +86 -0
  42. package/src/scaffold/ethereum.test.js +2 -1
  43. package/src/scaffold/index.js +5 -3
  44. package/src/scaffold/near.test.js +2 -1
  45. package/src/validation/manifest.js +52 -12
  46. package/src/validation/schema.js +2 -0
  47. package/tests/cli/validation/conflicting-protocol-names/Abi.json +7 -0
  48. package/tests/cli/validation/conflicting-protocol-names/mapping.ts +0 -0
  49. package/tests/cli/validation/conflicting-protocol-names/schema.graphql +3 -0
  50. package/tests/cli/validation/conflicting-protocol-names/subgraph.yaml +41 -0
  51. package/tests/cli/validation/conflicting-protocol-names.stderr +10 -0
  52. package/tests/cli/validation.test.js +9 -0
  53. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/tendermint.ts +0 -554
  54. package/examples/basic-event-handlers/node_modules/keccak/build/Makefile +0 -342
  55. package/examples/basic-event-handlers/node_modules/keccak/build/Release/.deps/Release/obj.target/keccak/src/addon.o.d.raw +0 -27
  56. package/examples/basic-event-handlers/node_modules/keccak/build/binding.Makefile +0 -6
  57. package/examples/basic-event-handlers/node_modules/keccak/build/gyp-mac-tool +0 -615
  58. package/examples/basic-event-handlers/node_modules/keccak/build/keccak.target.mk +0 -209
  59. package/examples/basic-event-handlers/node_modules/websocket/build/Makefile +0 -347
  60. package/examples/basic-event-handlers/node_modules/websocket/build/Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw +0 -25
  61. package/examples/basic-event-handlers/node_modules/websocket/build/binding.Makefile +0 -6
  62. package/examples/basic-event-handlers/node_modules/websocket/build/bufferutil.target.mk +0 -192
  63. package/examples/basic-event-handlers/node_modules/websocket/build/gyp-mac-tool +0 -615
  64. package/examples/basic-event-handlers/node_modules/websocket/build/validation.target.mk +0 -192
  65. package/src/codegen/types/defaults.js +0 -34
  66. package/src/migrations/mapping_api_version_0_0_6.js +0 -74
@@ -5,11 +5,12 @@
5
5
  "default_configuration": "Release",
6
6
  "defines": [],
7
7
  "include_dirs": [],
8
- "libraries": []
8
+ "libraries": [],
9
+ "msvs_configuration_platform": "ARM64",
10
+ "xcode_configuration_platform": "arm64"
9
11
  },
10
12
  "variables": {
11
13
  "asan": 0,
12
- "build_v8_with_gn": "false",
13
14
  "coverage": "false",
14
15
  "dcheck_always_on": 0,
15
16
  "debug_nghttp2": "false",
@@ -19,23 +20,296 @@
19
20
  "enable_pgo_use": "false",
20
21
  "error_on_warn": "false",
21
22
  "force_dynamic_crt": 0,
22
- "host_arch": "x64",
23
- "icu_data_in": "../../deps/icu-tmp/icudt67l.dat",
23
+ "host_arch": "arm64",
24
+ "icu_data_in": "../../deps/icu-tmp/icudt70l.dat",
24
25
  "icu_endianness": "l",
25
26
  "icu_gyp_path": "tools/icu/icu-generic.gyp",
26
27
  "icu_path": "deps/icu-small",
27
28
  "icu_small": "false",
28
- "icu_ver_major": "67",
29
+ "icu_ver_major": "70",
29
30
  "is_debug": 0,
30
- "llvm_version": "11.0",
31
- "napi_build_version": "7",
31
+ "llvm_version": "12.0",
32
+ "napi_build_version": "8",
32
33
  "node_byteorder": "little",
33
34
  "node_debug_lib": "false",
34
35
  "node_enable_d8": "false",
36
+ "node_fipsinstall": "false",
37
+ "node_install_corepack": "true",
35
38
  "node_install_npm": "true",
36
- "node_module_version": 83,
39
+ "node_library_files": [
40
+ "lib/constants.js",
41
+ "lib/net.js",
42
+ "lib/trace_events.js",
43
+ "lib/events.js",
44
+ "lib/repl.js",
45
+ "lib/util.js",
46
+ "lib/dgram.js",
47
+ "lib/vm.js",
48
+ "lib/stream.js",
49
+ "lib/child_process.js",
50
+ "lib/assert.js",
51
+ "lib/_tls_wrap.js",
52
+ "lib/http2.js",
53
+ "lib/inspector.js",
54
+ "lib/os.js",
55
+ "lib/_http_server.js",
56
+ "lib/console.js",
57
+ "lib/perf_hooks.js",
58
+ "lib/readline.js",
59
+ "lib/punycode.js",
60
+ "lib/_http_incoming.js",
61
+ "lib/https.js",
62
+ "lib/_stream_wrap.js",
63
+ "lib/domain.js",
64
+ "lib/dns.js",
65
+ "lib/_http_client.js",
66
+ "lib/diagnostics_channel.js",
67
+ "lib/tty.js",
68
+ "lib/_http_agent.js",
69
+ "lib/timers.js",
70
+ "lib/_http_outgoing.js",
71
+ "lib/querystring.js",
72
+ "lib/_tls_common.js",
73
+ "lib/module.js",
74
+ "lib/_stream_passthrough.js",
75
+ "lib/_stream_transform.js",
76
+ "lib/worker_threads.js",
77
+ "lib/sys.js",
78
+ "lib/_stream_duplex.js",
79
+ "lib/path.js",
80
+ "lib/_http_common.js",
81
+ "lib/string_decoder.js",
82
+ "lib/cluster.js",
83
+ "lib/v8.js",
84
+ "lib/crypto.js",
85
+ "lib/wasi.js",
86
+ "lib/_stream_readable.js",
87
+ "lib/zlib.js",
88
+ "lib/url.js",
89
+ "lib/tls.js",
90
+ "lib/_stream_writable.js",
91
+ "lib/async_hooks.js",
92
+ "lib/process.js",
93
+ "lib/http.js",
94
+ "lib/buffer.js",
95
+ "lib/fs.js",
96
+ "lib/util/types.js",
97
+ "lib/timers/promises.js",
98
+ "lib/path/win32.js",
99
+ "lib/path/posix.js",
100
+ "lib/stream/consumers.js",
101
+ "lib/stream/promises.js",
102
+ "lib/stream/web.js",
103
+ "lib/readline/promises.js",
104
+ "lib/internal/constants.js",
105
+ "lib/internal/abort_controller.js",
106
+ "lib/internal/net.js",
107
+ "lib/internal/v8_prof_processor.js",
108
+ "lib/internal/event_target.js",
109
+ "lib/internal/inspector_async_hook.js",
110
+ "lib/internal/validators.js",
111
+ "lib/internal/linkedlist.js",
112
+ "lib/internal/cli_table.js",
113
+ "lib/internal/repl.js",
114
+ "lib/internal/util.js",
115
+ "lib/internal/histogram.js",
116
+ "lib/internal/error_serdes.js",
117
+ "lib/internal/dgram.js",
118
+ "lib/internal/structured_clone.js",
119
+ "lib/internal/child_process.js",
120
+ "lib/internal/assert.js",
121
+ "lib/internal/fixed_queue.js",
122
+ "lib/internal/blocklist.js",
123
+ "lib/internal/v8_prof_polyfill.js",
124
+ "lib/internal/options.js",
125
+ "lib/internal/worker.js",
126
+ "lib/internal/dtrace.js",
127
+ "lib/internal/idna.js",
128
+ "lib/internal/watchdog.js",
129
+ "lib/internal/encoding.js",
130
+ "lib/internal/tty.js",
131
+ "lib/internal/freeze_intrinsics.js",
132
+ "lib/internal/timers.js",
133
+ "lib/internal/heap_utils.js",
134
+ "lib/internal/querystring.js",
135
+ "lib/internal/js_stream_socket.js",
136
+ "lib/internal/errors.js",
137
+ "lib/internal/priority_queue.js",
138
+ "lib/internal/freelist.js",
139
+ "lib/internal/blob.js",
140
+ "lib/internal/socket_list.js",
141
+ "lib/internal/socketaddress.js",
142
+ "lib/internal/promise_hooks.js",
143
+ "lib/internal/stream_base_commons.js",
144
+ "lib/internal/url.js",
145
+ "lib/internal/async_hooks.js",
146
+ "lib/internal/http.js",
147
+ "lib/internal/buffer.js",
148
+ "lib/internal/trace_events_async_hooks.js",
149
+ "lib/internal/crypto/sig.js",
150
+ "lib/internal/crypto/rsa.js",
151
+ "lib/internal/crypto/aes.js",
152
+ "lib/internal/crypto/util.js",
153
+ "lib/internal/crypto/scrypt.js",
154
+ "lib/internal/crypto/random.js",
155
+ "lib/internal/crypto/keys.js",
156
+ "lib/internal/crypto/x509.js",
157
+ "lib/internal/crypto/certificate.js",
158
+ "lib/internal/crypto/ec.js",
159
+ "lib/internal/crypto/keygen.js",
160
+ "lib/internal/crypto/mac.js",
161
+ "lib/internal/crypto/diffiehellman.js",
162
+ "lib/internal/crypto/hkdf.js",
163
+ "lib/internal/crypto/cipher.js",
164
+ "lib/internal/crypto/hash.js",
165
+ "lib/internal/crypto/pbkdf2.js",
166
+ "lib/internal/crypto/webcrypto.js",
167
+ "lib/internal/crypto/dsa.js",
168
+ "lib/internal/crypto/hashnames.js",
169
+ "lib/internal/cluster/shared_handle.js",
170
+ "lib/internal/cluster/round_robin_handle.js",
171
+ "lib/internal/cluster/worker.js",
172
+ "lib/internal/cluster/primary.js",
173
+ "lib/internal/cluster/utils.js",
174
+ "lib/internal/cluster/child.js",
175
+ "lib/internal/webstreams/compression.js",
176
+ "lib/internal/webstreams/util.js",
177
+ "lib/internal/webstreams/writablestream.js",
178
+ "lib/internal/webstreams/readablestream.js",
179
+ "lib/internal/webstreams/queuingstrategies.js",
180
+ "lib/internal/webstreams/encoding.js",
181
+ "lib/internal/webstreams/transformstream.js",
182
+ "lib/internal/webstreams/adapters.js",
183
+ "lib/internal/webstreams/transfer.js",
184
+ "lib/internal/bootstrap/loaders.js",
185
+ "lib/internal/bootstrap/pre_execution.js",
186
+ "lib/internal/bootstrap/node.js",
187
+ "lib/internal/bootstrap/environment.js",
188
+ "lib/internal/bootstrap/switches/does_not_own_process_state.js",
189
+ "lib/internal/bootstrap/switches/is_not_main_thread.js",
190
+ "lib/internal/bootstrap/switches/does_own_process_state.js",
191
+ "lib/internal/bootstrap/switches/is_main_thread.js",
192
+ "lib/internal/test/binding.js",
193
+ "lib/internal/test/transfer.js",
194
+ "lib/internal/util/types.js",
195
+ "lib/internal/util/inspector.js",
196
+ "lib/internal/util/comparisons.js",
197
+ "lib/internal/util/debuglog.js",
198
+ "lib/internal/util/inspect.js",
199
+ "lib/internal/util/iterable_weak_map.js",
200
+ "lib/internal/streams/add-abort-signal.js",
201
+ "lib/internal/streams/compose.js",
202
+ "lib/internal/streams/duplexify.js",
203
+ "lib/internal/streams/destroy.js",
204
+ "lib/internal/streams/legacy.js",
205
+ "lib/internal/streams/passthrough.js",
206
+ "lib/internal/streams/readable.js",
207
+ "lib/internal/streams/from.js",
208
+ "lib/internal/streams/writable.js",
209
+ "lib/internal/streams/state.js",
210
+ "lib/internal/streams/buffer_list.js",
211
+ "lib/internal/streams/end-of-stream.js",
212
+ "lib/internal/streams/utils.js",
213
+ "lib/internal/streams/transform.js",
214
+ "lib/internal/streams/lazy_transform.js",
215
+ "lib/internal/streams/duplex.js",
216
+ "lib/internal/streams/pipeline.js",
217
+ "lib/internal/readline/interface.js",
218
+ "lib/internal/readline/promises.js",
219
+ "lib/internal/readline/utils.js",
220
+ "lib/internal/readline/emitKeypressEvents.js",
221
+ "lib/internal/readline/callbacks.js",
222
+ "lib/internal/repl/history.js",
223
+ "lib/internal/repl/utils.js",
224
+ "lib/internal/repl/await.js",
225
+ "lib/internal/legacy/processbinding.js",
226
+ "lib/internal/assert/calltracker.js",
227
+ "lib/internal/assert/assertion_error.js",
228
+ "lib/internal/http2/util.js",
229
+ "lib/internal/http2/core.js",
230
+ "lib/internal/http2/compat.js",
231
+ "lib/internal/per_context/messageport.js",
232
+ "lib/internal/per_context/primordials.js",
233
+ "lib/internal/per_context/domexception.js",
234
+ "lib/internal/vm/module.js",
235
+ "lib/internal/tls/secure-pair.js",
236
+ "lib/internal/tls/parse-cert-string.js",
237
+ "lib/internal/tls/secure-context.js",
238
+ "lib/internal/child_process/serialization.js",
239
+ "lib/internal/debugger/inspect_repl.js",
240
+ "lib/internal/debugger/inspect_client.js",
241
+ "lib/internal/debugger/inspect.js",
242
+ "lib/internal/worker/io.js",
243
+ "lib/internal/worker/js_transferable.js",
244
+ "lib/internal/main/repl.js",
245
+ "lib/internal/main/print_help.js",
246
+ "lib/internal/main/eval_string.js",
247
+ "lib/internal/main/check_syntax.js",
248
+ "lib/internal/main/prof_process.js",
249
+ "lib/internal/main/worker_thread.js",
250
+ "lib/internal/main/inspect.js",
251
+ "lib/internal/main/eval_stdin.js",
252
+ "lib/internal/main/run_main_module.js",
253
+ "lib/internal/modules/run_main.js",
254
+ "lib/internal/modules/package_json_reader.js",
255
+ "lib/internal/modules/esm/module_job.js",
256
+ "lib/internal/modules/esm/assert.js",
257
+ "lib/internal/modules/esm/get_source.js",
258
+ "lib/internal/modules/esm/translators.js",
259
+ "lib/internal/modules/esm/resolve.js",
260
+ "lib/internal/modules/esm/create_dynamic_module.js",
261
+ "lib/internal/modules/esm/load.js",
262
+ "lib/internal/modules/esm/initialize_import_meta.js",
263
+ "lib/internal/modules/esm/module_map.js",
264
+ "lib/internal/modules/esm/get_format.js",
265
+ "lib/internal/modules/esm/loader.js",
266
+ "lib/internal/modules/cjs/helpers.js",
267
+ "lib/internal/modules/cjs/loader.js",
268
+ "lib/internal/source_map/source_map.js",
269
+ "lib/internal/source_map/prepare_stack_trace.js",
270
+ "lib/internal/source_map/source_map_cache.js",
271
+ "lib/internal/dns/promises.js",
272
+ "lib/internal/dns/utils.js",
273
+ "lib/internal/fs/watchers.js",
274
+ "lib/internal/fs/promises.js",
275
+ "lib/internal/fs/read_file_context.js",
276
+ "lib/internal/fs/rimraf.js",
277
+ "lib/internal/fs/sync_write_stream.js",
278
+ "lib/internal/fs/dir.js",
279
+ "lib/internal/fs/streams.js",
280
+ "lib/internal/fs/utils.js",
281
+ "lib/internal/fs/cp/cp.js",
282
+ "lib/internal/fs/cp/cp-sync.js",
283
+ "lib/internal/perf/nodetiming.js",
284
+ "lib/internal/perf/usertiming.js",
285
+ "lib/internal/perf/performance_entry.js",
286
+ "lib/internal/perf/performance.js",
287
+ "lib/internal/perf/timerify.js",
288
+ "lib/internal/perf/utils.js",
289
+ "lib/internal/perf/observe.js",
290
+ "lib/internal/perf/event_loop_delay.js",
291
+ "lib/internal/perf/event_loop_utilization.js",
292
+ "lib/internal/policy/manifest.js",
293
+ "lib/internal/policy/sri.js",
294
+ "lib/internal/process/task_queues.js",
295
+ "lib/internal/process/per_thread.js",
296
+ "lib/internal/process/warning.js",
297
+ "lib/internal/process/policy.js",
298
+ "lib/internal/process/promises.js",
299
+ "lib/internal/process/signal.js",
300
+ "lib/internal/process/execution.js",
301
+ "lib/internal/process/esm_loader.js",
302
+ "lib/internal/process/report.js",
303
+ "lib/internal/process/worker_thread_only.js",
304
+ "lib/internal/console/constructor.js",
305
+ "lib/internal/console/global.js",
306
+ "lib/assert/strict.js",
307
+ "lib/dns/promises.js",
308
+ "lib/fs/promises.js"
309
+ ],
310
+ "node_module_version": 102,
37
311
  "node_no_browser_globals": "false",
38
- "node_prefix": "/usr/local",
312
+ "node_prefix": "/",
39
313
  "node_release_urlbase": "https://nodejs.org/download/release/",
40
314
  "node_shared": "false",
41
315
  "node_shared_brotli": "false",
@@ -43,6 +317,8 @@
43
317
  "node_shared_http_parser": "false",
44
318
  "node_shared_libuv": "false",
45
319
  "node_shared_nghttp2": "false",
320
+ "node_shared_nghttp3": "false",
321
+ "node_shared_ngtcp2": "false",
46
322
  "node_shared_openssl": "false",
47
323
  "node_shared_zlib": "false",
48
324
  "node_tag": "",
@@ -56,11 +332,11 @@
56
332
  "node_use_v8_platform": "true",
57
333
  "node_with_ltcg": "false",
58
334
  "node_without_node_options": "false",
59
- "openssl_fips": "",
60
335
  "openssl_is_fips": "false",
336
+ "openssl_quic": "true",
61
337
  "ossfuzz": "false",
62
- "shlib_suffix": "83.dylib",
63
- "target_arch": "x64",
338
+ "shlib_suffix": "102.dylib",
339
+ "target_arch": "arm64",
64
340
  "v8_enable_31bit_smis_on_64bit_arch": 0,
65
341
  "v8_enable_gdbjit": 0,
66
342
  "v8_enable_i18n_support": 1,
@@ -68,6 +344,7 @@
68
344
  "v8_enable_lite_mode": 0,
69
345
  "v8_enable_object_print": 1,
70
346
  "v8_enable_pointer_compression": 0,
347
+ "v8_enable_webassembly": 1,
71
348
  "v8_no_strict_aliasing": 1,
72
349
  "v8_optimized_debug": 1,
73
350
  "v8_promise_internal_field_count": 1,
@@ -75,8 +352,8 @@
75
352
  "v8_trace_maps": 0,
76
353
  "v8_use_siphash": 1,
77
354
  "want_separate_host_toolset": 0,
78
- "xcode_version": "11.0",
79
- "nodedir": "/Users/eva/Library/Caches/node-gyp/14.16.0",
355
+ "xcode_version": "12.0",
356
+ "nodedir": "/Users/eva/Library/Caches/node-gyp/17.3.1",
80
357
  "standalone_static_library": 1,
81
358
  "version_git_tag": "true",
82
359
  "init_license": "MIT",
@@ -86,7 +363,7 @@
86
363
  "strict_ssl": "true",
87
364
  "save_prefix": "^",
88
365
  "version_git_message": "v%s",
89
- "user_agent": "yarn/1.22.10 npm/? node/v14.16.0 darwin x64",
366
+ "user_agent": "yarn/1.22.10 npm/? node/v17.3.1 darwin arm64",
90
367
  "ignore_scripts": "",
91
368
  "version_git_sign": "",
92
369
  "ignore_optional": "",
@@ -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.27.0-alpha.0",
12
+ "@graphprotocol/graph-ts": "0.27.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.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==
5
+ "@graphprotocol/graph-ts@0.27.0":
6
+ version "0.27.0"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.27.0.tgz#948fe1716f6082964a01a63a19bcbf9ac44e06ff"
8
+ integrity sha512-r1SPDIZVQiGMxcY8rhFSM0y7d/xAbQf5vHMWUf59js1KgoyWpM6P3tczZqmQd7JTmeyNsDGIPzd9FeaxllsU4w==
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.27.0-alpha.0"
10
+ "@graphprotocol/graph-ts": "0.27.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.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==
5
+ "@graphprotocol/graph-ts@0.27.0":
6
+ version "0.27.0"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.27.0.tgz#948fe1716f6082964a01a63a19bcbf9ac44e06ff"
8
+ integrity sha512-r1SPDIZVQiGMxcY8rhFSM0y7d/xAbQf5vHMWUf59js1KgoyWpM6P3tczZqmQd7JTmeyNsDGIPzd9FeaxllsU4w==
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.30.0-alpha.0",
3
+ "version": "0.30.1",
4
4
  "license": "(Apache-2.0 OR MIT)",
5
5
  "description": "CLI for building for and deploying to The Graph",
6
6
  "dependencies": {
@@ -1,7 +1,8 @@
1
1
  version: '3'
2
2
  services:
3
3
  graph-node:
4
- image: graphprotocol/graph-node:2e0dc0b # TODO: change to latest once it has 0.0.5
4
+ # TODO: change to "latest" once it supports apiVersion 0.0.5 and specVersion 0.0.7
5
+ image: graphprotocol/graph-node:4a8e819
5
6
  ports:
6
7
  - '18000:8000'
7
8
  - '18001:8001'
@@ -20,7 +21,8 @@ services:
20
21
  ipfs: 'ipfs:5001'
21
22
  ethereum: 'test:http://ethereum:8545'
22
23
  GRAPH_LOG: trace
23
- GRAPH_MAX_API_VERSION: '0.0.5' # TODO: remove once latest has 0.0.5 by default
24
+ GRAPH_MAX_API_VERSION: '0.0.7' # TODO: remove once "latest" supports apiVersion 0.0.7 by default
25
+ GRAPH_MAX_SPEC_VERSION: '0.0.5' # TODO: remove once "latest" supports specVersion 0.0.5 by default
24
26
  ethereum:
25
27
  image: trufflesuite/ganache-cli:latest
26
28
  ports:
@@ -96,6 +96,10 @@ module.exports = class SchemaCodeGenerator {
96
96
  )
97
97
  }
98
98
 
99
+ _isInterfaceDefinition(def) {
100
+ return def.get('kind') === 'InterfaceTypeDefinition'
101
+ }
102
+
99
103
  _generateEntityType(def) {
100
104
  let name = def.getIn(['name', 'value'])
101
105
  let klass = tsCodegen.klass(name, { export: true, extends: 'Entity' })
@@ -120,41 +124,6 @@ module.exports = class SchemaCodeGenerator {
120
124
  return klass
121
125
  }
122
126
 
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
127
  _generateConstructor(entityName, fields) {
159
128
  const idField = IdField.fromFields(fields)
160
129
  return tsCodegen.method(
@@ -164,7 +133,6 @@ module.exports = class SchemaCodeGenerator {
164
133
  `
165
134
  super()
166
135
  this.set('id', ${idField.tsValueFrom()})
167
- ${this._generateDefaultFieldValues(fields)}
168
136
  `,
169
137
  )
170
138
  }
@@ -279,7 +247,7 @@ Suggestion: add an '!' to the member type of the List, change from '[${baseType}
279
247
  // If this is a reference to another type, the field has the type of
280
248
  // the referred type's id field
281
249
  const typeDef = this.schema.ast.get("definitions").
282
- find(def => this._isEntityTypeDefinition(def) && def.getIn(["name", "value"]) === typeName)
250
+ find(def => (this._isEntityTypeDefinition(def) || this._isInterfaceDefinition(def)) && def.getIn(["name", "value"]) === typeName)
283
251
  if (typeDef) {
284
252
  return IdField.fromTypeDef(typeDef).typeName()
285
253
  } else {
@@ -313,7 +281,7 @@ Suggestion: add an '!' to the member type of the List, change from '[${baseType}
313
281
  }
314
282
  }
315
283
 
316
- _typeFromGraphQl(gqlType, nullable = true, nullablePrimitive = false) {
284
+ _typeFromGraphQl(gqlType, nullable = true) {
317
285
  if (gqlType.get('kind') === 'NonNullType') {
318
286
  return this._typeFromGraphQl(gqlType.get('type'), false)
319
287
  } else if (gqlType.get('kind') === 'ListType') {
@@ -324,13 +292,8 @@ Suggestion: add an '!' to the member type of the List, change from '[${baseType}
324
292
  let type = tsCodegen.namedType(
325
293
  typesCodegen.ascTypeForValue(this._resolveFieldType(gqlType)),
326
294
  )
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
295
+ // In AssemblyScript, primitives cannot be nullable.
296
+ return nullable && !type.isPrimitive() ? tsCodegen.nullableType(type) : type
334
297
  }
335
298
  }
336
299
  }
@@ -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
  {
@@ -361,4 +355,106 @@ describe('Schema code generator', () => {
361
355
  })
362
356
  })
363
357
  })
358
+
359
+ test('Should handle references with Bytes id types', () => {
360
+ const codegen = createSchemaCodeGen(`
361
+ interface Employee {
362
+ id: Bytes!
363
+ name: String!
364
+ }
365
+
366
+ type Worker implements Employee @entity {
367
+ id: Bytes!
368
+ name: String!
369
+ }
370
+
371
+ type Task @entity {
372
+ id: Bytes!
373
+ employee: Employee!
374
+ worker: Worker!
375
+ }
376
+ `)
377
+
378
+ const generatedTypes = codegen.generateTypes()
379
+ testEntity(generatedTypes, {
380
+ name: "Task",
381
+ members: [],
382
+ methods: [
383
+ {
384
+ name: 'constructor',
385
+ params: [new Param('id', new NamedType('Bytes'))],
386
+ returnType: undefined,
387
+ body: "\n super()\n this.set('id', Value.fromBytes(id))\n "
388
+ },
389
+ {
390
+ name: 'save',
391
+ params: [],
392
+ returnType: new NamedType('void'),
393
+ body: '\n' +
394
+ " let id = this.get('id')\n" +
395
+ ' assert(id != null,\n' +
396
+ " 'Cannot save Task entity without an ID')\n" +
397
+ ' if (id) {\n' +
398
+ ' assert(id.kind == ValueKind.BYTES,\n' +
399
+ " `Entities of type Task must have an ID of type Bytes but the id '${id.displayData()}' is of type ${id.displayKind()}`)\n" +
400
+ " store.set('Task', id.toBytes().toHexString(), this)\n" +
401
+ ' }'
402
+ },
403
+ {
404
+ name: 'load',
405
+ static: true,
406
+ params: [new Param('id', new NamedType('Bytes'))],
407
+ returnType: new NullableType(new NamedType('Task')),
408
+ body: '\n' +
409
+ " return changetype<Task | null>(store.get('Task', id.toHexString()))\n" +
410
+ ' '
411
+ },
412
+ {
413
+ name: 'get id',
414
+ params: [],
415
+ returnType: new NamedType('Bytes'),
416
+ body: '\n' +
417
+ " let value = this.get('id')\n" +
418
+ ' return value!.toBytes()\n' +
419
+ ' '
420
+ },
421
+ {
422
+ name: 'set id',
423
+ params: [new Param('value', new NamedType('Bytes'))],
424
+ returnType: undefined,
425
+ body: "\n this.set('id', Value.fromBytes(value))\n "
426
+ },
427
+ {
428
+ name: 'get employee',
429
+ params: [],
430
+ returnType: new NamedType('Bytes'),
431
+ body: '\n' +
432
+ " let value = this.get('employee')\n" +
433
+ ' return value!.toBytes()\n' +
434
+ ' '
435
+ },
436
+ {
437
+ name: 'set employee',
438
+ params: [new Param('value', new NamedType('Bytes'))],
439
+ returnType: undefined,
440
+ body: "\n this.set('employee', Value.fromBytes(value))\n "
441
+ },
442
+ {
443
+ name: 'get worker',
444
+ params: [],
445
+ returnType: new NamedType('Bytes'),
446
+ body: '\n' +
447
+ " let value = this.get('worker')\n" +
448
+ ' return value!.toBytes()\n' +
449
+ ' '
450
+ },
451
+ {
452
+ name: 'set worker',
453
+ params: [new Param('value', new NamedType('Bytes'))],
454
+ returnType: undefined,
455
+ body: "\n this.set('worker', Value.fromBytes(value))\n "
456
+ }
457
+ ]
458
+ })
459
+ })
364
460
  })