@graphprotocol/graph-cli 0.22.3 → 0.23.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.
- package/README.md +83 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/.travis.yml +4 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/ethereum.ts +9 -15
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/near.ts +402 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/collections.ts +125 -4
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/eager_offset.ts +2 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/json.ts +14 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/numbers.ts +58 -16
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/value.ts +2 -5
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/global/global.ts +108 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/helper-functions.ts +5 -5
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/index.ts +6 -15
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/package.json +5 -2
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/bigInt.ts +138 -108
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/bytes.ts +31 -20
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/test.js +120 -88
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/tsconfig.json +2 -2
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/types/tsconfig.base.json +3 -0
- package/examples/basic-event-handlers/node_modules/websocket/build/Makefile +2 -2
- package/examples/basic-event-handlers/package.json +1 -1
- package/examples/basic-event-handlers/yarn.lock +4 -4
- package/examples/example-subgraph/package.json +1 -1
- package/examples/example-subgraph/yarn.lock +4 -4
- package/examples/near/.gitkeep +0 -0
- package/jest.config.js +2 -2
- package/manifest-schema.graphql +35 -2
- package/package.json +2 -6
- package/src/codegen/schema.js +1 -2
- package/src/codegen/template.js +9 -51
- package/src/codegen/typescript.js +7 -0
- package/src/command-helpers/compiler.js +6 -2
- package/src/command-helpers/data-sources.js +38 -0
- package/src/command-helpers/fs.js +8 -0
- package/src/commands/build.js +14 -0
- package/src/commands/codegen.js +8 -0
- package/src/commands/deploy.js +11 -8
- package/src/commands/init.js +35 -11
- package/src/commands/test.js +9 -4
- package/src/compiler/index.js +93 -76
- package/src/{abi.js → protocols/ethereum/abi.js} +0 -0
- package/src/{codegen → protocols/ethereum/codegen}/abi.js +9 -6
- package/src/{codegen → protocols/ethereum/codegen}/abi.test.js +1 -1
- package/src/protocols/ethereum/codegen/template.js +42 -0
- package/src/protocols/ethereum/subgraph.js +205 -0
- package/src/protocols/ethereum/type-generator.js +203 -0
- package/src/protocols/index.js +97 -0
- package/src/protocols/near/subgraph.js +42 -0
- package/src/scaffold.js +21 -4
- package/src/scaffold.test.js +1 -1
- package/src/subgraph.js +30 -252
- package/src/type-generator.js +31 -211
- package/src/validation/index.js +1 -0
- package/src/validation/manifest.js +73 -23
- package/src/validation/schema.js +6 -0
- package/subgraph-ethereum.yaml +134 -0
- package/subgraph-near.yaml +134 -0
- package/tests/cli/globalSetup.js +6 -0
- package/tests/cli/globalTeardown.js +6 -0
- package/tests/cli/init.test.js +1 -1
- package/tests/cli/util.js +17 -8
- package/tests/cli/validation/near-is-valid/mapping.ts +0 -0
- package/tests/cli/validation/near-is-valid/schema.graphql +8 -0
- package/tests/cli/validation/near-is-valid/subgraph.yaml +21 -0
- package/tests/cli/validation.test.js +8 -0
package/src/validation/index.js
CHANGED
|
@@ -51,13 +51,24 @@ const validators = immutable.fromJS({
|
|
|
51
51
|
ScalarTypeDefinition: (value, ctx) =>
|
|
52
52
|
validators.get(ctx.getIn(['type', 'name', 'value']))(value, ctx),
|
|
53
53
|
|
|
54
|
-
UnionTypeDefinition: (value, ctx) =>
|
|
55
|
-
ctx
|
|
54
|
+
UnionTypeDefinition: (value, ctx) => {
|
|
55
|
+
const unionVariants = ctx
|
|
56
56
|
.getIn(['type', 'types'])
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
|
|
58
|
+
let errors = List()
|
|
59
|
+
|
|
60
|
+
for (const variantType of unionVariants) {
|
|
61
|
+
const variantErrors = validateValue(value, ctx.set('type', variantType))
|
|
62
|
+
// No errors found, union variant matched, early return
|
|
63
|
+
if (variantErrors.isEmpty()) {
|
|
64
|
+
return List()
|
|
65
|
+
}
|
|
66
|
+
errors = errors.push(variantErrors)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Return errors from variant that matched the most
|
|
70
|
+
return List(errors.minBy(variantErrors => variantErrors.count()))
|
|
71
|
+
},
|
|
61
72
|
|
|
62
73
|
NamedType: (value, ctx) =>
|
|
63
74
|
validateValue(
|
|
@@ -199,9 +210,8 @@ const validateValue = (value, ctx) => {
|
|
|
199
210
|
}
|
|
200
211
|
}
|
|
201
212
|
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
.filter(dataSource => dataSource.kind === 'ethereum/contract')
|
|
213
|
+
const validateDataSourceForNetwork = (dataSources, protocol) =>
|
|
214
|
+
dataSources.filter(dataSource => protocol.isValidKindName(dataSource.kind))
|
|
205
215
|
.reduce(
|
|
206
216
|
(networks, dataSource) =>
|
|
207
217
|
networks.update(dataSource.network, dataSources =>
|
|
@@ -210,28 +220,37 @@ const validateDataSourceNetworks = value => {
|
|
|
210
220
|
immutable.OrderedMap(),
|
|
211
221
|
)
|
|
212
222
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
223
|
+
const validateDataSourceNetworks = (value, protocol) => {
|
|
224
|
+
const dataSources = [...value.dataSources, ...(value.templates || [])]
|
|
225
|
+
|
|
226
|
+
// Networks found valid for a protocol.
|
|
227
|
+
// By searching through all data sources and templates.
|
|
228
|
+
const networks = validateDataSourceForNetwork(dataSources, protocol)
|
|
229
|
+
|
|
230
|
+
if (networks.size > 1) {
|
|
231
|
+
return immutable.fromJS([
|
|
232
|
+
{
|
|
233
|
+
path: [],
|
|
234
|
+
message: `Conflicting networks used in data sources and templates:
|
|
218
235
|
${networks
|
|
219
236
|
.map(
|
|
220
237
|
(dataSources, network) =>
|
|
221
|
-
|
|
238
|
+
` ${
|
|
222
239
|
network === undefined
|
|
223
240
|
? 'Data sources and templates having no network set'
|
|
224
|
-
|
|
225
|
-
|
|
241
|
+
: `Data sources and templates using '${network}'`
|
|
242
|
+
}:\n${dataSources.map(ds => ` - ${ds}`).join('\n')}`,
|
|
226
243
|
)
|
|
227
244
|
.join('\n')}
|
|
228
245
|
Recommendation: Make all data sources and templates use the same network name.`,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
246
|
+
},
|
|
247
|
+
])
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return List()
|
|
232
251
|
}
|
|
233
252
|
|
|
234
|
-
const validateManifest = (value, type, schema, { resolveFile }) => {
|
|
253
|
+
const validateManifest = (value, type, schema, protocol, { resolveFile }) => {
|
|
235
254
|
// Validate manifest using the GraphQL schema that defines its structure
|
|
236
255
|
let errors =
|
|
237
256
|
value !== null && value !== undefined
|
|
@@ -260,7 +279,38 @@ const validateManifest = (value, type, schema, { resolveFile }) => {
|
|
|
260
279
|
|
|
261
280
|
// Validate that all data sources are for the same `network` (this includes
|
|
262
281
|
// _no_ network at all)
|
|
263
|
-
return validateDataSourceNetworks(value)
|
|
282
|
+
return validateDataSourceNetworks(value, protocol)
|
|
264
283
|
}
|
|
265
284
|
|
|
266
|
-
|
|
285
|
+
const validateContractValues = (manifest, protocol, fieldName, validator, errorMessage) =>
|
|
286
|
+
manifest
|
|
287
|
+
.get('dataSources')
|
|
288
|
+
.filter(dataSource => protocol.isValidKindName(dataSource.get('kind')))
|
|
289
|
+
.reduce((errors, dataSource, dataSourceIndex) => {
|
|
290
|
+
let path = ['dataSources', dataSourceIndex, 'source', fieldName]
|
|
291
|
+
|
|
292
|
+
// No need to validate if the source has no contract field
|
|
293
|
+
if (!dataSource.get('source').has(fieldName)) {
|
|
294
|
+
return errors
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
let contractValue = dataSource.getIn(['source', fieldName])
|
|
298
|
+
|
|
299
|
+
// Validate whether the contract is valid
|
|
300
|
+
if (validator(contractValue)) {
|
|
301
|
+
return errors
|
|
302
|
+
} else {
|
|
303
|
+
return errors.push(
|
|
304
|
+
immutable.fromJS({
|
|
305
|
+
path,
|
|
306
|
+
message: `\
|
|
307
|
+
Contract ${fieldName} is invalid: ${contractValue}${errorMessage ? `\n${errorMessage}` : ''}`,
|
|
308
|
+
}),
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
}, immutable.List())
|
|
312
|
+
|
|
313
|
+
module.exports = {
|
|
314
|
+
validateManifest,
|
|
315
|
+
validateContractValues,
|
|
316
|
+
}
|
package/src/validation/schema.js
CHANGED
|
@@ -20,6 +20,12 @@ const BUILTIN_SCALAR_TYPES = [
|
|
|
20
20
|
const TYPE_SUGGESTIONS = [
|
|
21
21
|
['Address', 'Bytes'],
|
|
22
22
|
['address', 'Bytes'],
|
|
23
|
+
['Account', 'String'],
|
|
24
|
+
['account', 'String'],
|
|
25
|
+
['AccountId', 'String'],
|
|
26
|
+
['AccountID', 'String'],
|
|
27
|
+
['accountId', 'String'],
|
|
28
|
+
['accountid', 'String'],
|
|
23
29
|
['bytes', 'Bytes'],
|
|
24
30
|
['string', 'String'],
|
|
25
31
|
['bool', 'Boolean'],
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
specVersion: 0.0.2
|
|
2
|
+
schema:
|
|
3
|
+
file: ./schema.graphql
|
|
4
|
+
dataSources:
|
|
5
|
+
- kind: ethereum/contract
|
|
6
|
+
name: NiftyInk
|
|
7
|
+
network: xdai
|
|
8
|
+
source:
|
|
9
|
+
address: "0x49dE55fbA08af88f55EB797a456fdf76B151c8b0"
|
|
10
|
+
abi: NiftyInk
|
|
11
|
+
startBlock: 11296636
|
|
12
|
+
mapping:
|
|
13
|
+
kind: ethereum/events
|
|
14
|
+
apiVersion: 0.0.5
|
|
15
|
+
language: wasm/assemblyscript
|
|
16
|
+
entities:
|
|
17
|
+
- Ink
|
|
18
|
+
- Artist
|
|
19
|
+
- InkNumberLookUp
|
|
20
|
+
abis:
|
|
21
|
+
- name: NiftyInk
|
|
22
|
+
file: ./abis/NiftyInk.json
|
|
23
|
+
eventHandlers:
|
|
24
|
+
- event: newInk(uint256,indexed address,string,string,uint256)
|
|
25
|
+
handler: handlenewInk
|
|
26
|
+
callHandlers:
|
|
27
|
+
- function: setPrice(string,uint256)
|
|
28
|
+
handler: handleSetPrice
|
|
29
|
+
- function: setPriceFromSignature(string,uint256,bytes)
|
|
30
|
+
handler: handleSetPriceFromSignature
|
|
31
|
+
file: ./src/mapping.ts
|
|
32
|
+
- kind: ethereum/contract
|
|
33
|
+
name: NiftyToken
|
|
34
|
+
network: xdai
|
|
35
|
+
source:
|
|
36
|
+
address: "0xCF964c89f509a8c0Ac36391c5460dF94B91daba5"
|
|
37
|
+
abi: NiftyToken
|
|
38
|
+
startBlock: 11296637
|
|
39
|
+
mapping:
|
|
40
|
+
kind: ethereum/events
|
|
41
|
+
apiVersion: 0.0.5
|
|
42
|
+
language: wasm/assemblyscript
|
|
43
|
+
entities:
|
|
44
|
+
- Ink
|
|
45
|
+
- Token
|
|
46
|
+
- Sale
|
|
47
|
+
- Transfer
|
|
48
|
+
abis:
|
|
49
|
+
- name: NiftyToken
|
|
50
|
+
file: ./abis/NiftyToken.json
|
|
51
|
+
- name: NiftyInk
|
|
52
|
+
file: ./abis/NiftyInk.json
|
|
53
|
+
eventHandlers:
|
|
54
|
+
- event: Transfer(indexed address,indexed address,indexed uint256)
|
|
55
|
+
handler: handleTransfer
|
|
56
|
+
- event: boughtInk(uint256,string,address,uint256)
|
|
57
|
+
handler: handleBoughtInk
|
|
58
|
+
- event: mintedInk(uint256,string,address)
|
|
59
|
+
handler: handleMintedInk
|
|
60
|
+
callHandlers:
|
|
61
|
+
- function: setTokenPrice(uint256,uint256)
|
|
62
|
+
handler: handleSetTokenPrice
|
|
63
|
+
file: ./src/mapping.ts
|
|
64
|
+
# - kind: ethereum/contract
|
|
65
|
+
# name: NiftyMain
|
|
66
|
+
# network: mainnet
|
|
67
|
+
# source:
|
|
68
|
+
# address: "0xc02697c417DdAcfbe5EdbF23eDad956BC883F4fb"
|
|
69
|
+
# abi: NiftyMain
|
|
70
|
+
# startBlock: 10609660
|
|
71
|
+
# mapping:
|
|
72
|
+
# kind: ethereum/events
|
|
73
|
+
# apiVersion: 0.0.4
|
|
74
|
+
# language: wasm/assemblyscript
|
|
75
|
+
# entities:
|
|
76
|
+
# - Token
|
|
77
|
+
# - Transfer
|
|
78
|
+
# abis:
|
|
79
|
+
# - name: NiftyMain
|
|
80
|
+
# file: ./abis/NiftyMain.json
|
|
81
|
+
# - name: NiftyToken
|
|
82
|
+
# file: ./abis/NiftyToken.json
|
|
83
|
+
# eventHandlers:
|
|
84
|
+
# - event: Transfer(indexed address,indexed address,indexed uint256)
|
|
85
|
+
# handler: handleTransfer
|
|
86
|
+
# - event: mintedInk(uint256,string,address)
|
|
87
|
+
# handler: handleMintedOnMain
|
|
88
|
+
# file: ./src/mapping.ts
|
|
89
|
+
- kind: ethereum/contract
|
|
90
|
+
name: NiftyMediator
|
|
91
|
+
network: xdai
|
|
92
|
+
source:
|
|
93
|
+
address: "0x73cA9C4e72fF109259cf7374F038faf950949C51"
|
|
94
|
+
abi: NiftyMediator
|
|
95
|
+
startBlock: 11296637
|
|
96
|
+
mapping:
|
|
97
|
+
kind: ethereum/events
|
|
98
|
+
apiVersion: 0.0.5
|
|
99
|
+
language: wasm/assemblyscript
|
|
100
|
+
entities:
|
|
101
|
+
- Token
|
|
102
|
+
abis:
|
|
103
|
+
- name: NiftyMediator
|
|
104
|
+
file: ./abis/NiftyMediator.json
|
|
105
|
+
- name: NiftyToken
|
|
106
|
+
file: ./abis/NiftyToken.json
|
|
107
|
+
eventHandlers:
|
|
108
|
+
- event: tokenSentViaBridge(uint256,bytes32)
|
|
109
|
+
handler: handleTokenSentViaBridge
|
|
110
|
+
- event: newPrice(uint256)
|
|
111
|
+
handler: handleNewRelayPrice
|
|
112
|
+
file: ./src/mapping.ts
|
|
113
|
+
- kind: ethereum/contract
|
|
114
|
+
name: Liker
|
|
115
|
+
network: xdai
|
|
116
|
+
source:
|
|
117
|
+
address: "0xBD0621dcb64e1EEd503f709422b019B2fA197aF6"
|
|
118
|
+
abi: Liker
|
|
119
|
+
startBlock: 11296637
|
|
120
|
+
mapping:
|
|
121
|
+
kind: ethereum/events
|
|
122
|
+
apiVersion: 0.0.5
|
|
123
|
+
language: wasm/assemblyscript
|
|
124
|
+
entities:
|
|
125
|
+
- InkLookUp
|
|
126
|
+
- Like
|
|
127
|
+
- Ink
|
|
128
|
+
abis:
|
|
129
|
+
- name: Liker
|
|
130
|
+
file: ./abis/Liker.json
|
|
131
|
+
eventHandlers:
|
|
132
|
+
- event: liked(uint256,address,uint256,uint256,address)
|
|
133
|
+
handler: handleLikedInk
|
|
134
|
+
file: ./src/mapping.ts
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
specVersion: 0.0.2
|
|
2
|
+
schema:
|
|
3
|
+
file: ./schema.graphql
|
|
4
|
+
dataSources:
|
|
5
|
+
- kind: ethereum/contract
|
|
6
|
+
name: NiftyInk
|
|
7
|
+
network: xdai
|
|
8
|
+
source:
|
|
9
|
+
address: "0x49dE55fbA08af88f55EB797a456fdf76B151c8b0"
|
|
10
|
+
abi: NiftyInk
|
|
11
|
+
startBlock: 11296636
|
|
12
|
+
mapping:
|
|
13
|
+
kind: ethereum/events
|
|
14
|
+
apiVersion: 0.0.5
|
|
15
|
+
language: wasm/assemblyscript
|
|
16
|
+
entities:
|
|
17
|
+
- Ink
|
|
18
|
+
- Artist
|
|
19
|
+
- InkNumberLookUp
|
|
20
|
+
abis:
|
|
21
|
+
- name: NiftyInk
|
|
22
|
+
file: ./abis/NiftyInk.json
|
|
23
|
+
eventHandlers:
|
|
24
|
+
- event: newInk(uint256,indexed address,string,string,uint256)
|
|
25
|
+
handler: handlenewInk
|
|
26
|
+
callHandlers:
|
|
27
|
+
- function: setPrice(string,uint256)
|
|
28
|
+
handler: handleSetPrice
|
|
29
|
+
- function: setPriceFromSignature(string,uint256,bytes)
|
|
30
|
+
handler: handleSetPriceFromSignature
|
|
31
|
+
file: ./src/mapping.ts
|
|
32
|
+
- kind: ethereum/contract
|
|
33
|
+
name: NiftyToken
|
|
34
|
+
network: xdai
|
|
35
|
+
source:
|
|
36
|
+
address: "0xCF964c89f509a8c0Ac36391c5460dF94B91daba5"
|
|
37
|
+
abi: NiftyToken
|
|
38
|
+
startBlock: 11296637
|
|
39
|
+
mapping:
|
|
40
|
+
kind: ethereum/events
|
|
41
|
+
apiVersion: 0.0.5
|
|
42
|
+
language: wasm/assemblyscript
|
|
43
|
+
entities:
|
|
44
|
+
- Ink
|
|
45
|
+
- Token
|
|
46
|
+
- Sale
|
|
47
|
+
- Transfer
|
|
48
|
+
abis:
|
|
49
|
+
- name: NiftyToken
|
|
50
|
+
file: ./abis/NiftyToken.json
|
|
51
|
+
- name: NiftyInk
|
|
52
|
+
file: ./abis/NiftyInk.json
|
|
53
|
+
eventHandlers:
|
|
54
|
+
- event: Transfer(indexed address,indexed address,indexed uint256)
|
|
55
|
+
handler: handleTransfer
|
|
56
|
+
- event: boughtInk(uint256,string,address,uint256)
|
|
57
|
+
handler: handleBoughtInk
|
|
58
|
+
- event: mintedInk(uint256,string,address)
|
|
59
|
+
handler: handleMintedInk
|
|
60
|
+
callHandlers:
|
|
61
|
+
- function: setTokenPrice(uint256,uint256)
|
|
62
|
+
handler: handleSetTokenPrice
|
|
63
|
+
file: ./src/mapping.ts
|
|
64
|
+
# - kind: ethereum/contract
|
|
65
|
+
# name: NiftyMain
|
|
66
|
+
# network: mainnet
|
|
67
|
+
# source:
|
|
68
|
+
# address: "0xc02697c417DdAcfbe5EdbF23eDad956BC883F4fb"
|
|
69
|
+
# abi: NiftyMain
|
|
70
|
+
# startBlock: 10609660
|
|
71
|
+
# mapping:
|
|
72
|
+
# kind: ethereum/events
|
|
73
|
+
# apiVersion: 0.0.4
|
|
74
|
+
# language: wasm/assemblyscript
|
|
75
|
+
# entities:
|
|
76
|
+
# - Token
|
|
77
|
+
# - Transfer
|
|
78
|
+
# abis:
|
|
79
|
+
# - name: NiftyMain
|
|
80
|
+
# file: ./abis/NiftyMain.json
|
|
81
|
+
# - name: NiftyToken
|
|
82
|
+
# file: ./abis/NiftyToken.json
|
|
83
|
+
# eventHandlers:
|
|
84
|
+
# - event: Transfer(indexed address,indexed address,indexed uint256)
|
|
85
|
+
# handler: handleTransfer
|
|
86
|
+
# - event: mintedInk(uint256,string,address)
|
|
87
|
+
# handler: handleMintedOnMain
|
|
88
|
+
# file: ./src/mapping.ts
|
|
89
|
+
- kind: ethereum/contract
|
|
90
|
+
name: NiftyMediator
|
|
91
|
+
network: xdai
|
|
92
|
+
source:
|
|
93
|
+
address: "0x73cA9C4e72fF109259cf7374F038faf950949C51"
|
|
94
|
+
abi: NiftyMediator
|
|
95
|
+
startBlock: 11296637
|
|
96
|
+
mapping:
|
|
97
|
+
kind: ethereum/events
|
|
98
|
+
apiVersion: 0.0.5
|
|
99
|
+
language: wasm/assemblyscript
|
|
100
|
+
entities:
|
|
101
|
+
- Token
|
|
102
|
+
abis:
|
|
103
|
+
- name: NiftyMediator
|
|
104
|
+
file: ./abis/NiftyMediator.json
|
|
105
|
+
- name: NiftyToken
|
|
106
|
+
file: ./abis/NiftyToken.json
|
|
107
|
+
eventHandlers:
|
|
108
|
+
- event: tokenSentViaBridge(uint256,bytes32)
|
|
109
|
+
handler: handleTokenSentViaBridge
|
|
110
|
+
- event: newPrice(uint256)
|
|
111
|
+
handler: handleNewRelayPrice
|
|
112
|
+
file: ./src/mapping.ts
|
|
113
|
+
- kind: ethereum/contract
|
|
114
|
+
name: Liker
|
|
115
|
+
network: xdai
|
|
116
|
+
source:
|
|
117
|
+
address: "0xBD0621dcb64e1EEd503f709422b019B2fA197aF6"
|
|
118
|
+
abi: Liker
|
|
119
|
+
startBlock: 11296637
|
|
120
|
+
mapping:
|
|
121
|
+
kind: ethereum/events
|
|
122
|
+
apiVersion: 0.0.5
|
|
123
|
+
language: wasm/assemblyscript
|
|
124
|
+
entities:
|
|
125
|
+
- InkLookUp
|
|
126
|
+
- Like
|
|
127
|
+
- Ink
|
|
128
|
+
abis:
|
|
129
|
+
- name: Liker
|
|
130
|
+
file: ./abis/Liker.json
|
|
131
|
+
eventHandlers:
|
|
132
|
+
- event: liked(uint256,address,uint256,uint256,address)
|
|
133
|
+
handler: handleLikedInk
|
|
134
|
+
file: ./src/mapping.ts
|
package/tests/cli/init.test.js
CHANGED
package/tests/cli/util.js
CHANGED
|
@@ -13,7 +13,7 @@ const cliTest = (title, args, testPath, options) => {
|
|
|
13
13
|
let cwd =
|
|
14
14
|
options !== undefined && options.cwd ? options.cwd : resolvePath(`./${testPath}`)
|
|
15
15
|
|
|
16
|
-
let [exitCode, stdout, stderr] = await
|
|
16
|
+
let [exitCode, stdout, stderr] = await runGraphCli(args, cwd)
|
|
17
17
|
|
|
18
18
|
let expectedExitCode = undefined
|
|
19
19
|
if (options !== undefined && options.exitCode !== undefined) {
|
|
@@ -55,18 +55,14 @@ const cliTest = (title, args, testPath, options) => {
|
|
|
55
55
|
)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const
|
|
59
|
-
// Resolve the path to graph.js
|
|
60
|
-
let graphCli = path.join(__dirname, '..', '..', 'bin', 'graph')
|
|
61
|
-
|
|
58
|
+
const runCommand = async (command, args = [], cwd = process.cwd()) => {
|
|
62
59
|
// Make sure to set an absolute working directory
|
|
63
60
|
cwd = cwd[0] !== '/' ? path.resolve(__dirname, cwd) : cwd
|
|
64
61
|
|
|
65
62
|
return new Promise((resolve, reject) => {
|
|
66
63
|
let stdout = ''
|
|
67
64
|
let stderr = ''
|
|
68
|
-
const
|
|
69
|
-
const child = spawn(command, { cwd })
|
|
65
|
+
const child = spawn(`${command} ${args.join(' ')}`, { cwd })
|
|
70
66
|
|
|
71
67
|
child.on('error', error => {
|
|
72
68
|
reject(error)
|
|
@@ -86,7 +82,20 @@ const runCli = async (args = [], cwd = process.cwd()) => {
|
|
|
86
82
|
})
|
|
87
83
|
}
|
|
88
84
|
|
|
85
|
+
const runGraphCli = async (args, cwd) => {
|
|
86
|
+
// Resolve the path to graph.js
|
|
87
|
+
let graphCli = path.join(__dirname, '..', '..', 'bin', 'graph')
|
|
88
|
+
|
|
89
|
+
return await runCommand(graphCli, args, cwd)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const npmLinkCli = () => runCommand('npm', ['link'])
|
|
93
|
+
|
|
94
|
+
const npmUnlinkCli = () => runCommand('npm', ['unlink'])
|
|
95
|
+
|
|
89
96
|
module.exports = {
|
|
90
97
|
cliTest,
|
|
91
|
-
|
|
98
|
+
npmLinkCli,
|
|
99
|
+
npmUnlinkCli,
|
|
100
|
+
runGraphCli,
|
|
92
101
|
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
specVersion: 0.0.1
|
|
2
|
+
repository: https://github.com/graphprotocol/near-subgraph
|
|
3
|
+
description: NEAR subgraph
|
|
4
|
+
schema:
|
|
5
|
+
file: ./schema.graphql
|
|
6
|
+
dataSources:
|
|
7
|
+
- kind: near
|
|
8
|
+
name: NearSubgraph
|
|
9
|
+
source:
|
|
10
|
+
account: wnear.flux-dev
|
|
11
|
+
startBlock: 1
|
|
12
|
+
mapping:
|
|
13
|
+
apiVersion: 0.0.5
|
|
14
|
+
language: wasm/assemblyscript
|
|
15
|
+
file: ./mapping.ts
|
|
16
|
+
entities:
|
|
17
|
+
- ExampleEntity
|
|
18
|
+
blockHandlers:
|
|
19
|
+
- handler: handleNewBlock
|
|
20
|
+
receiptHandlers:
|
|
21
|
+
- handler: handleReceipt
|
|
@@ -144,6 +144,14 @@ describe('Validation', () => {
|
|
|
144
144
|
exitCode: 1,
|
|
145
145
|
},
|
|
146
146
|
)
|
|
147
|
+
cliTest(
|
|
148
|
+
'NEAR is a valid chain',
|
|
149
|
+
['codegen', '--skip-migrations'],
|
|
150
|
+
'validation/near-is-valid',
|
|
151
|
+
{
|
|
152
|
+
exitCode: 0,
|
|
153
|
+
},
|
|
154
|
+
)
|
|
147
155
|
cliTest(
|
|
148
156
|
'Deprecated template format gives nice error',
|
|
149
157
|
['codegen', '--skip-migrations'],
|