@graphprotocol/graph-cli 0.64.1 → 0.65.0-alpha-20240111165930-d9ce44f
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/README.md +15 -3
- package/dist/command-helpers/node.d.ts +1 -0
- package/dist/command-helpers/node.js +3 -3
- package/dist/commands/init.js +40 -10
- package/oclif.manifest.json +2 -48
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
+
## 0.65.0-alpha-20240111165930-d9ce44f
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1557](https://github.com/graphprotocol/graph-tooling/pull/1557)
|
|
8
|
+
[`d9ce44f`](https://github.com/graphprotocol/graph-tooling/commit/d9ce44f2730b56097f6accbbc4f1090327e54d89)
|
|
9
|
+
Thanks [@saihaj](https://github.com/saihaj)! - fetch supported networks from API
|
|
10
|
+
|
|
3
11
|
## 0.64.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -37,14 +37,26 @@ or a local directory for debugging, and deploys the subgraph to a
|
|
|
37
37
|
|
|
38
38
|
## Installation
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
We recommend install the CLI using package manager `npm` or `yarn` or `pnpm` when developing
|
|
41
|
+
subgraphs locally:
|
|
41
42
|
|
|
42
43
|
```sh
|
|
43
44
|
# NPM
|
|
44
|
-
npm install
|
|
45
|
+
npm install @graphprotocol/graph-cli
|
|
45
46
|
|
|
46
47
|
# Yarn
|
|
47
|
-
yarn
|
|
48
|
+
yarn add @graphprotocol/graph-cli
|
|
49
|
+
|
|
50
|
+
# pnpm
|
|
51
|
+
pnpm install @graphprotocol/graph-cli
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
You can install the CLI globally using a binary. Eventually this will become the default mechanism
|
|
55
|
+
for installing the CLI and building subgraphs because users do not need to install `Node.js` or any
|
|
56
|
+
other external dependencies.
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
curl -LS https://cli.thegraph.com/install.sh | sudo sh
|
|
48
60
|
```
|
|
49
61
|
|
|
50
62
|
### On Linux
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { URL } from 'url';
|
|
3
|
+
export declare const SUBGRAPH_STUDIO_URL = "https://api.studio.thegraph.com/deploy/";
|
|
3
4
|
export declare const validateNodeUrl: (node: string) => URL;
|
|
4
5
|
export declare const normalizeNodeUrl: (node: string) => string;
|
|
5
6
|
export declare function chooseNodeUrl({ product, studio, node, allowSimpleName, }: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHostedServiceSubgraphId = exports.chooseNodeUrl = exports.normalizeNodeUrl = exports.validateNodeUrl = void 0;
|
|
3
|
+
exports.getHostedServiceSubgraphId = exports.chooseNodeUrl = exports.normalizeNodeUrl = exports.validateNodeUrl = exports.SUBGRAPH_STUDIO_URL = void 0;
|
|
4
4
|
const url_1 = require("url");
|
|
5
5
|
const gluegun_1 = require("gluegun");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
|
-
|
|
7
|
+
exports.SUBGRAPH_STUDIO_URL = 'https://api.studio.thegraph.com/deploy/';
|
|
8
8
|
const HOSTED_SERVICE_URL = 'https://api.thegraph.com/deploy/';
|
|
9
9
|
const HOSTED_SERVICE_INDEX_NODE_URL = 'https://api.thegraph.com/index-node/graphql';
|
|
10
10
|
const validateNodeUrl = (node) => new url_1.URL(node);
|
|
@@ -27,7 +27,7 @@ function chooseNodeUrl({ product, studio, node, allowSimpleName, }) {
|
|
|
27
27
|
}
|
|
28
28
|
switch (product) {
|
|
29
29
|
case 'subgraph-studio':
|
|
30
|
-
node = SUBGRAPH_STUDIO_URL;
|
|
30
|
+
node = exports.SUBGRAPH_STUDIO_URL;
|
|
31
31
|
break;
|
|
32
32
|
case 'hosted-service':
|
|
33
33
|
node = HOSTED_SERVICE_URL;
|
package/dist/commands/init.js
CHANGED
|
@@ -38,15 +38,50 @@ const node_1 = require("../command-helpers/node");
|
|
|
38
38
|
const scaffold_1 = require("../command-helpers/scaffold");
|
|
39
39
|
const spinner_1 = require("../command-helpers/spinner");
|
|
40
40
|
const subgraph_1 = require("../command-helpers/subgraph");
|
|
41
|
+
const constants_1 = require("../constants");
|
|
41
42
|
const debug_1 = __importDefault(require("../debug"));
|
|
42
43
|
const protocols_1 = __importDefault(require("../protocols"));
|
|
43
44
|
const schema_1 = require("../scaffold/schema");
|
|
44
45
|
const validation_1 = require("../validation");
|
|
45
46
|
const add_1 = __importDefault(require("./add"));
|
|
46
47
|
const protocolChoices = Array.from(protocols_1.default.availableProtocols().keys());
|
|
47
|
-
const availableNetworks = protocols_1.default.availableNetworks();
|
|
48
|
-
const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum-gravatar';
|
|
49
48
|
const initDebugger = (0, debug_1.default)('graph-cli:commands:init');
|
|
49
|
+
/**
|
|
50
|
+
* a dynamic list of available networks supported by the studio
|
|
51
|
+
*/
|
|
52
|
+
const AVAILABLE_NETWORKS = async () => {
|
|
53
|
+
const logger = initDebugger.extend('AVAILABLE_NETWORKS');
|
|
54
|
+
try {
|
|
55
|
+
const res = await fetch(node_1.SUBGRAPH_STUDIO_URL, {
|
|
56
|
+
method: 'POST',
|
|
57
|
+
headers: {
|
|
58
|
+
...constants_1.GRAPH_CLI_SHARED_HEADERS,
|
|
59
|
+
'content-type': 'application/json',
|
|
60
|
+
},
|
|
61
|
+
body: JSON.stringify({
|
|
62
|
+
jsonrpc: '2.0',
|
|
63
|
+
id: 1,
|
|
64
|
+
method: 'chain_list',
|
|
65
|
+
params: [],
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
if (!res.ok) {
|
|
69
|
+
logger("Something went wrong while fetching 'chain_list' from studio HTTP code: %o", res.status);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const result = await res.json();
|
|
73
|
+
if (result?.result) {
|
|
74
|
+
return result.result;
|
|
75
|
+
}
|
|
76
|
+
logger("Unable to get result for 'chain_list' from studio: %O", result);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
logger('error: %O', e);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum-gravatar';
|
|
50
85
|
class InitCommand extends core_1.Command {
|
|
51
86
|
async run() {
|
|
52
87
|
const { args: { subgraphName, directory }, flags, } = await this.parse(InitCommand);
|
|
@@ -308,12 +343,8 @@ InitCommand.flags = {
|
|
|
308
343
|
}),
|
|
309
344
|
network: core_1.Flags.string({
|
|
310
345
|
summary: 'Network the contract is deployed to.',
|
|
346
|
+
description: 'Check https://thegraph.com/docs/en/developing/supported-networks/ for supported networks',
|
|
311
347
|
dependsOn: ['from-contract'],
|
|
312
|
-
options: [
|
|
313
|
-
...availableNetworks.get('ethereum'),
|
|
314
|
-
...availableNetworks.get('near'),
|
|
315
|
-
...availableNetworks.get('cosmos'),
|
|
316
|
-
],
|
|
317
348
|
}),
|
|
318
349
|
};
|
|
319
350
|
exports.default = InitCommand;
|
|
@@ -468,14 +499,13 @@ async function processInitForm({ protocol: initProtocol, product: initProduct, s
|
|
|
468
499
|
: true,
|
|
469
500
|
},
|
|
470
501
|
]);
|
|
502
|
+
const choices = (await AVAILABLE_NETWORKS())?.[product === 'subgraph-studio' ? 'studio' : 'hostedService'];
|
|
471
503
|
const { network } = await gluegun_1.prompt.ask([
|
|
472
504
|
{
|
|
473
505
|
type: 'select',
|
|
474
506
|
name: 'network',
|
|
475
507
|
message: () => `${protocolInstance.displayName()} network`,
|
|
476
|
-
choices
|
|
477
|
-
.get(protocol) // Get networks related to the chosen protocol.
|
|
478
|
-
?.toArray() || ['mainnet'],
|
|
508
|
+
choices,
|
|
479
509
|
skip: initNetwork !== undefined,
|
|
480
510
|
result: value => {
|
|
481
511
|
if (initNetwork) {
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.65.0-alpha-20240111165930-d9ce44f",
|
|
3
3
|
"commands": {
|
|
4
4
|
"add": {
|
|
5
5
|
"id": "add",
|
|
@@ -632,54 +632,8 @@
|
|
|
632
632
|
"name": "network",
|
|
633
633
|
"type": "option",
|
|
634
634
|
"summary": "Network the contract is deployed to.",
|
|
635
|
+
"description": "Check https://thegraph.com/docs/en/developing/supported-networks/ for supported networks",
|
|
635
636
|
"multiple": false,
|
|
636
|
-
"options": [
|
|
637
|
-
"mainnet",
|
|
638
|
-
"rinkeby",
|
|
639
|
-
"goerli",
|
|
640
|
-
"poa-core",
|
|
641
|
-
"poa-sokol",
|
|
642
|
-
"gnosis",
|
|
643
|
-
"matic",
|
|
644
|
-
"mumbai",
|
|
645
|
-
"fantom",
|
|
646
|
-
"fantom-testnet",
|
|
647
|
-
"bsc",
|
|
648
|
-
"chapel",
|
|
649
|
-
"clover",
|
|
650
|
-
"avalanche",
|
|
651
|
-
"fuji",
|
|
652
|
-
"celo",
|
|
653
|
-
"celo-alfajores",
|
|
654
|
-
"fuse",
|
|
655
|
-
"moonbeam",
|
|
656
|
-
"moonriver",
|
|
657
|
-
"mbase",
|
|
658
|
-
"arbitrum-one",
|
|
659
|
-
"arbitrum-goerli",
|
|
660
|
-
"arbitrum-sepolia",
|
|
661
|
-
"optimism",
|
|
662
|
-
"optimism-goerli",
|
|
663
|
-
"aurora",
|
|
664
|
-
"aurora-testnet",
|
|
665
|
-
"base-testnet",
|
|
666
|
-
"base",
|
|
667
|
-
"zksync-era",
|
|
668
|
-
"zksync-era-testnet",
|
|
669
|
-
"sepolia",
|
|
670
|
-
"polygon-zkevm-testnet",
|
|
671
|
-
"polygon-zkevm",
|
|
672
|
-
"scroll-sepolia",
|
|
673
|
-
"scroll",
|
|
674
|
-
"near-mainnet",
|
|
675
|
-
"near-testnet",
|
|
676
|
-
"cosmoshub-4",
|
|
677
|
-
"theta-testnet-001",
|
|
678
|
-
"osmosis-1",
|
|
679
|
-
"osmo-test-4",
|
|
680
|
-
"juno-1",
|
|
681
|
-
"uni-3"
|
|
682
|
-
],
|
|
683
637
|
"dependsOn": [
|
|
684
638
|
"from-contract"
|
|
685
639
|
]
|