@graphprotocol/graph-cli 0.37.0 → 0.37.1-alpha-20221207192322-dd39b34
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/CHANGELOG.md +7 -0
- package/package.json +6 -3
- package/src/command-helpers/abi.js +2 -0
- package/src/command-helpers/network.test.js +13 -10
- package/tests/cli/validation/call-handler-with-tuple/generated/schema.ts +44 -0
- package/tests/cli/validation/example-values-found/generated/ExampleSubgraph/ExampleContract.ts +35 -0
- package/tests/cli/validation/example-values-found/generated/schema.ts +44 -0
- package/tests/cli/validation/source-without-address-is-valid/generated/ExampleSubgraph/ExampleContract.ts +35 -0
- package/.eslintrc +0 -10
- package/.prettierrc.json +0 -6
- package/.travis.yml +0 -37
- package/CONTRIBUTING.md +0 -16
- package/LICENSE-APACHE +0 -190
- package/LICENSE-MIT +0 -21
- package/NEWS.md +0 -80
- package/README.md +0 -146
- package/examples/basic-event-handlers/LICENSE +0 -21
- package/examples/basic-event-handlers/README.md +0 -3
- package/examples/basic-event-handlers/abis/Gravity.json +0 -1
- package/examples/basic-event-handlers/bin/Counter.bin +0 -1
- package/examples/basic-event-handlers/build/Gravity/Gravity.wasm +0 -0
- package/examples/basic-event-handlers/build/Gravity/abis/Gravity.json +0 -199
- package/examples/basic-event-handlers/build/schema.graphql +0 -13
- package/examples/basic-event-handlers/build/subgraph.yaml +0 -27
- package/examples/basic-event-handlers/contracts/Gravity.sol +0 -62
- package/examples/basic-event-handlers/contracts/Migrations.sol +0 -23
- package/examples/basic-event-handlers/generated/Gravity/Gravity.ts +0 -343
- package/examples/basic-event-handlers/generated/schema.ts +0 -133
- package/examples/basic-event-handlers/migrations/1_initial_migration.js +0 -5
- package/examples/basic-event-handlers/migrations/2_deploy_contract.js +0 -5
- package/examples/basic-event-handlers/migrations/3_create_gravatars.js +0 -14
- package/examples/basic-event-handlers/migrations/4_update_gravatars.js +0 -9
- package/examples/basic-event-handlers/package.json +0 -24
- package/examples/basic-event-handlers/schema.graphql +0 -13
- package/examples/basic-event-handlers/src/mapping.ts +0 -21
- package/examples/basic-event-handlers/subgraph.yaml +0 -27
- package/examples/basic-event-handlers/test/handlers.js +0 -110
- package/examples/basic-event-handlers/truffle.js +0 -34
- package/examples/basic-event-handlers/yarn.lock +0 -1027
- package/examples/example-subgraph/abis/ExampleContract.json +0 -2388
- package/examples/example-subgraph/dist/ExampleSubgraph/ExampleSubgraph.wasm +0 -0
- package/examples/example-subgraph/dist/ExampleSubgraph/abis/ExampleContract.json +0 -2394
- package/examples/example-subgraph/dist/abis/ExampleContract.json +0 -2388
- package/examples/example-subgraph/dist/schema.graphql +0 -37
- package/examples/example-subgraph/dist/subgraph.yaml +0 -26
- package/examples/example-subgraph/package.json +0 -15
- package/examples/example-subgraph/schema.graphql +0 -37
- package/examples/example-subgraph/src/mapping.ts +0 -286
- package/examples/example-subgraph/subgraph.yaml +0 -26
- package/examples/example-subgraph/yarn.lock +0 -28
- package/resources/test/docker-compose-standalone-node.yml +0 -20
- package/resources/test/docker-compose.yml +0 -43
package/README.md
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# The Graph CLI (graph-cli)
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@graphprotocol/graph-cli)
|
|
4
|
-
[](https://travis-ci.org/graphprotocol/graph-cli)
|
|
5
|
-
|
|
6
|
-
## The Graph Command Line Interface
|
|
7
|
-
|
|
8
|
-
As of today, the command line interface supports the following commands:
|
|
9
|
-
|
|
10
|
-
- `graph init` — Creates a new subgraph project from an example or an existing contract.
|
|
11
|
-
- `graph create` — Registers a subgraph name with a Graph Node.
|
|
12
|
-
- `graph remove` — Unregisters a subgraph name with a Graph Node.
|
|
13
|
-
- `graph codegen` — Generates AssemblyScript types for smart contract ABIs and the subgraph schema.
|
|
14
|
-
- `graph build` — Compiles a subgraph to WebAssembly.
|
|
15
|
-
- `graph deploy` — Deploys a subgraph to a [Graph Node](https://github.com/graphprotocol/graph-node).
|
|
16
|
-
- `graph auth` — Stores a [Graph Node](https://github.com/graphprotocol/graph-node) access token in the system's keychain.
|
|
17
|
-
- `graph local` — Runs tests against a [Graph Node](https://github.com/graphprotocol/graph-node) test environment (using Ganache by default).
|
|
18
|
-
- `graph test` — Downloads and runs the [Matchstick](https://github.com/LimeChain/matchstick) rust binary in order to test a subgraph.
|
|
19
|
-
- `graph add` - Adds a new datasource to the yaml file and writes the necessary changes to other files - schema.graphql, abi and mapping.
|
|
20
|
-
|
|
21
|
-
## How It Works
|
|
22
|
-
|
|
23
|
-
The Graph CLI takes a subgraph manifest (defaults to `subgraph.yaml`) with references to:
|
|
24
|
-
|
|
25
|
-
- A GraphQL schema,
|
|
26
|
-
- Smart contract ABIs, and
|
|
27
|
-
- Mappings written in AssemblyScript.
|
|
28
|
-
|
|
29
|
-
It compiles the mappings to WebAssembly, builds a ready-to-use version of the subgraph saved to IPFS or a local directory for debugging, and deploys the subgraph to a [Graph Node](https://github.com/graphprotocol/graph-node).
|
|
30
|
-
|
|
31
|
-
## Installation
|
|
32
|
-
|
|
33
|
-
The Graph CLI can be installed with `npm` or `yarn`:
|
|
34
|
-
|
|
35
|
-
```sh
|
|
36
|
-
# NPM
|
|
37
|
-
npm install -g @graphprotocol/graph-cli
|
|
38
|
-
|
|
39
|
-
# Yarn
|
|
40
|
-
yarn global add @graphprotocol/graph-cli
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### On Linux
|
|
44
|
-
|
|
45
|
-
`libsecret` is used for storing access tokens, so you may need to install it before getting started. Use one of the following commands depending on your distribution:
|
|
46
|
-
|
|
47
|
-
- Debian/Ubuntu: `sudo apt-get install libsecret-1-dev`
|
|
48
|
-
- Red Hat: `sudo yum install libsecret-devel`
|
|
49
|
-
- Arch Linux: `sudo pacman -S libsecret`
|
|
50
|
-
|
|
51
|
-
## Getting Started
|
|
52
|
-
|
|
53
|
-
The Graph CLI can be used with a local or self-hosted [Graph Node](https://github.com/graphprotocol/graph-node) or with the [Hosted Service](https://thegraph.com/explorer/). To help you get going, there are [quick start guides](https://thegraph.com/docs/en/developer/quick-start/) available for both.
|
|
54
|
-
|
|
55
|
-
If you are ready to dive into the details of building a subgraph from scratch, there is a [detailed walkthrough](https://thegraph.com/docs/en/developer/create-subgraph-hosted/) for that as well, along with API documentation for the [AssemblyScript API](https://thegraph.com/docs/en/developer/assemblyscript-api/).
|
|
56
|
-
|
|
57
|
-
## Release process
|
|
58
|
-
|
|
59
|
-
The steps to create a new version of the `graph-cli` are:
|
|
60
|
-
|
|
61
|
-
1. Decide which version number you'll be rolling out. You can check the differences between the current `main` branch and the latest release.
|
|
62
|
-
2. Create a PR with the commit generated by `npm version <VERSION> [<PREID>]`.
|
|
63
|
-
3. Once that's approved and merged to `main`, you can publish it to `npm` and push the git tags as well.
|
|
64
|
-
4. Last but not least, create a Github Release refering to the pushed git tag, linking to the PRs involved.
|
|
65
|
-
|
|
66
|
-
Helpful links:
|
|
67
|
-
|
|
68
|
-
- [Semver official docs](https://semver.org/)
|
|
69
|
-
- [`npm version` docs](https://docs.npmjs.com/cli/v7/commands/npm-version)
|
|
70
|
-
- [`npm publish` docs](https://docs.npmjs.com/cli/v7/commands/npm-publish)
|
|
71
|
-
- [`npm unpublish` docs](https://docs.npmjs.com/cli/v7/commands/npm-unpublish)
|
|
72
|
-
- [`npm deprecate` docs](https://docs.npmjs.com/cli/v7/commands/npm-deprecate)
|
|
73
|
-
|
|
74
|
-
### Stable release example
|
|
75
|
-
|
|
76
|
-
Current version: `0.34.9`.
|
|
77
|
-
Desired release: `0.35.0`.
|
|
78
|
-
|
|
79
|
-
To create the PR:
|
|
80
|
-
```
|
|
81
|
-
git checkout -b <BRANCH>
|
|
82
|
-
|
|
83
|
-
npm version minor
|
|
84
|
-
|
|
85
|
-
git push --set-upstream <REMOTE> <BRANCH>
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Once that's approved and merged, you can update your local `main` and:
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
npm publish
|
|
92
|
-
|
|
93
|
-
npm push --tags
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Alpha release example
|
|
97
|
-
|
|
98
|
-
Current version: `0.29.2`.
|
|
99
|
-
Desired release: `0.30.0-alpha.0`.
|
|
100
|
-
|
|
101
|
-
To create the PR:
|
|
102
|
-
```
|
|
103
|
-
git checkout -b <BRANCH>
|
|
104
|
-
|
|
105
|
-
npm version preminor --preid alpha
|
|
106
|
-
|
|
107
|
-
git push --set-upstream <REMOTE> <BRANCH>
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Once that's approved and merged, you can update your local `main` and:
|
|
111
|
-
|
|
112
|
-
```
|
|
113
|
-
npm publish --tag alpha
|
|
114
|
-
|
|
115
|
-
npm push --tags
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Alpha pre-release example
|
|
119
|
-
|
|
120
|
-
Current version: `0.30.0-alpha.0`.
|
|
121
|
-
Desired release: `0.30.0-alpha.1`.
|
|
122
|
-
|
|
123
|
-
To create the PR:
|
|
124
|
-
```
|
|
125
|
-
git checkout -b <BRANCH>
|
|
126
|
-
|
|
127
|
-
npm version prerelease --preid alpha
|
|
128
|
-
|
|
129
|
-
git push --set-upstream <REMOTE> <BRANCH>
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Once that's approved and merged, you can update your local `main` and:
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
npm publish --tag alpha
|
|
136
|
-
|
|
137
|
-
npm push --tags
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## License
|
|
141
|
-
|
|
142
|
-
Copyright © 2018-2019 Graph Protocol, Inc. and contributors.
|
|
143
|
-
|
|
144
|
-
The Graph CLI is dual-licensed under the [MIT license](LICENSE-MIT) and the [Apache License, Version 2.0](LICENSE-APACHE).
|
|
145
|
-
|
|
146
|
-
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
@@ -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 +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
|
|
Binary file
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"constant": false,
|
|
4
|
-
"inputs": [
|
|
5
|
-
{
|
|
6
|
-
"name": "_imageUrl",
|
|
7
|
-
"type": "string"
|
|
8
|
-
}
|
|
9
|
-
],
|
|
10
|
-
"name": "updateGravatarImage",
|
|
11
|
-
"outputs": [],
|
|
12
|
-
"payable": false,
|
|
13
|
-
"stateMutability": "nonpayable",
|
|
14
|
-
"type": "function"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"constant": false,
|
|
18
|
-
"inputs": [],
|
|
19
|
-
"name": "setMythicalGravatar",
|
|
20
|
-
"outputs": [],
|
|
21
|
-
"payable": false,
|
|
22
|
-
"stateMutability": "nonpayable",
|
|
23
|
-
"type": "function"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"constant": true,
|
|
27
|
-
"inputs": [
|
|
28
|
-
{
|
|
29
|
-
"name": "owner",
|
|
30
|
-
"type": "address"
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
"name": "getGravatar",
|
|
34
|
-
"outputs": [
|
|
35
|
-
{
|
|
36
|
-
"name": "",
|
|
37
|
-
"type": "string"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"name": "",
|
|
41
|
-
"type": "string"
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
"payable": false,
|
|
45
|
-
"stateMutability": "view",
|
|
46
|
-
"type": "function"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"constant": true,
|
|
50
|
-
"inputs": [
|
|
51
|
-
{
|
|
52
|
-
"name": "",
|
|
53
|
-
"type": "uint256"
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
"name": "gravatarToOwner",
|
|
57
|
-
"outputs": [
|
|
58
|
-
{
|
|
59
|
-
"name": "",
|
|
60
|
-
"type": "address"
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
"payable": false,
|
|
64
|
-
"stateMutability": "view",
|
|
65
|
-
"type": "function"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"constant": true,
|
|
69
|
-
"inputs": [
|
|
70
|
-
{
|
|
71
|
-
"name": "",
|
|
72
|
-
"type": "address"
|
|
73
|
-
}
|
|
74
|
-
],
|
|
75
|
-
"name": "ownerToGravatar",
|
|
76
|
-
"outputs": [
|
|
77
|
-
{
|
|
78
|
-
"name": "",
|
|
79
|
-
"type": "uint256"
|
|
80
|
-
}
|
|
81
|
-
],
|
|
82
|
-
"payable": false,
|
|
83
|
-
"stateMutability": "view",
|
|
84
|
-
"type": "function"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"constant": false,
|
|
88
|
-
"inputs": [
|
|
89
|
-
{
|
|
90
|
-
"name": "_displayName",
|
|
91
|
-
"type": "string"
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
"name": "updateGravatarName",
|
|
95
|
-
"outputs": [],
|
|
96
|
-
"payable": false,
|
|
97
|
-
"stateMutability": "nonpayable",
|
|
98
|
-
"type": "function"
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"constant": false,
|
|
102
|
-
"inputs": [
|
|
103
|
-
{
|
|
104
|
-
"name": "_displayName",
|
|
105
|
-
"type": "string"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"name": "_imageUrl",
|
|
109
|
-
"type": "string"
|
|
110
|
-
}
|
|
111
|
-
],
|
|
112
|
-
"name": "createGravatar",
|
|
113
|
-
"outputs": [],
|
|
114
|
-
"payable": false,
|
|
115
|
-
"stateMutability": "nonpayable",
|
|
116
|
-
"type": "function"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
"constant": true,
|
|
120
|
-
"inputs": [
|
|
121
|
-
{
|
|
122
|
-
"name": "",
|
|
123
|
-
"type": "uint256"
|
|
124
|
-
}
|
|
125
|
-
],
|
|
126
|
-
"name": "gravatars",
|
|
127
|
-
"outputs": [
|
|
128
|
-
{
|
|
129
|
-
"name": "owner",
|
|
130
|
-
"type": "address"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"name": "displayName",
|
|
134
|
-
"type": "string"
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
"name": "imageUrl",
|
|
138
|
-
"type": "string"
|
|
139
|
-
}
|
|
140
|
-
],
|
|
141
|
-
"payable": false,
|
|
142
|
-
"stateMutability": "view",
|
|
143
|
-
"type": "function"
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
"anonymous": false,
|
|
147
|
-
"inputs": [
|
|
148
|
-
{
|
|
149
|
-
"indexed": false,
|
|
150
|
-
"name": "id",
|
|
151
|
-
"type": "uint256"
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
"indexed": false,
|
|
155
|
-
"name": "owner",
|
|
156
|
-
"type": "address"
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
"indexed": false,
|
|
160
|
-
"name": "displayName",
|
|
161
|
-
"type": "string"
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
"indexed": false,
|
|
165
|
-
"name": "imageUrl",
|
|
166
|
-
"type": "string"
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
"name": "NewGravatar",
|
|
170
|
-
"type": "event"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"anonymous": false,
|
|
174
|
-
"inputs": [
|
|
175
|
-
{
|
|
176
|
-
"indexed": false,
|
|
177
|
-
"name": "id",
|
|
178
|
-
"type": "uint256"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"indexed": false,
|
|
182
|
-
"name": "owner",
|
|
183
|
-
"type": "address"
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
"indexed": false,
|
|
187
|
-
"name": "displayName",
|
|
188
|
-
"type": "string"
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"indexed": false,
|
|
192
|
-
"name": "imageUrl",
|
|
193
|
-
"type": "string"
|
|
194
|
-
}
|
|
195
|
-
],
|
|
196
|
-
"name": "UpdatedGravatar",
|
|
197
|
-
"type": "event"
|
|
198
|
-
}
|
|
199
|
-
]
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
specVersion: 0.0.5
|
|
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: test
|
|
10
|
-
source:
|
|
11
|
-
address: '0xCfEB869F69431e42cdB54A4F4f105C19C080A601'
|
|
12
|
-
abi: Gravity
|
|
13
|
-
mapping:
|
|
14
|
-
kind: ethereum/events
|
|
15
|
-
apiVersion: 0.0.7
|
|
16
|
-
language: wasm/assemblyscript
|
|
17
|
-
entities:
|
|
18
|
-
- Gravatar
|
|
19
|
-
abis:
|
|
20
|
-
- name: Gravity
|
|
21
|
-
file: Gravity/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: Gravity/Gravity.wasm
|
|
@@ -1,62 +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
|
-
gravatars.push(Gravatar(0x0, " ", " "));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -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
|
-
}
|