@graphprotocol/graph-cli 0.69.0-alpha-20240304175325-ee351c6 → 0.69.0-alpha-20240317072253-db1272f

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,12 +1,20 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
- ## 0.69.0-alpha-20240304175325-ee351c6
3
+ ## 0.69.0-alpha-20240317072253-db1272f
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - [#1592](https://github.com/graphprotocol/graph-tooling/pull/1592)
8
- [`9c4dbba`](https://github.com/graphprotocol/graph-tooling/commit/9c4dbba14ebfd5852a1c9f629f0be1bd6ae019b1)
9
- Thanks [@saihaj](https://github.com/saihaj)! - add support for `dataset` source kind
7
+ - [#1522](https://github.com/graphprotocol/graph-tooling/pull/1522)
8
+ [`db1272f`](https://github.com/graphprotocol/graph-tooling/commit/db1272f96e698b9d427b7ab6d48f01d67eb1173e)
9
+ Thanks [@dotansimha](https://github.com/dotansimha)! - Added support for handling GraphQL
10
+ `Timestamp` scalar as `i64` (AssemblyScript)
11
+
12
+ - [#1610](https://github.com/graphprotocol/graph-tooling/pull/1610)
13
+ [`fc03add`](https://github.com/graphprotocol/graph-tooling/commit/fc03add1a8510afa49110481b486c8fa56f8c19f)
14
+ Thanks [@yehia67](https://github.com/yehia67)! - Generate `docker-compose.yml` with `graph init`
15
+ command
16
+
17
+ ## 0.68.5
10
18
 
11
19
  ### Patch Changes
12
20
 
@@ -91,6 +91,7 @@ vitest_1.describe.concurrent('Schema code generator', () => {
91
91
 
92
92
  # New scalars
93
93
  int8: Int8!
94
+ timestamp: Timestamp!
94
95
  }
95
96
 
96
97
  type Wallet @entity {
@@ -296,6 +297,26 @@ vitest_1.describe.concurrent('Schema code generator', () => {
296
297
  returnType: undefined,
297
298
  body: `
298
299
  this.set('int8', Value.fromI64(value))
300
+ `,
301
+ },
302
+ {
303
+ name: 'get timestamp',
304
+ params: [],
305
+ returnType: new typescript_1.NamedType('i64'),
306
+ body: `let value = this.get('timestamp')
307
+ if (!value || value.kind == ValueKind.NULL) {
308
+ return 0
309
+ } else {
310
+ return value.toI64()
311
+ }
312
+ `,
313
+ },
314
+ {
315
+ name: 'set timestamp',
316
+ params: [new typescript_1.Param('value', new typescript_1.NamedType('i64'))],
317
+ returnType: undefined,
318
+ body: `
319
+ this.set('timestamp', Value.fromI64(value))
299
320
  `,
300
321
  },
301
322
  {
@@ -258,6 +258,7 @@ const VALUE_TO_ASSEMBLYSCRIPT = [
258
258
  ['[Boolean]', 'Array<boolean>', (code) => `${code}.toBooleanArray()`],
259
259
  ['[Int]', 'Array<i32>', (code) => `${code}.toI32Array()`],
260
260
  ['[Int8]', 'Array<i64>', (code) => `${code}.toI64Array()`],
261
+ ['[Timestamp]', 'Array<i64>', (code) => `${code}.toI64Array()`],
261
262
  ['[BigInt]', 'Array<BigInt>', (code) => `${code}.toBigIntArray()`],
262
263
  ['[ID]', 'Array<string>', (code) => `${code}.toStringArray()`],
263
264
  ['[String]', 'Array<string>', (code) => `${code}.toStringArray()`],
@@ -272,6 +273,7 @@ const VALUE_TO_ASSEMBLYSCRIPT = [
272
273
  ['ID', 'string', (code) => `${code}.toString()`],
273
274
  ['String', 'string', (code) => `${code}.toString()`],
274
275
  ['BigDecimal', 'BigDecimal', (code) => `${code}.toBigDecimal()`],
276
+ ['Timestamp', 'i64', (code) => `${code}.toI64()`],
275
277
  [/.*/, 'string', (code) => `${code}.toString()`],
276
278
  ];
277
279
  /**
@@ -288,6 +290,7 @@ const ASSEMBLYSCRIPT_TO_VALUE = [
288
290
  ['Array<Array<boolean>>', '[[Boolean]]', (code) => `Value.fromBooleanMatrix(${code})`],
289
291
  ['Array<Array<i32>>', '[[Int]]', (code) => `Value.fromI32Matrix(${code})`],
290
292
  ['Array<Array<i64>>', '[[Int8]]', (code) => `Value.fromI64Matrix(${code})`],
293
+ ['Array<Array<i64>>', '[[Timestamp]]', (code) => `Value.fromI64Matrix(${code})`],
291
294
  ['Array<Array<BigInt>>', '[[BigInt]]', (code) => `Value.fromBigIntMatrix(${code})`],
292
295
  ['Array<Array<string>>', '[[String]]', (code) => `Value.fromStringMatrix(${code})`],
293
296
  ['Array<Array<string>>', '[[ID]]', (code) => `Value.fromStringMatrix(${code})`],
@@ -305,6 +308,7 @@ const ASSEMBLYSCRIPT_TO_VALUE = [
305
308
  ['Array<boolean>', '[Boolean]', (code) => `Value.fromBooleanArray(${code})`],
306
309
  ['Array<i32>', '[Int]', (code) => `Value.fromI32Array(${code})`],
307
310
  ['Array<i64>', '[Int8]', (code) => `Value.fromI64Array(${code})`],
311
+ ['Array<i64>', '[Timestamp]', (code) => `Value.fromI64Array(${code})`],
308
312
  ['Array<BigInt>', '[BigInt]', (code) => `Value.fromBigIntArray(${code})`],
309
313
  ['Array<string>', '[String]', (code) => `Value.fromStringArray(${code})`],
310
314
  ['Array<string>', '[ID]', (code) => `Value.fromStringArray(${code})`],
@@ -317,6 +321,7 @@ const ASSEMBLYSCRIPT_TO_VALUE = [
317
321
  ['boolean', 'Boolean', (code) => `Value.fromBoolean(${code})`],
318
322
  ['i32', 'Int', (code) => `Value.fromI32(${code})`],
319
323
  ['i64', 'Int8', (code) => `Value.fromI64(${code})`],
324
+ ['i64', 'Timestamp', (code) => `Value.fromI64(${code})`],
320
325
  ['BigInt', 'BigInt', (code) => `Value.fromBigInt(${code})`],
321
326
  ['string', 'String', (code) => `Value.fromString(${code})`],
322
327
  ['string', 'ID', (code) => `Value.fromString(${code})`],
@@ -19,6 +19,7 @@ export declare const generateScaffold: ({ protocolInstance, abi, contract, netwo
19
19
  'schema.graphql': string;
20
20
  'package.json': string;
21
21
  'tsconfig.json'?: undefined;
22
+ 'docker-compose.yml'?: undefined;
22
23
  src?: undefined;
23
24
  abis?: undefined;
24
25
  tests?: undefined;
@@ -27,6 +28,7 @@ export declare const generateScaffold: ({ protocolInstance, abi, contract, netwo
27
28
  'subgraph.yaml': string;
28
29
  'schema.graphql': string;
29
30
  'tsconfig.json': string;
31
+ 'docker-compose.yml': string;
30
32
  src: {
31
33
  [x: string]: string;
32
34
  } | undefined;
@@ -44,12 +44,7 @@ const protocols_1 = __importDefault(require("../protocols"));
44
44
  const schema_1 = require("../scaffold/schema");
45
45
  const validation_1 = require("../validation");
46
46
  const add_1 = __importDefault(require("./add"));
47
- /**
48
- * Today we have protocol -> data source -> kind
49
- * Not the best but it is too deeply rooted to change now
50
- * So simpler just add a new protocol and hide from the `init` command
51
- */
52
- const protocolChoices = Array.from(protocols_1.default.availableProtocols().keys()).filter(n => n !== 'dataset');
47
+ const protocolChoices = Array.from(protocols_1.default.availableProtocols().keys());
53
48
  const initDebugger = (0, debug_1.default)('graph-cli:commands:init');
54
49
  /**
55
50
  * a dynamic list of available networks supported by the studio
@@ -362,7 +362,6 @@ class Compiler {
362
362
  fs_extra_1.default.copyFileSync(schemaFilePath, targetFile);
363
363
  return path_1.default.relative(this.options.outputDir, targetFile);
364
364
  });
365
- compilerDebug('Has ABIs: %s', protocol.hasABIs());
366
365
  // Copy data source files and update their paths
367
366
  subgraph = subgraph.update('dataSources', (dataSources) => dataSources.map(dataSource => {
368
367
  let updatedDataSource = dataSource;
@@ -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' | 'substreams/triggers' | 'dataset';
28
+ export type ProtocolName = 'arweave' | 'ethereum' | 'near' | 'cosmos' | 'substreams' | 'substreams/triggers';
29
29
  export interface ProtocolConfig {
30
30
  displayName: string;
31
31
  abi?: any;
@@ -34,20 +34,19 @@ const subgraph_1 = __importDefault(require("./arweave/subgraph"));
34
34
  const CosmosManifestScaffold = __importStar(require("./cosmos/scaffold/manifest"));
35
35
  const CosmosMappingScaffold = __importStar(require("./cosmos/scaffold/mapping"));
36
36
  const subgraph_2 = __importDefault(require("./cosmos/subgraph"));
37
- const subgraph_3 = __importDefault(require("./dataset/subgraph"));
38
37
  const abi_1 = __importDefault(require("./ethereum/abi"));
39
38
  const template_1 = __importDefault(require("./ethereum/codegen/template"));
40
39
  const contract_1 = __importDefault(require("./ethereum/contract"));
41
40
  const EthereumManifestScaffold = __importStar(require("./ethereum/scaffold/manifest"));
42
41
  const EthereumMappingScaffold = __importStar(require("./ethereum/scaffold/mapping"));
43
- const subgraph_4 = __importDefault(require("./ethereum/subgraph"));
42
+ const subgraph_3 = __importDefault(require("./ethereum/subgraph"));
44
43
  const type_generator_1 = __importDefault(require("./ethereum/type-generator"));
45
44
  const contract_2 = __importDefault(require("./near/contract"));
46
45
  const NearManifestScaffold = __importStar(require("./near/scaffold/manifest"));
47
46
  const NearMappingScaffold = __importStar(require("./near/scaffold/mapping"));
48
- const subgraph_5 = __importDefault(require("./near/subgraph"));
47
+ const subgraph_4 = __importDefault(require("./near/subgraph"));
49
48
  const SubstreamsManifestScaffold = __importStar(require("./substreams/scaffold/manifest"));
50
- const subgraph_6 = __importDefault(require("./substreams/subgraph"));
49
+ const subgraph_5 = __importDefault(require("./substreams/subgraph"));
51
50
  const protocolDebug = (0, debug_1.default)('graph-cli:protocol');
52
51
  class Protocol {
53
52
  static fromDataSources(dataSourcesAndTemplates) {
@@ -76,9 +75,6 @@ class Protocol {
76
75
  case 'near':
77
76
  this.config = nearProtocol;
78
77
  break;
79
- case 'dataset':
80
- this.config = datasetProtocol;
81
- break;
82
78
  case 'substreams':
83
79
  this.config = substreamsProtocol;
84
80
  /**
@@ -103,7 +99,6 @@ class Protocol {
103
99
  near: ['near'],
104
100
  cosmos: ['cosmos'],
105
101
  substreams: ['substreams'],
106
- dataset: ['dataset'],
107
102
  });
108
103
  }
109
104
  static availableNetworks() {
@@ -255,7 +250,7 @@ const ethereumProtocol = {
255
250
  return new type_generator_1.default(options);
256
251
  },
257
252
  getSubgraph(options) {
258
- return new subgraph_4.default(options);
253
+ return new subgraph_3.default(options);
259
254
  },
260
255
  manifestScaffold: EthereumManifestScaffold,
261
256
  mappingScaffold: EthereumMappingScaffold,
@@ -267,7 +262,7 @@ const nearProtocol = {
267
262
  getTypeGenerator: undefined,
268
263
  getTemplateCodeGen: undefined,
269
264
  getSubgraph(options) {
270
- return new subgraph_5.default(options);
265
+ return new subgraph_4.default(options);
271
266
  },
272
267
  manifestScaffold: NearManifestScaffold,
273
268
  mappingScaffold: NearMappingScaffold,
@@ -279,21 +274,9 @@ const substreamsProtocol = {
279
274
  getTypeGenerator: undefined,
280
275
  getTemplateCodeGen: undefined,
281
276
  getSubgraph(options) {
282
- return new subgraph_6.default(options);
277
+ return new subgraph_5.default(options);
283
278
  },
284
279
  manifestScaffold: SubstreamsManifestScaffold,
285
280
  mappingScaffold: undefined,
286
281
  };
287
- const datasetProtocol = {
288
- displayName: 'Dataset',
289
- abi: abi_1.default,
290
- contract: undefined,
291
- getTypeGenerator: undefined,
292
- getTemplateCodeGen: undefined,
293
- getSubgraph(options) {
294
- return new subgraph_3.default(options);
295
- },
296
- manifestScaffold: undefined,
297
- mappingScaffold: undefined,
298
- };
299
282
  protocolDebug('Available networks %M', Protocol.availableNetworks());
@@ -0,0 +1 @@
1
+ export declare const getDockerFile: () => string;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDockerFile = void 0;
4
+ const getDockerFile = () => {
5
+ return `version: '3'
6
+ services:
7
+ graph-node:
8
+ image: graphprotocol/graph-node
9
+ ports:
10
+ - '8000:8000'
11
+ - '8001:8001'
12
+ - '8020:8020'
13
+ - '8030:8030'
14
+ - '8040:8040'
15
+ depends_on:
16
+ - ipfs
17
+ - postgres
18
+ extra_hosts:
19
+ - host.docker.internal:host-gateway
20
+ environment:
21
+ postgres_host: postgres
22
+ postgres_user: graph-node
23
+ postgres_pass: let-me-in
24
+ postgres_db: graph-node
25
+ ipfs: 'ipfs:5001'
26
+ ethereum: 'mainnet:http://host.docker.internal:8545'
27
+ GRAPH_LOG: info
28
+ ipfs:
29
+ image: ipfs/kubo:v0.17.0
30
+ ports:
31
+ - '5001:5001'
32
+ volumes:
33
+ - ./data/ipfs:/data/ipfs
34
+ postgres:
35
+ image: postgres:14
36
+ ports:
37
+ - '5432:5432'
38
+ command:
39
+ [
40
+ "postgres",
41
+ "-cshared_preload_libraries=pg_stat_statements",
42
+ "-cmax_connections=200"
43
+ ]
44
+ environment:
45
+ POSTGRES_USER: graph-node
46
+ POSTGRES_PASSWORD: let-me-in
47
+ POSTGRES_DB: graph-node
48
+ # FIXME: remove this env. var. which we shouldn't need. Introduced by
49
+ # <https://github.com/graphprotocol/graph-node/pull/3511>, maybe as a
50
+ # workaround for https://github.com/docker/for-mac/issues/6270?
51
+ PGDATA: "/var/lib/postgresql/data"
52
+ POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
53
+ volumes:
54
+ - ./data/postgres:/var/lib/postgresql/data`;
55
+ };
56
+ exports.getDockerFile = getDockerFile;
@@ -29,6 +29,7 @@ export default class Scaffold {
29
29
  generateManifest(): Promise<string>;
30
30
  generateSchema(): Promise<string>;
31
31
  generateTsConfig(): Promise<string>;
32
+ generateDockerFileConfig(): Promise<string>;
32
33
  generateMappings(): Promise<{
33
34
  [x: string]: string;
34
35
  } | undefined>;
@@ -44,6 +45,7 @@ export default class Scaffold {
44
45
  'schema.graphql': string;
45
46
  'package.json': string;
46
47
  'tsconfig.json'?: undefined;
48
+ 'docker-compose.yml'?: undefined;
47
49
  src?: undefined;
48
50
  abis?: undefined;
49
51
  tests?: undefined;
@@ -52,6 +54,7 @@ export default class Scaffold {
52
54
  'subgraph.yaml': string;
53
55
  'schema.graphql': string;
54
56
  'tsconfig.json': string;
57
+ 'docker-compose.yml': string;
55
58
  src: {
56
59
  [x: string]: string;
57
60
  } | undefined;
@@ -7,6 +7,7 @@ const gluegun_1 = require("gluegun");
7
7
  const prettier_1 = __importDefault(require("prettier"));
8
8
  const subgraph_1 = require("../command-helpers/subgraph");
9
9
  const version_1 = require("../version");
10
+ const get_docker_file_1 = require("./get-docker-file");
10
11
  const mapping_1 = require("./mapping");
11
12
  const schema_1 = require("./schema");
12
13
  const tests_1 = require("./tests");
@@ -106,6 +107,9 @@ dataSources:
106
107
  include: ['src', 'tests'],
107
108
  }), { parser: 'json' });
108
109
  }
110
+ async generateDockerFileConfig() {
111
+ return await prettier_1.default.format((0, get_docker_file_1.getDockerFile)(), { parser: 'yaml' });
112
+ }
109
113
  async generateMappings() {
110
114
  return this.protocol.getMappingScaffold()
111
115
  ? { [`${gluegun_1.strings.kebabCase(this.contractName)}.ts`]: await this.generateMapping() }
@@ -151,6 +155,7 @@ dataSources:
151
155
  'subgraph.yaml': await this.generateManifest(),
152
156
  'schema.graphql': await this.generateSchema(),
153
157
  'tsconfig.json': await this.generateTsConfig(),
158
+ 'docker-compose.yml': await this.generateDockerFileConfig(),
154
159
  src: await this.generateMappings(),
155
160
  abis: await this.generateABIs(),
156
161
  tests: await this.generateTests(),
@@ -44,6 +44,7 @@ const BUILTIN_SCALAR_TYPES = [
44
44
  'Bytes',
45
45
  'ID',
46
46
  'Int8',
47
+ 'Timestamp',
47
48
  ];
48
49
  // Type suggestions for common mistakes
49
50
  const TYPE_SUGGESTIONS = [
@@ -64,6 +65,8 @@ const TYPE_SUGGESTIONS = [
64
65
  ['Float', 'BigDecimal'],
65
66
  ['int', 'Int'],
66
67
  ['int8', 'Int8'],
68
+ ['timestamp', 'Timestamp'],
69
+ ['ts', 'Timestamp'],
67
70
  ['uint', 'BigInt'],
68
71
  ['owner', 'String'],
69
72
  ['Owner', 'String'],
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.69.0-alpha-20240304175325-ee351c6",
2
+ "version": "0.69.0-alpha-20240317072253-db1272f",
3
3
  "commands": {
4
4
  "add": {
5
5
  "id": "add",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.69.0-alpha-20240304175325-ee351c6",
3
+ "version": "0.69.0-alpha-20240317072253-db1272f",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "engines": {
@@ -1,56 +0,0 @@
1
- # Each referenced type's in any of the types below must be listed
2
- # here either as `scalar` or `type` for the validation code to work
3
- # properly.
4
- #
5
- # That's why `String` is listed as a scalar even though it's built-in
6
- # GraphQL basic types.
7
- scalar String
8
- scalar File
9
- scalar BigInt
10
- scalar Boolean
11
- scalar JSON
12
-
13
- union StringOrBigInt = String | BigInt
14
-
15
- type SubgraphManifest {
16
- specVersion: String!
17
- features: [String!]
18
- schema: Schema!
19
- description: String
20
- repository: String
21
- dataSources: [DataSource!]!
22
- indexerHints: IndexerHints
23
- }
24
-
25
- type Schema {
26
- file: File!
27
- }
28
-
29
- type IndexerHints {
30
- prune: StringOrBigInt
31
- }
32
-
33
- type DataSource {
34
- kind: String!
35
- name: String!
36
- network: String!
37
- source: DatasetSource!
38
- mapping: DatasetMapping!
39
- }
40
-
41
- type DatasetSource {
42
- dataset: String!
43
- }
44
-
45
- type ContractAbi {
46
- name: String!
47
- file: File!
48
- }
49
-
50
- type DatasetMapping {
51
- kind: String!
52
- apiVersion: String!
53
- file: File!
54
- handler: String!
55
- abis: [ContractAbi!]!
56
- }
@@ -1,10 +0,0 @@
1
- import immutable from 'immutable';
2
- import { Subgraph, SubgraphOptions } from '../subgraph';
3
- export default class DatasetSubgraph implements Subgraph {
4
- manifest: SubgraphOptions['manifest'];
5
- resolveFile: SubgraphOptions['resolveFile'];
6
- protocol: SubgraphOptions['protocol'];
7
- constructor(options: SubgraphOptions);
8
- validateManifest(): immutable.List<unknown>;
9
- handlerTypes(): immutable.List<never>;
10
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const immutable_1 = __importDefault(require("immutable"));
7
- class DatasetSubgraph {
8
- constructor(options) {
9
- this.manifest = options.manifest;
10
- this.resolveFile = options.resolveFile;
11
- this.protocol = options.protocol;
12
- }
13
- validateManifest() {
14
- return immutable_1.default.List();
15
- }
16
- handlerTypes() {
17
- return immutable_1.default.List([]);
18
- }
19
- }
20
- exports.default = DatasetSubgraph;