@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,8 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import chokidar from 'chokidar'
|
|
2
|
+
import path from 'path'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export default class Watcher {
|
|
5
|
+
private onReady: () => void
|
|
6
|
+
private onTrigger: (arg: any) => void
|
|
7
|
+
private onCollectFiles: () => Promise<string[]>
|
|
8
|
+
private onError: (error: Error) => void
|
|
9
|
+
private watcher: chokidar.FSWatcher | undefined
|
|
10
|
+
|
|
11
|
+
constructor(options: {
|
|
12
|
+
onReady: () => void
|
|
13
|
+
onTrigger: (arg: any) => void
|
|
14
|
+
onCollectFiles: () => Promise<string[]>
|
|
15
|
+
onError: (error: Error) => void
|
|
16
|
+
}) {
|
|
6
17
|
const { onReady, onTrigger, onCollectFiles, onError } = options
|
|
7
18
|
this.onReady = onReady
|
|
8
19
|
this.onTrigger = onTrigger
|
|
@@ -36,11 +47,11 @@ module.exports = class Watcher {
|
|
|
36
47
|
await onTrigger(undefined)
|
|
37
48
|
})
|
|
38
49
|
|
|
39
|
-
watcher.on('error', error => {
|
|
50
|
+
watcher.on('error', (error: any) => {
|
|
40
51
|
onError(error)
|
|
41
52
|
})
|
|
42
53
|
|
|
43
|
-
watcher.on('all', async (
|
|
54
|
+
watcher.on('all', async (_: any, file: any) => {
|
|
44
55
|
try {
|
|
45
56
|
// Collect watch all new files to watch
|
|
46
57
|
let newFiles = await onCollectFiles()
|
|
@@ -50,17 +61,17 @@ module.exports = class Watcher {
|
|
|
50
61
|
|
|
51
62
|
let watched = watcher.getWatched()
|
|
52
63
|
watchedFiles = Object.keys(watched).reduce(
|
|
53
|
-
(files, dirname) =>
|
|
54
|
-
watched[dirname].reduce((files, filename) => {
|
|
64
|
+
(files: string[], dirname: string) =>
|
|
65
|
+
watched[dirname].reduce((files: string[], filename: string) => {
|
|
55
66
|
files.push(path.resolve(path.join(dirname, filename)))
|
|
56
67
|
return files
|
|
57
68
|
}, files),
|
|
58
|
-
[]
|
|
69
|
+
[],
|
|
59
70
|
)
|
|
60
71
|
|
|
61
|
-
let diff = (xs, ys) => ({
|
|
62
|
-
added: ys.filter(y => xs.indexOf(y) < 0),
|
|
63
|
-
removed: xs.filter(x => ys.indexOf(x) < 0),
|
|
72
|
+
let diff = (xs: any[], ys: any[]) => ({
|
|
73
|
+
added: ys.filter((y: any) => xs.indexOf(y) < 0),
|
|
74
|
+
removed: xs.filter((x: any) => ys.indexOf(x) < 0),
|
|
64
75
|
})
|
|
65
76
|
|
|
66
77
|
// Diff previously watched files and new files; then remove and
|
package/tests/cli/globalSetup.js
CHANGED
package/tests/cli/init.test.js
CHANGED
package/tests/cli/util.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import spawn from 'spawn-command'
|
|
4
|
+
import stripAnsi from 'strip-ansi'
|
|
5
5
|
|
|
6
6
|
// Deletes folder if:
|
|
7
7
|
// - flag is true
|
|
@@ -22,8 +22,7 @@ const cliTest = (title, args, testPath, options = {}) => {
|
|
|
22
22
|
deleteDir(resolvePath(`./${testPath}`), options.deleteDir)
|
|
23
23
|
|
|
24
24
|
// Use the provided cwd if desired
|
|
25
|
-
let cwd =
|
|
26
|
-
options.cwd ? options.cwd : resolvePath(`./${testPath}`)
|
|
25
|
+
let cwd = options.cwd ? options.cwd : resolvePath(`./${testPath}`)
|
|
27
26
|
|
|
28
27
|
let [exitCode, stdout, stderr] = await runGraphCli(args, cwd)
|
|
29
28
|
|
|
@@ -99,7 +98,7 @@ const runCommand = async (command, args = [], cwd = process.cwd()) => {
|
|
|
99
98
|
|
|
100
99
|
const runGraphCli = async (args, cwd) => {
|
|
101
100
|
// Resolve the path to graph.js
|
|
102
|
-
let graphCli = path.join(__dirname, '..', '..', '
|
|
101
|
+
let graphCli = path.join(__dirname, '..', '..', 'dist', 'bin.js')
|
|
103
102
|
|
|
104
103
|
return await runCommand(graphCli, args, cwd)
|
|
105
104
|
}
|
|
@@ -108,9 +107,4 @@ const npmLinkCli = () => runCommand('npm', ['link'])
|
|
|
108
107
|
|
|
109
108
|
const npmUnlinkCli = () => runCommand('npm', ['unlink'])
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
cliTest,
|
|
113
|
-
npmLinkCli,
|
|
114
|
-
npmUnlinkCli,
|
|
115
|
-
runGraphCli,
|
|
116
|
-
}
|
|
110
|
+
export { cliTest, npmLinkCli, npmUnlinkCli, runGraphCli }
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist",
|
|
4
|
+
"moduleResolution": "node",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"target": "es2022",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noUnusedLocals": true,
|
|
9
|
+
"noUnusedParameters": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"useUnknownInCatchVariables": false,
|
|
13
|
+
"declaration": false,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"allowJs": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["./src"]
|
|
18
|
+
}
|
package/src/cli.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const { exec } = require('child_process')
|
|
3
|
-
const which = require('which')
|
|
4
|
-
const { build, system } = require('gluegun')
|
|
5
|
-
|
|
6
|
-
const run = async argv => {
|
|
7
|
-
let cli = build()
|
|
8
|
-
.brand('graph')
|
|
9
|
-
.src(__dirname)
|
|
10
|
-
|
|
11
|
-
const pluginDirs = (
|
|
12
|
-
await Promise.all(
|
|
13
|
-
['npm root -g', 'npm root', 'yarn global dir'].map(async cmd => {
|
|
14
|
-
try {
|
|
15
|
-
return await system.run(cmd, { trim: true })
|
|
16
|
-
} catch (_) {
|
|
17
|
-
return undefined
|
|
18
|
-
}
|
|
19
|
-
}),
|
|
20
|
-
)
|
|
21
|
-
).filter(dir => dir !== undefined)
|
|
22
|
-
|
|
23
|
-
// Inject potential plugin directories
|
|
24
|
-
cli = pluginDirs.reduce(
|
|
25
|
-
(cli, dir) => cli.plugin(path.join(dir, '@graphprotocol', 'indexer-cli', 'dist')),
|
|
26
|
-
cli,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
cli = cli
|
|
30
|
-
.help()
|
|
31
|
-
.version()
|
|
32
|
-
.defaultCommand()
|
|
33
|
-
.create()
|
|
34
|
-
|
|
35
|
-
return await cli.run(argv)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = { run }
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
const immutable = require('immutable')
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ethereum.Value -> AssemblyScript conversions
|
|
5
|
-
*/
|
|
6
|
-
const ETHEREUM_VALUE_TO_ASSEMBLYSCRIPT = [
|
|
7
|
-
// Scalar values
|
|
8
|
-
|
|
9
|
-
['address', 'Address', code => `${code}.toAddress()`],
|
|
10
|
-
['bool', 'boolean', code => `${code}.toBoolean()`],
|
|
11
|
-
['byte', 'Bytes', code => `${code}.toBytes()`],
|
|
12
|
-
[
|
|
13
|
-
/^bytes(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)?$/,
|
|
14
|
-
'Bytes',
|
|
15
|
-
code => `${code}.toBytes()`,
|
|
16
|
-
],
|
|
17
|
-
[/^int(8|16|24|32)$/, 'i32', code => `${code}.toI32()`],
|
|
18
|
-
[/^uint(8|16|24)$/, 'i32', code => `${code}.toI32()`],
|
|
19
|
-
['uint32', 'BigInt', code => `${code}.toBigInt()`],
|
|
20
|
-
[
|
|
21
|
-
/^u?int(40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)$/,
|
|
22
|
-
'BigInt',
|
|
23
|
-
code => `${code}.toBigInt()`,
|
|
24
|
-
],
|
|
25
|
-
['string', 'string', code => `${code}.toString()`],
|
|
26
|
-
|
|
27
|
-
// Arrays
|
|
28
|
-
|
|
29
|
-
[/^address\[([0-9]+)?\]$/, 'Array<Address>', code => `${code}.toAddressArray()`],
|
|
30
|
-
[/^bool\[([0-9]+)?\]$/, 'Array<boolean>', code => `${code}.toBooleanArray()`],
|
|
31
|
-
[/^byte\[([0-9]+)?\]$/, 'Array<Bytes>', code => `${code}.toBytesArray()`],
|
|
32
|
-
[
|
|
33
|
-
/^bytes(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)?\[([0-9]+)?\]$/,
|
|
34
|
-
'Array<Bytes>',
|
|
35
|
-
code => `${code}.toBytesArray()`,
|
|
36
|
-
],
|
|
37
|
-
[/^int(8|16|24|32)\[([0-9]+)?\]$/, 'Array<i32>', code => `${code}.toI32Array()`],
|
|
38
|
-
[/^uint(8|16|24)\[([0-9]+)?\]$/, 'Array<i32>', code => `${code}.toI32Array()`],
|
|
39
|
-
[/^uint32\[([0-9]+)?\]$/, 'Array<BigInt>', code => `${code}.toBigIntArray()`],
|
|
40
|
-
[
|
|
41
|
-
/^u?int(40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)\[([0-9]+)?\]$/,
|
|
42
|
-
'Array<BigInt>',
|
|
43
|
-
code => `${code}.toBigIntArray()`,
|
|
44
|
-
],
|
|
45
|
-
[/^string\[([0-9]+)?\]$/, 'Array<string>', code => `${code}.toStringArray()`],
|
|
46
|
-
|
|
47
|
-
// Tuples
|
|
48
|
-
|
|
49
|
-
['tuple', 'ethereum.Tuple', code => `${code}.toTuple()`],
|
|
50
|
-
[
|
|
51
|
-
/^tuple\[([0-9]+)?\]$/,
|
|
52
|
-
'Array<ethereum.Tuple>',
|
|
53
|
-
(code, type) => `${code}.toTupleArray<${type}>()`,
|
|
54
|
-
],
|
|
55
|
-
|
|
56
|
-
// Multi dimensional arrays
|
|
57
|
-
|
|
58
|
-
[/^address\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<Address>>', code => `${code}.toAddressMatrix()`],
|
|
59
|
-
[/^bool\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<boolean>>', code => `${code}.toBooleanMatrix()`],
|
|
60
|
-
[/^byte\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<Bytes>>', code => `${code}.toBytesMatrix()`],
|
|
61
|
-
[
|
|
62
|
-
/^bytes(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)?\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
63
|
-
'Array<Array<Bytes>>',
|
|
64
|
-
code => `${code}.toBytesMatrix()`,
|
|
65
|
-
],
|
|
66
|
-
[/^int(8|16|24|32)\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<i32>>', code => `${code}.toI32Matrix()`],
|
|
67
|
-
[/^uint(8|16|24)\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<i32>>', code => `${code}.toI32Matrix()`],
|
|
68
|
-
[/^uint32\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<BigInt>>', code => `${code}.toBigIntMatrix()`],
|
|
69
|
-
[
|
|
70
|
-
/^u?int(40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
71
|
-
'Array<Array<BigInt>>',
|
|
72
|
-
code => `${code}.toBigIntMatrix()`,
|
|
73
|
-
],
|
|
74
|
-
[/^string\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<string>>', code => `${code}.toStringMatrix()`],
|
|
75
|
-
[
|
|
76
|
-
/^tuple\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
77
|
-
'Array<Array<ethereum.Tuple>>',
|
|
78
|
-
(code, type) => `${code}.toTupleMatrix<${type}>()`,
|
|
79
|
-
],
|
|
80
|
-
|
|
81
|
-
]
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* AssemblyScript -> ethereum.Value conversions
|
|
85
|
-
*
|
|
86
|
-
* Note: The order and patterns for conversions in this direction differ slightly
|
|
87
|
-
* from ethereum.Value -> AssemblyScript, which is why there is a separate table
|
|
88
|
-
* for them.
|
|
89
|
-
*/
|
|
90
|
-
const ASSEMBLYSCRIPT_TO_ETHEREUM_VALUE = [
|
|
91
|
-
// Scalar values
|
|
92
|
-
|
|
93
|
-
['Address', 'address', code => `ethereum.Value.fromAddress(${code})`],
|
|
94
|
-
['boolean', 'bool', code => `ethereum.Value.fromBoolean(${code})`],
|
|
95
|
-
['Bytes', 'byte', code => `ethereum.Value.fromFixedBytes(${code})`],
|
|
96
|
-
['Bytes', 'bytes', code => `ethereum.Value.fromBytes(${code})`],
|
|
97
|
-
[
|
|
98
|
-
'Bytes',
|
|
99
|
-
/^bytes(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)$/,
|
|
100
|
-
code => `ethereum.Value.fromFixedBytes(${code})`,
|
|
101
|
-
],
|
|
102
|
-
['i32', /^int(8|16|24|32)$/, code => `ethereum.Value.fromI32(${code})`],
|
|
103
|
-
[
|
|
104
|
-
'i32',
|
|
105
|
-
/^uint(8|16|24)$/,
|
|
106
|
-
code => `ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(${code}))`,
|
|
107
|
-
],
|
|
108
|
-
[
|
|
109
|
-
'BigInt',
|
|
110
|
-
/^int(40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)$/,
|
|
111
|
-
code => `ethereum.Value.fromSignedBigInt(${code})`,
|
|
112
|
-
],
|
|
113
|
-
[
|
|
114
|
-
'BigInt',
|
|
115
|
-
/^uint(32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)$/,
|
|
116
|
-
code => `ethereum.Value.fromUnsignedBigInt(${code})`,
|
|
117
|
-
],
|
|
118
|
-
['string', 'string', code => `ethereum.Value.fromString(${code})`],
|
|
119
|
-
|
|
120
|
-
// Arrays
|
|
121
|
-
|
|
122
|
-
[
|
|
123
|
-
'Array<Address>',
|
|
124
|
-
/^address\[([0-9]+)?\]$/,
|
|
125
|
-
code => `ethereum.Value.fromAddressArray(${code})`,
|
|
126
|
-
],
|
|
127
|
-
[
|
|
128
|
-
'Array<boolean>',
|
|
129
|
-
/^bool\[([0-9]+)?\]$/,
|
|
130
|
-
code => `ethereum.Value.fromBooleanArray(${code})`,
|
|
131
|
-
],
|
|
132
|
-
[
|
|
133
|
-
'Array<Bytes>',
|
|
134
|
-
/^byte\[([0-9]+)?\]$/,
|
|
135
|
-
code => `ethereum.Value.fromFixedBytesArray(${code})`,
|
|
136
|
-
],
|
|
137
|
-
[
|
|
138
|
-
'Array<Bytes>',
|
|
139
|
-
/bytes\[([0-9]+)?\]$/,
|
|
140
|
-
code => `ethereum.Value.fromBytesArray(${code})`,
|
|
141
|
-
],
|
|
142
|
-
[
|
|
143
|
-
'Array<Bytes>',
|
|
144
|
-
/^bytes(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)\[([0-9]+)?\]$/,
|
|
145
|
-
code => `ethereum.Value.fromFixedBytesArray(${code})`,
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
'Array<i32>',
|
|
149
|
-
/^int(8|16|24|32)\[([0-9]+)?\]$/,
|
|
150
|
-
code => `ethereum.Value.fromI32Array(${code})`,
|
|
151
|
-
],
|
|
152
|
-
[
|
|
153
|
-
'Array<i32>',
|
|
154
|
-
/^uint(8|16|24)\[([0-9]+)?\]$/,
|
|
155
|
-
code => `ethereum.Value.fromI32Array(${code})`,
|
|
156
|
-
],
|
|
157
|
-
[
|
|
158
|
-
'Array<BigInt>',
|
|
159
|
-
/^int(40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)\[([0-9]+)?\]$/,
|
|
160
|
-
code => `ethereum.Value.fromSignedBigIntArray(${code})`,
|
|
161
|
-
],
|
|
162
|
-
[
|
|
163
|
-
'Array<BigInt>',
|
|
164
|
-
/^uint(32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)\[([0-9]+)?\]$/,
|
|
165
|
-
code => `ethereum.Value.fromUnsignedBigIntArray(${code})`,
|
|
166
|
-
],
|
|
167
|
-
[
|
|
168
|
-
'Array<string>',
|
|
169
|
-
/^string\[([0-9]+)?\]$/,
|
|
170
|
-
code => `ethereum.Value.fromStringArray(${code})`,
|
|
171
|
-
],
|
|
172
|
-
|
|
173
|
-
// Tuples
|
|
174
|
-
|
|
175
|
-
['ethereum.Tuple', 'tuple', code => `ethereum.Value.fromTuple(${code})`],
|
|
176
|
-
[
|
|
177
|
-
'Array<ethereum.Tuple>',
|
|
178
|
-
/^tuple\[([0-9]+)?\]$/,
|
|
179
|
-
code => `ethereum.Value.fromTupleArray(${code})`,
|
|
180
|
-
],
|
|
181
|
-
|
|
182
|
-
// Multi dimentional arrays
|
|
183
|
-
|
|
184
|
-
[
|
|
185
|
-
'Array<Array<Address>>',
|
|
186
|
-
/^address\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
187
|
-
code => `ethereum.Value.fromAddressMatrix(${code})`,
|
|
188
|
-
],
|
|
189
|
-
[
|
|
190
|
-
'Array<Array<boolean>>',
|
|
191
|
-
/^bool\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
192
|
-
code => `ethereum.Value.fromBooleanMatrix(${code})`,
|
|
193
|
-
],
|
|
194
|
-
[
|
|
195
|
-
'Array<Array<Bytes>>',
|
|
196
|
-
/^byte\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
197
|
-
code => `ethereum.Value.fromFixedBytesMatrix(${code})`,
|
|
198
|
-
],
|
|
199
|
-
[
|
|
200
|
-
'Array<Array<Bytes>>',
|
|
201
|
-
/bytes\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
202
|
-
code => `ethereum.Value.fromBytesMatrix(${code})`,
|
|
203
|
-
],
|
|
204
|
-
[
|
|
205
|
-
'Array<Array<Bytes>>',
|
|
206
|
-
/^bytes(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
207
|
-
code => `ethereum.Value.fromFixedBytesMatrix(${code})`,
|
|
208
|
-
],
|
|
209
|
-
[
|
|
210
|
-
'Array<Array<i32>>',
|
|
211
|
-
/^int(8|16|24|32)\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
212
|
-
code => `ethereum.Value.fromI32Matrix(${code})`,
|
|
213
|
-
],
|
|
214
|
-
[
|
|
215
|
-
'Array<Array<i32>>',
|
|
216
|
-
/^uint(8|16|24)\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
217
|
-
code => `ethereum.Value.fromI32Matrix(${code})`,
|
|
218
|
-
],
|
|
219
|
-
[
|
|
220
|
-
'Array<Array<BigInt>>',
|
|
221
|
-
/^int(40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
222
|
-
code => `ethereum.Value.fromSignedBigIntMatrix(${code})`,
|
|
223
|
-
],
|
|
224
|
-
[
|
|
225
|
-
'Array<Array<BigInt>>',
|
|
226
|
-
/^uint(32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
227
|
-
code => `ethereum.Value.fromUnsignedBigIntMatrix(${code})`,
|
|
228
|
-
],
|
|
229
|
-
[
|
|
230
|
-
'Array<Array<string>>',
|
|
231
|
-
/^string\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
232
|
-
code => `ethereum.Value.fromStringMatrix(${code})`,
|
|
233
|
-
],
|
|
234
|
-
[
|
|
235
|
-
'Array<Array<ethereum.Tuple>>',
|
|
236
|
-
/^tuple\[([0-9]+)?\]\[([0-9]+)?\]$/,
|
|
237
|
-
code => `ethereum.Value.fromTupleMatrix(${code})`,
|
|
238
|
-
],
|
|
239
|
-
]
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Value -> AssemblyScript conversions
|
|
243
|
-
*/
|
|
244
|
-
const VALUE_TO_ASSEMBLYSCRIPT = [
|
|
245
|
-
// Arrays
|
|
246
|
-
|
|
247
|
-
['[Bytes]', 'Array<Bytes>', code => `${code}.toBytesArray()`],
|
|
248
|
-
['[Boolean]', 'Array<boolean>', code => `${code}.toBooleanArray()`],
|
|
249
|
-
['[Int]', 'Array<i32>', code => `${code}.toI32Array()`],
|
|
250
|
-
['[BigInt]', 'Array<BigInt>', code => `${code}.toBigIntArray()`],
|
|
251
|
-
['[ID]', 'Array<string>', code => `${code}.toStringArray()`],
|
|
252
|
-
['[String]', 'Array<string>', code => `${code}.toStringArray()`],
|
|
253
|
-
['[BigDecimal]', 'Array<BigDecimal>', code => `${code}.toBigDecimalArray()`],
|
|
254
|
-
[/\[.*\]/, 'Array<string>', code => `${code}.toStringArray()`],
|
|
255
|
-
|
|
256
|
-
// Scalar values
|
|
257
|
-
|
|
258
|
-
['Bytes', 'Bytes', code => `${code}.toBytes()`],
|
|
259
|
-
['Boolean', 'boolean', code => `${code}.toBoolean()`],
|
|
260
|
-
['Int', 'i32', code => `${code}.toI32()`],
|
|
261
|
-
['BigInt', 'BigInt', code => `${code}.toBigInt()`],
|
|
262
|
-
['ID', 'string', code => `${code}.toString()`],
|
|
263
|
-
['String', 'string', code => `${code}.toString()`],
|
|
264
|
-
['BigDecimal', 'BigDecimal', code => `${code}.toBigDecimal()`],
|
|
265
|
-
[/.*/, 'string', code => `${code}.toString()`],
|
|
266
|
-
]
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* AssemblyScript -> Value conversions
|
|
270
|
-
*
|
|
271
|
-
* Note: The order and patterns for conversions in this direction differ slightly
|
|
272
|
-
* from Value -> AssemblyScript, which is why there is a separate table
|
|
273
|
-
* for them.
|
|
274
|
-
*/
|
|
275
|
-
const ASSEMBLYSCRIPT_TO_VALUE = [
|
|
276
|
-
// Matrices
|
|
277
|
-
|
|
278
|
-
['Array<Array<Address>>', '[[Bytes]]', code => `Value.fromBytesMatrix(${code})`],
|
|
279
|
-
['Array<Array<Bytes>>', '[[Bytes]]', code => `Value.fromBytesMatrix(${code})`],
|
|
280
|
-
['Array<Array<boolean>>', '[[Boolean]]', code => `Value.fromBooleanMatrix(${code})`],
|
|
281
|
-
['Array<Array<i32>>', '[[Int]]', code => `Value.fromI32Matrix(${code})`],
|
|
282
|
-
['Array<Array<BigInt>>', '[[BigInt]]', code => `Value.fromBigIntMatrix(${code})`],
|
|
283
|
-
['Array<Array<string>>', '[[String]]', code => `Value.fromStringMatrix(${code})`],
|
|
284
|
-
['Array<Array<string>>', '[[ID]]', code => `Value.fromStringMatrix(${code})`],
|
|
285
|
-
['Array<Array<BigDecimal>>', '[[BigDecimal]]', code => `Value.fromBigDecimalMatrix(${code})`],
|
|
286
|
-
['Array<Array<string>>', /\[\[.*\]\]/, code => `Value.fromStringMatrix(${code})`],
|
|
287
|
-
['Array<Array<string | null>>', null, code => `Value.fromStringMatrix(${code})`],// is this overwriting the Array null below?
|
|
288
|
-
|
|
289
|
-
// Arrays
|
|
290
|
-
|
|
291
|
-
['Array<Address>', '[Bytes]', code => `Value.fromBytesArray(${code})`],
|
|
292
|
-
['Array<Bytes>', '[Bytes]', code => `Value.fromBytesArray(${code})`],
|
|
293
|
-
['Array<boolean>', '[Boolean]', code => `Value.fromBooleanArray(${code})`],
|
|
294
|
-
['Array<i32>', '[Int]', code => `Value.fromI32Array(${code})`],
|
|
295
|
-
['Array<BigInt>', '[BigInt]', code => `Value.fromBigIntArray(${code})`],
|
|
296
|
-
['Array<string>', '[String]', code => `Value.fromStringArray(${code})`],
|
|
297
|
-
['Array<string>', '[ID]', code => `Value.fromStringArray(${code})`],
|
|
298
|
-
['Array<BigDecimal>', '[BigDecimal]', code => `Value.fromBigDecimalArray(${code})`],
|
|
299
|
-
['Array<string>', /\[.*\]/, code => `Value.fromStringArray(${code})`],
|
|
300
|
-
['Array<string | null>', null, code => `Value.fromStringArray(${code})`],
|
|
301
|
-
|
|
302
|
-
// Scalar values
|
|
303
|
-
|
|
304
|
-
['Address', 'Bytes', code => `Value.fromBytes(${code})`],
|
|
305
|
-
['Bytes', 'Bytes', code => `Value.fromBytes(${code})`],
|
|
306
|
-
['boolean', 'Boolean', code => `Value.fromBoolean(${code})`],
|
|
307
|
-
['i32', 'Int', code => `Value.fromI32(${code})`],
|
|
308
|
-
['BigInt', 'BigInt', code => `Value.fromBigInt(${code})`],
|
|
309
|
-
['string', 'String', code => `Value.fromString(${code})`],
|
|
310
|
-
['string', 'ID', code => `Value.fromString(${code})`],
|
|
311
|
-
['BigDecimal', 'BigDecimal', code => `Value.fromBigDecimal(${code})`],
|
|
312
|
-
['string', /.*/, code => `Value.fromString(${code})`],
|
|
313
|
-
]
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Type conversions
|
|
317
|
-
*/
|
|
318
|
-
module.exports = immutable.fromJS({
|
|
319
|
-
ethereum: {
|
|
320
|
-
AssemblyScript: ETHEREUM_VALUE_TO_ASSEMBLYSCRIPT,
|
|
321
|
-
},
|
|
322
|
-
AssemblyScript: {
|
|
323
|
-
ethereum: ASSEMBLYSCRIPT_TO_ETHEREUM_VALUE,
|
|
324
|
-
Value: ASSEMBLYSCRIPT_TO_VALUE,
|
|
325
|
-
},
|
|
326
|
-
Value: {
|
|
327
|
-
AssemblyScript: VALUE_TO_ASSEMBLYSCRIPT,
|
|
328
|
-
},
|
|
329
|
-
})
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const allowedStudioNetworks = ['mainnet', 'rinkeby', 'goerli', 'gnosis']
|
|
2
|
-
|
|
3
|
-
const validateStudioNetwork = ({ studio, product, network }) => {
|
|
4
|
-
let isStudio = studio || product === 'subgraph-studio'
|
|
5
|
-
let isAllowedNetwork = allowedStudioNetworks.includes(network)
|
|
6
|
-
|
|
7
|
-
if (isStudio && !isAllowedNetwork) {
|
|
8
|
-
throw new Error(`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(', ')}`)
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = {
|
|
13
|
-
allowedStudioNetworks,
|
|
14
|
-
validateStudioNetwork,
|
|
15
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const immutable = require('immutable')
|
|
2
|
-
|
|
3
|
-
module.exports = class ArweaveSubgraph {
|
|
4
|
-
constructor(options = {}) {
|
|
5
|
-
this.manifest = options.manifest
|
|
6
|
-
this.resolveFile = options.resolveFile
|
|
7
|
-
this.protocol = options.protocol
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
validateManifest() {
|
|
11
|
-
return immutable.List()
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
handlerTypes() {
|
|
15
|
-
return immutable.List([
|
|
16
|
-
'blockHandlers',
|
|
17
|
-
'transactionHandlers',
|
|
18
|
-
])
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const immutable = require('immutable')
|
|
2
|
-
|
|
3
|
-
module.exports = class SubstreamsSubgraph {
|
|
4
|
-
constructor(options = {}) {
|
|
5
|
-
this.manifest = options.manifest
|
|
6
|
-
this.resolveFile = options.resolveFile
|
|
7
|
-
this.protocol = options.protocol
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
validateManifest() {
|
|
11
|
-
return immutable.List()
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
handlerTypes() {
|
|
15
|
-
return immutable.List([])
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/schema.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
let fs = require('fs-extra')
|
|
2
|
-
let graphql = require('graphql/language')
|
|
3
|
-
let immutable = require('immutable')
|
|
4
|
-
|
|
5
|
-
let SchemaCodeGenerator = require('./codegen/schema')
|
|
6
|
-
|
|
7
|
-
module.exports = class Schema {
|
|
8
|
-
constructor(filename, document, ast) {
|
|
9
|
-
this.filename = filename
|
|
10
|
-
this.document = document
|
|
11
|
-
this.ast = ast
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
codeGenerator() {
|
|
15
|
-
return new SchemaCodeGenerator(this)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static async load(filename) {
|
|
19
|
-
let document = await fs.readFile(filename, 'utf-8')
|
|
20
|
-
let ast = graphql.parse(document)
|
|
21
|
-
return new Schema(filename, document, immutable.fromJS(ast))
|
|
22
|
-
}
|
|
23
|
-
}
|