@graphprotocol/graph-cli 0.64.1-alpha-20231219035922-3e45e5d → 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 +9 -1
- 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/dist/protocols/ethereum/codegen/abi.test.js +93 -6
- package/oclif.manifest.json +2 -48
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
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
|
+
|
|
11
|
+
## 0.64.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
6
14
|
|
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) {
|
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
const path_1 = __importDefault(require("path"));
|
|
7
30
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
31
|
+
const immutable_1 = __importDefault(require("immutable"));
|
|
8
32
|
const vitest_1 = require("vitest");
|
|
33
|
+
const ts = __importStar(require("../../../codegen/typescript"));
|
|
9
34
|
const abi_1 = __importDefault(require("../abi"));
|
|
10
35
|
const abi_2 = __importDefault(require("./abi"));
|
|
11
36
|
let tempdir;
|
|
@@ -175,7 +200,14 @@ vitest_1.describe.concurrent('ABI code generation', () => {
|
|
|
175
200
|
});
|
|
176
201
|
(0, vitest_1.describe)('Generated types', () => {
|
|
177
202
|
(0, vitest_1.test)('All expected types are generated', () => {
|
|
178
|
-
(0, vitest_1.expect)(generatedTypes.map(type => type.name)).
|
|
203
|
+
(0, vitest_1.expect)(generatedTypes.map(type => type.name)).toEqual([
|
|
204
|
+
'Contract__getProposalResultValue0Struct',
|
|
205
|
+
'Contract__getProposalInputParam1Struct',
|
|
206
|
+
'Contract__getProposalInputParam1BarStruct',
|
|
207
|
+
'Contract__getProposalsResultValue1Struct',
|
|
208
|
+
'Contract__getProposalsResult',
|
|
209
|
+
'Contract',
|
|
210
|
+
]);
|
|
179
211
|
});
|
|
180
212
|
});
|
|
181
213
|
(0, vitest_1.describe)('Contract class', () => {
|
|
@@ -198,11 +230,51 @@ vitest_1.describe.concurrent('ABI code generation', () => {
|
|
|
198
230
|
(0, vitest_1.describe)('Methods for callable functions', () => {
|
|
199
231
|
(0, vitest_1.test)('Have correct parameters', () => {
|
|
200
232
|
const contract = generatedTypes.find(type => type.name === 'Contract');
|
|
201
|
-
(0, vitest_1.expect)(contract.methods.map((method) => [method.name, method.params])).
|
|
233
|
+
(0, vitest_1.expect)(contract.methods.map((method) => [method.name, method.params])).toEqual([
|
|
234
|
+
['bind', immutable_1.default.List([ts.param('address', 'Address')])],
|
|
235
|
+
['read', immutable_1.default.List()],
|
|
236
|
+
['try_read', immutable_1.default.List()],
|
|
237
|
+
[
|
|
238
|
+
'getProposal',
|
|
239
|
+
immutable_1.default.List([
|
|
240
|
+
ts.param('proposalId', 'BigInt'),
|
|
241
|
+
ts.param('param1', 'Contract__getProposalInputParam1Struct'),
|
|
242
|
+
]),
|
|
243
|
+
],
|
|
244
|
+
[
|
|
245
|
+
'try_getProposal',
|
|
246
|
+
immutable_1.default.List([
|
|
247
|
+
ts.param('proposalId', 'BigInt'),
|
|
248
|
+
ts.param('param1', 'Contract__getProposalInputParam1Struct'),
|
|
249
|
+
]),
|
|
250
|
+
],
|
|
251
|
+
['getProposals', immutable_1.default.List()],
|
|
252
|
+
['try_getProposals', immutable_1.default.List()],
|
|
253
|
+
['overloaded', immutable_1.default.List([ts.param('param0', 'string')])],
|
|
254
|
+
['try_overloaded', immutable_1.default.List([ts.param('param0', 'string')])],
|
|
255
|
+
['overloaded1', immutable_1.default.List([ts.param('param0', 'BigInt')])],
|
|
256
|
+
['try_overloaded1', immutable_1.default.List([ts.param('param0', 'BigInt')])],
|
|
257
|
+
['overloaded2', immutable_1.default.List([ts.param('param0', 'Bytes')])],
|
|
258
|
+
['try_overloaded2', immutable_1.default.List([ts.param('param0', 'Bytes')])],
|
|
259
|
+
]);
|
|
202
260
|
});
|
|
203
261
|
(0, vitest_1.test)('Have correct return types', () => {
|
|
204
262
|
const contract = generatedTypes.find(type => type.name === 'Contract');
|
|
205
|
-
(0, vitest_1.expect)(contract.methods.map((method) => [method.name, method.returnType])).
|
|
263
|
+
(0, vitest_1.expect)(contract.methods.map((method) => [method.name, method.returnType])).toEqual([
|
|
264
|
+
['bind', ts.namedType('Contract')],
|
|
265
|
+
['read', ts.namedType('Bytes')],
|
|
266
|
+
['try_read', 'ethereum.CallResult<Bytes>'],
|
|
267
|
+
['getProposal', ts.namedType('Contract__getProposalResultValue0Struct')],
|
|
268
|
+
['try_getProposal', 'ethereum.CallResult<Contract__getProposalResultValue0Struct>'],
|
|
269
|
+
['getProposals', ts.namedType('Contract__getProposalsResult')],
|
|
270
|
+
['try_getProposals', 'ethereum.CallResult<Contract__getProposalsResult>'],
|
|
271
|
+
['overloaded', ts.namedType('string')],
|
|
272
|
+
['try_overloaded', 'ethereum.CallResult<string>'],
|
|
273
|
+
['overloaded1', ts.namedType('string')],
|
|
274
|
+
['try_overloaded1', 'ethereum.CallResult<string>'],
|
|
275
|
+
['overloaded2', ts.namedType('string')],
|
|
276
|
+
['try_overloaded2', 'ethereum.CallResult<string>'],
|
|
277
|
+
]);
|
|
206
278
|
});
|
|
207
279
|
});
|
|
208
280
|
(0, vitest_1.describe)('Tuples', () => {
|
|
@@ -212,14 +284,19 @@ vitest_1.describe.concurrent('ABI code generation', () => {
|
|
|
212
284
|
(0, vitest_1.expect)(tupleType.methods).toBeDefined();
|
|
213
285
|
// Verify that the tuple type has getters for all tuple fields with
|
|
214
286
|
// the right return types
|
|
215
|
-
(0, vitest_1.expect)(tupleType.methods.map((method) => [method.name, method.returnType])).
|
|
287
|
+
(0, vitest_1.expect)(tupleType.methods.map((method) => [method.name, method.returnType])).toEqual([
|
|
288
|
+
['get foo', 'i32'],
|
|
289
|
+
['get bar', 'Contract__getProposalInputParam1BarStruct'],
|
|
290
|
+
]);
|
|
216
291
|
// Inner tuple:
|
|
217
292
|
tupleType = generatedTypes.find(type => type.name === 'Contract__getProposalInputParam1BarStruct');
|
|
218
293
|
// Verify that the tuple type has methods
|
|
219
294
|
(0, vitest_1.expect)(tupleType.methods).toBeDefined();
|
|
220
295
|
// Verify that the tuple type has getters for all tuple fields with
|
|
221
296
|
// the right return types
|
|
222
|
-
(0, vitest_1.expect)(tupleType.methods.map((method) => [method.name, method.returnType])).
|
|
297
|
+
(0, vitest_1.expect)(tupleType.methods.map((method) => [method.name, method.returnType])).toEqual([
|
|
298
|
+
['get baz', 'Address'],
|
|
299
|
+
]);
|
|
223
300
|
});
|
|
224
301
|
(0, vitest_1.test)('Tuple types exist for function return values', () => {
|
|
225
302
|
const tupleType = generatedTypes.find(type => type.name === 'Contract__getProposalResultValue0Struct');
|
|
@@ -227,7 +304,17 @@ vitest_1.describe.concurrent('ABI code generation', () => {
|
|
|
227
304
|
(0, vitest_1.expect)(tupleType.methods).toBeDefined();
|
|
228
305
|
// Verify that the tuple type has getters for all tuple fields with
|
|
229
306
|
// the right return types
|
|
230
|
-
(0, vitest_1.expect)(tupleType.methods.map((method) => [method.name, method.returnType])).
|
|
307
|
+
(0, vitest_1.expect)(tupleType.methods.map((method) => [method.name, method.returnType])).toEqual([
|
|
308
|
+
['get result', 'i32'],
|
|
309
|
+
['get target', 'Address'],
|
|
310
|
+
['get data', 'Bytes'],
|
|
311
|
+
['get proposer', 'Address'],
|
|
312
|
+
['get feeRecipient', 'Address'],
|
|
313
|
+
['get fee', 'BigInt'],
|
|
314
|
+
['get startTime', 'BigInt'],
|
|
315
|
+
['get yesCount', 'BigInt'],
|
|
316
|
+
['get noCount', 'BigInt'],
|
|
317
|
+
]);
|
|
231
318
|
});
|
|
232
319
|
(0, vitest_1.test)('Function bodies are generated correctly for tuple arrays', () => {
|
|
233
320
|
const contract = generatedTypes.find(type => type.name === 'Contract');
|
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
|
]
|
package/package.json
CHANGED