@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
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import yaml from 'js-yaml'
|
|
4
4
|
|
|
5
5
|
async function loadManifest(manifestFile) {
|
|
6
|
-
if(manifestFile.match(/.js$/)) {
|
|
6
|
+
if (manifestFile.match(/.js$/)) {
|
|
7
7
|
return require(path.resolve(manifestFile))
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
8
|
+
} else {
|
|
10
9
|
return yaml.safeLoad(await fs.readFile(manifestFile, 'utf-8'))
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
loadManifest,
|
|
16
|
-
}
|
|
13
|
+
export { loadManifest }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs-extra'
|
|
3
|
+
import yaml from 'js-yaml'
|
|
4
4
|
|
|
5
5
|
const getGraphTsVersion = async sourceDir => {
|
|
6
6
|
let graphTsPath
|
|
@@ -26,15 +26,10 @@ const getGraphTsVersion = async sourceDir => {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
let pkgJsonFile = path.join(
|
|
30
|
-
graphTsPath,
|
|
31
|
-
'package.json',
|
|
32
|
-
)
|
|
29
|
+
let pkgJsonFile = path.join(graphTsPath, 'package.json')
|
|
33
30
|
let data = await fs.readFile(pkgJsonFile)
|
|
34
31
|
let jsonData = JSON.parse(data)
|
|
35
32
|
return jsonData.version
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
getGraphTsVersion,
|
|
40
|
-
}
|
|
35
|
+
export { getGraphTsVersion }
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
import { withSpinner, step } from './command-helpers/spinner'
|
|
2
2
|
|
|
3
3
|
const MIGRATIONS = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import('./migrations/mapping_api_version_0_0_1'),
|
|
5
|
+
import('./migrations/mapping_api_version_0_0_2'),
|
|
6
|
+
import('./migrations/mapping_api_version_0_0_3'),
|
|
7
|
+
import('./migrations/mapping_api_version_0_0_4'),
|
|
8
|
+
import('./migrations/mapping_api_version_0_0_5'),
|
|
9
|
+
import('./migrations/spec_version_0_0_2'),
|
|
10
|
+
import('./migrations/spec_version_0_0_3'),
|
|
11
11
|
]
|
|
12
12
|
|
|
13
|
-
const applyMigrations = async options
|
|
13
|
+
export const applyMigrations = async (options: {
|
|
14
|
+
sourceDir: string
|
|
15
|
+
manifestFile: string
|
|
16
|
+
}) =>
|
|
14
17
|
await withSpinner(
|
|
15
18
|
`Apply migrations`,
|
|
16
19
|
`Failed to apply migrations`,
|
|
17
20
|
`Warnings while applying migraitons`,
|
|
18
21
|
async spinner => {
|
|
19
|
-
await MIGRATIONS.reduce(async (previousPromise,
|
|
22
|
+
await MIGRATIONS.reduce(async (previousPromise, migrationImport) => {
|
|
20
23
|
await previousPromise
|
|
21
|
-
|
|
24
|
+
const { default: migration } = await migrationImport
|
|
22
25
|
let skipHint = await migration.predicate(options)
|
|
23
26
|
if (typeof skipHint !== 'string' && skipHint) {
|
|
24
27
|
step(spinner, 'Apply migration:', migration.name)
|
|
@@ -33,7 +36,3 @@ const applyMigrations = async options =>
|
|
|
33
36
|
}, Promise.resolve())
|
|
34
37
|
},
|
|
35
38
|
)
|
|
36
|
-
|
|
37
|
-
module.exports = {
|
|
38
|
-
applyMigrations,
|
|
39
|
-
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import immutable from 'immutable'
|
|
2
|
+
import { Subgraph, SubgraphOptions } from '../subgraph'
|
|
3
|
+
|
|
4
|
+
export default class ArweaveSubgraph implements Subgraph {
|
|
5
|
+
manifest: SubgraphOptions['manifest']
|
|
6
|
+
resolveFile: SubgraphOptions['resolveFile']
|
|
7
|
+
protocol: SubgraphOptions['protocol']
|
|
8
|
+
|
|
9
|
+
constructor(options: SubgraphOptions = {}) {
|
|
10
|
+
this.manifest = options.manifest
|
|
11
|
+
this.resolveFile = options.resolveFile
|
|
12
|
+
this.protocol = options.protocol
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
validateManifest() {
|
|
16
|
+
return immutable.List()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
handlerTypes() {
|
|
20
|
+
return immutable.List(['blockHandlers', 'transactionHandlers'])
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import immutable from 'immutable'
|
|
3
|
+
import path from 'path'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import AbiCodeGenerator from './codegen/abi'
|
|
6
6
|
|
|
7
7
|
const TUPLE_ARRAY_PATTERN = /^tuple\[([0-9]*)\]$/
|
|
8
8
|
const TUPLE_MATRIX_PATTERN = /^tuple\[([0-9]*)\]\[([0-9]*)\]$/
|
|
@@ -40,7 +40,7 @@ const buildSignatureParameter = input => {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
export default class ABI {
|
|
44
44
|
constructor(name, file, data) {
|
|
45
45
|
this.name = name
|
|
46
46
|
this.file = file
|
|
@@ -78,14 +78,8 @@ module.exports = class ABI {
|
|
|
78
78
|
* - Multiple inputs and outputs: `example(uint256,(string,bytes32)):(bool,uint256)`
|
|
79
79
|
*/
|
|
80
80
|
functionSignature(fn) {
|
|
81
|
-
let inputs = fn
|
|
82
|
-
|
|
83
|
-
.map(buildSignatureParameter)
|
|
84
|
-
.join(',')
|
|
85
|
-
let outputs = fn
|
|
86
|
-
.get('outputs', [])
|
|
87
|
-
.map(buildSignatureParameter)
|
|
88
|
-
.join(',')
|
|
81
|
+
let inputs = fn.get('inputs', []).map(buildSignatureParameter).join(',')
|
|
82
|
+
let outputs = fn.get('outputs', []).map(buildSignatureParameter).join(',')
|
|
89
83
|
return `${fn.get('name')}(${inputs})${outputs.length > 0 ? `:(${outputs})` : ''}`
|
|
90
84
|
}
|
|
91
85
|
|