@graphprotocol/graph-cli 0.55.0-alpha-20230810204930-d2e4934 → 0.55.0-alpha-20230817135924-19cf8e6
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 +4 -5
- package/dist/command-helpers/abi.js +4 -0
- package/dist/command-helpers/node.d.ts +0 -7
- package/dist/command-helpers/node.js +1 -34
- package/dist/command-helpers/studio.d.ts +1 -1
- package/dist/command-helpers/studio.js +1 -0
- package/dist/commands/deploy.d.ts +0 -1
- package/dist/commands/deploy.js +1 -100
- package/dist/protocols/index.js +1 -0
- package/oclif.manifest.json +2 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
-
## 0.55.0-alpha-
|
|
3
|
+
## 0.55.0-alpha-20230817135924-19cf8e6
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
- [#
|
|
8
|
-
[`
|
|
9
|
-
Thanks [@
|
|
10
|
-
make it easier to deploy subgraphs from hosted service to Studio.
|
|
7
|
+
- [#1421](https://github.com/graphprotocol/graph-tooling/pull/1421)
|
|
8
|
+
[`19cf8e6`](https://github.com/graphprotocol/graph-tooling/commit/19cf8e6b91acfc8cdd9abf35205b5ba2da37b8a9)
|
|
9
|
+
Thanks [@pranavdaa](https://github.com/pranavdaa)! - Add Scroll testnet to graph-cli
|
|
11
10
|
|
|
12
11
|
## 0.54.0
|
|
13
12
|
|
|
@@ -156,6 +156,8 @@ const getEtherscanLikeAPIUrl = (network) => {
|
|
|
156
156
|
return `https://zkevm.polygonscan.com/api`;
|
|
157
157
|
case 'sepolia':
|
|
158
158
|
return `https://api-sepolia.etherscan.io/api`;
|
|
159
|
+
case 'scroll-sepolia':
|
|
160
|
+
return `https://sepolia-blockscout.scroll.io/api`;
|
|
159
161
|
default:
|
|
160
162
|
return `https://api-${network}.etherscan.io/api`;
|
|
161
163
|
}
|
|
@@ -228,6 +230,8 @@ const getPublicRPCEndpoint = (network) => {
|
|
|
228
230
|
return 'https://zksync2-mainnet.zksync.io';
|
|
229
231
|
case 'sepolia':
|
|
230
232
|
return 'https://rpc.ankr.com/eth_sepolia';
|
|
233
|
+
case 'scroll-sepolia':
|
|
234
|
+
return 'https://rpc.ankr.com/scroll_sepolia_testnet';
|
|
231
235
|
default:
|
|
232
236
|
throw new Error(`Unknown network: ${network}`);
|
|
233
237
|
}
|
|
@@ -11,10 +11,3 @@ export declare function chooseNodeUrl({ product, studio, node, allowSimpleName,
|
|
|
11
11
|
node: string | undefined;
|
|
12
12
|
allowSimpleName: boolean | undefined;
|
|
13
13
|
};
|
|
14
|
-
export declare function getHostedServiceSubgraphId({ subgraphName, }: {
|
|
15
|
-
subgraphName: string;
|
|
16
|
-
}): Promise<{
|
|
17
|
-
subgraph: string;
|
|
18
|
-
synced: boolean;
|
|
19
|
-
health: 'healthy' | 'unhealthy' | 'failed';
|
|
20
|
-
}>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.chooseNodeUrl = exports.normalizeNodeUrl = exports.validateNodeUrl = void 0;
|
|
4
4
|
const url_1 = require("url");
|
|
5
5
|
const gluegun_1 = require("gluegun");
|
|
6
6
|
const SUBGRAPH_STUDIO_URL = 'https://api.studio.thegraph.com/deploy/';
|
|
7
7
|
const HOSTED_SERVICE_URL = 'https://api.thegraph.com/deploy/';
|
|
8
|
-
const HOSTED_SERVICE_INDEX_NODE_URL = 'https://api.thegraph.com/index-node/graphql';
|
|
9
8
|
const validateNodeUrl = (node) => new url_1.URL(node);
|
|
10
9
|
exports.validateNodeUrl = validateNodeUrl;
|
|
11
10
|
const normalizeNodeUrl = (node) => new url_1.URL(node).toString();
|
|
@@ -39,35 +38,3 @@ function chooseNodeUrl({ product, studio, node, allowSimpleName, }) {
|
|
|
39
38
|
return { node, allowSimpleName };
|
|
40
39
|
}
|
|
41
40
|
exports.chooseNodeUrl = chooseNodeUrl;
|
|
42
|
-
async function getHostedServiceSubgraphId({ subgraphName, }) {
|
|
43
|
-
const response = await fetch(HOSTED_SERVICE_INDEX_NODE_URL, {
|
|
44
|
-
method: 'POST',
|
|
45
|
-
body: JSON.stringify({
|
|
46
|
-
query: /* GraphQL */ `
|
|
47
|
-
query GraphCli_getSubgraphId($subgraphName: String!) {
|
|
48
|
-
indexingStatusForCurrentVersion(subgraphName: $subgraphName) {
|
|
49
|
-
subgraph
|
|
50
|
-
synced
|
|
51
|
-
health
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`,
|
|
55
|
-
variables: {
|
|
56
|
-
subgraphName,
|
|
57
|
-
},
|
|
58
|
-
}),
|
|
59
|
-
headers: {
|
|
60
|
-
'content-type': 'application/json',
|
|
61
|
-
'User-Agent': '@graphprotocol/graph-cli',
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
const { data, errors } = await response.json();
|
|
65
|
-
if (errors) {
|
|
66
|
-
throw new Error(errors[0].message);
|
|
67
|
-
}
|
|
68
|
-
if (!data.indexingStatusForCurrentVersion) {
|
|
69
|
-
throw new Error(`Subgraph "${subgraphName}" not found on the hosted service`);
|
|
70
|
-
}
|
|
71
|
-
return data.indexingStatusForCurrentVersion;
|
|
72
|
-
}
|
|
73
|
-
exports.getHostedServiceSubgraphId = getHostedServiceSubgraphId;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const allowedStudioNetworks: readonly ["mainnet", "rinkeby", "goerli", "gnosis", "chapel", "optimism-goerli", "clover", "fantom", "matic", "fantom-testnet", "arbitrum-goerli", "fuji", "celo-alfajores", "mumbai", "aurora-testnet", "near-testnet", "optimism", "optimism-goerli", "theta-testnet-001", "osmo-test-4", "base-testnet", "base", "celo", "arbitrum-one", "avalanche", "zksync-era", "sepolia", "polygon-zkevm-testnet", "polygon-zkevm"];
|
|
1
|
+
export declare const allowedStudioNetworks: readonly ["mainnet", "rinkeby", "goerli", "gnosis", "chapel", "optimism-goerli", "clover", "fantom", "matic", "fantom-testnet", "arbitrum-goerli", "fuji", "celo-alfajores", "mumbai", "aurora-testnet", "near-testnet", "optimism", "optimism-goerli", "theta-testnet-001", "osmo-test-4", "base-testnet", "base", "celo", "arbitrum-one", "avalanche", "zksync-era", "sepolia", "polygon-zkevm-testnet", "polygon-zkevm", "scroll-sepolia"];
|
|
2
2
|
export declare const validateStudioNetwork: ({ studio, product, network, }: {
|
|
3
3
|
studio?: string | boolean | undefined;
|
|
4
4
|
product?: string | undefined;
|
|
@@ -22,7 +22,6 @@ export default class DeployCommand extends Command {
|
|
|
22
22
|
watch: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
23
23
|
network: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
24
24
|
'network-file': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
25
|
-
'from-hosted-service': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
26
25
|
};
|
|
27
26
|
run(): Promise<void>;
|
|
28
27
|
}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -50,103 +50,7 @@ const headersFlag = core_1.Flags.custom({
|
|
|
50
50
|
const productOptions = ['subgraph-studio', 'hosted-service'];
|
|
51
51
|
class DeployCommand extends core_1.Command {
|
|
52
52
|
async run() {
|
|
53
|
-
const { args: { 'subgraph-name': subgraphNameArg, 'subgraph-manifest': manifest }, flags: { product: productFlag, studio, 'deploy-key': deployKeyFlag, 'access-token': accessToken, 'version-label': versionLabelFlag, ipfs, headers, node: nodeFlag, 'output-dir': outputDir, 'skip-migrations': skipMigrations, watch, 'debug-fork': debugFork, network, 'network-file': networkFile, 'ipfs-hash': ipfsHash,
|
|
54
|
-
if (hostedServiceSubgraphName) {
|
|
55
|
-
const { health, subgraph: subgraphIpfsHash } = await (0, node_1.getHostedServiceSubgraphId)({
|
|
56
|
-
subgraphName: hostedServiceSubgraphName,
|
|
57
|
-
});
|
|
58
|
-
const safeToDeployFailedSubgraph = health === 'failed'
|
|
59
|
-
? await core_1.ux.confirm('This subgraph has failed indexing on hosted service. Do you wish to continue the deploy?')
|
|
60
|
-
: true;
|
|
61
|
-
if (!safeToDeployFailedSubgraph)
|
|
62
|
-
return;
|
|
63
|
-
const safeToDeployUnhealthySubgraph = health === 'unhealthy'
|
|
64
|
-
? await core_1.ux.confirm('This subgraph is not healthy on hosted service. Do you wish to continue the deploy?')
|
|
65
|
-
: true;
|
|
66
|
-
if (!safeToDeployUnhealthySubgraph)
|
|
67
|
-
return;
|
|
68
|
-
const { node } = (0, node_1.chooseNodeUrl)({ studio: true, product: undefined });
|
|
69
|
-
// shouldn't happen, but we need to satisfy the compiler
|
|
70
|
-
if (!node) {
|
|
71
|
-
this.error('No node URL available');
|
|
72
|
-
}
|
|
73
|
-
const requestUrl = new url_1.URL(node);
|
|
74
|
-
const client = (0, jsonrpc_1.createJsonRpcClient)(requestUrl);
|
|
75
|
-
// Exit with an error code if the client couldn't be created
|
|
76
|
-
if (!client) {
|
|
77
|
-
this.error('Failed to create RPC client');
|
|
78
|
-
}
|
|
79
|
-
// Use the deploy key, if one is set
|
|
80
|
-
let deployKey = deployKeyFlag;
|
|
81
|
-
if (!deployKey && accessToken) {
|
|
82
|
-
deployKey = accessToken; // backwards compatibility
|
|
83
|
-
}
|
|
84
|
-
deployKey = await (0, auth_1.identifyDeployKey)(node, deployKey);
|
|
85
|
-
if (!deployKey) {
|
|
86
|
-
this.error('No deploy key available');
|
|
87
|
-
}
|
|
88
|
-
// @ts-expect-error options property seems to exist
|
|
89
|
-
client.options.headers = { Authorization: 'Bearer ' + deployKey };
|
|
90
|
-
const subgraphName = await core_1.ux.prompt('What is the name of the subgraph you want to deploy?', {
|
|
91
|
-
required: true,
|
|
92
|
-
});
|
|
93
|
-
// Ask for label if not on hosted service
|
|
94
|
-
const versionLabel = versionLabelFlag ||
|
|
95
|
-
(await core_1.ux.prompt('Which version label to use? (e.g. "v0.0.1")', {
|
|
96
|
-
required: true,
|
|
97
|
-
}));
|
|
98
|
-
const spinner = gluegun_1.print.spin(`Deploying to Graph node ${requestUrl}`);
|
|
99
|
-
client.request('subgraph_deploy', {
|
|
100
|
-
name: subgraphName,
|
|
101
|
-
ipfs_hash: subgraphIpfsHash,
|
|
102
|
-
version_label: versionLabel,
|
|
103
|
-
debug_fork: debugFork,
|
|
104
|
-
}, async (
|
|
105
|
-
// @ts-expect-error TODO: why are the arguments not typed?
|
|
106
|
-
requestError,
|
|
107
|
-
// @ts-expect-error TODO: why are the arguments not typed?
|
|
108
|
-
jsonRpcError,
|
|
109
|
-
// @ts-expect-error TODO: why are the arguments not typed?
|
|
110
|
-
res) => {
|
|
111
|
-
if (jsonRpcError) {
|
|
112
|
-
let errorMessage = `Failed to deploy to Graph node ${requestUrl}: ${jsonRpcError.message}`;
|
|
113
|
-
// Provide helpful advice when the subgraph has not been created yet
|
|
114
|
-
if (jsonRpcError.message.match(/subgraph name not found/)) {
|
|
115
|
-
errorMessage += `
|
|
116
|
-
Make sure to create the subgraph first by running the following command:
|
|
117
|
-
$ graph create --node ${node} ${subgraphName}`;
|
|
118
|
-
}
|
|
119
|
-
if (jsonRpcError.message.match(/auth failure/)) {
|
|
120
|
-
errorMessage += '\nYou may need to authenticate first.';
|
|
121
|
-
}
|
|
122
|
-
spinner.fail(errorMessage);
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
125
|
-
else if (requestError) {
|
|
126
|
-
spinner.fail(`HTTP error deploying the subgraph ${requestError.code}`);
|
|
127
|
-
process.exit(1);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
spinner.stop();
|
|
131
|
-
const base = requestUrl.protocol + '//' + requestUrl.hostname;
|
|
132
|
-
let playground = res.playground;
|
|
133
|
-
let queries = res.queries;
|
|
134
|
-
// Add a base URL if graph-node did not return the full URL
|
|
135
|
-
if (playground.charAt(0) === ':') {
|
|
136
|
-
playground = base + playground;
|
|
137
|
-
}
|
|
138
|
-
if (queries.charAt(0) === ':') {
|
|
139
|
-
queries = base + queries;
|
|
140
|
-
}
|
|
141
|
-
gluegun_1.print.success(`Deployed to ${playground}`);
|
|
142
|
-
gluegun_1.print.info('\nSubgraph endpoints:');
|
|
143
|
-
gluegun_1.print.info(`Queries (HTTP): ${queries}`);
|
|
144
|
-
gluegun_1.print.info(``);
|
|
145
|
-
process.exit(0);
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
53
|
+
const { args: { 'subgraph-name': subgraphNameArg, 'subgraph-manifest': manifest }, flags: { product: productFlag, studio, 'deploy-key': deployKeyFlag, 'access-token': accessToken, 'version-label': versionLabelFlag, ipfs, headers, node: nodeFlag, 'output-dir': outputDir, 'skip-migrations': skipMigrations, watch, 'debug-fork': debugFork, network, 'network-file': networkFile, 'ipfs-hash': ipfsHash, }, } = await this.parse(DeployCommand);
|
|
150
54
|
const subgraphName = subgraphNameArg ||
|
|
151
55
|
(await core_1.ux.prompt('What is the subgraph name?', {
|
|
152
56
|
required: true,
|
|
@@ -425,8 +329,5 @@ DeployCommand.flags = {
|
|
|
425
329
|
summary: 'Networks config file path.',
|
|
426
330
|
default: 'networks.json',
|
|
427
331
|
}),
|
|
428
|
-
'from-hosted-service': core_1.Flags.string({
|
|
429
|
-
summary: 'Hosted service Subgraph Name to deploy to studio.',
|
|
430
|
-
}),
|
|
431
332
|
};
|
|
432
333
|
exports.default = DeployCommand;
|
package/dist/protocols/index.js
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.55.0-alpha-
|
|
2
|
+
"version": "0.55.0-alpha-20230817135924-19cf8e6",
|
|
3
3
|
"commands": {
|
|
4
4
|
"add": {
|
|
5
5
|
"id": "add",
|
|
@@ -451,12 +451,6 @@
|
|
|
451
451
|
"summary": "Networks config file path.",
|
|
452
452
|
"multiple": false,
|
|
453
453
|
"default": "networks.json"
|
|
454
|
-
},
|
|
455
|
-
"from-hosted-service": {
|
|
456
|
-
"name": "from-hosted-service",
|
|
457
|
-
"type": "option",
|
|
458
|
-
"summary": "Hosted service Subgraph Name to deploy to studio.",
|
|
459
|
-
"multiple": false
|
|
460
454
|
}
|
|
461
455
|
},
|
|
462
456
|
"args": {
|
|
@@ -637,6 +631,7 @@
|
|
|
637
631
|
"sepolia",
|
|
638
632
|
"polygon-zkevm-testnet",
|
|
639
633
|
"polygon-zkevm",
|
|
634
|
+
"scroll-sepolia",
|
|
640
635
|
"near-mainnet",
|
|
641
636
|
"near-testnet",
|
|
642
637
|
"cosmoshub-4",
|
package/package.json
CHANGED