@graphprotocol/graph-cli 0.23.1 → 0.24.1

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.
@@ -69,6 +69,89 @@ For examples of `graph-ts` in use take a look at one of the following subgraphs:
69
69
  * https://github.com/graphprotocol/aragon-subgraph
70
70
  * https://github.com/graphprotocol/dharma-subgraph
71
71
 
72
+ ## Release process
73
+
74
+ The steps to create a new version of the `graph-ts` are:
75
+
76
+ 1. Decide which version number you'll be rolling out. You can check the differences between the current `master` branch and the latest release.
77
+ 2. Create a PR with the commit generated by `npm version <VERSION> [<PREID>]`.
78
+ 3. Once that's approved and merged to `master`, you can publish it to `npm` and push the git tags as well.
79
+ 4. Last but not least, create a Github Release refering to the pushed git tag, linking to the PRs involved.
80
+
81
+ Helpful links:
82
+
83
+ - [Semver official docs](https://semver.org/)
84
+ - [`npm version` docs](https://docs.npmjs.com/cli/v7/commands/npm-version)
85
+ - [`npm publish` docs](https://docs.npmjs.com/cli/v7/commands/npm-publish)
86
+ - [`npm unpublish` docs](https://docs.npmjs.com/cli/v7/commands/npm-unpublish)
87
+ - [`npm deprecate` docs](https://docs.npmjs.com/cli/v7/commands/npm-deprecate)
88
+
89
+ ### Stable release example
90
+
91
+ Current version: `0.34.9`.
92
+ Desired release: `0.35.0`.
93
+
94
+ To create the PR:
95
+ ```
96
+ git checkout -b <BRANCH>
97
+
98
+ npm version minor
99
+
100
+ git push --set-upstream <REMOTE> <BRANCH>
101
+ ```
102
+
103
+ Once that's approved and merged, you can update your local `master` and:
104
+
105
+ ```
106
+ npm publish
107
+
108
+ npm push --tags
109
+ ```
110
+
111
+ ### Alpha release example
112
+
113
+ Current version: `0.29.2`.
114
+ Desired release: `0.30.0-alpha.0`.
115
+
116
+ To create the PR:
117
+ ```
118
+ git checkout -b <BRANCH>
119
+
120
+ npm version preminor --preid alpha
121
+
122
+ git push --set-upstream <REMOTE> <BRANCH>
123
+ ```
124
+
125
+ Once that's approved and merged, you can update your local `master` and:
126
+
127
+ ```
128
+ npm publish --tag alpha
129
+
130
+ npm push --tags
131
+ ```
132
+
133
+ ### Alpha pre-release example
134
+
135
+ Current version: `0.30.0-alpha.0`.
136
+ Desired release: `0.30.0-alpha.1`.
137
+
138
+ To create the PR:
139
+ ```
140
+ git checkout -b <BRANCH>
141
+
142
+ npm version prerelease --preid alpha
143
+
144
+ git push --set-upstream <REMOTE> <BRANCH>
145
+ ```
146
+
147
+ Once that's approved and merged, you can update your local `master` and:
148
+
149
+ ```
150
+ npm publish --tag alpha
151
+
152
+ npm push --tags
153
+ ```
154
+
72
155
  ## License
73
156
 
74
157
  Copyright &copy; 2018 Graph Protocol, Inc. and contributors.
@@ -339,6 +339,7 @@ export namespace ethereum {
339
339
  public difficulty: BigInt,
340
340
  public totalDifficulty: BigInt,
341
341
  public size: BigInt | null,
342
+ public baseFeePerGas: BigInt | null,
342
343
  ) {}
343
344
  }
344
345
 
@@ -355,6 +356,7 @@ export namespace ethereum {
355
356
  public gasLimit: BigInt,
356
357
  public gasPrice: BigInt,
357
358
  public input: Bytes,
359
+ public nonce: Bytes,
358
360
  ) {}
359
361
  }
360
362
 
@@ -14,13 +14,13 @@ export declare namespace json {
14
14
  }
15
15
 
16
16
  export namespace json {
17
- function fromString(data: string): JSONValue {
17
+ export function fromString(data: string): JSONValue {
18
18
  let bytes = Bytes.fromUTF8(data)
19
19
 
20
20
  return json.fromBytes(bytes)
21
21
  }
22
22
 
23
- function try_fromString(data: string): Result<JSONValue, boolean> {
23
+ export function try_fromString(data: string): Result<JSONValue, boolean> {
24
24
  let bytes = Bytes.fromUTF8(data)
25
25
 
26
26
  return json.try_fromBytes(bytes)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-ts",
3
3
  "description": "TypeScript/AssemblyScript library for writing subgraph mappings for The Graph",
4
- "version": "0.23.1",
4
+ "version": "0.24.0",
5
5
  "module": "index.ts",
6
6
  "types": "index.ts",
7
7
  "main": "index.ts",
@@ -9,16 +9,11 @@
9
9
  "assemblyscript": "0.19.10"
10
10
  },
11
11
  "devDependencies": {
12
- "glob": "^7.1.2",
13
12
  "prettier": "^2.4.1"
14
13
  },
15
14
  "scripts": {
16
15
  "lint": "prettier -c **/*.{js,ts}",
17
16
  "build": "asc --explicitStart --exportRuntime --runtime stub index.ts helper-functions.ts --lib graph-ts -b index.wasm",
18
- "test": "node test/test.js",
19
- "release:patch": "npm version patch && npm publish && git push origin master && git push --tags",
20
- "release:minor": "npm version minor && npm publish && git push origin master && git push --tags",
21
- "release:alpha:minor": "npm version preminor --preid alpha && npm publish --tag alpha && git push origin master && git push --tags",
22
- "release:alpha:prerelease": "npm version prerelease --preid alpha && npm publish --tag alpha && git push origin master && git push --tags"
17
+ "test": "node test/test.js"
23
18
  }
24
19
  }
@@ -9,7 +9,7 @@
9
9
  "deploy-test": "../../bin/graph deploy test/basic-event-handlers --version-label v0.0.1 --ipfs http://localhost:15001 --node http://127.0.0.1:18020"
10
10
  },
11
11
  "devDependencies": {
12
- "@graphprotocol/graph-ts": "0.23.1",
12
+ "@graphprotocol/graph-ts": "0.24.1",
13
13
  "apollo-fetch": "^0.7.0"
14
14
  },
15
15
  "dependencies": {
@@ -2,10 +2,10 @@
2
2
  # yarn lockfile v1
3
3
 
4
4
 
5
- "@graphprotocol/graph-ts@0.23.1":
6
- version "0.23.1"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.23.1.tgz#76e595d26ec5672f3778b1d3830e4640a57aec1b"
8
- integrity sha512-pipofvN1LlwLOXrS7IWy8hSBFZzVyVHdLXDpQskl9nKqdbb3chelj4JoVEzCl7klvomDpP84ngLpW17fBh5vww==
5
+ "@graphprotocol/graph-ts@0.24.1":
6
+ version "0.24.1"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.24.1.tgz#50961b52b5383f9c5cf5e6e23fa039f24e729ddf"
8
+ integrity sha512-2vU4m5ZPQIqMlMce/z5vmOtGHRlRmcRhMfemS3NIwxCSxSBGVnX2zb7QBTzzdQKGwsAZdbz6V0okkOtvohELfQ==
9
9
  dependencies:
10
10
  assemblyscript "0.19.10"
11
11
 
@@ -7,7 +7,7 @@
7
7
  "build-wast": "../../bin/graph build -t wast subgraph.yaml"
8
8
  },
9
9
  "devDependencies": {
10
- "@graphprotocol/graph-ts": "0.23.1"
10
+ "@graphprotocol/graph-ts": "0.24.1"
11
11
  },
12
12
  "resolutions": {
13
13
  "assemblyscript": "0.19.10"
@@ -2,10 +2,10 @@
2
2
  # yarn lockfile v1
3
3
 
4
4
 
5
- "@graphprotocol/graph-ts@0.23.1":
6
- version "0.23.1"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.23.1.tgz#76e595d26ec5672f3778b1d3830e4640a57aec1b"
8
- integrity sha512-pipofvN1LlwLOXrS7IWy8hSBFZzVyVHdLXDpQskl9nKqdbb3chelj4JoVEzCl7klvomDpP84ngLpW17fBh5vww==
5
+ "@graphprotocol/graph-ts@0.24.1":
6
+ version "0.24.1"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.24.1.tgz#50961b52b5383f9c5cf5e6e23fa039f24e729ddf"
8
+ integrity sha512-2vU4m5ZPQIqMlMce/z5vmOtGHRlRmcRhMfemS3NIwxCSxSBGVnX2zb7QBTzzdQKGwsAZdbz6V0okkOtvohELfQ==
9
9
  dependencies:
10
10
  assemblyscript "0.19.10"
11
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.23.1",
3
+ "version": "0.24.1",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "dependencies": {
6
6
  "assemblyscript": "0.19.10",
@@ -262,6 +262,7 @@ const getEtherscanLikeAPIUrl = (network) => {
262
262
  case "mainnet": return `https://api.etherscan.io/api`;
263
263
  case "bsc": return `https://api.bscscan.com/api`;
264
264
  case "matic": return `https://api.polygonscan.com/api`;
265
+ case "mumbai": return `https://api-testnet.polygonscan.com/api`;
265
266
  default: return `https://api-${network}.etherscan.io/api`;
266
267
  }
267
268
  }
@@ -11,6 +11,7 @@ ${chalk.dim('Options:')}
11
11
 
12
12
  -f --force Overwrite folder + file when downloading
13
13
  -h, --help Show usage information
14
+ -l, --logs Logs to the console information about the OS, CPU model and download url (debugging purposes)
14
15
  -v, --version <tag> Choose the version of the rust binary that you want to be downloaded/used
15
16
  `
16
17
 
@@ -21,12 +22,13 @@ module.exports = {
21
22
  let { print } = toolbox
22
23
 
23
24
  // Read CLI parameters
24
- let { f, force, h, help, v, version } = toolbox.parameters.options
25
+ let { f, force, h, help, l, logs, v, version } = toolbox.parameters.options
25
26
  let datasource = toolbox.parameters.first
26
27
 
27
28
  // Support both long and short option variants
28
29
  force = force || f
29
30
  help = help || h
31
+ logs = logs || l
30
32
  version = version || v
31
33
 
32
34
  // Show help text if requested
@@ -35,48 +37,56 @@ module.exports = {
35
37
  return
36
38
  }
37
39
 
38
- const platform = getPlatform();
40
+ const platform = getPlatform(logs)
39
41
  if (!version) {
40
- let result = await fetch('https://api.github.com/repos/LimeChain/matchstick/releases/latest');
41
- let json = await result.json();
42
- version = json.tag_name;
42
+ let result = await fetch('https://api.github.com/repos/LimeChain/matchstick/releases/latest')
43
+ let json = await result.json()
44
+ version = json.tag_name
43
45
  }
44
46
 
45
- const url = `https://github.com/LimeChain/matchstick/releases/download/${version}/${platform}`;
47
+ const url = `https://github.com/LimeChain/matchstick/releases/download/${version}/${platform}`
46
48
 
47
- let binary = new Binary(platform, url, version);
48
- await binary.install(force);
49
- datasource ? binary.run(datasource) : binary.run();
49
+ if (logs) {
50
+ console.log(`Download link: ${url}`)
51
+ }
52
+
53
+ let binary = new Binary(platform, url, version)
54
+ await binary.install(force)
55
+ datasource ? binary.run(datasource) : binary.run()
50
56
  }
51
57
  }
52
58
 
53
- function getPlatform() {
54
- const type = os.type();
55
- const arch = os.arch();
56
- const release = os.release();
57
- const cpuCore = os.cpus()[0];
58
- const majorVersion = semver.major(release);
59
- const isM1 = cpuCore.model.includes("Apple M1");
59
+ function getPlatform(logs) {
60
+ const type = os.type()
61
+ const arch = os.arch()
62
+ const release = os.release()
63
+ const cpuCore = os.cpus()[0]
64
+ const majorVersion = semver.major(release)
65
+ const isM1 = cpuCore.model.includes("Apple M1")
66
+
67
+ if (logs) {
68
+ console.log(`OS type: ${type}\nOS arch: ${arch}\nOS release: ${release}\nOS major version: ${majorVersion}\nCPU model: ${cpuCore.model}`)
69
+ }
60
70
 
61
71
  if (arch === 'x64' || (arch === 'arm64' && isM1)) {
62
72
  if (type === 'Darwin') {
63
- if (majorVersion === '19') {
64
- return 'binary-macos-10.15';
65
- } else if (majorVersion === '18') {
66
- return 'binary-macos-10.14';
73
+ if (majorVersion === 19) {
74
+ return 'binary-macos-10.15'
75
+ } else if (majorVersion === 18) {
76
+ return 'binary-macos-10.14'
67
77
  } else if (isM1) {
68
- return 'binary-macos-11-m1';
78
+ return 'binary-macos-11-m1'
69
79
  }
70
- return 'binary-macos-11';
80
+ return 'binary-macos-11'
71
81
  } else if (type === 'Linux') {
72
- if (majorVersion === '18') {
73
- return 'binary-linux-18';
82
+ if (majorVersion === 18) {
83
+ return 'binary-linux-18'
74
84
  }
75
- return 'binary-linux-20';
85
+ return 'binary-linux-20'
76
86
  } else if (type === 'Windows_NT') {
77
- return 'binary-windows';
87
+ return 'binary-windows'
78
88
  }
79
89
  }
80
90
 
81
- throw new Error(`Unsupported platform: ${type} ${arch} ${majorVersion}`);
91
+ throw new Error(`Unsupported platform: ${type} ${arch} ${majorVersion}`)
82
92
  }
@@ -0,0 +1,74 @@
1
+ const fs = require('fs-extra')
2
+ const semver = require('semver')
3
+ const toolbox = require('gluegun/toolbox')
4
+ const yaml = require('js-yaml')
5
+ const { loadManifest } = require('./util/load-manifest')
6
+ const { getGraphTsVersion } = require('./util/versions')
7
+
8
+ // If any of the manifest apiVersions are 0.0.5, replace them with 0.0.6
9
+ module.exports = {
10
+ name: 'Bump mapping apiVersion from 0.0.5 to 0.0.6',
11
+ predicate: async ({ sourceDir, manifestFile }) => {
12
+ // Obtain the graph-ts version, if possible
13
+ let graphTsVersion
14
+ try {
15
+ graphTsVersion = await getGraphTsVersion(sourceDir)
16
+ } catch (_) {
17
+ // If we cannot obtain the version, return a hint that the graph-ts
18
+ // hasn't been installed yet
19
+ return 'graph-ts dependency not installed yet'
20
+ }
21
+
22
+ let manifest = loadManifest(manifestFile)
23
+ return (
24
+ // Only migrate if the graph-ts version is >= 0.23.0...
25
+ // Coerce needed because we may be dealing with an alpha version
26
+ // and in the `semver` library this would not return true on equality.
27
+ semver.gte(semver.coerce(graphTsVersion), '0.24.0') &&
28
+ // ...and we have a manifest with mapping > apiVersion = 0.0.5
29
+ manifest &&
30
+ typeof manifest === 'object' &&
31
+ Array.isArray(manifest.dataSources) &&
32
+ (manifest.dataSources.reduce(
33
+ (hasOldMappings, dataSource) =>
34
+ hasOldMappings ||
35
+ (typeof dataSource === 'object' &&
36
+ dataSource.mapping &&
37
+ typeof dataSource.mapping === 'object' &&
38
+ dataSource.mapping.apiVersion === '0.0.5'),
39
+ false,
40
+ ) ||
41
+ (Array.isArray(manifest.templates) &&
42
+ manifest.templates.reduce(
43
+ (hasOldMappings, template) =>
44
+ hasOldMappings ||
45
+ (typeof template === 'object' &&
46
+ template.mapping &&
47
+ typeof template.mapping === 'object' &&
48
+ template.mapping.apiVersion === '0.0.5'),
49
+ false,
50
+ )))
51
+ )
52
+ },
53
+ apply: async ({ manifestFile }) => {
54
+ // Make sure we catch all variants; we could load the manifest
55
+ // and replace the values in the data structures here; unfortunately
56
+ // writing that back to the file messes with the formatting more than
57
+ // we'd like; that's why for now, we use a simple patching approach
58
+ await toolbox.patching.replace(
59
+ manifestFile,
60
+ new RegExp('apiVersion: 0.0.5', 'g'),
61
+ 'apiVersion: 0.0.6',
62
+ )
63
+ await toolbox.patching.replace(
64
+ manifestFile,
65
+ new RegExp("apiVersion: '0.0.5'", 'g'),
66
+ "apiVersion: '0.0.6'",
67
+ )
68
+ await toolbox.patching.replace(
69
+ manifestFile,
70
+ new RegExp('apiVersion: "0.0.5"', 'g'),
71
+ 'apiVersion: "0.0.6"',
72
+ )
73
+ },
74
+ }
package/src/scaffold.js CHANGED
@@ -49,7 +49,7 @@ const generatePackageJson = ({ subgraphName, node }) =>
49
49
  },
50
50
  dependencies: {
51
51
  '@graphprotocol/graph-cli': graphCliVersion,
52
- '@graphprotocol/graph-ts': `0.23.1`,
52
+ '@graphprotocol/graph-ts': `0.24.1`,
53
53
  },
54
54
  }),
55
55
  { parser: 'json' },