Skip to content

Commit 55a93b8

Browse files
authored
Merge branch 'graphprotocol:master' into master
2 parents e23103d + 67440ee commit 55a93b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1192
-680
lines changed

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,89 @@ The Graph CLI can be used with a local or self-hosted [Graph Node](https://githu
5353

5454
If you are ready to dive into the details of building a subgraph from scratch, there is a [detailed walkthrough](https://thegraph.com/docs/define-a-subgraph) for that as well, along with API documentation for the [AssemblyScript API](https://thegraph.com/docs/assemblyscript-api).
5555

56+
## Release process
57+
58+
The steps to create a new version of the `graph-cli` are:
59+
60+
1. Decide which version number you'll be rolling out. You can check the differences between the current `master` branch and the latest release.
61+
2. Create a PR with the commit generated by `npm version <VERSION> [<PREID>]`.
62+
3. Once that's approved and merged to `master`, you can publish it to `npm` and push the git tags as well.
63+
4. Last but not least, create a Github Release refering to the pushed git tag, linking to the PRs involved.
64+
65+
Helpful links:
66+
67+
- [Semver official docs](https://semver.org/)
68+
- [`npm version` docs](https://docs.npmjs.com/cli/v7/commands/npm-version)
69+
- [`npm publish` docs](https://docs.npmjs.com/cli/v7/commands/npm-publish)
70+
- [`npm unpublish` docs](https://docs.npmjs.com/cli/v7/commands/npm-unpublish)
71+
- [`npm deprecate` docs](https://docs.npmjs.com/cli/v7/commands/npm-deprecate)
72+
73+
### Stable release example
74+
75+
Current version: `0.34.9`.
76+
Desired release: `0.35.0`.
77+
78+
To create the PR:
79+
```
80+
git checkout -b <BRANCH>
81+
82+
npm version minor
83+
84+
git push --set-upstream <REMOTE> <BRANCH>
85+
```
86+
87+
Once that's approved and merged, you can update your local `master` and:
88+
89+
```
90+
npm publish
91+
92+
npm push --tags
93+
```
94+
95+
### Alpha release example
96+
97+
Current version: `0.29.2`.
98+
Desired release: `0.30.0-alpha.0`.
99+
100+
To create the PR:
101+
```
102+
git checkout -b <BRANCH>
103+
104+
npm version preminor --preid alpha
105+
106+
git push --set-upstream <REMOTE> <BRANCH>
107+
```
108+
109+
Once that's approved and merged, you can update your local `master` and:
110+
111+
```
112+
npm publish --tag alpha
113+
114+
npm push --tags
115+
```
116+
117+
### Alpha pre-release example
118+
119+
Current version: `0.30.0-alpha.0`.
120+
Desired release: `0.30.0-alpha.1`.
121+
122+
To create the PR:
123+
```
124+
git checkout -b <BRANCH>
125+
126+
npm version prerelease --preid alpha
127+
128+
git push --set-upstream <REMOTE> <BRANCH>
129+
```
130+
131+
Once that's approved and merged, you can update your local `master` and:
132+
133+
```
134+
npm publish --tag alpha
135+
136+
npm push --tags
137+
```
138+
56139
## License
57140

58141
Copyright &copy; 2018-2019 Graph Protocol, Inc. and contributors.

examples/basic-event-handlers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"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"
1010
},
1111
"devDependencies": {
12-
"@graphprotocol/graph-ts": "0.22.1",
12+
"@graphprotocol/graph-ts": "0.23.1",
1313
"apollo-fetch": "^0.7.0"
1414
},
1515
"dependencies": {

examples/basic-event-handlers/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

5-
"@graphprotocol/graph-ts@0.22.1":
6-
version "0.22.1"
7-
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.22.1.tgz#3189b2495b33497280f617316cce68074d48e236"
8-
integrity sha512-T5xrHN0tHJwd7ZnSTLhk5hAL3rCIp6rJ40kBCrETnv1mfK9hVyoojJK6VtBQXTbLsYtKe4SYjjD0cdOsAR9QiA==
5+
"@graphprotocol/graph-ts@0.23.1":
6+
version "0.23.1"
7+
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.23.1.tgz#76e595d26ec5672f3778b1d3830e4640a57aec1b"
8+
integrity sha512-pipofvN1LlwLOXrS7IWy8hSBFZzVyVHdLXDpQskl9nKqdbb3chelj4JoVEzCl7klvomDpP84ngLpW17fBh5vww==
99
dependencies:
1010
assemblyscript "0.19.10"
1111

examples/example-subgraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build-wast": "../../bin/graph build -t wast subgraph.yaml"
88
},
99
"devDependencies": {
10-
"@graphprotocol/graph-ts": "0.22.1"
10+
"@graphprotocol/graph-ts": "0.23.1"
1111
},
1212
"resolutions": {
1313
"assemblyscript": "0.19.10"

examples/example-subgraph/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

5-
"@graphprotocol/graph-ts@0.22.1":
6-
version "0.22.1"
7-
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.22.1.tgz#3189b2495b33497280f617316cce68074d48e236"
8-
integrity sha512-T5xrHN0tHJwd7ZnSTLhk5hAL3rCIp6rJ40kBCrETnv1mfK9hVyoojJK6VtBQXTbLsYtKe4SYjjD0cdOsAR9QiA==
5+
"@graphprotocol/graph-ts@0.23.1":
6+
version "0.23.1"
7+
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.23.1.tgz#76e595d26ec5672f3778b1d3830e4640a57aec1b"
8+
integrity sha512-pipofvN1LlwLOXrS7IWy8hSBFZzVyVHdLXDpQskl9nKqdbb3chelj4JoVEzCl7klvomDpP84ngLpW17fBh5vww==
99
dependencies:
1010
assemblyscript "0.19.10"
1111

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ module.exports = {
4949
// forceCoverageMatch: [],
5050

5151
// A path to a module which exports an async function that is triggered once before all test suites
52-
// globalSetup: null,
52+
globalSetup: './tests/cli/globalSetup',
5353

5454
// A path to a module which exports an async function that is triggered once after all test suites
55-
// globalTeardown: null,
55+
globalTeardown: './tests/cli/globalTeardown',
5656

5757
// A set of global variables that need to be available in all test environments
5858
// globals: {},

manifest-schema.graphql

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ type Schema {
66
file: File!
77
}
88

9-
union DataSource = EthereumContractDataSource
9+
union DataSource =
10+
EthereumContractDataSource |
11+
NearContractDataSource
12+
1013
union DataSourceTemplate = EthereumContractDataSourceTemplate
1114

1215
type EthereumContractDataSource {
@@ -17,14 +20,27 @@ type EthereumContractDataSource {
1720
mapping: EthereumContractMapping!
1821
}
1922

23+
type NearContractDataSource {
24+
kind: String!
25+
name: String!
26+
network: String
27+
source: NearContractSource!
28+
mapping: NearContractMapping!
29+
}
30+
2031
type EthereumContractSource {
2132
address: String
2233
abi: String!
2334
startBlock: BigInt
2435
}
2536

37+
type NearContractSource {
38+
account: String
39+
startBlock: BigInt
40+
}
41+
2642
type EthereumContractMapping {
27-
kind: String!
43+
kind: String
2844
apiVersion: String!
2945
language: String!
3046
file: File!
@@ -35,6 +51,15 @@ type EthereumContractMapping {
3551
eventHandlers: [EthereumContractEventHandler!]
3652
}
3753

54+
type NearContractMapping {
55+
apiVersion: String!
56+
language: String!
57+
file: File!
58+
entities: [String!]!
59+
blockHandlers: [NearBlockHandler!]
60+
receiptHandlers: [NearReceiptHandler!]
61+
}
62+
3863
type EthereumContractAbi {
3964
name: String!
4065
file: File!
@@ -49,11 +74,19 @@ type EthereumBlockFilter {
4974
kind: String!
5075
}
5176

77+
type NearBlockHandler {
78+
handler: String!
79+
}
80+
5281
type EthereumCallHandler {
5382
function: String!
5483
handler: String!
5584
}
5685

86+
type NearReceiptHandler {
87+
handler: String!
88+
}
89+
5790
type EthereumContractEventHandler {
5891
event: String!
5992
topic0: String

package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphprotocol/graph-cli",
3-
"version": "0.22.3",
3+
"version": "0.23.1",
44
"description": "CLI for building for and deploying to The Graph",
55
"dependencies": {
66
"assemblyscript": "0.19.10",
@@ -40,10 +40,6 @@
4040
"scripts": {
4141
"test": "jest --verbose",
4242
"test:init": "jest tests/cli/init.test.js --verbose",
43-
"test:validation": "jest tests/cli/validation.test.js --verbose",
44-
"release:patch": "npm version patch && npm publish && git push origin master && git push --tags",
45-
"release:minor": "npm version minor && npm publish && git push origin master && git push --tags",
46-
"release:alpha:minor": "npm version preminor --preid alpha && npm publish --tag alpha && git push origin master && git push --tags",
47-
"release:alpha:prerelease": "npm version prerelease --preid alpha && npm publish --tag alpha && git push origin master && git push --tags"
43+
"test:validation": "jest tests/cli/validation.test.js --verbose"
4844
}
4945
}

src/codegen/schema.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ module.exports = class SchemaCodeGenerator {
2323
// APIs
2424
'store',
2525

26-
// Basic Ethereum types
27-
'Address',
26+
// Basic Scalar types
2827
'Bytes',
2928
'BigInt',
3029
'BigDecimal',

src/codegen/template.js

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ const immutable = require('immutable')
33
const tsCodegen = require('./typescript')
44

55
module.exports = class DataSourceTemplateCodeGenerator {
6-
constructor(template) {
6+
constructor(template, protocol) {
77
this.template = template
8+
this.protocolTemplateCodeGen = protocol.getTemplateCodeGen(template)
89
}
910

1011
generateModuleImports() {
1112
return [
1213
tsCodegen.moduleImports(
13-
['Address', 'DataSourceTemplate', 'DataSourceContext'],
14+
[
15+
...this.protocolTemplateCodeGen.generateModuleImports(),
16+
'DataSourceTemplate',
17+
'DataSourceContext',
18+
],
1419
'@graphprotocol/graph-ts',
1520
),
1621
]
@@ -24,55 +29,8 @@ module.exports = class DataSourceTemplateCodeGenerator {
2429
let name = this.template.get('name')
2530

2631
let klass = tsCodegen.klass(name, { export: true, extends: 'DataSourceTemplate' })
27-
klass.addMethod(this._generateCreateMethod())
28-
klass.addMethod(this._generateCreateWithContextMethod())
32+
klass.addMethod(this.protocolTemplateCodeGen.generateCreateMethod())
33+
klass.addMethod(this.protocolTemplateCodeGen.generateCreateWithContextMethod())
2934
return klass
3035
}
31-
32-
_generateCreateMethod() {
33-
let name = this.template.get('name')
34-
let kind = this.template.get('kind')
35-
36-
switch (kind) {
37-
case 'ethereum/contract':
38-
return tsCodegen.staticMethod(
39-
'create',
40-
[tsCodegen.param('address', tsCodegen.namedType('Address'))],
41-
tsCodegen.namedType('void'),
42-
`
43-
DataSourceTemplate.create('${name}', [address.toHex()])
44-
`,
45-
)
46-
47-
default:
48-
throw new Error(
49-
`Data sources with kind != 'ethereum/contract' are not supported yet`,
50-
)
51-
}
52-
}
53-
54-
_generateCreateWithContextMethod() {
55-
let name = this.template.get('name')
56-
let kind = this.template.get('kind')
57-
58-
switch (kind) {
59-
case 'ethereum/contract':
60-
return tsCodegen.staticMethod(
61-
'createWithContext',
62-
[
63-
tsCodegen.param('address', tsCodegen.namedType('Address')),
64-
tsCodegen.param('context', tsCodegen.namedType('DataSourceContext')),
65-
],
66-
tsCodegen.namedType('void'),
67-
`
68-
DataSourceTemplate.createWithContext('${name}', [address.toHex()], context)
69-
`,
70-
)
71-
72-
default:
73-
throw new Error(
74-
`Data sources with kind != 'ethereum/contract' are not supported yet`,
75-
)
76-
}
77-
}
7836
}

0 commit comments

Comments
 (0)