Skip to content

Commit d0b05a3

Browse files
committed
Fix tests
1 parent 2d1aa3b commit d0b05a3

File tree

9 files changed

+43
-63
lines changed

9 files changed

+43
-63
lines changed

examples/basic-event-handlers/build/subgraph.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
specVersion: 0.0.2
1+
specVersion: 0.0.5
22
description: Gravatar for Ethereum
33
repository: https://github.com/graphprotocol/example-subgraph
44
schema:
@@ -8,11 +8,11 @@ dataSources:
88
name: Gravity
99
network: test
1010
source:
11-
address: "0xCfEB869F69431e42cdB54A4F4f105C19C080A601"
11+
address: '0xCfEB869F69431e42cdB54A4F4f105C19C080A601'
1212
abi: Gravity
1313
mapping:
1414
kind: ethereum/events
15-
apiVersion: 0.0.5
15+
apiVersion: 0.0.7
1616
language: wasm/assemblyscript
1717
entities:
1818
- Gravatar

examples/basic-event-handlers/subgraph.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
specVersion: 0.0.2
1+
specVersion: 0.0.5
22
description: Gravatar for Ethereum
33
repository: https://github.com/graphprotocol/example-subgraph
44
schema:
@@ -12,7 +12,7 @@ dataSources:
1212
abi: Gravity
1313
mapping:
1414
kind: ethereum/events
15-
apiVersion: 0.0.5
15+
apiVersion: 0.0.7
1616
language: wasm/assemblyscript
1717
entities:
1818
- Gravatar

examples/example-subgraph/dist/subgraph.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
specVersion: 0.0.1
1+
specVersion: 0.0.5
22
description: example of a subgraph
33
repository: 'https://github.com/graphprotocol/graph-cli.git'
44
schema:
@@ -12,7 +12,7 @@ dataSources:
1212
abi: ExampleContract
1313
mapping:
1414
kind: ethereum/events
15-
apiVersion: 0.0.5
15+
apiVersion: 0.0.7
1616
language: wasm/assemblyscript
1717
file: ExampleSubgraph/ExampleSubgraph.wasm
1818
entities:

examples/example-subgraph/subgraph.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
specVersion: 0.0.2
2-
description: "example of a subgraph"
1+
specVersion: 0.0.5
2+
description: 'example of a subgraph'
33
repository: https://github.com/graphprotocol/graph-cli.git
44
schema:
55
file: ./schema.graphql
@@ -12,7 +12,7 @@ dataSources:
1212
abi: ExampleContract
1313
mapping:
1414
kind: ethereum/events
15-
apiVersion: 0.0.5
15+
apiVersion: 0.0.7
1616
language: wasm/assemblyscript
1717
file: ./src/mapping.ts
1818
entities:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphprotocol/graph-cli",
3-
"version": "0.35.0",
3+
"version": "0.35.0-best-practices",
44
"license": "(Apache-2.0 OR MIT)",
55
"description": "CLI for building for and deploying to The Graph",
66
"dependencies": {

src/protocols/ethereum/scaffold/manifest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const source = ({ contract, contractName }) => `
88

99
const mapping = ({ abi, contractName }) => `
1010
kind: ethereum/events
11-
apiVersion: 0.0.5
11+
apiVersion: 0.0.7
1212
language: wasm/assemblyscript
1313
entities:
1414
${abiEvents(abi)

src/scaffold/cosmos.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ const protocol = new Protocol('cosmos')
77
const scaffoldOptions = {
88
protocol,
99
network: 'cosmoshub-4',
10-
contractName: 'CosmosHub'
10+
contractName: 'CosmosHub',
1111
}
1212

1313
const scaffold = new Scaffold(scaffoldOptions)
1414

1515
describe('Cosmos subgraph scaffolding', () => {
1616
test('Manifest', () => {
17-
expect(
18-
scaffold.generateManifest(),
19-
).toEqual(`\
20-
specVersion: 0.0.1
17+
expect(scaffold.generateManifest()).toEqual(`\
18+
specVersion: 0.0.5
2119
schema:
2220
file: ./schema.graphql
2321
dataSources:

src/scaffold/index.js

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ const pkginfo = require('pkginfo')(module)
33
const { strings } = require('gluegun')
44

55
const GRAPH_CLI_VERSION = process.env.GRAPH_CLI_TESTS
6-
// JSON.stringify should remove this key, we will install the local
7-
// graph-cli for the tests using `npm link` instead of fetching from npm.
8-
? undefined
9-
// For scaffolding real subgraphs
10-
: `${module.exports.version}`
11-
12-
const {
13-
abiEvents,
14-
generateEventType,
15-
generateExampleEntityType,
16-
} = require('./schema')
6+
? // JSON.stringify should remove this key, we will install the local
7+
// graph-cli for the tests using `npm link` instead of fetching from npm.
8+
undefined
9+
: // For scaffolding real subgraphs
10+
`${module.exports.version}`
11+
12+
const { abiEvents, generateEventType, generateExampleEntityType } = require('./schema')
1713
const { generateEventIndexingHandlers } = require('./mapping')
1814
const { generateTestsFiles } = require('./tests')
1915
const { getSubgraphBasename } = require('../command-helpers/subgraph')
@@ -38,24 +34,23 @@ module.exports = class Scaffold {
3834
scripts: {
3935
codegen: 'graph codegen',
4036
build: 'graph build',
41-
deploy:
42-
`graph deploy ` +
43-
`--node ${this.node} ` +
44-
this.subgraphName,
37+
deploy: `graph deploy ` + `--node ${this.node} ` + this.subgraphName,
4538
'create-local': `graph create --node http://localhost:8020/ ${this.subgraphName}`,
4639
'remove-local': `graph remove --node http://localhost:8020/ ${this.subgraphName}`,
4740
'deploy-local':
4841
`graph deploy ` +
4942
`--node http://localhost:8020/ ` +
5043
`--ipfs http://localhost:5001 ` +
5144
this.subgraphName,
52-
'test': 'graph test',
45+
test: 'graph test',
5346
},
5447
dependencies: {
5548
'@graphprotocol/graph-cli': GRAPH_CLI_VERSION,
5649
'@graphprotocol/graph-ts': `0.28.1`,
5750
},
58-
devDependencies: this.protocol.hasEvents() ? { 'matchstick-as': `0.5.0`} : undefined,
51+
devDependencies: this.protocol.hasEvents()
52+
? { 'matchstick-as': `0.5.0` }
53+
: undefined,
5954
}),
6055
{ parser: 'json' },
6156
)
@@ -64,8 +59,9 @@ module.exports = class Scaffold {
6459
generateManifest() {
6560
const protocolManifest = this.protocol.getManifestScaffold()
6661

67-
return prettier.format(`
68-
specVersion: 0.0.1
62+
return prettier.format(
63+
`
64+
specVersion: 0.0.5
6965
schema:
7066
file: ./schema.graphql
7167
dataSources:
@@ -81,16 +77,11 @@ dataSources:
8177

8278
generateSchema() {
8379
const hasEvents = this.protocol.hasEvents()
84-
const events = hasEvents
85-
? abiEvents(this.abi).toJS()
86-
: []
80+
const events = hasEvents ? abiEvents(this.abi).toJS() : []
8781

8882
return prettier.format(
8983
hasEvents && this.indexEvents
90-
? events.map(
91-
event => generateEventType(event, this.protocol.name)
92-
)
93-
.join('\n\n')
84+
? events.map(event => generateEventType(event, this.protocol.name)).join('\n\n')
9485
: generateExampleEntityType(this.protocol, events),
9586
{
9687
parser: 'graphql',
@@ -110,18 +101,13 @@ dataSources:
110101

111102
generateMapping() {
112103
const hasEvents = this.protocol.hasEvents()
113-
const events = hasEvents
114-
? abiEvents(this.abi).toJS()
115-
: []
104+
const events = hasEvents ? abiEvents(this.abi).toJS() : []
116105

117106
const protocolMapping = this.protocol.getMappingScaffold()
118107

119108
return prettier.format(
120109
hasEvents && this.indexEvents
121-
? generateEventIndexingHandlers(
122-
events,
123-
this.contractName,
124-
)
110+
? generateEventIndexingHandlers(events, this.contractName)
125111
: protocolMapping.generatePlaceholderHandlers({
126112
...this,
127113
events,
@@ -133,21 +119,19 @@ dataSources:
133119
generateABIs() {
134120
return this.protocol.hasABIs()
135121
? {
136-
[`${this.contractName}.json`]: prettier.format(JSON.stringify(this.abi.data), {
137-
parser: 'json',
138-
}),
139-
}
122+
[`${this.contractName}.json`]: prettier.format(JSON.stringify(this.abi.data), {
123+
parser: 'json',
124+
}),
125+
}
140126
: undefined
141127
}
142128

143129
generateTests() {
144130
const hasEvents = this.protocol.hasEvents()
145-
const events = hasEvents
146-
? abiEvents(this.abi).toJS()
147-
: []
131+
const events = hasEvents ? abiEvents(this.abi).toJS() : []
148132

149133
return events.length > 0
150-
? generateTestsFiles(this.contractName, events, this.indexEvents)
134+
? generateTestsFiles(this.contractName, events, this.indexEvents)
151135
: undefined
152136
}
153137

src/scaffold/near.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ const scaffoldOptions = {
88
protocol,
99
contract: 'abc.def.near',
1010
network: 'near-mainnet',
11-
contractName: 'Contract'
11+
contractName: 'Contract',
1212
}
1313

1414
const scaffold = new Scaffold(scaffoldOptions)
1515

1616
describe('NEAR subgraph scaffolding', () => {
1717
test('Manifest', () => {
18-
expect(
19-
scaffold.generateManifest(),
20-
).toEqual(`\
21-
specVersion: 0.0.1
18+
expect(scaffold.generateManifest()).toEqual(`\
19+
specVersion: 0.0.5
2220
schema:
2321
file: ./schema.graphql
2422
dataSources:

0 commit comments

Comments
 (0)