@graphprotocol/graph-cli 0.41.1 → 0.42.0-alpha-20230223071949-5163086

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,17 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
+ ## 0.42.0-alpha-20230223071949-5163086
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1068](https://github.com/graphprotocol/graph-tooling/pull/1068)
8
+ [`8c7e4e0`](https://github.com/graphprotocol/graph-tooling/commit/8c7e4e0b33033b83cf97eb2466d9cd77437e2dd0)
9
+ Thanks [@incrypto32](https://github.com/incrypto32)! - Add startblock auto fetch for `add` command
10
+
11
+ - [#1079](https://github.com/graphprotocol/graph-tooling/pull/1079)
12
+ [`570eb22`](https://github.com/graphprotocol/graph-tooling/commit/570eb225fad705998cca3998879a6a1140a73143)
13
+ Thanks [@incrypto32](https://github.com/incrypto32)! - Remove optimism-kovan, Add optimism-goerli
14
+
3
15
  ## 0.41.1
4
16
 
5
17
  ### Patch Changes
@@ -120,8 +120,8 @@ const getEtherscanLikeAPIUrl = (network) => {
120
120
  return `https://api.aurorascan.dev/api`;
121
121
  case 'aurora-testnet':
122
122
  return `https://api-testnet.aurorascan.dev/api`;
123
- case 'optimism-kovan':
124
- return `https://api-kovan-optimistic.etherscan.io/api`;
123
+ case 'optimism-goerli':
124
+ return `https://api-goerli-optimistic.etherscan.io/api`;
125
125
  case 'optimism':
126
126
  return `https://api-optimistic.etherscan.io/api`;
127
127
  case 'moonbeam':
@@ -196,8 +196,8 @@ const getPublicRPCEndpoint = (network) => {
196
196
  return 'https://moonriver.public.blastapi.io';
197
197
  case 'optimism':
198
198
  return 'https://mainnet.optimism.io';
199
- case 'optimism-kovan':
200
- return 'https://kovan.optimism.io';
199
+ case 'optimism-goerli':
200
+ return 'https://goerli.optimism.io';
201
201
  case 'poa-core':
202
202
  return 'https://core.poa.network';
203
203
  case 'poa-sokol':
@@ -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',
@@ -40,12 +40,13 @@ const abi_2 = __importDefault(require("../protocols/ethereum/abi"));
40
40
  const subgraph_1 = __importDefault(require("../subgraph"));
41
41
  class AddCommand extends core_1.Command {
42
42
  async run() {
43
- const { args: { address, 'subgraph-manifest': manifestPath }, flags: { abi, 'contract-name': contractName, 'merge-entities': mergeEntities, 'network-file': networksFile, }, } = await this.parse(AddCommand);
43
+ const { args: { address, 'subgraph-manifest': manifestPath }, flags: { abi, 'contract-name': contractName, 'merge-entities': mergeEntities, 'network-file': networksFile, 'start-block': startBlockFlag, }, } = await this.parse(AddCommand);
44
44
  const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifestPath);
45
45
  const protocol = protocols_1.default.fromDataSources(dataSourcesAndTemplates);
46
46
  const manifest = await subgraph_1.default.load(manifestPath, { protocol });
47
47
  const network = manifest.result.getIn(['dataSources', 0, 'network']);
48
48
  const result = manifest.result.asMutable();
49
+ let startBlock = startBlockFlag;
49
50
  const entities = getEntities(manifest);
50
51
  const contractNames = getContractNames(manifest);
51
52
  if (contractNames.includes(contractName)) {
@@ -61,6 +62,13 @@ class AddCommand extends core_1.Command {
61
62
  else {
62
63
  ethabi = await (0, abi_1.loadAbiFromEtherscan)(abi_2.default, network, address);
63
64
  }
65
+ try {
66
+ startBlock || (startBlock = Number(await (0, abi_1.loadStartBlockForContract)(network, address)).toString());
67
+ }
68
+ catch (error) {
69
+ // If we can't get the start block, we'll just leave it out of the manifest
70
+ // TODO: Ask the user for the start block
71
+ }
64
72
  const { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(ethabi, entities, contractName, mergeEntities);
65
73
  ethabi.data = abiData;
66
74
  await (0, scaffold_1.writeABI)(ethabi, contractName);
@@ -68,7 +76,7 @@ class AddCommand extends core_1.Command {
68
76
  await (0, scaffold_1.writeMapping)(ethabi, protocol, contractName, collisionEntities);
69
77
  await (0, scaffold_1.writeTestsFiles)(ethabi, protocol, contractName);
70
78
  const dataSources = result.get('dataSources');
71
- const dataSource = await (0, scaffold_1.generateDataSource)(protocol, contractName, network, address, ethabi);
79
+ const dataSource = await (0, scaffold_1.generateDataSource)(protocol, contractName, network, address, ethabi, startBlock);
72
80
  // Handle the collisions edge case by copying another data source yaml data
73
81
  if (mergeEntities && onlyCollisions) {
74
82
  const firstDataSource = dataSources.get(0);
@@ -113,6 +121,10 @@ AddCommand.flags = {
113
121
  summary: 'Path to the contract ABI.',
114
122
  default: '*Download from Etherscan*',
115
123
  }),
124
+ 'start-block': core_1.Flags.string({
125
+ summary: 'The block number to start indexing events from.',
126
+ default: '*Zero*',
127
+ }),
116
128
  'contract-name': core_1.Flags.string({
117
129
  summary: 'Name of the contract.',
118
130
  default: 'Contract',
@@ -115,7 +115,7 @@ class Protocol {
115
115
  'arbitrum-one',
116
116
  'arbitrum-goerli',
117
117
  'optimism',
118
- 'optimism-kovan',
118
+ 'optimism-goerli',
119
119
  'aurora',
120
120
  'aurora-testnet',
121
121
  'base-testnet',
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.41.1",
2
+ "version": "0.42.0-alpha-20230223071949-5163086",
3
3
  "commands": {
4
4
  "add": {
5
5
  "id": "add",
@@ -24,6 +24,13 @@
24
24
  "multiple": false,
25
25
  "default": "*Download from Etherscan*"
26
26
  },
27
+ "start-block": {
28
+ "name": "start-block",
29
+ "type": "option",
30
+ "summary": "The block number to start indexing events from.",
31
+ "multiple": false,
32
+ "default": "*Zero*"
33
+ },
27
34
  "contract-name": {
28
35
  "name": "contract-name",
29
36
  "type": "option",
@@ -566,7 +573,7 @@
566
573
  "arbitrum-one",
567
574
  "arbitrum-goerli",
568
575
  "optimism",
569
- "optimism-kovan",
576
+ "optimism-goerli",
570
577
  "aurora",
571
578
  "aurora-testnet",
572
579
  "base-testnet",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.41.1",
3
+ "version": "0.42.0-alpha-20230223071949-5163086",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "engines": {