@graphprotocol/graph-cli 0.38.0-alpha-20230202071921-0765b2f → 0.38.0

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 CHANGED
@@ -1,9 +1,13 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
- ## 0.38.0-alpha-20230202071921-0765b2f
3
+ ## 0.38.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
+ - [#1049](https://github.com/graphprotocol/graph-tooling/pull/1049)
8
+ [`18cf83f`](https://github.com/graphprotocol/graph-tooling/commit/18cf83fe1ec703fdc74fa03f898e2ca8b7e5f1fd)
9
+ Thanks [@incrypto32](https://github.com/incrypto32)! - Add startBlock prompt
10
+
7
11
  - [#1053](https://github.com/graphprotocol/graph-tooling/pull/1053)
8
12
  [`bc82507`](https://github.com/graphprotocol/graph-tooling/commit/bc8250763799ae2871c5d5b67c279c673329bcbc)
9
13
  Thanks [@saihaj](https://github.com/saihaj)! - Remove arbitrum-rinkeby to add arbitrum-goerli
@@ -24,7 +24,7 @@ const generateDataSource = async (protocol, contractName, network, contractAddre
24
24
  }))).asMutable();
25
25
  };
26
26
  exports.generateDataSource = generateDataSource;
27
- const generateScaffold = async ({ protocolInstance, abi, contract, network, subgraphName, indexEvents, contractName = 'Contract', node, }, spinner) => {
27
+ const generateScaffold = async ({ protocolInstance, abi, contract, network, subgraphName, indexEvents, contractName = 'Contract', startBlock, node, }, spinner) => {
28
28
  (0, spinner_1.step)(spinner, 'Generate subgraph');
29
29
  const scaffold = new scaffold_1.default({
30
30
  protocol: protocolInstance,
@@ -33,6 +33,7 @@ const generateScaffold = async ({ protocolInstance, abi, contract, network, subg
33
33
  contract,
34
34
  network,
35
35
  contractName,
36
+ startBlock,
36
37
  subgraphName,
37
38
  node,
38
39
  });
@@ -70,6 +70,7 @@ ${chalk_1.default.dim('Options for --from-contract:')}
70
70
 
71
71
  --contract-name Name of the contract (default: Contract)
72
72
  --index-events Index contract events as entities
73
+ --start-block Block number to start indexing from (default: 0)
73
74
 
74
75
  ${chalk_1.default.dim.underline('Ethereum:')}
75
76
 
@@ -87,7 +88,7 @@ ${chalk_1.default.dim.underline('Cosmos:')}
87
88
  --network <${availableNetworks.get('cosmos').join('|')}>
88
89
  Selects the network the contract is deployed to
89
90
  `;
90
- const processInitForm = async (toolbox, { protocol, product, studio, node, abi, allowSimpleName, directory, contract, indexEvents, fromExample, network, subgraphName, contractName, }) => {
91
+ const processInitForm = async (toolbox, { protocol, product, studio, node, abi, allowSimpleName, directory, contract, indexEvents, fromExample, network, subgraphName, contractName, startBlock, }) => {
91
92
  let abiFromEtherscan = undefined;
92
93
  let abiFromFile = undefined;
93
94
  let protocolInstance;
@@ -249,6 +250,18 @@ const processInitForm = async (toolbox, { protocol, product, studio, node, abi,
249
250
  }
250
251
  },
251
252
  },
253
+ {
254
+ type: 'input',
255
+ name: 'startBlock',
256
+ message: 'Start Block',
257
+ initial: startBlock || '0',
258
+ skip: () => fromExample !== undefined || startBlock,
259
+ validate: (value) => parseInt(value) >= 0,
260
+ result: (value) => {
261
+ startBlock = value;
262
+ return value;
263
+ },
264
+ },
252
265
  {
253
266
  type: 'input',
254
267
  name: 'contractName',
@@ -308,7 +321,7 @@ exports.default = {
308
321
  // Obtain tools
309
322
  const { print, system } = toolbox;
310
323
  // Read CLI parameters
311
- let { protocol, product, studio, node, g, abi, allowSimpleName, fromContract, contractName, fromExample, h, help, indexEvents, network, } = toolbox.parameters.options;
324
+ let { protocol, product, studio, node, g, abi, allowSimpleName, fromContract, contractName, fromExample, h, help, indexEvents, network, startBlock, } = toolbox.parameters.options;
312
325
  node || (node = g);
313
326
  ({ node, allowSimpleName } = (0, node_1.chooseNodeUrl)({
314
327
  product,
@@ -415,6 +428,7 @@ exports.default = {
415
428
  node,
416
429
  studio,
417
430
  product,
431
+ startBlock,
418
432
  }, { commands, addContract: false });
419
433
  }
420
434
  // Otherwise, take the user through the interactive form
@@ -432,6 +446,7 @@ exports.default = {
432
446
  network,
433
447
  subgraphName,
434
448
  contractName,
449
+ startBlock,
435
450
  });
436
451
  // Exit immediately when the form is cancelled
437
452
  if (inputs === undefined) {
@@ -467,6 +482,7 @@ exports.default = {
467
482
  node,
468
483
  studio: inputs.studio,
469
484
  product: inputs.product,
485
+ startBlock: inputs.startBlock,
470
486
  }, { commands, addContract: true });
471
487
  }
472
488
  },
@@ -645,7 +661,7 @@ const initSubgraphFromExample = async (toolbox, { fromExample, allowSimpleName,
645
661
  }
646
662
  printNextSteps(toolbox, { subgraphName, directory }, { commands });
647
663
  };
648
- const initSubgraphFromContract = async (toolbox, { protocolInstance, allowSimpleName, subgraphName, directory, abi, network, contract, indexEvents, contractName, node, studio, product, }, { commands, addContract, }) => {
664
+ const initSubgraphFromContract = async (toolbox, { protocolInstance, allowSimpleName, subgraphName, directory, abi, network, contract, indexEvents, contractName, node, studio, product, startBlock, }, { commands, addContract, }) => {
649
665
  const { print } = toolbox;
650
666
  // Fail if the subgraph name is invalid
651
667
  if (!revalidateSubgraphName(toolbox, subgraphName, { allowSimpleName })) {
@@ -688,6 +704,7 @@ const initSubgraphFromContract = async (toolbox, { protocolInstance, allowSimple
688
704
  contract,
689
705
  indexEvents,
690
706
  contractName,
707
+ startBlock,
691
708
  node,
692
709
  }, spinner);
693
710
  await (0, scaffold_1.writeScaffold)(scaffold, directory, spinner);
@@ -7,7 +7,12 @@ exports.mapping = exports.source = void 0;
7
7
  const gluegun_1 = require("gluegun");
8
8
  const schema_1 = require("../../../scaffold/schema");
9
9
  const abi_1 = __importDefault(require("../abi"));
10
- const source = ({ contract, contractName }) => `
10
+ const source = ({ contract, contractName, startBlock, }) => startBlock
11
+ ? `
12
+ address: '${contract}'
13
+ abi: ${contractName}
14
+ startBlock: ${startBlock}`
15
+ : `
11
16
  address: '${contract}'
12
17
  abi: ${contractName}`;
13
18
  exports.source = source;
@@ -62,6 +62,7 @@ const scaffoldOptions = {
62
62
  contract: '0xf87e31492faf9a91b02ee0deaad50d51d56d5d4d',
63
63
  network: 'kovan',
64
64
  contractName: 'Contract',
65
+ startBlock: '12345',
65
66
  };
66
67
  const scaffold = new index_1.default(scaffoldOptions);
67
68
  const scaffoldWithIndexEvents = new index_1.default({
@@ -81,6 +82,7 @@ dataSources:
81
82
  source:
82
83
  address: "0xf87e31492faf9a91b02ee0deaad50d51d56d5d4d"
83
84
  abi: Contract
85
+ startBlock: 12345
84
86
  mapping:
85
87
  kind: ethereum/events
86
88
  apiVersion: 0.0.7
@@ -25,6 +25,7 @@ class Scaffold {
25
25
  this.network = options.network;
26
26
  this.contractName = options.contractName;
27
27
  this.subgraphName = options.subgraphName;
28
+ this.startBlock = options.startBlock;
28
29
  this.node = options.node;
29
30
  }
30
31
  generatePackageJson() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.38.0-alpha-20230202071921-0765b2f",
3
+ "version": "0.38.0",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "engines": {