@graphprotocol/graph-cli 0.63.0-alpha-20231204215314-34e2f68 → 0.63.0-alpha-20231206152354-981f2bb
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 +11 -1
- package/dist/commands/deploy.js +0 -19
- package/dist/commands/init.js +1 -15
- package/dist/compiler/index.js +11 -2
- package/dist/protocols/index.d.ts +3 -3
- package/dist/protocols/index.js +17 -3
- package/dist/protocols/substreams/manifest.graphql +4 -0
- package/dist/subgraph.js +3 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/dist/command-helpers/studio.d.ts +0 -6
- package/dist/command-helpers/studio.js +0 -49
- package/dist/command-helpers/studio.test.d.ts +0 -1
- package/dist/command-helpers/studio.test.js +0 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
-
## 0.63.0-alpha-
|
|
3
|
+
## 0.63.0-alpha-20231206152354-981f2bb
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
+
- [#1490](https://github.com/graphprotocol/graph-tooling/pull/1490)
|
|
8
|
+
[`3fa19c5`](https://github.com/graphprotocol/graph-tooling/commit/3fa19c5b212bff03d57b027f1dbdf80090e69b02)
|
|
9
|
+
Thanks [@mangas](https://github.com/mangas)! - substreams based triggers support
|
|
10
|
+
|
|
7
11
|
- [#1524](https://github.com/graphprotocol/graph-tooling/pull/1524)
|
|
8
12
|
[`086a2da`](https://github.com/graphprotocol/graph-tooling/commit/086a2da03a4388277b69b6db541a0673dc9505bb)
|
|
9
13
|
Thanks [@pedropregueiro](https://github.com/pedropregueiro)! - Add support for M3 apple silicon
|
|
10
14
|
for `graph test`
|
|
11
15
|
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#1521](https://github.com/graphprotocol/graph-tooling/pull/1521)
|
|
19
|
+
[`3571a57`](https://github.com/graphprotocol/graph-tooling/commit/3571a571b2a094f41932e7cbc91b605c7ba0962c)
|
|
20
|
+
Thanks [@saihaj](https://github.com/saihaj)! - remove studio network validation checks
|
|
21
|
+
|
|
12
22
|
## 0.62.0
|
|
13
23
|
|
|
14
24
|
### Minor Changes
|
package/dist/commands/deploy.js
CHANGED
|
@@ -38,7 +38,6 @@ const ipfs_1 = require("../command-helpers/ipfs");
|
|
|
38
38
|
const jsonrpc_1 = require("../command-helpers/jsonrpc");
|
|
39
39
|
const network_1 = require("../command-helpers/network");
|
|
40
40
|
const node_1 = require("../command-helpers/node");
|
|
41
|
-
const studio_1 = require("../command-helpers/studio");
|
|
42
41
|
const version_1 = require("../command-helpers/version");
|
|
43
42
|
const constants_1 = require("../constants");
|
|
44
43
|
const protocols_1 = __importDefault(require("../protocols"));
|
|
@@ -293,27 +292,9 @@ class DeployCommand extends core_1.Command {
|
|
|
293
292
|
this.error(`Could not find subgraph manifest at IPFS hash ${ipfsHash}`, { exit: 1 });
|
|
294
293
|
}
|
|
295
294
|
await ipfsClient.pin.add(ipfsHash);
|
|
296
|
-
try {
|
|
297
|
-
const dataSourcesAndTemplates = DataSourcesExtractor.fromManifestString(manifestFile);
|
|
298
|
-
for (const { network } of dataSourcesAndTemplates) {
|
|
299
|
-
(0, studio_1.validateStudioNetwork)({ studio, product, network });
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
catch (e) {
|
|
303
|
-
this.error(e, { exit: 1 });
|
|
304
|
-
}
|
|
305
295
|
await deploySubgraph(ipfsHash);
|
|
306
296
|
return;
|
|
307
297
|
}
|
|
308
|
-
try {
|
|
309
|
-
const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest);
|
|
310
|
-
for (const { network } of dataSourcesAndTemplates) {
|
|
311
|
-
(0, studio_1.validateStudioNetwork)({ studio, product, network });
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
catch (e) {
|
|
315
|
-
this.error(e, { exit: 1 });
|
|
316
|
-
}
|
|
317
298
|
let protocol;
|
|
318
299
|
try {
|
|
319
300
|
// Checks to make sure deploy doesn't run against
|
package/dist/commands/init.js
CHANGED
|
@@ -37,7 +37,6 @@ const network_1 = require("../command-helpers/network");
|
|
|
37
37
|
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
|
-
const studio_1 = require("../command-helpers/studio");
|
|
41
40
|
const subgraph_1 = require("../command-helpers/subgraph");
|
|
42
41
|
const debug_1 = __importDefault(require("../debug"));
|
|
43
42
|
const protocols_1 = __importDefault(require("../protocols"));
|
|
@@ -144,8 +143,6 @@ class InitCommand extends core_1.Command {
|
|
|
144
143
|
subgraphName,
|
|
145
144
|
contractName,
|
|
146
145
|
node,
|
|
147
|
-
studio,
|
|
148
|
-
product,
|
|
149
146
|
startBlock,
|
|
150
147
|
spkgPath,
|
|
151
148
|
skipInstall,
|
|
@@ -212,8 +209,6 @@ class InitCommand extends core_1.Command {
|
|
|
212
209
|
indexEvents: answers.indexEvents,
|
|
213
210
|
contractName: answers.contractName,
|
|
214
211
|
node,
|
|
215
|
-
studio: answers.studio,
|
|
216
|
-
product: answers.product,
|
|
217
212
|
startBlock: answers.startBlock,
|
|
218
213
|
spkgPath: answers.spkgPath,
|
|
219
214
|
skipInstall,
|
|
@@ -831,7 +826,7 @@ async function initSubgraphFromExample({ fromExample, allowSimpleName, subgraphN
|
|
|
831
826
|
}
|
|
832
827
|
printNextSteps.bind(this)({ subgraphName, directory }, { commands });
|
|
833
828
|
}
|
|
834
|
-
async function initSubgraphFromContract({ protocolInstance, allowSimpleName, subgraphName, directory, abi, network, contract, indexEvents, contractName, node,
|
|
829
|
+
async function initSubgraphFromContract({ protocolInstance, allowSimpleName, subgraphName, directory, abi, network, contract, indexEvents, contractName, node, startBlock, spkgPath, skipInstall, }, { commands, addContract, }) {
|
|
835
830
|
const isSubstreams = protocolInstance.name === 'substreams';
|
|
836
831
|
// Fail if the subgraph name is invalid
|
|
837
832
|
if (!revalidateSubgraphName.bind(this)(subgraphName, { allowSimpleName })) {
|
|
@@ -849,15 +844,6 @@ async function initSubgraphFromContract({ protocolInstance, allowSimpleName, sub
|
|
|
849
844
|
// Fail if the ABI does not contain any events
|
|
850
845
|
this.error(`ABI does not contain any events`, { exit: 1 });
|
|
851
846
|
}
|
|
852
|
-
// We can validate this before the scaffold because we receive
|
|
853
|
-
// the network from the form or via command line argument.
|
|
854
|
-
// We don't need to read the manifest in this case.
|
|
855
|
-
try {
|
|
856
|
-
(0, studio_1.validateStudioNetwork)({ studio, product, network });
|
|
857
|
-
}
|
|
858
|
-
catch (e) {
|
|
859
|
-
this.error(e, { exit: 1 });
|
|
860
|
-
}
|
|
861
847
|
// Scaffold subgraph
|
|
862
848
|
const scaffold = await (0, spinner_1.withSpinner)(`Create subgraph scaffold`, `Failed to create subgraph scaffold`, `Warnings while creating subgraph scaffold`, async (spinner) => {
|
|
863
849
|
const scaffold = await (0, scaffold_1.generateScaffold)({
|
package/dist/compiler/index.js
CHANGED
|
@@ -374,7 +374,7 @@ class Compiler {
|
|
|
374
374
|
return path_1.default.relative(this.options.outputDir, this._writeSubgraphFile(abiFile, JSON.stringify(abiData.data.toJS(), null, 2), this.sourceDir, this.subgraphDir(this.options.outputDir, dataSource), spinner));
|
|
375
375
|
})));
|
|
376
376
|
}
|
|
377
|
-
if (protocol.name == 'substreams') {
|
|
377
|
+
if (protocol.name == 'substreams' || protocol.name == 'substreams/triggers') {
|
|
378
378
|
updatedDataSource = updatedDataSource
|
|
379
379
|
// Write data source ABIs to the output directory
|
|
380
380
|
.updateIn(['source', 'package'], (substreamsPackage) => substreamsPackage.update('file', (packageFile) => {
|
|
@@ -382,6 +382,9 @@ class Compiler {
|
|
|
382
382
|
const packageContent = fs_extra_1.default.readFileSync(packageFile);
|
|
383
383
|
return path_1.default.relative(this.options.outputDir, this._writeSubgraphFile(packageFile, packageContent, this.sourceDir, this.subgraphDir(this.options.outputDir, dataSource), spinner));
|
|
384
384
|
}));
|
|
385
|
+
if (updatedDataSource.getIn(['mapping', 'file'])) {
|
|
386
|
+
updatedDataSource = updatedDataSource.updateIn(['mapping', 'file'], (mappingFile) => path_1.default.relative(this.options.outputDir, path_1.default.resolve(this.sourceDir, mappingFile)));
|
|
387
|
+
}
|
|
385
388
|
return updatedDataSource;
|
|
386
389
|
}
|
|
387
390
|
// The mapping file is already being written to the output
|
|
@@ -435,12 +438,18 @@ class Compiler {
|
|
|
435
438
|
}
|
|
436
439
|
}
|
|
437
440
|
// Upload all mappings
|
|
438
|
-
if (this.protocol.name === 'substreams') {
|
|
441
|
+
if (this.protocol.name === 'substreams' || this.protocol.name === 'substreams/triggers') {
|
|
439
442
|
for (const [i, dataSource] of subgraph.get('dataSources').entries()) {
|
|
440
443
|
updates.push({
|
|
441
444
|
keyPath: ['dataSources', i, 'source', 'package', 'file'],
|
|
442
445
|
value: await this._uploadFileToIPFS(dataSource.getIn(['source', 'package', 'file']), uploadedFiles, spinner),
|
|
443
446
|
});
|
|
447
|
+
if (dataSource.getIn(['mapping', 'file'])) {
|
|
448
|
+
updates.push({
|
|
449
|
+
keyPath: ['dataSources', i, 'mapping', 'file'],
|
|
450
|
+
value: await this._uploadFileToIPFS(dataSource.getIn(['mapping', 'file']), uploadedFiles, spinner),
|
|
451
|
+
});
|
|
452
|
+
}
|
|
444
453
|
}
|
|
445
454
|
}
|
|
446
455
|
else {
|
|
@@ -6,9 +6,9 @@ export default class Protocol {
|
|
|
6
6
|
static fromDataSources(dataSourcesAndTemplates: any): Protocol;
|
|
7
7
|
name: ProtocolName;
|
|
8
8
|
config: ProtocolConfig;
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(datasource: any);
|
|
10
10
|
static availableProtocols(): immutable.Collection<ProtocolName, string[]>;
|
|
11
|
-
static availableNetworks(): immutable.Map<"ethereum" | "arweave" | "near" | "cosmos" | "substreams", immutable.List<string>>;
|
|
11
|
+
static availableNetworks(): immutable.Map<"ethereum" | "arweave" | "near" | "cosmos" | "substreams" | "substreams/triggers", immutable.List<string>>;
|
|
12
12
|
static normalizeName(name: ProtocolName): ProtocolName;
|
|
13
13
|
displayName(): string;
|
|
14
14
|
isValidKindName(kind: string): boolean;
|
|
@@ -25,7 +25,7 @@ export default class Protocol {
|
|
|
25
25
|
getManifestScaffold(): any;
|
|
26
26
|
getMappingScaffold(): any;
|
|
27
27
|
}
|
|
28
|
-
export type ProtocolName = 'arweave' | 'ethereum' | 'near' | 'cosmos' | 'substreams';
|
|
28
|
+
export type ProtocolName = 'arweave' | 'ethereum' | 'near' | 'cosmos' | 'substreams' | 'substreams/triggers';
|
|
29
29
|
export interface ProtocolConfig {
|
|
30
30
|
displayName: string;
|
|
31
31
|
abi?: any;
|
package/dist/protocols/index.js
CHANGED
|
@@ -50,11 +50,18 @@ const subgraph_5 = __importDefault(require("./substreams/subgraph"));
|
|
|
50
50
|
const protocolDebug = (0, debug_1.default)('graph-cli:protocol');
|
|
51
51
|
class Protocol {
|
|
52
52
|
static fromDataSources(dataSourcesAndTemplates) {
|
|
53
|
-
const
|
|
54
|
-
return new Protocol(
|
|
53
|
+
const firstDataSource = dataSourcesAndTemplates[0];
|
|
54
|
+
return new Protocol(firstDataSource);
|
|
55
55
|
}
|
|
56
|
-
constructor(
|
|
56
|
+
constructor(datasource) {
|
|
57
|
+
/**
|
|
58
|
+
* TODO: we should improve this `any` type, because some places
|
|
59
|
+
* we can initiate a Protocol with just a string (the name) and
|
|
60
|
+
* some other places use datasource object
|
|
61
|
+
*/
|
|
62
|
+
const name = typeof datasource === 'string' ? datasource : datasource.kind;
|
|
57
63
|
this.name = Protocol.normalizeName(name);
|
|
64
|
+
protocolDebug('Initializing protocol %s', this.name);
|
|
58
65
|
switch (this.name) {
|
|
59
66
|
case 'arweave':
|
|
60
67
|
this.config = arweaveProtocol;
|
|
@@ -70,6 +77,13 @@ class Protocol {
|
|
|
70
77
|
break;
|
|
71
78
|
case 'substreams':
|
|
72
79
|
this.config = substreamsProtocol;
|
|
80
|
+
/**
|
|
81
|
+
* Substreams triggers are a special case of substreams data sources
|
|
82
|
+
* which have a mapping file and a handler.
|
|
83
|
+
*/
|
|
84
|
+
if (datasource?.mapping?.file && datasource?.mapping.handler) {
|
|
85
|
+
this.name = 'substreams/triggers';
|
|
86
|
+
}
|
|
73
87
|
break;
|
|
74
88
|
default:
|
|
75
89
|
// Do not throw when undefined, a better error message is printed after the constructor
|
|
@@ -32,14 +32,18 @@ type DataSource {
|
|
|
32
32
|
|
|
33
33
|
type SubstreamsSource {
|
|
34
34
|
package: SubstreamsPackage!
|
|
35
|
+
startBlock: BigInt
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
type SubstreamsPackage {
|
|
38
39
|
moduleName: String!
|
|
39
40
|
file: String!
|
|
41
|
+
params: String
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
type SubstreamMapping {
|
|
43
45
|
apiVersion: String!
|
|
44
46
|
kind: String!
|
|
47
|
+
file: File
|
|
48
|
+
handler: String
|
|
45
49
|
}
|
package/dist/subgraph.js
CHANGED
|
@@ -60,7 +60,9 @@ class Subgraph {
|
|
|
60
60
|
]);
|
|
61
61
|
}
|
|
62
62
|
// Parse the default subgraph schema
|
|
63
|
-
const schema = graphql.parse(await fs_extra_1.default.readFile(path_1.default.join(__dirname, 'protocols',
|
|
63
|
+
const schema = graphql.parse(await fs_extra_1.default.readFile(path_1.default.join(__dirname, 'protocols',
|
|
64
|
+
// TODO: substreams/triggers is a special case, should be handled better
|
|
65
|
+
protocol.name === 'substreams/triggers' ? 'substreams' : protocol.name, `manifest.graphql`), 'utf-8'));
|
|
64
66
|
// Obtain the root `SubgraphManifest` type from the schema
|
|
65
67
|
const rootType = schema.definitions.find(definition => {
|
|
66
68
|
// @ts-expect-error TODO: name field does not exist on definition, really?
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
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", "arbitrum-sepolia", "avalanche", "zksync-era", "zksync-era-testnet", "sepolia", "polygon-zkevm-testnet", "polygon-zkevm", "scroll-sepolia", "scroll"];
|
|
2
|
-
export declare const validateStudioNetwork: ({ studio, product, network, }: {
|
|
3
|
-
studio?: string | boolean | undefined;
|
|
4
|
-
product?: string | undefined;
|
|
5
|
-
network?: string | undefined;
|
|
6
|
-
}) => void;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateStudioNetwork = exports.allowedStudioNetworks = void 0;
|
|
4
|
-
exports.allowedStudioNetworks = [
|
|
5
|
-
'mainnet',
|
|
6
|
-
'rinkeby',
|
|
7
|
-
'goerli',
|
|
8
|
-
'gnosis',
|
|
9
|
-
'chapel',
|
|
10
|
-
'optimism-goerli',
|
|
11
|
-
'clover',
|
|
12
|
-
'fantom',
|
|
13
|
-
'matic',
|
|
14
|
-
'fantom-testnet',
|
|
15
|
-
'arbitrum-goerli',
|
|
16
|
-
'fuji',
|
|
17
|
-
'celo-alfajores',
|
|
18
|
-
'mumbai',
|
|
19
|
-
'aurora-testnet',
|
|
20
|
-
'near-testnet',
|
|
21
|
-
'optimism',
|
|
22
|
-
'optimism-goerli',
|
|
23
|
-
'theta-testnet-001',
|
|
24
|
-
'osmo-test-4',
|
|
25
|
-
'base-testnet',
|
|
26
|
-
'base',
|
|
27
|
-
'celo',
|
|
28
|
-
'arbitrum-one',
|
|
29
|
-
'arbitrum-sepolia',
|
|
30
|
-
'avalanche',
|
|
31
|
-
'zksync-era',
|
|
32
|
-
'zksync-era-testnet',
|
|
33
|
-
'sepolia',
|
|
34
|
-
'polygon-zkevm-testnet',
|
|
35
|
-
'polygon-zkevm',
|
|
36
|
-
'scroll-sepolia',
|
|
37
|
-
'scroll',
|
|
38
|
-
];
|
|
39
|
-
const validateStudioNetwork = ({ studio, product, network, }) => {
|
|
40
|
-
const isStudio = studio || product === 'subgraph-studio';
|
|
41
|
-
const isAllowedNetwork = !network ||
|
|
42
|
-
exports.allowedStudioNetworks.includes(
|
|
43
|
-
// @ts-expect-error we're checking if the network is allowed
|
|
44
|
-
network);
|
|
45
|
-
if (isStudio && !isAllowedNetwork) {
|
|
46
|
-
throw new Error(`The Subgraph Studio only allows subgraphs for these networks: ${exports.allowedStudioNetworks.join(', ')}`);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
exports.validateStudioNetwork = validateStudioNetwork;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const studio_1 = require("./studio");
|
|
4
|
-
describe('Version Command Helpers', () => {
|
|
5
|
-
describe('validateStudioNetwork', () => {
|
|
6
|
-
describe("When it's studio", () => {
|
|
7
|
-
test("And it's Ethereum mainnet", () => {
|
|
8
|
-
expect(() => (0, studio_1.validateStudioNetwork)({
|
|
9
|
-
studio: true,
|
|
10
|
-
network: 'mainnet',
|
|
11
|
-
})).not.toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${studio_1.allowedStudioNetworks.join(', ')}`));
|
|
12
|
-
});
|
|
13
|
-
test("And it's Gnosis chain", () => {
|
|
14
|
-
expect(() => (0, studio_1.validateStudioNetwork)({
|
|
15
|
-
studio: true,
|
|
16
|
-
network: 'gnosis',
|
|
17
|
-
})).not.toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${studio_1.allowedStudioNetworks.join(', ')}`));
|
|
18
|
-
});
|
|
19
|
-
test('And no network is passed', () => {
|
|
20
|
-
expect(() => (0, studio_1.validateStudioNetwork)({
|
|
21
|
-
studio: true,
|
|
22
|
-
network: undefined,
|
|
23
|
-
})).not.toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${studio_1.allowedStudioNetworks.join(', ')}`));
|
|
24
|
-
});
|
|
25
|
-
test("And it's NOT an allowed network", () => {
|
|
26
|
-
expect(() => (0, studio_1.validateStudioNetwork)({
|
|
27
|
-
product: 'subgraph-studio',
|
|
28
|
-
network: 'moonriver',
|
|
29
|
-
})).toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${studio_1.allowedStudioNetworks.join(', ')}`));
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe("When it's NOT studio", () => {
|
|
33
|
-
test("And it's Rinkeby", () => {
|
|
34
|
-
expect(() => (0, studio_1.validateStudioNetwork)({
|
|
35
|
-
studio: false,
|
|
36
|
-
network: 'rinkeby',
|
|
37
|
-
})).not.toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${studio_1.allowedStudioNetworks.join(', ')}`));
|
|
38
|
-
});
|
|
39
|
-
test("And it's NOT an allowed network", () => {
|
|
40
|
-
expect(() => (0, studio_1.validateStudioNetwork)({
|
|
41
|
-
product: 'hosted-service',
|
|
42
|
-
network: 'celo',
|
|
43
|
-
})).not.toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${studio_1.allowedStudioNetworks.join(', ')}`));
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|