@graphprotocol/graph-cli 0.37.4 → 0.37.5
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 +8 -0
- package/dist/bin.js +6 -0
- package/dist/cli.js +26 -0
- package/dist/codegen/schema.js +244 -0
- package/dist/codegen/schema.test.js +455 -0
- package/dist/codegen/template.js +66 -0
- package/dist/codegen/types/conversions.js +335 -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 +40 -0
- package/dist/codegen/util.test.js +93 -0
- package/dist/command-helpers/abi.js +76 -0
- package/dist/command-helpers/auth.js +76 -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 +48 -0
- package/dist/command-helpers/ipfs.js +5 -0
- package/dist/command-helpers/jsonrpc.js +27 -0
- package/dist/command-helpers/network.js +90 -0
- package/dist/command-helpers/network.test.js +86 -0
- package/dist/command-helpers/node.js +40 -0
- package/dist/command-helpers/scaffold.js +110 -0
- package/dist/command-helpers/spinner.js +80 -0
- package/dist/command-helpers/studio.js +14 -0
- package/dist/command-helpers/studio.test.js +41 -0
- package/dist/command-helpers/subgraph.js +22 -0
- package/dist/command-helpers/version.js +66 -0
- package/dist/command-helpers/version.test.js +186 -0
- package/dist/commands/add.js +187 -0
- package/dist/commands/auth.js +122 -0
- package/dist/commands/build.js +136 -0
- package/dist/commands/codegen.js +128 -0
- package/dist/commands/create.js +94 -0
- package/dist/commands/deploy.js +335 -0
- package/dist/commands/init.js +800 -0
- package/dist/commands/local.js +380 -0
- package/dist/commands/remove.js +95 -0
- package/dist/commands/test.js +293 -0
- package/dist/compiler/asc.js +83 -0
- package/dist/compiler/index.js +466 -0
- package/dist/debug.js +16 -0
- package/dist/migrations/mapping_api_version_0_0_1.js +83 -0
- package/dist/migrations/mapping_api_version_0_0_2.js +83 -0
- package/dist/migrations/mapping_api_version_0_0_3.js +83 -0
- package/dist/migrations/mapping_api_version_0_0_4.js +85 -0
- package/dist/migrations/mapping_api_version_0_0_5.js +85 -0
- package/dist/migrations/spec_version_0_0_2.js +45 -0
- package/dist/migrations/spec_version_0_0_3.js +50 -0
- package/dist/migrations/util/load-manifest.js +16 -0
- package/dist/migrations/util/versions.js +28 -0
- package/dist/migrations.js +54 -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/contract.js +2 -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 +28 -0
- package/dist/protocols/ethereum/abi.js +138 -0
- package/dist/protocols/ethereum/codegen/abi.js +474 -0
- package/dist/protocols/ethereum/codegen/abi.test.js +325 -0
- package/dist/protocols/ethereum/codegen/template.js +52 -0
- package/dist/protocols/ethereum/contract.js +22 -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 +172 -0
- package/dist/protocols/ethereum/type-generator.js +123 -0
- package/dist/protocols/index.js +266 -0
- package/dist/protocols/ipfs/codegen/file_template.js +53 -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 +23 -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 +82 -0
- package/dist/scaffold/ethereum.test.js +496 -0
- package/dist/scaffold/index.js +133 -0
- package/dist/scaffold/mapping.js +57 -0
- package/dist/scaffold/near.test.js +85 -0
- package/dist/scaffold/schema.js +86 -0
- package/dist/scaffold/tests.js +179 -0
- package/dist/schema.js +54 -0
- package/dist/subgraph.js +243 -0
- package/dist/type-generator.js +225 -0
- package/dist/validation/contract.js +44 -0
- package/dist/validation/index.js +10 -0
- package/dist/validation/manifest.js +266 -0
- package/dist/validation/schema.js +768 -0
- package/dist/validation/schema.test.js +35 -0
- package/dist/watcher.js +79 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_1 = require("./schema");
|
|
4
|
+
describe('Schema validation', () => {
|
|
5
|
+
test('Type suggestions', () => {
|
|
6
|
+
expect((0, schema_1.typeSuggestion)('Address')).toEqual('Bytes');
|
|
7
|
+
expect((0, schema_1.typeSuggestion)('address')).toEqual('Bytes');
|
|
8
|
+
expect((0, schema_1.typeSuggestion)('bytes')).toEqual('Bytes');
|
|
9
|
+
expect((0, schema_1.typeSuggestion)('string')).toEqual('String');
|
|
10
|
+
expect((0, schema_1.typeSuggestion)('bool')).toEqual('Boolean');
|
|
11
|
+
expect((0, schema_1.typeSuggestion)('boolean')).toEqual('Boolean');
|
|
12
|
+
expect((0, schema_1.typeSuggestion)('float')).toEqual('BigDecimal');
|
|
13
|
+
expect((0, schema_1.typeSuggestion)('Float')).toEqual('BigDecimal');
|
|
14
|
+
expect((0, schema_1.typeSuggestion)(`int`)).toBe('Int');
|
|
15
|
+
expect((0, schema_1.typeSuggestion)(`uint`)).toBe('BigInt');
|
|
16
|
+
expect((0, schema_1.typeSuggestion)(`uint32`)).toBe('BigInt');
|
|
17
|
+
// Test i8..i32, int8..int32
|
|
18
|
+
for (let i = 8; i <= 32; i += 8) {
|
|
19
|
+
expect((0, schema_1.typeSuggestion)(`i${i}`)).toBe('Int');
|
|
20
|
+
expect((0, schema_1.typeSuggestion)(`int${i}`)).toBe('Int');
|
|
21
|
+
}
|
|
22
|
+
// Test u8..u24, uint8..uint24
|
|
23
|
+
for (let i = 8; i <= 24; i += 8) {
|
|
24
|
+
expect((0, schema_1.typeSuggestion)(`u${i}`)).toBe('Int');
|
|
25
|
+
expect((0, schema_1.typeSuggestion)(`uint${i}`)).toBe('Int');
|
|
26
|
+
}
|
|
27
|
+
// Test i40..i256, int40..int256, u40..u256, uint40..uint256
|
|
28
|
+
for (let i = 40; i <= 256; i += 8) {
|
|
29
|
+
expect((0, schema_1.typeSuggestion)(`i${i}`)).toBe('BigInt');
|
|
30
|
+
expect((0, schema_1.typeSuggestion)(`int${i}`)).toBe('BigInt');
|
|
31
|
+
expect((0, schema_1.typeSuggestion)(`u${i}`)).toBe('BigInt');
|
|
32
|
+
expect((0, schema_1.typeSuggestion)(`uint${i}`)).toBe('BigInt');
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
package/dist/watcher.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
|
+
class Watcher {
|
|
9
|
+
onReady;
|
|
10
|
+
onTrigger;
|
|
11
|
+
onCollectFiles;
|
|
12
|
+
onError;
|
|
13
|
+
watcher;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
const { onReady, onTrigger, onCollectFiles, onError } = options;
|
|
16
|
+
this.onReady = onReady;
|
|
17
|
+
this.onTrigger = onTrigger;
|
|
18
|
+
this.onCollectFiles = onCollectFiles;
|
|
19
|
+
this.onError = onError;
|
|
20
|
+
}
|
|
21
|
+
async watch() {
|
|
22
|
+
// Collect files to watch
|
|
23
|
+
const files = await this.onCollectFiles();
|
|
24
|
+
// Initialize watcher
|
|
25
|
+
this.watcher = chokidar_1.default.watch(files, {
|
|
26
|
+
persistent: true,
|
|
27
|
+
ignoreInitial: true,
|
|
28
|
+
atomic: 500,
|
|
29
|
+
});
|
|
30
|
+
// Bind variables locally
|
|
31
|
+
const watcher = this.watcher;
|
|
32
|
+
const onTrigger = this.onTrigger;
|
|
33
|
+
const onCollectFiles = this.onCollectFiles;
|
|
34
|
+
const onError = this.onError;
|
|
35
|
+
const onReady = this.onReady;
|
|
36
|
+
watcher.on('ready', async () => {
|
|
37
|
+
// Notify listeners that we're watching
|
|
38
|
+
onReady();
|
|
39
|
+
// Trigger once when ready
|
|
40
|
+
await onTrigger(undefined);
|
|
41
|
+
});
|
|
42
|
+
watcher.on('error', (error) => {
|
|
43
|
+
onError(error);
|
|
44
|
+
});
|
|
45
|
+
watcher.on('all', async (_, file) => {
|
|
46
|
+
try {
|
|
47
|
+
// Collect watch all new files to watch
|
|
48
|
+
const newFiles = await onCollectFiles();
|
|
49
|
+
// Collect watched files, if there are any
|
|
50
|
+
let watchedFiles = [];
|
|
51
|
+
const watched = watcher.getWatched();
|
|
52
|
+
watchedFiles = Object.keys(watched).reduce((files, dirname) => watched[dirname].reduce((files, filename) => {
|
|
53
|
+
files.push(path_1.default.resolve(path_1.default.join(dirname, filename)));
|
|
54
|
+
return files;
|
|
55
|
+
}, files), []);
|
|
56
|
+
const diff = (xs, ys) => ({
|
|
57
|
+
added: ys.filter((y) => !xs.includes(y)),
|
|
58
|
+
removed: xs.filter((x) => !ys.includes(x)),
|
|
59
|
+
});
|
|
60
|
+
// Diff previously watched files and new files; then remove and
|
|
61
|
+
// add files from/to the watcher accordingly
|
|
62
|
+
const filesDiff = diff(watchedFiles, newFiles);
|
|
63
|
+
watcher.unwatch(filesDiff.removed);
|
|
64
|
+
watcher.add(filesDiff.added);
|
|
65
|
+
// Run the trigger callback
|
|
66
|
+
await onTrigger(file);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
onError(e);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
close() {
|
|
74
|
+
if (this.watcher !== undefined) {
|
|
75
|
+
this.watcher.close();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.default = Watcher;
|