@graphprotocol/graph-cli 0.39.0 → 0.40.0-alpha-20230215122800-10a35bc

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,5 +1,13 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
+ ## 0.40.0-alpha-20230215122800-10a35bc
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1068](https://github.com/graphprotocol/graph-tooling/pull/1068)
8
+ [`10a35bc`](https://github.com/graphprotocol/graph-tooling/commit/10a35bcbb8aa1d056b3007329c84e3a52e6ce88d)
9
+ Thanks [@incrypto32](https://github.com/incrypto32)! - Add startblock auto fetch for `add` command
10
+
3
11
  ## 0.39.0
4
12
 
5
13
  ### Minor Changes
@@ -15,9 +15,9 @@ const mapping_1 = require("../scaffold/mapping");
15
15
  const schema_1 = require("../scaffold/schema");
16
16
  const tests_1 = require("../scaffold/tests");
17
17
  const spinner_1 = require("./spinner");
18
- const generateDataSource = async (protocol, contractName, network, contractAddress, abi) => {
18
+ const generateDataSource = async (protocol, contractName, network, contractAddress, abi, startBlock) => {
19
19
  const protocolManifest = protocol.getManifestScaffold();
20
- return immutable_1.Map.of('kind', protocol.name, 'name', contractName, 'network', network, 'source', yaml_1.default.parse(prettier_1.default.format(protocolManifest.source({ contract: contractAddress, contractName }), {
20
+ return immutable_1.Map.of('kind', protocol.name, 'name', contractName, 'network', network, 'source', yaml_1.default.parse(prettier_1.default.format(protocolManifest.source({ contract: contractAddress, contractName, startBlock }), {
21
21
  parser: 'yaml',
22
22
  })), 'mapping', yaml_1.default.parse(prettier_1.default.format(protocolManifest.mapping({ abi, contractName }), {
23
23
  parser: 'yaml',
@@ -54,7 +54,7 @@ exports.default = {
54
54
  // Obtain tools
55
55
  const { print, system } = toolbox;
56
56
  // Read CLI parameters
57
- let { abi, contractName, h, help, mergeEntities, networkFile } = toolbox.parameters.options;
57
+ let { abi, contractName, h, help, mergeEntities, networkFile, startBlock } = toolbox.parameters.options;
58
58
  contractName || (contractName = 'Contract');
59
59
  try {
60
60
  (0, gluegun_1.fixParameters)(toolbox.parameters, {
@@ -103,6 +103,13 @@ exports.default = {
103
103
  else {
104
104
  ethabi = await (0, abi_1.loadAbiFromEtherscan)(abi_2.default, network, address);
105
105
  }
106
+ try {
107
+ startBlock || (startBlock = Number(await (0, abi_1.loadStartBlockForContract)(network, address)).toString());
108
+ }
109
+ catch (error) {
110
+ // If we can't get the start block, we'll just leave it out of the manifest
111
+ // TODO: Ask the user for the start block
112
+ }
106
113
  const { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(toolbox, ethabi, entities, contractName, mergeEntities);
107
114
  ethabi.data = abiData;
108
115
  await (0, scaffold_1.writeABI)(ethabi, contractName);
@@ -110,7 +117,7 @@ exports.default = {
110
117
  await (0, scaffold_1.writeMapping)(ethabi, protocol, contractName, collisionEntities);
111
118
  await (0, scaffold_1.writeTestsFiles)(ethabi, protocol, contractName);
112
119
  const dataSources = result.get('dataSources');
113
- const dataSource = await (0, scaffold_1.generateDataSource)(protocol, contractName, network, address, ethabi);
120
+ const dataSource = await (0, scaffold_1.generateDataSource)(protocol, contractName, network, address, ethabi, startBlock);
114
121
  // Handle the collisions edge case by copying another data source yaml data
115
122
  if (mergeEntities && onlyCollisions) {
116
123
  const firstDataSource = dataSources.get(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.39.0",
3
+ "version": "0.40.0-alpha-20230215122800-10a35bc",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "engines": {