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

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 (42) hide show
  1. package/examples/basic-event-handlers/package.json +1 -1
  2. package/examples/basic-event-handlers/yarn.lock +4 -4
  3. package/examples/example-subgraph/package.json +1 -1
  4. package/examples/example-subgraph/yarn.lock +4 -4
  5. package/package.json +1 -1
  6. package/resources/test/docker-compose.yml +4 -2
  7. package/src/codegen/schema.js +3 -44
  8. package/src/codegen/schema.test.js +0 -6
  9. package/src/codegen/types/conversions.js +19 -19
  10. package/src/codegen/types/index.js +0 -25
  11. package/src/codegen/types/index.test.js +0 -22
  12. package/src/commands/init.js +1 -0
  13. package/src/migrations/spec_version_0_0_2.js +1 -1
  14. package/src/migrations/spec_version_0_0_3.js +29 -0
  15. package/src/migrations.js +2 -0
  16. package/src/protocols/index.js +2 -2
  17. package/src/scaffold/index.js +1 -1
  18. package/src/validation/manifest.js +52 -12
  19. package/tests/cli/init/ethereum/from-example/.gitattributes +1 -0
  20. package/tests/cli/init/ethereum/from-example/LICENSE +21 -0
  21. package/tests/cli/init/ethereum/from-example/README.md +3 -0
  22. package/tests/cli/init/ethereum/from-example/abis/Gravity.json +1 -0
  23. package/tests/cli/init/ethereum/from-example/bin/Counter.bin +1 -0
  24. package/tests/cli/init/ethereum/from-example/contracts/Gravity.sol +63 -0
  25. package/tests/cli/init/ethereum/from-example/contracts/Migrations.sol +23 -0
  26. package/tests/cli/init/ethereum/from-example/docker-compose.yml +39 -0
  27. package/tests/cli/init/ethereum/from-example/migrations/1_initial_migration.js +5 -0
  28. package/tests/cli/init/ethereum/from-example/migrations/2_deploy_contract.js +5 -0
  29. package/tests/cli/init/ethereum/from-example/migrations/3_create_gravatars.js +15 -0
  30. package/tests/cli/init/ethereum/from-example/networks.json +7 -0
  31. package/tests/cli/init/ethereum/from-example/package.json +23 -0
  32. package/tests/cli/init/ethereum/from-example/schema.graphql +6 -0
  33. package/tests/cli/init/ethereum/from-example/src/mapping.ts +22 -0
  34. package/tests/cli/init/ethereum/from-example/subgraph.yaml +27 -0
  35. package/tests/cli/init/ethereum/from-example/truffle.js +27 -0
  36. package/tests/cli/init/ethereum/from-example/yarn.lock +5977 -0
  37. package/tests/cli/validation/conflicting-protocol-names/Abi.json +7 -0
  38. package/tests/cli/validation/conflicting-protocol-names/mapping.ts +0 -0
  39. package/tests/cli/validation/conflicting-protocol-names/schema.graphql +3 -0
  40. package/tests/cli/validation/conflicting-protocol-names/subgraph.yaml +41 -0
  41. package/tests/cli/validation/conflicting-protocol-names.stderr +10 -0
  42. package/tests/cli/validation.test.js +9 -0
@@ -0,0 +1,5 @@
1
+ var Migrations = artifacts.require('./Migrations.sol')
2
+
3
+ module.exports = function(deployer) {
4
+ deployer.deploy(Migrations)
5
+ }
@@ -0,0 +1,5 @@
1
+ const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
2
+
3
+ module.exports = async function(deployer) {
4
+ await deployer.deploy(GravatarRegistry)
5
+ }
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "mainnet": {
3
+ "Gravity": {
4
+ "address": "0x2E645469f354BB4F5c8a05B3b30A929361cf77eC"
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,23 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ type Gravatar @entity {
2
+ id: ID!
3
+ owner: Bytes!
4
+ displayName: String!
5
+ imageUrl: String!
6
+ }
@@ -0,0 +1,22 @@
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
+ }
@@ -0,0 +1,27 @@
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
@@ -0,0 +1,27 @@
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
+ }