@graphprotocol/graph-cli 0.37.2 → 0.37.3-alpha-20230110163550-d64bef6
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/CHANGELOG.md +7 -0
- package/babel.config.js +3 -0
- package/dist/bin.js +6 -0
- package/dist/cli.js +32 -0
- package/dist/codegen/schema.js +250 -0
- package/dist/codegen/schema.test.js +458 -0
- package/dist/codegen/template.js +65 -0
- package/dist/codegen/types/conversions.js +359 -0
- package/dist/codegen/types/index.js +71 -0
- package/dist/codegen/types/index.test.js +563 -0
- package/dist/codegen/typescript.js +200 -0
- package/dist/codegen/util.js +46 -0
- package/dist/codegen/util.test.js +93 -0
- package/dist/command-helpers/abi.js +78 -0
- package/dist/command-helpers/auth.js +77 -0
- package/dist/command-helpers/compiler.js +66 -0
- package/dist/command-helpers/data-sources.js +29 -0
- package/dist/command-helpers/fs.js +9 -0
- package/dist/command-helpers/gluegun.js +49 -0
- package/dist/command-helpers/ipfs.js +5 -0
- package/dist/command-helpers/jsonrpc.js +29 -0
- package/dist/command-helpers/network.js +93 -0
- package/dist/command-helpers/network.test.js +86 -0
- package/dist/command-helpers/node.js +40 -0
- package/dist/command-helpers/scaffold.js +112 -0
- package/dist/command-helpers/spinner.js +84 -0
- package/dist/command-helpers/studio.js +13 -0
- package/dist/command-helpers/studio.test.js +41 -0
- package/dist/command-helpers/subgraph.js +24 -0
- package/dist/command-helpers/version.js +74 -0
- package/dist/command-helpers/version.test.js +179 -0
- package/dist/commands/add.js +190 -0
- package/dist/commands/auth.js +127 -0
- package/dist/commands/build.js +140 -0
- package/dist/commands/codegen.js +135 -0
- package/dist/commands/create.js +86 -0
- package/dist/commands/deploy.js +334 -0
- package/dist/commands/init.js +788 -0
- package/dist/commands/local.js +387 -0
- package/dist/commands/remove.js +86 -0
- package/dist/commands/test.js +295 -0
- package/dist/compiler/asc.js +83 -0
- package/dist/compiler/index.js +474 -0
- package/dist/debug.js +16 -0
- package/dist/migrations/mapping_api_version_0_0_1.js +78 -0
- package/dist/migrations/mapping_api_version_0_0_2.js +76 -0
- package/dist/migrations/mapping_api_version_0_0_3.js +78 -0
- package/dist/migrations/mapping_api_version_0_0_4.js +80 -0
- package/dist/migrations/mapping_api_version_0_0_5.js +80 -0
- package/dist/migrations/spec_version_0_0_2.js +49 -0
- package/dist/migrations/spec_version_0_0_3.js +54 -0
- package/dist/migrations/util/load-manifest.js +18 -0
- package/dist/migrations/util/versions.js +29 -0
- package/dist/migrations.js +56 -0
- package/dist/protocols/arweave/manifest.graphql +57 -0
- package/dist/protocols/arweave/scaffold/manifest.js +18 -0
- package/dist/protocols/arweave/scaffold/mapping.js +52 -0
- package/dist/protocols/arweave/subgraph.js +23 -0
- package/dist/protocols/cosmos/manifest.graphql +76 -0
- package/dist/protocols/cosmos/scaffold/manifest.js +15 -0
- package/dist/protocols/cosmos/scaffold/mapping.js +38 -0
- package/dist/protocols/cosmos/subgraph.js +25 -0
- package/dist/protocols/ethereum/abi.js +140 -0
- package/dist/protocols/ethereum/codegen/abi.js +451 -0
- package/dist/protocols/ethereum/codegen/abi.test.js +328 -0
- package/dist/protocols/ethereum/codegen/template.js +50 -0
- package/dist/protocols/ethereum/contract.js +20 -0
- package/dist/protocols/ethereum/manifest.graphql +94 -0
- package/dist/protocols/ethereum/scaffold/manifest.js +32 -0
- package/dist/protocols/ethereum/scaffold/mapping.js +65 -0
- package/dist/protocols/ethereum/subgraph.js +171 -0
- package/dist/protocols/ethereum/type-generator.js +125 -0
- package/dist/protocols/index.js +268 -0
- package/dist/protocols/ipfs/codegen/file_template.js +50 -0
- package/dist/protocols/near/contract.js +41 -0
- package/dist/protocols/near/manifest.graphql +64 -0
- package/dist/protocols/near/scaffold/manifest.js +16 -0
- package/dist/protocols/near/scaffold/mapping.js +38 -0
- package/dist/protocols/near/subgraph.js +20 -0
- package/dist/protocols/subgraph.js +2 -0
- package/dist/protocols/substreams/manifest.graphql +45 -0
- package/dist/protocols/substreams/scaffold/manifest.js +12 -0
- package/dist/protocols/substreams/subgraph.js +23 -0
- package/dist/scaffold/cosmos.test.js +83 -0
- package/dist/scaffold/ethereum.test.js +505 -0
- package/dist/scaffold/index.js +128 -0
- package/dist/scaffold/mapping.js +61 -0
- package/dist/scaffold/near.test.js +86 -0
- package/dist/scaffold/schema.js +83 -0
- package/dist/scaffold/tests.js +175 -0
- package/dist/schema.js +54 -0
- package/dist/subgraph.js +249 -0
- package/dist/type-generator.js +224 -0
- package/dist/validation/contract.js +46 -0
- package/dist/validation/index.js +8 -0
- package/dist/validation/manifest.js +271 -0
- package/dist/validation/schema.js +796 -0
- package/dist/validation/schema.test.js +35 -0
- package/dist/watcher.js +79 -0
- package/jest.config.js +1 -1
- package/package.json +16 -9
- package/{bin/graph → src/bin.ts} +2 -1
- package/src/cli.ts +36 -0
- package/src/codegen/schema.js +23 -22
- package/src/codegen/schema.test.js +33 -27
- package/src/codegen/{template.js → template.ts} +8 -6
- package/src/codegen/types/conversions.ts +382 -0
- package/src/codegen/types/index.js +4 -7
- package/src/codegen/types/index.test.js +10 -4
- package/src/codegen/{typescript.js → typescript.ts} +44 -26
- package/src/codegen/util.js +1 -1
- package/src/codegen/util.test.js +5 -2
- package/src/command-helpers/abi.js +46 -30
- package/src/command-helpers/auth.js +6 -9
- package/src/command-helpers/compiler.js +4 -6
- package/src/command-helpers/data-sources.js +8 -11
- package/src/command-helpers/fs.ts +5 -0
- package/src/command-helpers/gluegun.js +2 -4
- package/src/command-helpers/ipfs.ts +3 -0
- package/src/command-helpers/{jsonrpc.js → jsonrpc.ts} +11 -16
- package/src/command-helpers/network.js +58 -44
- package/src/command-helpers/network.test.js +23 -19
- package/src/command-helpers/node.js +3 -7
- package/src/command-helpers/scaffold.js +34 -25
- package/src/command-helpers/{spinner.js → spinner.ts} +10 -10
- package/src/command-helpers/studio.test.js +61 -30
- package/src/command-helpers/studio.ts +20 -0
- package/src/command-helpers/{subgraph.js → subgraph.ts} +6 -6
- package/src/command-helpers/version.js +11 -16
- package/src/command-helpers/version.test.js +111 -82
- package/src/commands/add.js +49 -35
- package/src/commands/auth.js +13 -25
- package/src/commands/build.js +9 -9
- package/src/commands/codegen.js +12 -12
- package/src/commands/create.js +22 -22
- package/src/commands/deploy.js +39 -34
- package/src/commands/init.js +21 -24
- package/src/commands/local.js +15 -14
- package/src/commands/remove.js +22 -22
- package/src/commands/test.js +86 -70
- package/src/compiler/{asc.js → asc.ts} +29 -16
- package/src/compiler/index.js +18 -18
- package/src/{debug.js → debug.ts} +2 -2
- package/src/migrations/mapping_api_version_0_0_1.js +7 -7
- package/src/migrations/mapping_api_version_0_0_2.js +5 -5
- package/src/migrations/mapping_api_version_0_0_3.js +7 -7
- package/src/migrations/mapping_api_version_0_0_4.js +7 -7
- package/src/migrations/mapping_api_version_0_0_5.js +7 -7
- package/src/migrations/spec_version_0_0_2.js +5 -5
- package/src/migrations/spec_version_0_0_3.js +5 -5
- package/src/migrations/util/load-manifest.js +6 -9
- package/src/migrations/util/versions.js +5 -10
- package/src/{migrations.js → migrations.ts} +14 -15
- package/src/protocols/arweave/scaffold/manifest.js +1 -4
- package/src/protocols/arweave/scaffold/mapping.js +1 -3
- package/src/protocols/arweave/subgraph.ts +22 -0
- package/src/protocols/cosmos/scaffold/manifest.js +1 -4
- package/src/protocols/cosmos/scaffold/mapping.js +1 -3
- package/src/protocols/cosmos/subgraph.js +2 -2
- package/src/protocols/ethereum/abi.js +7 -13
- package/src/protocols/ethereum/codegen/abi.js +219 -222
- package/src/protocols/ethereum/codegen/abi.test.js +6 -6
- package/src/protocols/ethereum/codegen/template.js +3 -5
- package/src/protocols/ethereum/contract.js +3 -2
- package/src/protocols/ethereum/scaffold/manifest.js +4 -7
- package/src/protocols/ethereum/scaffold/mapping.js +4 -11
- package/src/protocols/ethereum/subgraph.js +21 -20
- package/src/protocols/ethereum/type-generator.js +24 -30
- package/src/protocols/{index.js → index.ts} +65 -46
- package/src/protocols/ipfs/codegen/file_template.js +2 -2
- package/src/protocols/near/{contract.js → contract.ts} +16 -12
- package/src/protocols/near/scaffold/manifest.js +2 -5
- package/src/protocols/near/scaffold/mapping.js +1 -3
- package/src/protocols/near/subgraph.js +3 -6
- package/src/protocols/subgraph.ts +12 -0
- package/src/protocols/substreams/scaffold/{manifest.js → manifest.ts} +2 -7
- package/src/protocols/substreams/subgraph.ts +22 -0
- package/src/scaffold/cosmos.test.js +3 -3
- package/src/scaffold/ethereum.test.js +4 -4
- package/src/scaffold/index.js +7 -7
- package/src/scaffold/mapping.js +3 -3
- package/src/scaffold/near.test.js +3 -3
- package/src/scaffold/schema.js +4 -4
- package/src/scaffold/tests.js +72 -58
- package/src/schema.ts +26 -0
- package/src/{subgraph.js → subgraph.ts} +80 -60
- package/src/type-generator.js +20 -20
- package/src/validation/contract.js +2 -6
- package/src/validation/index.js +1 -1
- package/src/validation/manifest.js +24 -22
- package/src/validation/schema.test.js +1 -1
- package/src/validation/{schema.js → schema.ts} +268 -221
- package/src/{watcher.js → watcher.ts} +23 -12
- package/tests/cli/globalSetup.js +2 -2
- package/tests/cli/globalTeardown.js +2 -2
- package/tests/cli/init.test.js +2 -2
- package/tests/cli/util.js +7 -13
- package/tsconfig.json +18 -0
- package/src/cli.js +0 -38
- package/src/codegen/types/conversions.js +0 -329
- package/src/command-helpers/fs.js +0 -8
- package/src/command-helpers/ipfs.js +0 -6
- package/src/command-helpers/studio.js +0 -15
- package/src/protocols/arweave/subgraph.js +0 -20
- package/src/protocols/substreams/subgraph.js +0 -17
- package/src/schema.js +0 -23
package/src/commands/add.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import * as toolbox from 'gluegun/toolbox'
|
|
3
|
+
import immutable from 'immutable'
|
|
4
|
+
import { withSpinner } from '../command-helpers/spinner'
|
|
5
|
+
import Subgraph from '../subgraph'
|
|
6
|
+
import Protocol from '../protocols'
|
|
7
|
+
import * as DataSourcesExtractor from '../command-helpers/data-sources'
|
|
8
|
+
import {
|
|
9
|
+
generateDataSource,
|
|
10
|
+
writeABI,
|
|
11
|
+
writeSchema,
|
|
12
|
+
writeMapping,
|
|
13
|
+
writeTestsFiles,
|
|
14
|
+
} from '../command-helpers/scaffold'
|
|
15
|
+
import { loadAbiFromEtherscan, loadAbiFromBlockScout } from '../command-helpers/abi'
|
|
16
|
+
import EthereumABI from '../protocols/ethereum/abi'
|
|
17
|
+
import { fixParameters } from '../command-helpers/gluegun'
|
|
18
|
+
import { updateNetworksFile } from '../command-helpers/network'
|
|
13
19
|
|
|
14
20
|
const HELP = `
|
|
15
21
|
${chalk.bold('graph add')} <address> [<subgraph-manifest default: "./subgraph.yaml">]
|
|
@@ -23,21 +29,15 @@ ${chalk.dim('Options:')}
|
|
|
23
29
|
-h, --help Show usage information
|
|
24
30
|
`
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
export default {
|
|
27
33
|
description: 'Adds a new datasource to a subgraph',
|
|
28
34
|
run: async toolbox => {
|
|
29
35
|
// Obtain tools
|
|
30
36
|
let { print, system } = toolbox
|
|
31
37
|
|
|
32
38
|
// Read CLI parameters
|
|
33
|
-
let {
|
|
34
|
-
|
|
35
|
-
contractName,
|
|
36
|
-
h,
|
|
37
|
-
help,
|
|
38
|
-
mergeEntities,
|
|
39
|
-
networkFile
|
|
40
|
-
} = toolbox.parameters.options
|
|
39
|
+
let { abi, contractName, h, help, mergeEntities, networkFile } =
|
|
40
|
+
toolbox.parameters.options
|
|
41
41
|
|
|
42
42
|
contractName = contractName || 'Contract'
|
|
43
43
|
|
|
@@ -54,7 +54,8 @@ module.exports = {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
let address = toolbox.parameters.first || toolbox.parameters.array[0]
|
|
57
|
-
let manifestPath =
|
|
57
|
+
let manifestPath =
|
|
58
|
+
toolbox.parameters.second || toolbox.parameters.array[1] || './subgraph.yaml'
|
|
58
59
|
|
|
59
60
|
// Show help text if requested
|
|
60
61
|
if (help || h) {
|
|
@@ -96,17 +97,32 @@ module.exports = {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
let { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(
|
|
100
|
+
let { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(
|
|
101
|
+
ethabi,
|
|
102
|
+
entities,
|
|
103
|
+
contractName,
|
|
104
|
+
mergeEntities,
|
|
105
|
+
)
|
|
100
106
|
ethabi.data = abiData
|
|
101
107
|
|
|
102
108
|
await writeABI(ethabi, contractName)
|
|
103
|
-
await writeSchema(
|
|
109
|
+
await writeSchema(
|
|
110
|
+
ethabi,
|
|
111
|
+
protocol,
|
|
112
|
+
result.getIn(['schema', 'file']),
|
|
113
|
+
collisionEntities,
|
|
114
|
+
)
|
|
104
115
|
await writeMapping(ethabi, protocol, contractName, collisionEntities)
|
|
105
116
|
await writeTestsFiles(ethabi, protocol, contractName)
|
|
106
117
|
|
|
107
118
|
let dataSources = result.get('dataSources')
|
|
108
|
-
let dataSource = await generateDataSource(
|
|
109
|
-
|
|
119
|
+
let dataSource = await generateDataSource(
|
|
120
|
+
protocol,
|
|
121
|
+
contractName,
|
|
122
|
+
network,
|
|
123
|
+
address,
|
|
124
|
+
ethabi,
|
|
125
|
+
)
|
|
110
126
|
|
|
111
127
|
// Handle the collisions edge case by copying another data source yaml data
|
|
112
128
|
if (mergeEntities && onlyCollisions) {
|
|
@@ -126,7 +142,7 @@ module.exports = {
|
|
|
126
142
|
await Subgraph.write(result, manifestPath)
|
|
127
143
|
|
|
128
144
|
// Update networks.json
|
|
129
|
-
const networksFile = networkFile ||
|
|
145
|
+
const networksFile = networkFile || './networks.json'
|
|
130
146
|
await updateNetworksFile(toolbox, network, contractName, address, networksFile)
|
|
131
147
|
|
|
132
148
|
// Detect Yarn and/or NPM
|
|
@@ -146,12 +162,12 @@ module.exports = {
|
|
|
146
162
|
'Warning during codegen',
|
|
147
163
|
async spinner => {
|
|
148
164
|
await system.run(yarn ? 'yarn codegen' : 'npm run codegen')
|
|
149
|
-
}
|
|
165
|
+
},
|
|
150
166
|
)
|
|
151
|
-
}
|
|
167
|
+
},
|
|
152
168
|
}
|
|
153
169
|
|
|
154
|
-
const getEntities =
|
|
170
|
+
const getEntities = manifest => {
|
|
155
171
|
let dataSources = manifest.result.get('dataSources', immutable.List())
|
|
156
172
|
let templates = manifest.result.get('templates', immutable.List())
|
|
157
173
|
|
|
@@ -161,13 +177,11 @@ const getEntities = (manifest) => {
|
|
|
161
177
|
.flatten()
|
|
162
178
|
}
|
|
163
179
|
|
|
164
|
-
const getContractNames =
|
|
180
|
+
const getContractNames = manifest => {
|
|
165
181
|
let dataSources = manifest.result.get('dataSources', immutable.List())
|
|
166
182
|
let templates = manifest.result.get('templates', immutable.List())
|
|
167
183
|
|
|
168
|
-
return dataSources
|
|
169
|
-
.concat(templates)
|
|
170
|
-
.map(dataSource => dataSource.get('name'))
|
|
184
|
+
return dataSources.concat(templates).map(dataSource => dataSource.get('name'))
|
|
171
185
|
}
|
|
172
186
|
|
|
173
187
|
const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntities) => {
|
|
@@ -179,7 +193,7 @@ const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntiti
|
|
|
179
193
|
for (let i = 0; i < abiData.size; i++) {
|
|
180
194
|
let dataRow = abiData.get(i).asMutable()
|
|
181
195
|
|
|
182
|
-
if (dataRow.get('type') === 'event'){
|
|
196
|
+
if (dataRow.get('type') === 'event') {
|
|
183
197
|
if (entities.indexOf(dataRow.get('name')) !== -1) {
|
|
184
198
|
if (entities.indexOf(`${contractName}${dataRow.get('name')}`) !== -1) {
|
|
185
199
|
print.error(`Contract name ('${contractName}')
|
package/src/commands/auth.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { saveDeployKey } from '../command-helpers/auth'
|
|
3
|
+
import { chooseNodeUrl } from '../command-helpers/node'
|
|
4
|
+
import { fixParameters } from '../command-helpers/gluegun'
|
|
5
5
|
|
|
6
6
|
const HELP = `
|
|
7
7
|
${chalk.bold('graph auth')} [options] ${chalk.bold('<node>')} ${chalk.bold(
|
|
8
|
-
'<deploy-key>'
|
|
8
|
+
'<deploy-key>',
|
|
9
9
|
)}
|
|
10
10
|
|
|
11
11
|
${chalk.dim('Options:')}
|
|
@@ -16,25 +16,18 @@ ${chalk.dim('Options:')}
|
|
|
16
16
|
-h, --help Show usage information
|
|
17
17
|
`
|
|
18
18
|
|
|
19
|
-
const processForm = async (
|
|
20
|
-
toolbox,
|
|
21
|
-
{
|
|
22
|
-
product,
|
|
23
|
-
studio,
|
|
24
|
-
node,
|
|
25
|
-
deployKey,
|
|
26
|
-
},
|
|
27
|
-
) => {
|
|
19
|
+
const processForm = async (toolbox, { product, studio, node, deployKey }) => {
|
|
28
20
|
const questions = [
|
|
29
21
|
{
|
|
30
22
|
type: 'select',
|
|
31
23
|
name: 'product',
|
|
32
24
|
message: 'Product for which to initialize',
|
|
33
25
|
choices: ['subgraph-studio', 'hosted-service'],
|
|
34
|
-
skip:
|
|
26
|
+
skip:
|
|
35
27
|
product === 'subgraph-studio' ||
|
|
36
28
|
product === 'hosted-service' ||
|
|
37
|
-
studio !== undefined ||
|
|
29
|
+
studio !== undefined ||
|
|
30
|
+
node !== undefined,
|
|
38
31
|
},
|
|
39
32
|
{
|
|
40
33
|
type: 'password',
|
|
@@ -52,19 +45,14 @@ const processForm = async (
|
|
|
52
45
|
}
|
|
53
46
|
}
|
|
54
47
|
|
|
55
|
-
|
|
48
|
+
export default {
|
|
56
49
|
description: 'Sets the deploy key to use when deploying to a Graph node',
|
|
57
50
|
run: async toolbox => {
|
|
58
51
|
// Obtain tools
|
|
59
52
|
let { filesystem, print, system } = toolbox
|
|
60
53
|
|
|
61
54
|
// Read CLI parameters
|
|
62
|
-
let {
|
|
63
|
-
product,
|
|
64
|
-
studio,
|
|
65
|
-
h,
|
|
66
|
-
help,
|
|
67
|
-
} = toolbox.parameters.options
|
|
55
|
+
let { product, studio, h, help } = toolbox.parameters.options
|
|
68
56
|
|
|
69
57
|
// Show help text if requested
|
|
70
58
|
if (help || h) {
|
|
@@ -77,7 +65,7 @@ module.exports = {
|
|
|
77
65
|
;[firstParam, secondParam] = fixParameters(toolbox.parameters, {
|
|
78
66
|
h,
|
|
79
67
|
help,
|
|
80
|
-
studio
|
|
68
|
+
studio,
|
|
81
69
|
})
|
|
82
70
|
} catch (e) {
|
|
83
71
|
print.error(e.message)
|
|
@@ -101,7 +89,7 @@ module.exports = {
|
|
|
101
89
|
product,
|
|
102
90
|
studio,
|
|
103
91
|
node,
|
|
104
|
-
deployKey
|
|
92
|
+
deployKey,
|
|
105
93
|
})
|
|
106
94
|
if (inputs === undefined) {
|
|
107
95
|
process.exit(1)
|
package/src/commands/build.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { createCompiler } from '../command-helpers/compiler'
|
|
3
|
+
import { fixParameters } from '../command-helpers/gluegun'
|
|
4
|
+
import { updateSubgraphNetwork } from '../command-helpers/network'
|
|
5
|
+
import * as DataSourcesExtractor from '../command-helpers/data-sources'
|
|
6
|
+
import Protocol from '../protocols'
|
|
7
|
+
import debug from '../debug'
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
const { fixParameters } = require('../command-helpers/gluegun')
|
|
5
|
-
const { updateSubgraphNetwork } = require('../command-helpers/network')
|
|
6
|
-
const DataSourcesExtractor = require('../command-helpers/data-sources')
|
|
7
|
-
const Protocol = require('../protocols')
|
|
8
|
-
|
|
9
|
-
let buildDebug = require('../debug')('graph-cli:build')
|
|
9
|
+
let buildDebug = debug('graph-cli:build')
|
|
10
10
|
|
|
11
11
|
const HELP = `
|
|
12
12
|
${chalk.bold('graph build')} [options] ${chalk.bold('[<subgraph-manifest>]')}
|
|
@@ -23,7 +23,7 @@ Options:
|
|
|
23
23
|
--network-file <path> Networks config file path (default: "./networks.json")
|
|
24
24
|
`
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
export default {
|
|
27
27
|
description: 'Builds a subgraph and (optionally) uploads it to IPFS',
|
|
28
28
|
run: async toolbox => {
|
|
29
29
|
// Obtain tools
|
package/src/commands/codegen.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import TypeGenerator from '../type-generator'
|
|
4
|
+
import Protocol from '../protocols'
|
|
5
|
+
import { fixParameters } from '../command-helpers/gluegun'
|
|
6
|
+
import * as DataSourcesExtractor from '../command-helpers/data-sources'
|
|
7
|
+
import debug from '../debug'
|
|
8
|
+
import {
|
|
9
9
|
assertManifestApiVersion,
|
|
10
10
|
assertGraphTsVersion,
|
|
11
|
-
}
|
|
11
|
+
} from '../command-helpers/version'
|
|
12
12
|
|
|
13
13
|
const HELP = `
|
|
14
14
|
${chalk.bold('graph codegen')} [options] ${chalk.bold('[<subgraph-manifest>]')}
|
|
@@ -21,9 +21,9 @@ Options:
|
|
|
21
21
|
-uc, --uncrashable-config <path> Directory for uncrashable config (default: ./uncrashable-config.yaml)
|
|
22
22
|
`
|
|
23
23
|
|
|
24
|
-
let codegenDebug =
|
|
24
|
+
let codegenDebug = debug('graph-cli:codegen')
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
export default {
|
|
27
27
|
description: 'Generates AssemblyScript types for a subgraph',
|
|
28
28
|
run: async toolbox => {
|
|
29
29
|
// Obtain tools
|
|
@@ -49,7 +49,7 @@ module.exports = {
|
|
|
49
49
|
outputDir = outputDir || o
|
|
50
50
|
watch = watch || w
|
|
51
51
|
uncrashable = uncrashable || u
|
|
52
|
-
uncrashable_config = uncrashableConfig || uc
|
|
52
|
+
let uncrashable_config = uncrashableConfig || uc
|
|
53
53
|
|
|
54
54
|
let manifest
|
|
55
55
|
try {
|
package/src/commands/create.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { URL } from 'url'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import { validateNodeUrl } from '../command-helpers/node'
|
|
4
|
+
import { identifyDeployKey as identifyAccessToken } from '../command-helpers/auth'
|
|
5
|
+
import { createJsonRpcClient } from '../command-helpers/jsonrpc'
|
|
6
6
|
|
|
7
7
|
const HELP = `
|
|
8
8
|
${chalk.bold('graph create')} ${chalk.dim('[options]')} ${chalk.bold('<subgraph-name>')}
|
|
@@ -14,7 +14,7 @@ ${chalk.dim('Options:')}
|
|
|
14
14
|
-g, --node <url> Graph node to create the subgraph in
|
|
15
15
|
`
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
export default {
|
|
18
18
|
description: 'Registers a subgraph name',
|
|
19
19
|
run: async toolbox => {
|
|
20
20
|
// Obtain tools
|
|
@@ -73,21 +73,21 @@ module.exports = {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
let spinner = print.spin(`Creating subgraph in Graph node: ${requestUrl}`)
|
|
76
|
-
client.request(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
res
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
76
|
+
client.request(
|
|
77
|
+
'subgraph_create',
|
|
78
|
+
{ name: subgraphName },
|
|
79
|
+
function (requestError, jsonRpcError, res) {
|
|
80
|
+
if (jsonRpcError) {
|
|
81
|
+
spinner.fail(`Error creating the subgraph: ${jsonRpcError.message}`)
|
|
82
|
+
process.exitCode = 1
|
|
83
|
+
} else if (requestError) {
|
|
84
|
+
spinner.fail(`HTTP error creating the subgraph: ${requestError.code}`)
|
|
85
|
+
process.exitCode = 1
|
|
86
|
+
} else {
|
|
87
|
+
spinner.stop()
|
|
88
|
+
print.success(`Created subgraph: ${subgraphName}`)
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
)
|
|
92
92
|
},
|
|
93
93
|
}
|
package/src/commands/deploy.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
const URL = require('url').URL
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
import { identifyDeployKey } from '../command-helpers/auth'
|
|
6
|
+
import { createCompiler } from '../command-helpers/compiler'
|
|
7
|
+
import { fixParameters } from '../command-helpers/gluegun'
|
|
8
|
+
import { createJsonRpcClient } from '../command-helpers/jsonrpc'
|
|
9
|
+
import { chooseNodeUrl } from '../command-helpers/node'
|
|
10
|
+
import { withSpinner } from '../command-helpers/spinner'
|
|
11
|
+
import { validateSubgraphName } from '../command-helpers/subgraph'
|
|
12
|
+
import { DEFAULT_IPFS_URL } from '../command-helpers/ipfs'
|
|
13
|
+
import {
|
|
14
|
+
assertManifestApiVersion,
|
|
15
|
+
assertGraphTsVersion,
|
|
16
|
+
} from '../command-helpers/version'
|
|
17
|
+
import * as DataSourcesExtractor from '../command-helpers/data-sources'
|
|
18
|
+
import { validateStudioNetwork } from '../command-helpers/studio'
|
|
19
|
+
import Protocol from '../protocols'
|
|
20
|
+
import { updateSubgraphNetwork } from '../command-helpers/network'
|
|
18
21
|
|
|
19
22
|
const HELP = `
|
|
20
23
|
${chalk.bold('graph deploy')} [options] ${chalk.bold('<subgraph-name>')} ${chalk.bold(
|
|
@@ -40,15 +43,7 @@ Options:
|
|
|
40
43
|
--network-file <path> Networks config file path (default: "./networks.json")
|
|
41
44
|
`
|
|
42
45
|
|
|
43
|
-
const processForm = async (
|
|
44
|
-
toolbox,
|
|
45
|
-
{
|
|
46
|
-
product,
|
|
47
|
-
studio,
|
|
48
|
-
node,
|
|
49
|
-
versionLabel,
|
|
50
|
-
},
|
|
51
|
-
) => {
|
|
46
|
+
const processForm = async (toolbox, { product, studio, node, versionLabel }) => {
|
|
52
47
|
const questions = [
|
|
53
48
|
{
|
|
54
49
|
type: 'select',
|
|
@@ -58,7 +53,8 @@ const processForm = async (
|
|
|
58
53
|
skip:
|
|
59
54
|
product === 'subgraph-studio' ||
|
|
60
55
|
product === 'hosted-service' ||
|
|
61
|
-
studio !== undefined ||
|
|
56
|
+
studio !== undefined ||
|
|
57
|
+
node !== undefined,
|
|
62
58
|
},
|
|
63
59
|
{
|
|
64
60
|
type: 'input',
|
|
@@ -76,7 +72,7 @@ const processForm = async (
|
|
|
76
72
|
}
|
|
77
73
|
}
|
|
78
74
|
|
|
79
|
-
|
|
75
|
+
export default {
|
|
80
76
|
description: 'Deploys the subgraph to a Graph node',
|
|
81
77
|
run: async toolbox => {
|
|
82
78
|
// Obtain tools
|
|
@@ -111,7 +107,7 @@ module.exports = {
|
|
|
111
107
|
// Support both long and short option variants
|
|
112
108
|
help = help || h
|
|
113
109
|
ipfs = ipfs || i || DEFAULT_IPFS_URL
|
|
114
|
-
headers = headers || hdr ||
|
|
110
|
+
headers = headers || hdr || '{}'
|
|
115
111
|
node = node || g
|
|
116
112
|
outputDir = outputDir || o
|
|
117
113
|
watch = watch || w
|
|
@@ -120,7 +116,7 @@ module.exports = {
|
|
|
120
116
|
try {
|
|
121
117
|
headers = JSON.parse(headers)
|
|
122
118
|
} catch (e) {
|
|
123
|
-
print.error(
|
|
119
|
+
print.error('Please make sure headers is a valid JSON value')
|
|
124
120
|
process.exitCode = 1
|
|
125
121
|
return
|
|
126
122
|
}
|
|
@@ -132,7 +128,7 @@ module.exports = {
|
|
|
132
128
|
help,
|
|
133
129
|
w,
|
|
134
130
|
watch,
|
|
135
|
-
studio
|
|
131
|
+
studio,
|
|
136
132
|
})
|
|
137
133
|
} catch (e) {
|
|
138
134
|
print.error(e.message)
|
|
@@ -149,7 +145,7 @@ module.exports = {
|
|
|
149
145
|
networkFile =
|
|
150
146
|
networkFile !== undefined && networkFile !== ''
|
|
151
147
|
? networkFile
|
|
152
|
-
: filesystem.resolve(
|
|
148
|
+
: filesystem.resolve('networks.json')
|
|
153
149
|
|
|
154
150
|
try {
|
|
155
151
|
const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest)
|
|
@@ -190,7 +186,11 @@ module.exports = {
|
|
|
190
186
|
|
|
191
187
|
// Validate the subgraph name
|
|
192
188
|
if (!subgraphName) {
|
|
193
|
-
print.error(
|
|
189
|
+
print.error(
|
|
190
|
+
`No subgraph ${
|
|
191
|
+
product == 'subgraph-studio' || studio ? 'slug' : 'name'
|
|
192
|
+
} provided`,
|
|
193
|
+
)
|
|
194
194
|
print.info(HELP)
|
|
195
195
|
process.exitCode = 1
|
|
196
196
|
return
|
|
@@ -246,7 +246,7 @@ module.exports = {
|
|
|
246
246
|
outputDir,
|
|
247
247
|
outputFormat: 'wasm',
|
|
248
248
|
skipMigrations,
|
|
249
|
-
blockIpfsMethods: isStudio,
|
|
249
|
+
blockIpfsMethods: isStudio, // Network does not support publishing subgraphs with IPFS methods
|
|
250
250
|
protocol,
|
|
251
251
|
})
|
|
252
252
|
|
|
@@ -293,7 +293,12 @@ module.exports = {
|
|
|
293
293
|
// `Failed to deploy to Graph node ${requestUrl}`,
|
|
294
294
|
client.request(
|
|
295
295
|
'subgraph_deploy',
|
|
296
|
-
{
|
|
296
|
+
{
|
|
297
|
+
name: subgraphName,
|
|
298
|
+
ipfs_hash: ipfsHash,
|
|
299
|
+
version_label: versionLabel,
|
|
300
|
+
debug_fork: debugFork,
|
|
301
|
+
},
|
|
297
302
|
async (requestError, jsonRpcError, res) => {
|
|
298
303
|
if (jsonRpcError) {
|
|
299
304
|
spinner.fail(
|
package/src/commands/init.js
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const { abiEvents } = require('../scaffold/schema')
|
|
21
|
-
const { validateContract } = require('../validation')
|
|
22
|
-
const Protocol = require('../protocols')
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import os from 'os'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import * as toolbox from 'gluegun/toolbox'
|
|
5
|
+
import fs from 'fs'
|
|
6
|
+
import graphCli from '../cli'
|
|
7
|
+
import { getSubgraphBasename, validateSubgraphName } from '../command-helpers/subgraph'
|
|
8
|
+
import * as DataSourcesExtractor from '../command-helpers/data-sources'
|
|
9
|
+
import { validateStudioNetwork } from '../command-helpers/studio'
|
|
10
|
+
import { initNetworksConfig } from '../command-helpers/network'
|
|
11
|
+
import { withSpinner, step } from '../command-helpers/spinner'
|
|
12
|
+
import { fixParameters } from '../command-helpers/gluegun'
|
|
13
|
+
import { chooseNodeUrl } from '../command-helpers/node'
|
|
14
|
+
import { loadAbiFromEtherscan, loadAbiFromBlockScout } from '../command-helpers/abi'
|
|
15
|
+
import { generateScaffold, writeScaffold } from '../command-helpers/scaffold'
|
|
16
|
+
import { abiEvents } from '../scaffold/schema'
|
|
17
|
+
import { validateContract } from '../validation'
|
|
18
|
+
import Protocol from '../protocols'
|
|
19
|
+
import debug from '../debug'
|
|
23
20
|
|
|
24
21
|
const protocolChoices = Array.from(Protocol.availableProtocols().keys())
|
|
25
22
|
const availableNetworks = Protocol.availableNetworks()
|
|
26
23
|
|
|
27
24
|
const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum/gravatar'
|
|
28
25
|
|
|
29
|
-
let initDebug =
|
|
26
|
+
let initDebug = debug('graph-cli:init')
|
|
30
27
|
|
|
31
28
|
const HELP = `
|
|
32
29
|
${chalk.bold('graph init')} [options] [subgraph-name] [directory]
|
|
@@ -303,7 +300,7 @@ const loadAbiFromFile = async (ABI, filename) => {
|
|
|
303
300
|
}
|
|
304
301
|
}
|
|
305
302
|
|
|
306
|
-
|
|
303
|
+
export default {
|
|
307
304
|
description: 'Creates a new subgraph with basic scaffolding',
|
|
308
305
|
run: async toolbox => {
|
|
309
306
|
// Obtain tools
|
package/src/commands/local.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import compose from 'docker-compose'
|
|
3
|
+
import http from 'http'
|
|
4
|
+
import net from 'net'
|
|
5
|
+
import tmp from 'tmp-promise'
|
|
6
|
+
import Docker from 'dockerode'
|
|
7
|
+
import path from 'path'
|
|
8
|
+
import stripAnsi from 'strip-ansi'
|
|
9
9
|
const spawn = require('child_process').spawn
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
import { fixParameters } from '../command-helpers/gluegun'
|
|
12
|
+
import { step, withSpinner } from '../command-helpers/spinner'
|
|
13
13
|
|
|
14
14
|
// Clean up temporary files even when an uncaught exception occurs
|
|
15
15
|
tmp.setGracefulCleanup()
|
|
@@ -32,8 +32,9 @@ Options:
|
|
|
32
32
|
--timeout Time to wait for service containers. (optional, defaults to 120000 milliseconds)
|
|
33
33
|
`
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
description:
|
|
35
|
+
export default {
|
|
36
|
+
description:
|
|
37
|
+
'Runs local tests against a Graph Node environment (using Ganache by default)',
|
|
37
38
|
run: async toolbox => {
|
|
38
39
|
// Obtain tools
|
|
39
40
|
let { filesystem, print } = toolbox
|
|
@@ -130,7 +131,7 @@ module.exports = {
|
|
|
130
131
|
skipWaitForEthereum,
|
|
131
132
|
skipWaitForIpfs,
|
|
132
133
|
skipWaitForPostgres,
|
|
133
|
-
|
|
134
|
+
timeout,
|
|
134
135
|
})
|
|
135
136
|
} catch (e) {
|
|
136
137
|
await stopTestEnvironment(tempdir)
|
|
@@ -454,7 +455,7 @@ const startGraphNode = async (standaloneNode, standaloneNodeArgs, nodeOutputChun
|
|
|
454
455
|
},
|
|
455
456
|
)
|
|
456
457
|
|
|
457
|
-
const waitForGraphNode = async
|
|
458
|
+
const waitForGraphNode = async timeout =>
|
|
458
459
|
await withSpinner(
|
|
459
460
|
`Wait for Graph node`,
|
|
460
461
|
`Failed to wait for Graph node`,
|