@graphprotocol/graph-cli 0.31.0 → 0.32.0
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
CHANGED
|
@@ -16,6 +16,7 @@ As of today, the command line interface supports the following commands:
|
|
|
16
16
|
- `graph auth` — Stores a [Graph Node](https://github.com/graphprotocol/graph-node) access token in the system's keychain.
|
|
17
17
|
- `graph local` — Runs tests against a [Graph Node](https://github.com/graphprotocol/graph-node) test environment (using Ganache by default).
|
|
18
18
|
- `graph test` — Downloads and runs the [Matchstick](https://github.com/LimeChain/matchstick) rust binary in order to test a subgraph.
|
|
19
|
+
- `graph add` - Adds a new datasource to the yaml file and writes the necessary changes to other files - schema.graphql, abi and mapping.
|
|
19
20
|
|
|
20
21
|
## How It Works
|
|
21
22
|
|
package/package.json
CHANGED
package/src/commands/add.js
CHANGED
|
@@ -19,12 +19,12 @@ ${chalk.dim('Options:')}
|
|
|
19
19
|
--abi <path> Path to the contract ABI (default: download from Etherscan)
|
|
20
20
|
--contract-name Name of the contract (default: Contract)
|
|
21
21
|
--merge-entities Whether to merge entities with the same name (default: false)
|
|
22
|
-
--network-file <path> Networks file (default: "./networks.json")
|
|
22
|
+
--network-file <path> Networks config file path (default: "./networks.json")
|
|
23
23
|
-h, --help Show usage information
|
|
24
24
|
`
|
|
25
25
|
|
|
26
26
|
module.exports = {
|
|
27
|
-
description: '
|
|
27
|
+
description: 'Adds a new datasource to a subgraph',
|
|
28
28
|
run: async toolbox => {
|
|
29
29
|
// Obtain tools
|
|
30
30
|
let { print, system } = toolbox
|
|
@@ -104,7 +104,7 @@ module.exports = {
|
|
|
104
104
|
await writeMapping(ethabi, protocol, contractName, collisionEntities)
|
|
105
105
|
|
|
106
106
|
let dataSources = result.get('dataSources')
|
|
107
|
-
let dataSource = await generateDataSource(protocol,
|
|
107
|
+
let dataSource = await generateDataSource(protocol,
|
|
108
108
|
contractName, network, address, ethabi)
|
|
109
109
|
|
|
110
110
|
// Handle the collisions edge case by copying another data source yaml data
|
|
@@ -181,12 +181,12 @@ const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntiti
|
|
|
181
181
|
if (dataRow.get('type') === 'event'){
|
|
182
182
|
if (entities.indexOf(dataRow.get('name')) !== -1) {
|
|
183
183
|
if (entities.indexOf(`${contractName}${dataRow.get('name')}`) !== -1) {
|
|
184
|
-
print.error(`Contract name ('${contractName}')
|
|
184
|
+
print.error(`Contract name ('${contractName}')
|
|
185
185
|
+ event name ('${dataRow.get('name')}') entity already exists.`)
|
|
186
186
|
process.exitCode = 1
|
|
187
187
|
return
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
|
|
190
190
|
if (mergeEntities) {
|
|
191
191
|
collisionEntities.push(dataRow.get('name'))
|
|
192
192
|
abiData = abiData.asImmutable().delete(i) // needs to be immutable when deleting, yes you read that right - https://github.com/immutable-js/immutable-js/issues/1901
|
package/src/commands/build.js
CHANGED
|
@@ -17,8 +17,8 @@ Options:
|
|
|
17
17
|
-t, --output-format <format> Output format for mappings (wasm, wast) (default: wasm)
|
|
18
18
|
--skip-migrations Skip subgraph migrations (default: false)
|
|
19
19
|
-w, --watch Regenerate types when subgraph files change (default: false)
|
|
20
|
-
--network <name> Network to use from networks
|
|
21
|
-
--network-file <path>
|
|
20
|
+
--network <name> Network configuration to use from the networks config file
|
|
21
|
+
--network-file <path> Networks config file path (default: "./networks.json")
|
|
22
22
|
`
|
|
23
23
|
|
|
24
24
|
module.exports = {
|
package/src/commands/deploy.js
CHANGED
|
@@ -14,6 +14,7 @@ const { assertManifestApiVersion, assertGraphTsVersion } = require('../command-h
|
|
|
14
14
|
const DataSourcesExtractor = require('../command-helpers/data-sources')
|
|
15
15
|
const { validateStudioNetwork } = require('../command-helpers/studio')
|
|
16
16
|
const Protocol = require('../protocols')
|
|
17
|
+
const { updateSubgraphNetwork } = require('../command-helpers/network')
|
|
17
18
|
|
|
18
19
|
const HELP = `
|
|
19
20
|
${chalk.bold('graph deploy')} [options] ${chalk.bold('<subgraph-name>')} ${chalk.bold(
|
|
@@ -35,6 +36,8 @@ Options:
|
|
|
35
36
|
-o, --output-dir <path> Output directory for build results (default: build/)
|
|
36
37
|
--skip-migrations Skip subgraph migrations (default: false)
|
|
37
38
|
-w, --watch Regenerate types when subgraph files change (default: false)
|
|
39
|
+
--network <name> Network configuration to use from the networks config file
|
|
40
|
+
--network-file <path> Networks config file path (default: "./networks.json")
|
|
38
41
|
`
|
|
39
42
|
|
|
40
43
|
const processForm = async (
|
|
@@ -52,7 +55,7 @@ const processForm = async (
|
|
|
52
55
|
name: 'product',
|
|
53
56
|
message: 'Product for which to deploy',
|
|
54
57
|
choices: ['subgraph-studio', 'hosted-service'],
|
|
55
|
-
skip:
|
|
58
|
+
skip:
|
|
56
59
|
product === 'subgraph-studio' ||
|
|
57
60
|
product === 'hosted-service' ||
|
|
58
61
|
studio !== undefined || node !== undefined,
|
|
@@ -101,6 +104,8 @@ module.exports = {
|
|
|
101
104
|
w,
|
|
102
105
|
watch,
|
|
103
106
|
debugFork,
|
|
107
|
+
network,
|
|
108
|
+
networkFile,
|
|
104
109
|
} = toolbox.parameters.options
|
|
105
110
|
|
|
106
111
|
// Support both long and short option variants
|
|
@@ -141,6 +146,10 @@ module.exports = {
|
|
|
141
146
|
manifest !== undefined && manifest !== ''
|
|
142
147
|
? manifest
|
|
143
148
|
: filesystem.resolve('subgraph.yaml')
|
|
149
|
+
networkFile =
|
|
150
|
+
networkFile !== undefined && networkFile !== ''
|
|
151
|
+
? networkFile
|
|
152
|
+
: filesystem.resolve("networks.json")
|
|
144
153
|
|
|
145
154
|
try {
|
|
146
155
|
const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest)
|
|
@@ -223,6 +232,11 @@ module.exports = {
|
|
|
223
232
|
return
|
|
224
233
|
}
|
|
225
234
|
|
|
235
|
+
if (network) {
|
|
236
|
+
let identifierName = protocol.getContract().identifierName()
|
|
237
|
+
await updateSubgraphNetwork(toolbox, manifest, network, networkFile, identifierName)
|
|
238
|
+
}
|
|
239
|
+
|
|
226
240
|
const isStudio = node.match(/studio/)
|
|
227
241
|
const isHostedService = node.match(/thegraph.com/) && !isStudio
|
|
228
242
|
|
|
@@ -10,6 +10,14 @@ dataSources:
|
|
|
10
10
|
source:
|
|
11
11
|
account: wnear.flux-dev
|
|
12
12
|
startBlock: 1
|
|
13
|
+
accounts:
|
|
14
|
+
prefixes:
|
|
15
|
+
- some-prefix
|
|
16
|
+
- a-prefix.with-dot
|
|
17
|
+
suffixes:
|
|
18
|
+
- suffix.near
|
|
19
|
+
- near
|
|
20
|
+
- another-suffix.testnet
|
|
13
21
|
mapping:
|
|
14
22
|
apiVersion: 0.0.5
|
|
15
23
|
language: wasm/assemblyscript
|