@graphprotocol/graph-cli 0.28.1 → 0.28.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.
- package/examples/basic-event-handlers/node_modules/keccak/build/Makefile +1 -1
- package/examples/basic-event-handlers/node_modules/keccak/build/Release/.deps/Release/obj.target/keccak/src/addon.o.d.raw +16 -16
- package/examples/basic-event-handlers/node_modules/keccak/build/config.gypi +4 -4
- package/examples/basic-event-handlers/node_modules/keccak/build/keccak.target.mk +14 -14
- package/examples/basic-event-handlers/node_modules/websocket/build/Makefile +1 -1
- package/examples/basic-event-handlers/node_modules/websocket/build/Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw +16 -16
- package/examples/basic-event-handlers/node_modules/websocket/build/bufferutil.target.mk +14 -14
- package/examples/basic-event-handlers/node_modules/websocket/build/config.gypi +1 -1
- package/examples/basic-event-handlers/node_modules/websocket/build/validation.target.mk +14 -14
- package/package.json +1 -1
- package/src/codegen/schema.js +3 -44
- package/src/codegen/schema.test.js +0 -6
- package/src/codegen/types/conversions.js +19 -19
- package/src/codegen/types/index.js +0 -25
- package/src/codegen/types/index.test.js +0 -22
- package/tests/cli/init/ethereum/from-example/.gitattributes +1 -0
- package/tests/cli/init/ethereum/from-example/LICENSE +21 -0
- package/tests/cli/init/ethereum/from-example/README.md +3 -0
- package/tests/cli/init/ethereum/from-example/abis/Gravity.json +1 -0
- package/tests/cli/init/ethereum/from-example/bin/Counter.bin +1 -0
- package/tests/cli/init/ethereum/from-example/contracts/Gravity.sol +63 -0
- package/tests/cli/init/ethereum/from-example/contracts/Migrations.sol +23 -0
- package/tests/cli/init/ethereum/from-example/docker-compose.yml +39 -0
- package/tests/cli/init/ethereum/from-example/migrations/1_initial_migration.js +5 -0
- package/tests/cli/init/ethereum/from-example/migrations/2_deploy_contract.js +5 -0
- package/tests/cli/init/ethereum/from-example/migrations/3_create_gravatars.js +15 -0
- package/tests/cli/init/ethereum/from-example/package.json +23 -0
- package/tests/cli/init/ethereum/from-example/schema.graphql +6 -0
- package/tests/cli/init/ethereum/from-example/src/mapping.ts +22 -0
- package/tests/cli/init/ethereum/from-example/subgraph.yaml +27 -0
- package/tests/cli/init/ethereum/from-example/truffle.js +27 -0
- package/tests/cli/init/ethereum/from-example/yarn.lock +5977 -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/
|
|
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/
|
|
3
|
-
/Users/
|
|
4
|
-
/Users/
|
|
5
|
-
/Users/
|
|
6
|
-
/Users/
|
|
7
|
-
/Users/
|
|
8
|
-
/Users/
|
|
9
|
-
/Users/
|
|
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/
|
|
12
|
-
/Users/
|
|
13
|
-
/Users/
|
|
14
|
-
/Users/
|
|
15
|
-
/Users/
|
|
16
|
-
/Users/
|
|
17
|
-
/Users/
|
|
18
|
-
/Users/
|
|
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/
|
|
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/
|
|
137
|
-
"init_module": "/Users/
|
|
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/
|
|
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/
|
|
56
|
-
-I/Users/
|
|
57
|
-
-I/Users/
|
|
58
|
-
-I/Users/
|
|
59
|
-
-I/Users/
|
|
60
|
-
-I/Users/
|
|
61
|
-
-I/Users/
|
|
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/
|
|
112
|
-
-I/Users/
|
|
113
|
-
-I/Users/
|
|
114
|
-
-I/Users/
|
|
115
|
-
-I/Users/
|
|
116
|
-
-I/Users/
|
|
117
|
-
-I/Users/
|
|
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/
|
|
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/
|
|
3
|
-
/Users/
|
|
4
|
-
/Users/
|
|
5
|
-
/Users/
|
|
6
|
-
/Users/
|
|
7
|
-
/Users/
|
|
8
|
-
/Users/
|
|
9
|
-
/Users/
|
|
10
|
-
/Users/
|
|
11
|
-
/Users/
|
|
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/
|
|
14
|
-
/Users/
|
|
15
|
-
/Users/
|
|
16
|
-
/Users/
|
|
17
|
-
/Users/
|
|
18
|
-
/Users/
|
|
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/
|
|
53
|
-
-I/Users/
|
|
54
|
-
-I/Users/
|
|
55
|
-
-I/Users/
|
|
56
|
-
-I/Users/
|
|
57
|
-
-I/Users/
|
|
58
|
-
-I/Users/
|
|
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/
|
|
106
|
-
-I/Users/
|
|
107
|
-
-I/Users/
|
|
108
|
-
-I/Users/
|
|
109
|
-
-I/Users/
|
|
110
|
-
-I/Users/
|
|
111
|
-
-I/Users/
|
|
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/
|
|
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/
|
|
53
|
-
-I/Users/
|
|
54
|
-
-I/Users/
|
|
55
|
-
-I/Users/
|
|
56
|
-
-I/Users/
|
|
57
|
-
-I/Users/
|
|
58
|
-
-I/Users/
|
|
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/
|
|
106
|
-
-I/Users/
|
|
107
|
-
-I/Users/
|
|
108
|
-
-I/Users/
|
|
109
|
-
-I/Users/
|
|
110
|
-
-I/Users/
|
|
111
|
-
-I/Users/
|
|
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
package/src/codegen/schema.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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})
|
|
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})
|
|
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})
|
|
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})
|
|
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 @@
|
|
|
1
|
+
*.sol linguist-language=Solidity
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 The Graph
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"constant":false,"inputs":[{"name":"_imageUrl","type":"string"}],"name":"updateGravatarImage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"setMythicalGravatar","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"}],"name":"getGravatar","outputs":[{"name":"","type":"string"},{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"gravatarToOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"ownerToGravatar","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_displayName","type":"string"}],"name":"updateGravatarName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_displayName","type":"string"},{"name":"_imageUrl","type":"string"}],"name":"createGravatar","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"gravatars","outputs":[{"name":"owner","type":"address"},{"name":"displayName","type":"string"},{"name":"imageUrl","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"id","type":"uint256"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"displayName","type":"string"},{"indexed":false,"name":"imageUrl","type":"string"}],"name":"NewGravatar","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"id","type":"uint256"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"displayName","type":"string"},{"indexed":false,"name":"imageUrl","type":"string"}],"name":"UpdatedGravatar","type":"event"}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
60806040526000808190555060f5806100196000396000f3fe6080604052600436106043576000357c0100000000000000000000000000000000000000000000000000000000900480633fa4f245146048578063d09de08a146070575b600080fd5b348015605357600080fd5b50605a6078565b6040518082815260200191505060405180910390f35b6076607e565b005b60005481565b600160008082825401925050819055507f20d8a6f5a693f9d1d627a598e8820f7a55ee74c183aa8f1a30e8d4e8dd9a8d846000546040518082815260200191505060405180910390a156fea165627a7a72305820fca3d11af59a6ac98027ec3bebdb10711f195860d6d9abd07921c88c8c50228f0029
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
pragma solidity ^0.4.0;
|
|
2
|
+
|
|
3
|
+
contract GravatarRegistry {
|
|
4
|
+
event NewGravatar(uint id, address owner, string displayName, string imageUrl);
|
|
5
|
+
event UpdatedGravatar(uint id, address owner, string displayName, string imageUrl);
|
|
6
|
+
|
|
7
|
+
struct Gravatar {
|
|
8
|
+
address owner;
|
|
9
|
+
string displayName;
|
|
10
|
+
string imageUrl;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Gravatar[] public gravatars;
|
|
14
|
+
|
|
15
|
+
mapping (uint => address) public gravatarToOwner;
|
|
16
|
+
mapping (address => uint) public ownerToGravatar;
|
|
17
|
+
|
|
18
|
+
function createGravatar(string _displayName, string _imageUrl) public {
|
|
19
|
+
require(ownerToGravatar[msg.sender] == 0);
|
|
20
|
+
uint id = gravatars.push(Gravatar(msg.sender, _displayName, _imageUrl)) - 1;
|
|
21
|
+
|
|
22
|
+
gravatarToOwner[id] = msg.sender;
|
|
23
|
+
ownerToGravatar[msg.sender] = id;
|
|
24
|
+
|
|
25
|
+
emit NewGravatar(id, msg.sender, _displayName, _imageUrl);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getGravatar(address owner) public view returns (string, string) {
|
|
29
|
+
uint id = ownerToGravatar[owner];
|
|
30
|
+
return (gravatars[id].displayName, gravatars[id].imageUrl);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function updateGravatarName(string _displayName) public {
|
|
34
|
+
require(ownerToGravatar[msg.sender] != 0);
|
|
35
|
+
require(msg.sender == gravatars[ownerToGravatar[msg.sender]].owner);
|
|
36
|
+
|
|
37
|
+
uint id = ownerToGravatar[msg.sender];
|
|
38
|
+
|
|
39
|
+
gravatars[id].displayName = _displayName;
|
|
40
|
+
emit UpdatedGravatar(id, msg.sender, _displayName, gravatars[id].imageUrl);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function updateGravatarImage(string _imageUrl) public {
|
|
44
|
+
require(ownerToGravatar[msg.sender] != 0);
|
|
45
|
+
require(msg.sender == gravatars[ownerToGravatar[msg.sender]].owner);
|
|
46
|
+
|
|
47
|
+
uint id = ownerToGravatar[msg.sender];
|
|
48
|
+
|
|
49
|
+
gravatars[id].imageUrl = _imageUrl;
|
|
50
|
+
emit UpdatedGravatar(id, msg.sender, gravatars[id].displayName, _imageUrl);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// the gravatar at position 0 of gravatars[]
|
|
54
|
+
// is fake
|
|
55
|
+
// it's a mythical gravatar
|
|
56
|
+
// that doesn't really exist
|
|
57
|
+
// dani will invoke this function once when this contract is deployed
|
|
58
|
+
// but then no more
|
|
59
|
+
function setMythicalGravatar() public {
|
|
60
|
+
require(msg.sender == 0x8d3e809Fbd258083a5Ba004a527159Da535c8abA);
|
|
61
|
+
gravatars.push(Gravatar(0x0, " ", " "));
|
|
62
|
+
}
|
|
63
|
+
}
|