@graphprotocol/graph-cli 0.30.0-alpha.1 → 0.30.2

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 (72) 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/src/codegen/schema.js +5 -1
  16. package/src/codegen/schema.test.js +102 -0
  17. package/src/command-helpers/abi.js +69 -0
  18. package/src/command-helpers/scaffold.js +65 -0
  19. package/src/commands/add.js +198 -0
  20. package/src/commands/init.js +23 -72
  21. package/src/migrations.js +0 -2
  22. package/src/protocols/arweave/manifest.graphql +57 -0
  23. package/src/protocols/arweave/scaffold/manifest.js +19 -0
  24. package/src/protocols/arweave/scaffold/mapping.js +53 -0
  25. package/src/protocols/arweave/subgraph.js +20 -0
  26. package/src/protocols/{tendermint → cosmos}/manifest.graphql +6 -0
  27. package/src/protocols/cosmos/scaffold/manifest.js +16 -0
  28. package/src/protocols/cosmos/scaffold/mapping.js +39 -0
  29. package/src/protocols/{tendermint → cosmos}/subgraph.js +2 -1
  30. package/src/protocols/ethereum/codegen/abi.js +21 -4
  31. package/src/protocols/ethereum/scaffold/manifest.js +2 -1
  32. package/src/protocols/index.js +51 -18
  33. package/src/protocols/near/manifest.graphql +1 -0
  34. package/src/protocols/near/scaffold/manifest.js +4 -2
  35. package/src/scaffold/cosmos.test.js +86 -0
  36. package/src/scaffold/ethereum.test.js +2 -2
  37. package/src/scaffold/index.js +3 -2
  38. package/src/scaffold/near.test.js +2 -2
  39. package/src/validation/schema.js +2 -0
  40. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/tendermint.ts +0 -554
  41. package/examples/basic-event-handlers/node_modules/keccak/build/Makefile +0 -342
  42. package/examples/basic-event-handlers/node_modules/keccak/build/Release/.deps/Release/obj.target/keccak/src/addon.o.d.raw +0 -27
  43. package/examples/basic-event-handlers/node_modules/keccak/build/binding.Makefile +0 -6
  44. package/examples/basic-event-handlers/node_modules/keccak/build/gyp-mac-tool +0 -615
  45. package/examples/basic-event-handlers/node_modules/keccak/build/keccak.target.mk +0 -209
  46. package/examples/basic-event-handlers/node_modules/websocket/build/Makefile +0 -347
  47. package/examples/basic-event-handlers/node_modules/websocket/build/Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw +0 -25
  48. package/examples/basic-event-handlers/node_modules/websocket/build/binding.Makefile +0 -6
  49. package/examples/basic-event-handlers/node_modules/websocket/build/bufferutil.target.mk +0 -192
  50. package/examples/basic-event-handlers/node_modules/websocket/build/gyp-mac-tool +0 -615
  51. package/examples/basic-event-handlers/node_modules/websocket/build/validation.target.mk +0 -192
  52. package/src/codegen/types/defaults.js +0 -34
  53. package/src/migrations/mapping_api_version_0_0_6.js +0 -74
  54. package/src/migrations/spec_version_0_0_4.js +0 -25
  55. package/tests/cli/init/ethereum/from-example/.gitattributes +0 -1
  56. package/tests/cli/init/ethereum/from-example/LICENSE +0 -21
  57. package/tests/cli/init/ethereum/from-example/README.md +0 -3
  58. package/tests/cli/init/ethereum/from-example/abis/Gravity.json +0 -1
  59. package/tests/cli/init/ethereum/from-example/bin/Counter.bin +0 -1
  60. package/tests/cli/init/ethereum/from-example/contracts/Gravity.sol +0 -63
  61. package/tests/cli/init/ethereum/from-example/contracts/Migrations.sol +0 -23
  62. package/tests/cli/init/ethereum/from-example/docker-compose.yml +0 -39
  63. package/tests/cli/init/ethereum/from-example/migrations/1_initial_migration.js +0 -5
  64. package/tests/cli/init/ethereum/from-example/migrations/2_deploy_contract.js +0 -5
  65. package/tests/cli/init/ethereum/from-example/migrations/3_create_gravatars.js +0 -15
  66. package/tests/cli/init/ethereum/from-example/networks.json +0 -7
  67. package/tests/cli/init/ethereum/from-example/package.json +0 -23
  68. package/tests/cli/init/ethereum/from-example/schema.graphql +0 -6
  69. package/tests/cli/init/ethereum/from-example/src/mapping.ts +0 -22
  70. package/tests/cli/init/ethereum/from-example/subgraph.yaml +0 -27
  71. package/tests/cli/init/ethereum/from-example/truffle.js +0 -27
  72. package/tests/cli/init/ethereum/from-example/yarn.lock +0 -5977
@@ -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.1",
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.1":
6
- version "0.27.0-alpha.1"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.27.0-alpha.1.tgz#1ea72417944820959c6edb24e217b4e37099deaa"
8
- integrity sha512-zQzbGZnP9SPo3K0y+DqPY0j80KSDAQHzGoPcR3wN8rz9++UF/vTGqWZV4f9RGY+n29SQ4KLzFzDiQaL67hxBsA==
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.1"
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.1":
6
- version "0.27.0-alpha.1"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.27.0-alpha.1.tgz#1ea72417944820959c6edb24e217b4e37099deaa"
8
- integrity sha512-zQzbGZnP9SPo3K0y+DqPY0j80KSDAQHzGoPcR3wN8rz9++UF/vTGqWZV4f9RGY+n29SQ4KLzFzDiQaL67hxBsA==
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.1",
3
+ "version": "0.30.2",
4
4
  "license": "(Apache-2.0 OR MIT)",
5
5
  "description": "CLI for building for and deploying to The Graph",
6
6
  "dependencies": {
@@ -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' })
@@ -243,7 +247,7 @@ Suggestion: add an '!' to the member type of the List, change from '[${baseType}
243
247
  // If this is a reference to another type, the field has the type of
244
248
  // the referred type's id field
245
249
  const typeDef = this.schema.ast.get("definitions").
246
- find(def => this._isEntityTypeDefinition(def) && def.getIn(["name", "value"]) === typeName)
250
+ find(def => (this._isEntityTypeDefinition(def) || this._isInterfaceDefinition(def)) && def.getIn(["name", "value"]) === typeName)
247
251
  if (typeDef) {
248
252
  return IdField.fromTypeDef(typeDef).typeName()
249
253
  } else {
@@ -355,4 +355,106 @@ describe('Schema code generator', () => {
355
355
  })
356
356
  })
357
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
+ })
358
460
  })
@@ -0,0 +1,69 @@
1
+ const { withSpinner } = require('./spinner')
2
+ const fetch = require('node-fetch')
3
+ const immutable = require('immutable')
4
+
5
+ const loadAbiFromEtherscan = async (ABI, network, address) =>
6
+ await withSpinner(
7
+ `Fetching ABI from Etherscan`,
8
+ `Failed to fetch ABI from Etherscan`,
9
+ `Warnings while fetching ABI from Etherscan`,
10
+ async spinner => {
11
+ const scanApiUrl = getEtherscanLikeAPIUrl(network);
12
+ let result = await fetch(
13
+ `${scanApiUrl}?module=contract&action=getabi&address=${address}`,
14
+ )
15
+ let json = await result.json()
16
+
17
+ // Etherscan returns a JSON object that has a `status`, a `message` and
18
+ // a `result` field. The `status` is '0' in case of errors and '1' in
19
+ // case of success
20
+ if (json.status === '1') {
21
+ return new ABI('Contract', undefined, immutable.fromJS(JSON.parse(json.result)))
22
+ } else {
23
+ throw new Error('ABI not found, try loading it from a local file')
24
+ }
25
+ },
26
+ )
27
+
28
+ const loadAbiFromBlockScout = async (ABI, network, address) =>
29
+ await withSpinner(
30
+ `Fetching ABI from BlockScout`,
31
+ `Failed to fetch ABI from BlockScout`,
32
+ `Warnings while fetching ABI from BlockScout`,
33
+ async spinner => {
34
+ let result = await fetch(
35
+ `https://blockscout.com/${
36
+ network.replace('-', '/')
37
+ }/api?module=contract&action=getabi&address=${address}`,
38
+ )
39
+ let json = await result.json()
40
+
41
+ // BlockScout returns a JSON object that has a `status`, a `message` and
42
+ // a `result` field. The `status` is '0' in case of errors and '1' in
43
+ // case of success
44
+ if (json.status === '1') {
45
+ return new ABI('Contract', undefined, immutable.fromJS(JSON.parse(json.result)))
46
+ } else {
47
+ throw new Error('ABI not found, try loading it from a local file')
48
+ }
49
+ },
50
+ )
51
+
52
+ const getEtherscanLikeAPIUrl = (network) => {
53
+ switch (network) {
54
+ case "mainnet": return `https://api.etherscan.io/api`
55
+ case "arbitrum-one": return `https://api.arbiscan.io/api`
56
+ case "bsc": return `https://api.bscscan.com/api`
57
+ case "matic": return `https://api.polygonscan.com/api`
58
+ case "mumbai": return `https://api-testnet.polygonscan.com/api`
59
+ case "aurora": return `https://api.aurorascan.dev/api`
60
+ case "aurora-testnet": return `https://api-testnet.aurorascan.dev/api`
61
+ case "optimism-kovan": return `https://api-kovan-optimistic.etherscan.io/api`
62
+ default: return `https://api-${network}.etherscan.io/api`
63
+ }
64
+ }
65
+
66
+ module.exports = {
67
+ loadAbiFromEtherscan,
68
+ loadAbiFromBlockScout,
69
+ }