@graphprotocol/graph-cli 0.36.1 → 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.
Files changed (64) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +6 -3
  3. package/src/command-helpers/abi.js +2 -0
  4. package/src/command-helpers/compiler.js +1 -1
  5. package/src/command-helpers/network.test.js +13 -10
  6. package/src/commands/build.js +7 -3
  7. package/src/commands/codegen.js +5 -0
  8. package/src/commands/init.js +12 -3
  9. package/src/compiler/index.js +128 -73
  10. package/src/debug.js +15 -0
  11. package/src/protocols/index.js +140 -128
  12. package/src/protocols/substreams/manifest.graphql +45 -0
  13. package/src/protocols/substreams/scaffold/manifest.js +13 -0
  14. package/src/protocols/substreams/subgraph.js +17 -0
  15. package/src/scaffold/index.js +7 -2
  16. package/src/subgraph.js +14 -3
  17. package/tests/cli/validation/call-handler-with-tuple/generated/schema.ts +44 -0
  18. package/tests/cli/validation/example-values-found/generated/ExampleSubgraph/ExampleContract.ts +35 -0
  19. package/tests/cli/validation/example-values-found/generated/schema.ts +44 -0
  20. package/tests/cli/validation/source-without-address-is-valid/generated/ExampleSubgraph/ExampleContract.ts +35 -0
  21. package/.eslintrc +0 -10
  22. package/.prettierrc.json +0 -6
  23. package/.travis.yml +0 -37
  24. package/CONTRIBUTING.md +0 -16
  25. package/LICENSE-APACHE +0 -190
  26. package/LICENSE-MIT +0 -21
  27. package/NEWS.md +0 -80
  28. package/README.md +0 -146
  29. package/examples/basic-event-handlers/LICENSE +0 -21
  30. package/examples/basic-event-handlers/README.md +0 -3
  31. package/examples/basic-event-handlers/abis/Gravity.json +0 -1
  32. package/examples/basic-event-handlers/bin/Counter.bin +0 -1
  33. package/examples/basic-event-handlers/build/Gravity/Gravity.wasm +0 -0
  34. package/examples/basic-event-handlers/build/Gravity/abis/Gravity.json +0 -199
  35. package/examples/basic-event-handlers/build/schema.graphql +0 -13
  36. package/examples/basic-event-handlers/build/subgraph.yaml +0 -27
  37. package/examples/basic-event-handlers/contracts/Gravity.sol +0 -62
  38. package/examples/basic-event-handlers/contracts/Migrations.sol +0 -23
  39. package/examples/basic-event-handlers/generated/Gravity/Gravity.ts +0 -343
  40. package/examples/basic-event-handlers/generated/schema.ts +0 -133
  41. package/examples/basic-event-handlers/migrations/1_initial_migration.js +0 -5
  42. package/examples/basic-event-handlers/migrations/2_deploy_contract.js +0 -5
  43. package/examples/basic-event-handlers/migrations/3_create_gravatars.js +0 -14
  44. package/examples/basic-event-handlers/migrations/4_update_gravatars.js +0 -9
  45. package/examples/basic-event-handlers/package.json +0 -24
  46. package/examples/basic-event-handlers/schema.graphql +0 -13
  47. package/examples/basic-event-handlers/src/mapping.ts +0 -21
  48. package/examples/basic-event-handlers/subgraph.yaml +0 -27
  49. package/examples/basic-event-handlers/test/handlers.js +0 -110
  50. package/examples/basic-event-handlers/truffle.js +0 -34
  51. package/examples/basic-event-handlers/yarn.lock +0 -1027
  52. package/examples/example-subgraph/abis/ExampleContract.json +0 -2388
  53. package/examples/example-subgraph/dist/ExampleSubgraph/ExampleSubgraph.wasm +0 -0
  54. package/examples/example-subgraph/dist/ExampleSubgraph/abis/ExampleContract.json +0 -2394
  55. package/examples/example-subgraph/dist/abis/ExampleContract.json +0 -2388
  56. package/examples/example-subgraph/dist/schema.graphql +0 -37
  57. package/examples/example-subgraph/dist/subgraph.yaml +0 -26
  58. package/examples/example-subgraph/package.json +0 -15
  59. package/examples/example-subgraph/schema.graphql +0 -37
  60. package/examples/example-subgraph/src/mapping.ts +0 -286
  61. package/examples/example-subgraph/subgraph.yaml +0 -26
  62. package/examples/example-subgraph/yarn.lock +0 -28
  63. package/resources/test/docker-compose-standalone-node.yml +0 -20
  64. package/resources/test/docker-compose.yml +0 -43
@@ -1,133 +0,0 @@
1
- // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
-
3
- import {
4
- TypedMap,
5
- Entity,
6
- Value,
7
- ValueKind,
8
- store,
9
- Address,
10
- Bytes,
11
- BigInt,
12
- BigDecimal
13
- } from "@graphprotocol/graph-ts";
14
-
15
- export class NewGravatar extends Entity {
16
- constructor(id: string) {
17
- super();
18
- this.set("id", Value.fromString(id));
19
- }
20
-
21
- save(): void {
22
- let id = this.get("id");
23
- assert(id != null, "Cannot save NewGravatar entity without an ID");
24
- if (id) {
25
- assert(
26
- id.kind == ValueKind.STRING,
27
- "Cannot save NewGravatar entity with non-string ID. " +
28
- 'Considering using .toHex() to convert the "id" to a string.'
29
- );
30
- store.set("NewGravatar", id.toString(), this);
31
- }
32
- }
33
-
34
- static load(id: string): NewGravatar | null {
35
- return changetype<NewGravatar | null>(store.get("NewGravatar", id));
36
- }
37
-
38
- get id(): string {
39
- let value = this.get("id");
40
- return value!.toString();
41
- }
42
-
43
- set id(value: string) {
44
- this.set("id", Value.fromString(value));
45
- }
46
-
47
- get owner(): Bytes {
48
- let value = this.get("owner");
49
- return value!.toBytes();
50
- }
51
-
52
- set owner(value: Bytes) {
53
- this.set("owner", Value.fromBytes(value));
54
- }
55
-
56
- get displayName(): string {
57
- let value = this.get("displayName");
58
- return value!.toString();
59
- }
60
-
61
- set displayName(value: string) {
62
- this.set("displayName", Value.fromString(value));
63
- }
64
-
65
- get imageUrl(): string {
66
- let value = this.get("imageUrl");
67
- return value!.toString();
68
- }
69
-
70
- set imageUrl(value: string) {
71
- this.set("imageUrl", Value.fromString(value));
72
- }
73
- }
74
-
75
- export class UpdatedGravatar extends Entity {
76
- constructor(id: string) {
77
- super();
78
- this.set("id", Value.fromString(id));
79
- }
80
-
81
- save(): void {
82
- let id = this.get("id");
83
- assert(id != null, "Cannot save UpdatedGravatar entity without an ID");
84
- if (id) {
85
- assert(
86
- id.kind == ValueKind.STRING,
87
- "Cannot save UpdatedGravatar entity with non-string ID. " +
88
- 'Considering using .toHex() to convert the "id" to a string.'
89
- );
90
- store.set("UpdatedGravatar", id.toString(), this);
91
- }
92
- }
93
-
94
- static load(id: string): UpdatedGravatar | null {
95
- return changetype<UpdatedGravatar | null>(store.get("UpdatedGravatar", id));
96
- }
97
-
98
- get id(): string {
99
- let value = this.get("id");
100
- return value!.toString();
101
- }
102
-
103
- set id(value: string) {
104
- this.set("id", Value.fromString(value));
105
- }
106
-
107
- get owner(): Bytes {
108
- let value = this.get("owner");
109
- return value!.toBytes();
110
- }
111
-
112
- set owner(value: Bytes) {
113
- this.set("owner", Value.fromBytes(value));
114
- }
115
-
116
- get displayName(): string {
117
- let value = this.get("displayName");
118
- return value!.toString();
119
- }
120
-
121
- set displayName(value: string) {
122
- this.set("displayName", Value.fromString(value));
123
- }
124
-
125
- get imageUrl(): string {
126
- let value = this.get("imageUrl");
127
- return value!.toString();
128
- }
129
-
130
- set imageUrl(value: string) {
131
- this.set("imageUrl", Value.fromString(value));
132
- }
133
- }
@@ -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,14 +0,0 @@
1
- const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
2
-
3
- module.exports = async function(deployer) {
4
- let accounts = await web3.eth.getAccounts()
5
-
6
- const registry = await GravatarRegistry.deployed()
7
- await registry.setMythicalGravatar( { from: accounts[0] });
8
- await registry.createGravatar('Carl', 'https://thegraph.com/img/team/team_04.png', {
9
- from: accounts[0],
10
- })
11
- await registry.createGravatar('Lucas', 'https://thegraph.com/img/team/bw_Lucas.jpg', {
12
- from: accounts[1],
13
- })
14
- }
@@ -1,9 +0,0 @@
1
- const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
2
-
3
- module.exports = async function(deployer) {
4
- let accounts = await web3.eth.getAccounts()
5
-
6
- const registry = await GravatarRegistry.deployed()
7
- await registry.updateGravatarName('Nena', { from: accounts[0] })
8
- await registry.updateGravatarName('Jorge', { from: accounts[1] })
9
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "basic-event-handlers",
3
- "version": "0.1.0",
4
- "scripts": {
5
- "codegen": "../../bin/graph codegen",
6
- "build": "../../bin/graph build",
7
- "test": "truffle test --network test",
8
- "create-test": "../../bin/graph create test/basic-event-handlers --node http://127.0.0.1:18020",
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
- },
11
- "devDependencies": {
12
- "@graphprotocol/graph-ts": "0.28.1",
13
- "apollo-fetch": "^0.7.0"
14
- },
15
- "dependencies": {
16
- "babel-polyfill": "6.26.0",
17
- "babel-register": "6.26.0",
18
- "truffle": "5.0.12",
19
- "truffle-hdwallet-provider": "1.0.6"
20
- },
21
- "resolutions": {
22
- "assemblyscript": "0.19.10"
23
- }
24
- }
@@ -1,13 +0,0 @@
1
- type NewGravatar @entity {
2
- id: ID!
3
- owner: Bytes!
4
- displayName: String!
5
- imageUrl: String!
6
- }
7
-
8
- type UpdatedGravatar @entity {
9
- id: ID!
10
- owner: Bytes!
11
- displayName: String!
12
- imageUrl: String!
13
- }
@@ -1,21 +0,0 @@
1
- import {
2
- NewGravatar as NewGravatarEvent,
3
- UpdatedGravatar as UpdatedGravatarEvent,
4
- } from '../generated/Gravity/Gravity'
5
- import { NewGravatar, UpdatedGravatar } from '../generated/schema'
6
-
7
- export function handleNewGravatar(event: NewGravatarEvent): void {
8
- let newGravatar = new NewGravatar(event.params.id.toHex())
9
- newGravatar.owner = event.params.owner
10
- newGravatar.displayName = event.params.displayName
11
- newGravatar.imageUrl = event.params.imageUrl
12
- newGravatar.save()
13
- }
14
-
15
- export function handleUpdatedGravatar(event: UpdatedGravatarEvent): void {
16
- let updatedGravatar = new UpdatedGravatar(event.params.id.toHex())
17
- updatedGravatar.owner = event.params.owner
18
- updatedGravatar.displayName = event.params.displayName
19
- updatedGravatar.imageUrl = event.params.imageUrl
20
- updatedGravatar.save()
21
- }
@@ -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: ./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,110 +0,0 @@
1
- const path = require('path')
2
- const { system, patching } = require('gluegun')
3
- const { createApolloFetch } = require('apollo-fetch')
4
-
5
- const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
6
-
7
- const srcDir = path.join(__dirname, '..')
8
-
9
- const fetchSubgraphs = createApolloFetch({ uri: 'http://localhost:18030/graphql' })
10
- const fetchSubgraph = createApolloFetch({
11
- uri: 'http://localhost:18000/subgraphs/name/test/basic-event-handlers',
12
- })
13
-
14
- const waitForSubgraphToBeSynced = async () =>
15
- new Promise((resolve, reject) => {
16
- // Wait for 10s
17
- let deadline = Date.now() + 10 * 1000
18
-
19
- const checkSubgraphSynced = async () => {
20
- if (Date.now() > deadline) {
21
- reject('Timeout while waiting for the subgraph to be synced')
22
- }
23
-
24
- // Query the subgraph meta data for the indexing status
25
- let result = await fetchSubgraphs({
26
- query: `
27
- {
28
- statuses: indexingStatusesForSubgraphName(
29
- subgraphName: "test/basic-event-handlers"
30
- ) {
31
- synced
32
- }
33
- }
34
- `,
35
- })
36
-
37
- if (
38
- JSON.stringify(result.data) === JSON.stringify({ statuses: [{ synced: true }] })
39
- ) {
40
- setTimeout(resolve, 1000)
41
- } else {
42
- setTimeout(checkSubgraphSynced, 500)
43
- }
44
- }
45
-
46
- setTimeout(checkSubgraphSynced, 0)
47
- })
48
-
49
- contract('Basic event handlers', accounts => {
50
- // Deploy the subgraph once before all tests
51
- before(async () => {
52
- // Deploy the contract
53
- const registry = await GravatarRegistry.deployed()
54
-
55
- // Insert its address into subgraph manifest
56
- await patching.replace(
57
- path.join(srcDir, 'subgraph.yaml'),
58
- '0x2E645469f354BB4F5c8a05B3b30A929361cf77eC',
59
- registry.address,
60
- )
61
-
62
- // Create and deploy the subgraph
63
- await system.run(`yarn codegen`, { cwd: srcDir })
64
- await system.run(`yarn create-test`, { cwd: srcDir })
65
- await system.run(`yarn deploy-test`, { cwd: srcDir })
66
-
67
- // Wait for the subgraph to be indexed
68
- await waitForSubgraphToBeSynced()
69
- })
70
-
71
- it('all events are indexed', async () => {
72
- // Query the subgraph for entities
73
- let result = await fetchSubgraph({
74
- query: `
75
- {
76
- newGravatars(orderBy: id) { id displayName imageUrl }
77
- updatedGravatars(orderBy: id) { id displayName imageUrl }
78
- }
79
- `,
80
- })
81
-
82
- expect(result.errors).to.be.undefined
83
- expect(result.data).to.deep.equal({
84
- newGravatars: [
85
- {
86
- displayName: 'Carl',
87
- id: '0x1',
88
- imageUrl: 'https://thegraph.com/img/team/team_04.png',
89
- },
90
- {
91
- displayName: 'Lucas',
92
- id: '0x2',
93
- imageUrl: 'https://thegraph.com/img/team/bw_Lucas.jpg',
94
- },
95
- ],
96
- updatedGravatars: [
97
- {
98
- displayName: 'Nena',
99
- id: '0x1',
100
- imageUrl: 'https://thegraph.com/img/team/team_04.png',
101
- },
102
- {
103
- displayName: 'Jorge',
104
- id: '0x2',
105
- imageUrl: 'https://thegraph.com/img/team/bw_Lucas.jpg',
106
- },
107
- ],
108
- })
109
- })
110
- })
@@ -1,34 +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
- test: {
22
- host: 'localhost',
23
- port: 18545,
24
- network_id: '*',
25
- gas: '100000000000',
26
- gasPrice: '1',
27
- },
28
- },
29
- compilers: {
30
- solc: {
31
- version: '0.4.25', // Fetch exact version from solc-bin (default: truffle's version)
32
- },
33
- },
34
- }