@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.
Files changed (100) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/bin.js +6 -0
  3. package/dist/cli.js +26 -0
  4. package/dist/codegen/schema.js +244 -0
  5. package/dist/codegen/schema.test.js +455 -0
  6. package/dist/codegen/template.js +66 -0
  7. package/dist/codegen/types/conversions.js +335 -0
  8. package/dist/codegen/types/index.js +71 -0
  9. package/dist/codegen/types/index.test.js +563 -0
  10. package/dist/codegen/typescript.js +200 -0
  11. package/dist/codegen/util.js +40 -0
  12. package/dist/codegen/util.test.js +93 -0
  13. package/dist/command-helpers/abi.js +76 -0
  14. package/dist/command-helpers/auth.js +76 -0
  15. package/dist/command-helpers/compiler.js +66 -0
  16. package/dist/command-helpers/data-sources.js +29 -0
  17. package/dist/command-helpers/fs.js +9 -0
  18. package/dist/command-helpers/gluegun.js +48 -0
  19. package/dist/command-helpers/ipfs.js +5 -0
  20. package/dist/command-helpers/jsonrpc.js +27 -0
  21. package/dist/command-helpers/network.js +90 -0
  22. package/dist/command-helpers/network.test.js +86 -0
  23. package/dist/command-helpers/node.js +40 -0
  24. package/dist/command-helpers/scaffold.js +110 -0
  25. package/dist/command-helpers/spinner.js +80 -0
  26. package/dist/command-helpers/studio.js +14 -0
  27. package/dist/command-helpers/studio.test.js +41 -0
  28. package/dist/command-helpers/subgraph.js +22 -0
  29. package/dist/command-helpers/version.js +66 -0
  30. package/dist/command-helpers/version.test.js +186 -0
  31. package/dist/commands/add.js +187 -0
  32. package/dist/commands/auth.js +122 -0
  33. package/dist/commands/build.js +136 -0
  34. package/dist/commands/codegen.js +128 -0
  35. package/dist/commands/create.js +94 -0
  36. package/dist/commands/deploy.js +335 -0
  37. package/dist/commands/init.js +800 -0
  38. package/dist/commands/local.js +380 -0
  39. package/dist/commands/remove.js +95 -0
  40. package/dist/commands/test.js +293 -0
  41. package/dist/compiler/asc.js +83 -0
  42. package/dist/compiler/index.js +466 -0
  43. package/dist/debug.js +16 -0
  44. package/dist/migrations/mapping_api_version_0_0_1.js +83 -0
  45. package/dist/migrations/mapping_api_version_0_0_2.js +83 -0
  46. package/dist/migrations/mapping_api_version_0_0_3.js +83 -0
  47. package/dist/migrations/mapping_api_version_0_0_4.js +85 -0
  48. package/dist/migrations/mapping_api_version_0_0_5.js +85 -0
  49. package/dist/migrations/spec_version_0_0_2.js +45 -0
  50. package/dist/migrations/spec_version_0_0_3.js +50 -0
  51. package/dist/migrations/util/load-manifest.js +16 -0
  52. package/dist/migrations/util/versions.js +28 -0
  53. package/dist/migrations.js +54 -0
  54. package/dist/protocols/arweave/manifest.graphql +57 -0
  55. package/dist/protocols/arweave/scaffold/manifest.js +18 -0
  56. package/dist/protocols/arweave/scaffold/mapping.js +52 -0
  57. package/dist/protocols/arweave/subgraph.js +23 -0
  58. package/dist/protocols/contract.js +2 -0
  59. package/dist/protocols/cosmos/manifest.graphql +76 -0
  60. package/dist/protocols/cosmos/scaffold/manifest.js +15 -0
  61. package/dist/protocols/cosmos/scaffold/mapping.js +38 -0
  62. package/dist/protocols/cosmos/subgraph.js +28 -0
  63. package/dist/protocols/ethereum/abi.js +138 -0
  64. package/dist/protocols/ethereum/codegen/abi.js +474 -0
  65. package/dist/protocols/ethereum/codegen/abi.test.js +325 -0
  66. package/dist/protocols/ethereum/codegen/template.js +52 -0
  67. package/dist/protocols/ethereum/contract.js +22 -0
  68. package/dist/protocols/ethereum/manifest.graphql +94 -0
  69. package/dist/protocols/ethereum/scaffold/manifest.js +32 -0
  70. package/dist/protocols/ethereum/scaffold/mapping.js +65 -0
  71. package/dist/protocols/ethereum/subgraph.js +172 -0
  72. package/dist/protocols/ethereum/type-generator.js +123 -0
  73. package/dist/protocols/index.js +266 -0
  74. package/dist/protocols/ipfs/codegen/file_template.js +53 -0
  75. package/dist/protocols/near/contract.js +41 -0
  76. package/dist/protocols/near/manifest.graphql +64 -0
  77. package/dist/protocols/near/scaffold/manifest.js +16 -0
  78. package/dist/protocols/near/scaffold/mapping.js +38 -0
  79. package/dist/protocols/near/subgraph.js +23 -0
  80. package/dist/protocols/subgraph.js +2 -0
  81. package/dist/protocols/substreams/manifest.graphql +45 -0
  82. package/dist/protocols/substreams/scaffold/manifest.js +12 -0
  83. package/dist/protocols/substreams/subgraph.js +23 -0
  84. package/dist/scaffold/cosmos.test.js +82 -0
  85. package/dist/scaffold/ethereum.test.js +496 -0
  86. package/dist/scaffold/index.js +133 -0
  87. package/dist/scaffold/mapping.js +57 -0
  88. package/dist/scaffold/near.test.js +85 -0
  89. package/dist/scaffold/schema.js +86 -0
  90. package/dist/scaffold/tests.js +179 -0
  91. package/dist/schema.js +54 -0
  92. package/dist/subgraph.js +243 -0
  93. package/dist/type-generator.js +225 -0
  94. package/dist/validation/contract.js +44 -0
  95. package/dist/validation/index.js +10 -0
  96. package/dist/validation/manifest.js +266 -0
  97. package/dist/validation/schema.js +768 -0
  98. package/dist/validation/schema.test.js +35 -0
  99. package/dist/watcher.js +79 -0
  100. 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
+ });
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.37.4",
3
+ "version": "0.37.5",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "bin": {