@graphprotocol/graph-cli 0.89.0 → 0.90.0-alpha-20241126184316-dc0c108
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 +15 -0
- package/dist/command-helpers/abi.js +12 -0
- package/dist/commands/init.js +6 -14
- package/dist/commands/publish.d.ts +3 -1
- package/dist/commands/publish.js +20 -3
- package/oclif.manifest.json +8 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
+
## 0.90.0-alpha-20241126184316-dc0c108
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`098b433`](https://github.com/graphprotocol/graph-tooling/commit/098b433815390e5aff2e0e52f22ab0ee44b9c206)
|
|
8
|
+
Thanks [@DenisCarriere](https://github.com/DenisCarriere)! - Update deprecated endpoints and
|
|
9
|
+
support API key for updating published subgraphs
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1767](https://github.com/graphprotocol/graph-tooling/pull/1767)
|
|
14
|
+
[`6f2cb45`](https://github.com/graphprotocol/graph-tooling/commit/6f2cb45e5a07d8de2946a485763feb0b1bcfd4f0)
|
|
15
|
+
Thanks [@0237h](https://github.com/0237h)! - Fix CLI validation for `startBlock` and
|
|
16
|
+
`contractName` fetched from external APIs
|
|
17
|
+
|
|
3
18
|
## 0.89.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -272,6 +272,12 @@ const getEtherscanLikeAPIUrl = (network) => {
|
|
|
272
272
|
return 'https://unichain-sepolia.blockscout.com/api';
|
|
273
273
|
case 'lens-testnet':
|
|
274
274
|
return 'https://block-explorer-api.testnet.lens.dev/api';
|
|
275
|
+
case 'abstract-testnet':
|
|
276
|
+
return 'https://block-explorer-api.testnet.abs.xyz/api';
|
|
277
|
+
case 'corn':
|
|
278
|
+
return 'https://maizenet-explorer.usecorn.com/api';
|
|
279
|
+
case 'corn-testnet':
|
|
280
|
+
return 'https://testnet-explorer.usecorn.com/api';
|
|
275
281
|
default:
|
|
276
282
|
return `https://api-${network}.etherscan.io/api`;
|
|
277
283
|
}
|
|
@@ -430,6 +436,12 @@ const getPublicRPCEndpoint = (network) => {
|
|
|
430
436
|
return 'https://sepolia.unichain.org';
|
|
431
437
|
case 'lens-testnet':
|
|
432
438
|
return 'https://api.staging.lens.zksync.dev';
|
|
439
|
+
case 'abstract-testnet':
|
|
440
|
+
return 'https://api.testnet.abs.xyz';
|
|
441
|
+
case 'corn':
|
|
442
|
+
return 'https://maizenet-rpc.usecorn.com';
|
|
443
|
+
case 'corn-testnet':
|
|
444
|
+
return 'https://testnet-rpc.usecorn.com';
|
|
433
445
|
default:
|
|
434
446
|
throw new Error(`Unknown network: ${network}`);
|
|
435
447
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -362,6 +362,8 @@ async function retryWithPrompt(func) {
|
|
|
362
362
|
}
|
|
363
363
|
async function processInitForm({ protocol: initProtocol, abi: initAbi, abiPath: initAbiPath, directory: initDirectory, contract: initContract, indexEvents: initIndexEvents, fromExample: initFromExample, network: initNetwork, subgraphName: initSubgraphName, contractName: initContractName, startBlock: initStartBlock, spkgPath: initSpkgPath, }) {
|
|
364
364
|
let abiFromEtherscan = undefined;
|
|
365
|
+
let startBlockFromEtherscan = undefined;
|
|
366
|
+
let contractNameFromEtherscan = undefined;
|
|
365
367
|
try {
|
|
366
368
|
const { protocol } = await gluegun_1.prompt.ask({
|
|
367
369
|
type: 'select',
|
|
@@ -461,7 +463,7 @@ async function processInitForm({ protocol: initProtocol, abi: initAbi, abiPath:
|
|
|
461
463
|
// Load startBlock for this contract
|
|
462
464
|
const startBlock = await retryWithPrompt(() => (0, abi_1.loadStartBlockForContract)(network, value));
|
|
463
465
|
if (startBlock) {
|
|
464
|
-
|
|
466
|
+
startBlockFromEtherscan = Number(startBlock).toString();
|
|
465
467
|
}
|
|
466
468
|
}
|
|
467
469
|
// If contract name is not set, try to load it.
|
|
@@ -469,7 +471,7 @@ async function processInitForm({ protocol: initProtocol, abi: initAbi, abiPath:
|
|
|
469
471
|
// Load contract name for this contract
|
|
470
472
|
const contractName = await retryWithPrompt(() => (0, abi_1.loadContractNameForAddress)(network, value));
|
|
471
473
|
if (contractName) {
|
|
472
|
-
|
|
474
|
+
contractNameFromEtherscan = contractName;
|
|
473
475
|
}
|
|
474
476
|
}
|
|
475
477
|
return value;
|
|
@@ -532,14 +534,9 @@ async function processInitForm({ protocol: initProtocol, abi: initAbi, abiPath:
|
|
|
532
534
|
type: 'input',
|
|
533
535
|
name: 'startBlock',
|
|
534
536
|
message: 'Start Block',
|
|
535
|
-
initial: initStartBlock || '0',
|
|
537
|
+
initial: initStartBlock || startBlockFromEtherscan || '0',
|
|
536
538
|
skip: () => initFromExample !== undefined || isSubstreams,
|
|
537
539
|
validate: value => parseInt(value) >= 0,
|
|
538
|
-
result(value) {
|
|
539
|
-
if (initStartBlock)
|
|
540
|
-
return initStartBlock;
|
|
541
|
-
return value;
|
|
542
|
-
},
|
|
543
540
|
},
|
|
544
541
|
]);
|
|
545
542
|
const { contractName } = await gluegun_1.prompt.ask([
|
|
@@ -547,14 +544,9 @@ async function processInitForm({ protocol: initProtocol, abi: initAbi, abiPath:
|
|
|
547
544
|
type: 'input',
|
|
548
545
|
name: 'contractName',
|
|
549
546
|
message: 'Contract Name',
|
|
550
|
-
initial: initContractName || 'Contract' || isSubstreams,
|
|
547
|
+
initial: initContractName || contractNameFromEtherscan || 'Contract' || isSubstreams,
|
|
551
548
|
skip: () => initFromExample !== undefined || !protocolInstance.hasContract(),
|
|
552
549
|
validate: value => value && value.length > 0,
|
|
553
|
-
result(value) {
|
|
554
|
-
if (initContractName)
|
|
555
|
-
return initContractName;
|
|
556
|
-
return value;
|
|
557
|
-
},
|
|
558
550
|
},
|
|
559
551
|
]);
|
|
560
552
|
const { indexEvents } = await gluegun_1.prompt.ask([
|
|
@@ -11,15 +11,17 @@ export default class PublishCommand extends Command {
|
|
|
11
11
|
ipfs: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
12
|
'ipfs-hash': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
13
|
'webapp-url': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
+
'api-key': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
17
|
* Prompt the user to open up the browser to continue publishing the subgraph
|
|
17
18
|
*/
|
|
18
|
-
publishWithBrowser({ ipfsHash, webapp, subgraphId, protocolNetwork, }: {
|
|
19
|
+
publishWithBrowser({ ipfsHash, webapp, subgraphId, protocolNetwork, apiKey, }: {
|
|
19
20
|
ipfsHash: string;
|
|
20
21
|
webapp: string;
|
|
21
22
|
subgraphId: string | undefined;
|
|
22
23
|
protocolNetwork: string | undefined;
|
|
24
|
+
apiKey: string | undefined;
|
|
23
25
|
}): Promise<void>;
|
|
24
26
|
run(): Promise<void>;
|
|
25
27
|
}
|
package/dist/commands/publish.js
CHANGED
|
@@ -40,7 +40,7 @@ class PublishCommand extends core_1.Command {
|
|
|
40
40
|
/**
|
|
41
41
|
* Prompt the user to open up the browser to continue publishing the subgraph
|
|
42
42
|
*/
|
|
43
|
-
async publishWithBrowser({ ipfsHash, webapp, subgraphId, protocolNetwork, }) {
|
|
43
|
+
async publishWithBrowser({ ipfsHash, webapp, subgraphId, protocolNetwork, apiKey, }) {
|
|
44
44
|
const answer = await core_1.ux.prompt(`Press ${chalk_1.default.green('y')} (or any key) to open up the browser to continue publishing or ${chalk_1.default.yellow('q')} to exit`);
|
|
45
45
|
if (answer.toLowerCase() === 'q') {
|
|
46
46
|
this.exit(0);
|
|
@@ -54,6 +54,9 @@ class PublishCommand extends core_1.Command {
|
|
|
54
54
|
if (protocolNetwork) {
|
|
55
55
|
searchParams.set('network', protocolNetwork);
|
|
56
56
|
}
|
|
57
|
+
if (apiKey) {
|
|
58
|
+
searchParams.set('apiKey', apiKey);
|
|
59
|
+
}
|
|
57
60
|
url.search = searchParams.toString();
|
|
58
61
|
const openUrl = url.toString();
|
|
59
62
|
gluegun_1.print.success(`Finalize the publish of the subgraph from the Graph CLI publish page. Opening up the browser to continue publishing at ${openUrl}`);
|
|
@@ -61,9 +64,18 @@ class PublishCommand extends core_1.Command {
|
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
63
66
|
async run() {
|
|
64
|
-
const { args: { 'subgraph-manifest': manifest }, flags: { 'ipfs-hash': ipfsHash, 'webapp-url': webUiUrl, ipfs, 'subgraph-id': subgraphId, 'protocol-network': protocolNetwork, }, } = await this.parse(PublishCommand);
|
|
67
|
+
const { args: { 'subgraph-manifest': manifest }, flags: { 'ipfs-hash': ipfsHash, 'webapp-url': webUiUrl, ipfs, 'subgraph-id': subgraphId, 'protocol-network': protocolNetwork, 'api-key': apiKey, }, } = await this.parse(PublishCommand);
|
|
68
|
+
if (subgraphId && !apiKey) {
|
|
69
|
+
core_1.ux.error('API key is required to publish to an existing subgraph (`--api-key`).\nSee https://thegraph.com/docs/en/deploying/subgraph-studio-faqs/#2-how-do-i-create-an-api-key', { exit: 1 });
|
|
70
|
+
}
|
|
65
71
|
if (ipfsHash) {
|
|
66
|
-
await this.publishWithBrowser({
|
|
72
|
+
await this.publishWithBrowser({
|
|
73
|
+
ipfsHash,
|
|
74
|
+
webapp: webUiUrl,
|
|
75
|
+
subgraphId,
|
|
76
|
+
protocolNetwork,
|
|
77
|
+
apiKey,
|
|
78
|
+
});
|
|
67
79
|
return;
|
|
68
80
|
}
|
|
69
81
|
let protocol;
|
|
@@ -97,6 +109,7 @@ class PublishCommand extends core_1.Command {
|
|
|
97
109
|
webapp: webUiUrl,
|
|
98
110
|
subgraphId,
|
|
99
111
|
protocolNetwork,
|
|
112
|
+
apiKey,
|
|
100
113
|
});
|
|
101
114
|
return;
|
|
102
115
|
}
|
|
@@ -135,5 +148,9 @@ PublishCommand.flags = {
|
|
|
135
148
|
required: false,
|
|
136
149
|
default: 'https://cli.thegraph.com/publish',
|
|
137
150
|
}),
|
|
151
|
+
'api-key': core_1.Flags.string({
|
|
152
|
+
summary: 'The API key to use for the Subgraph queries.',
|
|
153
|
+
required: false,
|
|
154
|
+
}),
|
|
138
155
|
};
|
|
139
156
|
exports.default = PublishCommand;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.90.0-alpha-20241126184316-dc0c108",
|
|
3
3
|
"commands": {
|
|
4
4
|
"add": {
|
|
5
5
|
"id": "add",
|
|
@@ -716,6 +716,13 @@
|
|
|
716
716
|
"required": false,
|
|
717
717
|
"multiple": false,
|
|
718
718
|
"default": "https://cli.thegraph.com/publish"
|
|
719
|
+
},
|
|
720
|
+
"api-key": {
|
|
721
|
+
"name": "api-key",
|
|
722
|
+
"type": "option",
|
|
723
|
+
"summary": "The API key to use for the Subgraph queries.",
|
|
724
|
+
"required": false,
|
|
725
|
+
"multiple": false
|
|
719
726
|
}
|
|
720
727
|
},
|
|
721
728
|
"args": {
|