@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
@@ -1,192 +0,0 @@
1
- # This file is generated by gyp; do not edit.
2
-
3
- TOOLSET := target
4
- TARGET := validation
5
- DEFS_Debug := \
6
- '-DNODE_GYP_MODULE_NAME=validation' \
7
- '-DUSING_UV_SHARED=1' \
8
- '-DUSING_V8_SHARED=1' \
9
- '-DV8_DEPRECATION_WARNINGS=1' \
10
- '-DV8_DEPRECATION_WARNINGS' \
11
- '-DV8_IMMINENT_DEPRECATION_WARNINGS' \
12
- '-D_DARWIN_USE_64_BIT_INODE=1' \
13
- '-D_LARGEFILE_SOURCE' \
14
- '-D_FILE_OFFSET_BITS=64' \
15
- '-DOPENSSL_NO_PINSHARED' \
16
- '-DOPENSSL_THREADS' \
17
- '-DBUILDING_NODE_EXTENSION' \
18
- '-DDEBUG' \
19
- '-D_DEBUG' \
20
- '-DV8_ENABLE_CHECKS'
21
-
22
- # Flags passed to all source files.
23
- CFLAGS_Debug := \
24
- -O0 \
25
- -gdwarf-2 \
26
- -mmacosx-version-min=10.13 \
27
- -arch x86_64 \
28
- -Wall \
29
- -Wendif-labels \
30
- -W \
31
- -Wno-unused-parameter
32
-
33
- # Flags passed to only C files.
34
- CFLAGS_C_Debug := \
35
- -fno-strict-aliasing
36
-
37
- # Flags passed to only C++ files.
38
- CFLAGS_CC_Debug := \
39
- -std=gnu++1y \
40
- -stdlib=libc++ \
41
- -fno-rtti \
42
- -fno-exceptions \
43
- -fno-strict-aliasing
44
-
45
- # Flags passed to only ObjC files.
46
- CFLAGS_OBJC_Debug :=
47
-
48
- # Flags passed to only ObjC++ files.
49
- CFLAGS_OBJCC_Debug :=
50
-
51
- INCS_Debug := \
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
- -I$(srcdir)/../nan
60
-
61
- DEFS_Release := \
62
- '-DNODE_GYP_MODULE_NAME=validation' \
63
- '-DUSING_UV_SHARED=1' \
64
- '-DUSING_V8_SHARED=1' \
65
- '-DV8_DEPRECATION_WARNINGS=1' \
66
- '-DV8_DEPRECATION_WARNINGS' \
67
- '-DV8_IMMINENT_DEPRECATION_WARNINGS' \
68
- '-D_DARWIN_USE_64_BIT_INODE=1' \
69
- '-D_LARGEFILE_SOURCE' \
70
- '-D_FILE_OFFSET_BITS=64' \
71
- '-DOPENSSL_NO_PINSHARED' \
72
- '-DOPENSSL_THREADS' \
73
- '-DBUILDING_NODE_EXTENSION'
74
-
75
- # Flags passed to all source files.
76
- CFLAGS_Release := \
77
- -O3 \
78
- -gdwarf-2 \
79
- -mmacosx-version-min=10.13 \
80
- -arch x86_64 \
81
- -Wall \
82
- -Wendif-labels \
83
- -W \
84
- -Wno-unused-parameter
85
-
86
- # Flags passed to only C files.
87
- CFLAGS_C_Release := \
88
- -fno-strict-aliasing
89
-
90
- # Flags passed to only C++ files.
91
- CFLAGS_CC_Release := \
92
- -std=gnu++1y \
93
- -stdlib=libc++ \
94
- -fno-rtti \
95
- -fno-exceptions \
96
- -fno-strict-aliasing
97
-
98
- # Flags passed to only ObjC files.
99
- CFLAGS_OBJC_Release :=
100
-
101
- # Flags passed to only ObjC++ files.
102
- CFLAGS_OBJCC_Release :=
103
-
104
- INCS_Release := \
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
- -I$(srcdir)/../nan
113
-
114
- OBJS := \
115
- $(obj).target/$(TARGET)/src/validation.o
116
-
117
- # Add to the list of files we specially track dependencies for.
118
- all_deps += $(OBJS)
119
-
120
- # CFLAGS et al overrides must be target-local.
121
- # See "Target-specific Variable Values" in the GNU Make manual.
122
- $(OBJS): TOOLSET := $(TOOLSET)
123
- $(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
124
- $(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
125
- $(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
126
- $(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))
127
-
128
- # Suffix rules, putting all outputs into $(obj).
129
-
130
- $(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
131
- @$(call do_cmd,cxx,1)
132
-
133
- # Try building from generated source, too.
134
-
135
- $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
136
- @$(call do_cmd,cxx,1)
137
-
138
- $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
139
- @$(call do_cmd,cxx,1)
140
-
141
- # End of this set of suffix rules
142
- ### Rules for final target.
143
- LDFLAGS_Debug := \
144
- -undefined dynamic_lookup \
145
- -Wl,-no_pie \
146
- -Wl,-search_paths_first \
147
- -mmacosx-version-min=10.13 \
148
- -arch x86_64 \
149
- -L$(builddir) \
150
- -stdlib=libc++
151
-
152
- LIBTOOLFLAGS_Debug := \
153
- -undefined dynamic_lookup \
154
- -Wl,-no_pie \
155
- -Wl,-search_paths_first
156
-
157
- LDFLAGS_Release := \
158
- -undefined dynamic_lookup \
159
- -Wl,-no_pie \
160
- -Wl,-search_paths_first \
161
- -mmacosx-version-min=10.13 \
162
- -arch x86_64 \
163
- -L$(builddir) \
164
- -stdlib=libc++
165
-
166
- LIBTOOLFLAGS_Release := \
167
- -undefined dynamic_lookup \
168
- -Wl,-no_pie \
169
- -Wl,-search_paths_first
170
-
171
- LIBS :=
172
-
173
- $(builddir)/validation.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
174
- $(builddir)/validation.node: LIBS := $(LIBS)
175
- $(builddir)/validation.node: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
176
- $(builddir)/validation.node: TOOLSET := $(TOOLSET)
177
- $(builddir)/validation.node: $(OBJS) FORCE_DO_CMD
178
- $(call do_cmd,solink_module)
179
-
180
- all_deps += $(builddir)/validation.node
181
- # Add target alias
182
- .PHONY: validation
183
- validation: $(builddir)/validation.node
184
-
185
- # Short alias for building this executable.
186
- .PHONY: validation.node
187
- validation.node: $(builddir)/validation.node
188
-
189
- # Add executable to "all" target.
190
- .PHONY: all
191
- all: $(builddir)/validation.node
192
-
@@ -1,34 +0,0 @@
1
- const immutable = require('immutable')
2
-
3
- // TODO: kill me
4
- const EMPTY_ARRAY = 'new Array(0)'
5
-
6
- const ASC_DEFAULTS = [
7
- // Scalar values
8
-
9
- ['Address', 'Address.zero()'],
10
- ['Bytes', 'Bytes.empty()'],
11
- ['boolean', 'false'],
12
- ['i32', '0'],
13
- ['string', '""'],
14
- ['BigInt', 'BigInt.zero()'],
15
- ['BigDecimal', 'BigDecimal.zero()'],
16
-
17
- // Arrays
18
-
19
- ['Array<Address>', EMPTY_ARRAY],
20
- ['Array<Bytes>', EMPTY_ARRAY],
21
- ['Array<boolean>', EMPTY_ARRAY],
22
- ['Array<i32>', EMPTY_ARRAY],
23
- ['Array<string>', EMPTY_ARRAY],
24
- ['Array<BigInt>', EMPTY_ARRAY],
25
- ['Array<BigDecimal>', EMPTY_ARRAY],
26
- ['Array<string | null>', EMPTY_ARRAY],
27
- ]
28
-
29
- module.exports = immutable.fromJS({
30
- AssemblyScript: ASC_DEFAULTS,
31
- })
32
- // TODO: use me:
33
- // [/Array<.*>/, 'new Array(0)'],
34
- // [/Array\<.*\>/, 'new Array(0)'],
@@ -1,74 +0,0 @@
1
- const fs = require('fs-extra')
2
- const semver = require('semver')
3
- const toolbox = require('gluegun/toolbox')
4
- const yaml = require('js-yaml')
5
- const { loadManifest } = require('./util/load-manifest')
6
- const { getGraphTsVersion } = require('./util/versions')
7
-
8
- // If any of the manifest apiVersions are 0.0.6, replace them with 0.0.7
9
- module.exports = {
10
- name: 'Bump mapping apiVersion from 0.0.6 to 0.0.7',
11
- predicate: async ({ sourceDir, manifestFile }) => {
12
- // Obtain the graph-ts version, if possible
13
- let graphTsVersion
14
- try {
15
- graphTsVersion = await getGraphTsVersion(sourceDir)
16
- } catch (_) {
17
- // If we cannot obtain the version, return a hint that the graph-ts
18
- // hasn't been installed yet
19
- return 'graph-ts dependency not installed yet'
20
- }
21
-
22
- let manifest = loadManifest(manifestFile)
23
- return (
24
- // Only migrate if the graph-ts version is >= 0.27.0...
25
- // Coerce needed because we may be dealing with an alpha version
26
- // and in the `semver` library this would not return true on equality.
27
- semver.gte(semver.coerce(graphTsVersion), '0.27.0') &&
28
- // ...and we have a manifest with mapping > apiVersion = 0.0.6
29
- manifest &&
30
- typeof manifest === 'object' &&
31
- Array.isArray(manifest.dataSources) &&
32
- (manifest.dataSources.reduce(
33
- (hasOldMappings, dataSource) =>
34
- hasOldMappings ||
35
- (typeof dataSource === 'object' &&
36
- dataSource.mapping &&
37
- typeof dataSource.mapping === 'object' &&
38
- dataSource.mapping.apiVersion === '0.0.6'),
39
- false,
40
- ) ||
41
- (Array.isArray(manifest.templates) &&
42
- manifest.templates.reduce(
43
- (hasOldMappings, template) =>
44
- hasOldMappings ||
45
- (typeof template === 'object' &&
46
- template.mapping &&
47
- typeof template.mapping === 'object' &&
48
- template.mapping.apiVersion === '0.0.6'),
49
- false,
50
- )))
51
- )
52
- },
53
- apply: async ({ manifestFile }) => {
54
- // Make sure we catch all variants; we could load the manifest
55
- // and replace the values in the data structures here; unfortunately
56
- // writing that back to the file messes with the formatting more than
57
- // we'd like; that's why for now, we use a simple patching approach
58
- await toolbox.patching.replace(
59
- manifestFile,
60
- new RegExp('apiVersion: 0.0.6', 'g'),
61
- 'apiVersion: 0.0.7',
62
- )
63
- await toolbox.patching.replace(
64
- manifestFile,
65
- new RegExp("apiVersion: '0.0.6'", 'g'),
66
- "apiVersion: '0.0.7'",
67
- )
68
- await toolbox.patching.replace(
69
- manifestFile,
70
- new RegExp('apiVersion: "0.0.6"', 'g'),
71
- 'apiVersion: "0.0.7"',
72
- )
73
- },
74
- }
@@ -1,25 +0,0 @@
1
- const fs = require('fs-extra')
2
- const toolbox = require('gluegun/toolbox')
3
- const yaml = require('js-yaml')
4
- const { loadManifest } = require('./util/load-manifest')
5
-
6
- // Spec version 0.0.5 let event handlers require transaction receipt
7
- // data to be accessed in the runtime.
8
- module.exports = {
9
- name: 'Bump manifest specVersion from 0.0.4 to 0.0.5',
10
- predicate: async ({ sourceDir, manifestFile }) => {
11
- let manifest = await loadManifest(manifestFile)
12
- return (
13
- manifest &&
14
- typeof manifest === 'object' &&
15
- manifest.specVersion &&
16
- manifest.specVersion === '0.0.4'
17
- )
18
- },
19
- apply: async ({ manifestFile }) => {
20
- await toolbox.patching.patch(manifestFile, {
21
- insert: 'specVersion: 0.0.5',
22
- replace: new RegExp(`specVersion: ['"]?0.0.4['"]?`),
23
- })
24
- },
25
- }
@@ -1 +0,0 @@
1
- *.sol linguist-language=Solidity
@@ -1,21 +0,0 @@
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.
@@ -1,3 +0,0 @@
1
- # Example Subgraph
2
-
3
- An example to help you get started with The Graph. For more information see the docs on https://thegraph.com/docs/.
@@ -1 +0,0 @@
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"}]
@@ -1 +0,0 @@
1
- 60806040526000808190555060f5806100196000396000f3fe6080604052600436106043576000357c0100000000000000000000000000000000000000000000000000000000900480633fa4f245146048578063d09de08a146070575b600080fd5b348015605357600080fd5b50605a6078565b6040518082815260200191505060405180910390f35b6076607e565b005b60005481565b600160008082825401925050819055507f20d8a6f5a693f9d1d627a598e8820f7a55ee74c183aa8f1a30e8d4e8dd9a8d846000546040518082815260200191505060405180910390a156fea165627a7a72305820fca3d11af59a6ac98027ec3bebdb10711f195860d6d9abd07921c88c8c50228f0029
@@ -1,63 +0,0 @@
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
- }
@@ -1,23 +0,0 @@
1
- pragma solidity ^0.4.0;
2
-
3
- contract Migrations {
4
- address public owner;
5
- uint public last_completed_migration;
6
-
7
- constructor() public {
8
- owner = msg.sender;
9
- }
10
-
11
- modifier restricted() {
12
- if (msg.sender == owner) _;
13
- }
14
-
15
- function setCompleted(uint completed) public restricted {
16
- last_completed_migration = completed;
17
- }
18
-
19
- function upgrade(address new_address) public restricted {
20
- Migrations upgraded = Migrations(new_address);
21
- upgraded.setCompleted(last_completed_migration);
22
- }
23
- }
@@ -1,39 +0,0 @@
1
- version: '3'
2
- services:
3
- graph-node:
4
- image: graphprotocol/graph-node:v0.22.0
5
- ports:
6
- - '8000:8000'
7
- - '8001:8001'
8
- - '8020:8020'
9
- - '8030:8030'
10
- - '8040:8040'
11
- depends_on:
12
- - ipfs
13
- - postgres
14
- environment:
15
- postgres_host: postgres
16
- postgres_user: graph-node
17
- postgres_pass: let-me-in
18
- postgres_db: graph-node
19
- ipfs: 'ipfs:5001'
20
- # Change next line if you want to connect to a different JSON-RPC endpoint
21
- ethereum: 'mainnet:http://host.docker.internal:8545'
22
- GRAPH_LOG: info
23
- ipfs:
24
- image: ipfs/go-ipfs:v0.4.23
25
- ports:
26
- - '5001:5001'
27
- volumes:
28
- - ./data/ipfs:/data/ipfs
29
- postgres:
30
- image: postgres
31
- ports:
32
- - '5432:5432'
33
- command: ["postgres", "-cshared_preload_libraries=pg_stat_statements"]
34
- environment:
35
- POSTGRES_USER: graph-node
36
- POSTGRES_PASSWORD: let-me-in
37
- POSTGRES_DB: graph-node
38
- volumes:
39
- - ./data/postgres:/var/lib/postgresql/data
@@ -1,5 +0,0 @@
1
- var Migrations = artifacts.require('./Migrations.sol')
2
-
3
- module.exports = function(deployer) {
4
- deployer.deploy(Migrations)
5
- }
@@ -1,5 +0,0 @@
1
- const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
2
-
3
- module.exports = async function(deployer) {
4
- await deployer.deploy(GravatarRegistry)
5
- }
@@ -1,15 +0,0 @@
1
- const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
2
-
3
- module.exports = async function(deployer) {
4
- const registry = await GravatarRegistry.deployed()
5
-
6
- console.log('Account address:', registry.address)
7
-
8
- let accounts = await web3.eth.getAccounts()
9
- await registry.createGravatar('Carl', 'https://thegraph.com/img/team/team_04.png', {
10
- from: accounts[0],
11
- })
12
- await registry.createGravatar('Lucas', 'https://thegraph.com/img/team/bw_Lucas.jpg', {
13
- from: accounts[1],
14
- })
15
- }
@@ -1,7 +0,0 @@
1
- {
2
- "mainnet": {
3
- "Gravity": {
4
- "address": "0x2E645469f354BB4F5c8a05B3b30A929361cf77eC"
5
- }
6
- }
7
- }
@@ -1,23 +0,0 @@
1
- {
2
- "name": "example-subgraph",
3
- "version": "0.1.0",
4
- "scripts": {
5
- "build-contract": "solc contracts/Gravity.sol --abi -o abis --overwrite && solc contracts/Gravity.sol --bin -o bin --overwrite",
6
- "create": "graph create user/example-subgraph --node https://api.thegraph.com/deploy/",
7
- "create-local": "graph create user/example-subgraph --node http://127.0.0.1:8020",
8
- "codegen": "graph codegen",
9
- "build": "graph build",
10
- "deploy": "graph deploy user/example-subgraph --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
11
- "deploy-local": "graph deploy user/example-subgraph --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020"
12
- },
13
- "devDependencies": {
14
- "@graphprotocol/graph-ts": "^0.26.0"
15
- },
16
- "dependencies": {
17
- "babel-polyfill": "^6.26.0",
18
- "babel-register": "^6.26.0",
19
- "truffle": "^5.0.4",
20
- "truffle-contract": "^4.0.5",
21
- "truffle-hdwallet-provider": "^1.0.4"
22
- }
23
- }
@@ -1,6 +0,0 @@
1
- type Gravatar @entity {
2
- id: ID!
3
- owner: Bytes!
4
- displayName: String!
5
- imageUrl: String!
6
- }
@@ -1,22 +0,0 @@
1
- import { NewGravatar, UpdatedGravatar } from '../generated/Gravity/Gravity'
2
- import { Gravatar } from '../generated/schema'
3
-
4
- export function handleNewGravatar(event: NewGravatar): void {
5
- let gravatar = new Gravatar(event.params.id.toHex())
6
- gravatar.owner = event.params.owner
7
- gravatar.displayName = event.params.displayName
8
- gravatar.imageUrl = event.params.imageUrl
9
- gravatar.save()
10
- }
11
-
12
- export function handleUpdatedGravatar(event: UpdatedGravatar): void {
13
- let id = event.params.id.toHex()
14
- let gravatar = Gravatar.load(id)
15
- if (gravatar == null) {
16
- gravatar = new Gravatar(id)
17
- }
18
- gravatar.owner = event.params.owner
19
- gravatar.displayName = event.params.displayName
20
- gravatar.imageUrl = event.params.imageUrl
21
- gravatar.save()
22
- }
@@ -1,27 +0,0 @@
1
- specVersion: 0.0.2
2
- description: Gravatar for Ethereum
3
- repository: https://github.com/graphprotocol/example-subgraph
4
- schema:
5
- file: ./schema.graphql
6
- dataSources:
7
- - kind: ethereum/contract
8
- name: Gravity
9
- network: mainnet
10
- source:
11
- address: '0x2E645469f354BB4F5c8a05B3b30A929361cf77eC'
12
- abi: Gravity
13
- mapping:
14
- kind: ethereum/events
15
- apiVersion: 0.0.5
16
- language: wasm/assemblyscript
17
- entities:
18
- - Gravatar
19
- abis:
20
- - name: Gravity
21
- file: ./abis/Gravity.json
22
- eventHandlers:
23
- - event: NewGravatar(uint256,address,string,string)
24
- handler: handleNewGravatar
25
- - event: UpdatedGravatar(uint256,address,string,string)
26
- handler: handleUpdatedGravatar
27
- file: ./src/mapping.ts
@@ -1,27 +0,0 @@
1
- require('babel-register')
2
- require('babel-polyfill')
3
- const HDWalletProvider = require('truffle-hdwallet-provider')
4
-
5
- module.exports = {
6
- networks: {
7
- development: {
8
- host: '127.0.0.1',
9
- port: 8545,
10
- network_id: '*',
11
- },
12
- ropsten: {
13
- provider: function() {
14
- return new HDWalletProvider(
15
- process.env.MNEMONIC,
16
- `https://ropsten.infura.io/v3/${process.env.ROPSTEN_INFURA_API_KEY}`
17
- )
18
- },
19
- network_id: '3',
20
- },
21
- },
22
- compilers: {
23
- solc: {
24
- version: '0.4.25' // Fetch exact version from solc-bin (default: truffle's version)
25
- }
26
- }
27
- }