@graphprotocol/graph-cli 0.34.0-alpha.0 → 0.34.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.
@@ -19,13 +19,35 @@ export namespace cosmos {
19
19
  }
20
20
 
21
21
  export class EventData {
22
- constructor(public event: Event, public block: HeaderOnlyBlock) {}
22
+ constructor(
23
+ public event: Event,
24
+ public block: HeaderOnlyBlock,
25
+ public tx: TransactionContext,
26
+ ) {}
23
27
  }
24
28
 
25
29
  export class TransactionData {
26
30
  constructor(public tx: TxResult, public block: HeaderOnlyBlock) {}
27
31
  }
28
32
 
33
+ export class MessageData {
34
+ constructor(
35
+ public message: Any,
36
+ public block: HeaderOnlyBlock,
37
+ public tx: TransactionContext,
38
+ ) {}
39
+ }
40
+
41
+ export class TransactionContext {
42
+ constructor(
43
+ public hash: Bytes,
44
+ public index: u32,
45
+ public code: u32,
46
+ public gasWanted: i64,
47
+ public gasUsed: i64,
48
+ ) {}
49
+ }
50
+
29
51
  export class Header {
30
52
  constructor(
31
53
  public version: Consensus,
@@ -22,7 +22,6 @@ export namespace ethereum {
22
22
  FIXED_ARRAY = 7,
23
23
  ARRAY = 8,
24
24
  TUPLE = 9,
25
- MATRIX = 10,
26
25
  }
27
26
 
28
27
  /**
@@ -104,8 +103,12 @@ export namespace ethereum {
104
103
  }
105
104
 
106
105
  toMatrix(): Array<Array<Value>> {
107
- assert(this.kind == ValueKind.MATRIX, 'Ethereum value is not a matrix.')
108
- return changetype<Array<Array<Value>>>(this.data as u32)
106
+ let valueArray = this.toArray()
107
+ let out = new Array<Array<Value>>(valueArray.length)
108
+ for (let i: i32 = 0; i < valueArray.length; i++) {
109
+ out[i] = valueArray[i].toArray()
110
+ }
111
+ return out
109
112
  }
110
113
 
111
114
  toTupleArray<T extends Tuple>(): Array<T> {
@@ -122,7 +125,6 @@ export namespace ethereum {
122
125
  }
123
126
 
124
127
  toTupleMatrix<T extends Tuple>(): Array<Array<T>> {
125
- assert(this.kind == ValueKind.MATRIX, 'Ethereum value is not a matrix.')
126
128
  let valueMatrix = this.toMatrix()
127
129
  let out = new Array<Array<T>>(valueMatrix.length)
128
130
  for (let i: i32 = 0; i < valueMatrix.length; i++) {
@@ -213,7 +215,6 @@ export namespace ethereum {
213
215
  }
214
216
 
215
217
  toBooleanMatrix(): Array<Array<boolean>> {
216
- assert(this.kind == ValueKind.MATRIX, 'Ethereum value is not a matrix.')
217
218
  let valueMatrix = this.toMatrix()
218
219
  let out = new Array<Array<boolean>>(valueMatrix.length)
219
220
  for (let i: i32 = 0; i < valueMatrix.length; i++) {
@@ -226,7 +227,6 @@ export namespace ethereum {
226
227
  }
227
228
 
228
229
  toBytesMatrix(): Array<Array<Bytes>> {
229
- assert(this.kind == ValueKind.MATRIX, 'Ethereum value is not a matrix.')
230
230
  let valueMatrix = this.toMatrix()
231
231
  let out = new Array<Array<Bytes>>(valueMatrix.length)
232
232
  for (let i: i32 = 0; i < valueMatrix.length; i++) {
@@ -239,7 +239,6 @@ export namespace ethereum {
239
239
  }
240
240
 
241
241
  toAddressMatrix(): Array<Array<Address>> {
242
- assert(this.kind == ValueKind.MATRIX, 'Ethereum value is not a matrix.')
243
242
  let valueMatrix = this.toMatrix()
244
243
  let out = new Array<Array<Address>>(valueMatrix.length)
245
244
  for (let i: i32 = 0; i < valueMatrix.length; i++) {
@@ -252,7 +251,6 @@ export namespace ethereum {
252
251
  }
253
252
 
254
253
  toStringMatrix(): Array<Array<string>> {
255
- assert(this.kind == ValueKind.MATRIX, 'Ethereum value is not a matrix.')
256
254
  let valueMatrix = this.toMatrix()
257
255
  let out = new Array<Array<string>>(valueMatrix.length)
258
256
  for (let i: i32 = 0; i < valueMatrix.length; i++) {
@@ -265,7 +263,6 @@ export namespace ethereum {
265
263
  }
266
264
 
267
265
  toI32Matrix(): Array<Array<i32>> {
268
- assert(this.kind == ValueKind.MATRIX, 'Ethereum value is not a matrix.')
269
266
  let valueMatrix = this.toMatrix()
270
267
  let out = new Array<Array<i32>>(valueMatrix.length)
271
268
  for (let i: i32 = 0; i < valueMatrix.length; i++) {
@@ -278,7 +275,6 @@ export namespace ethereum {
278
275
  }
279
276
 
280
277
  toBigIntMatrix(): Array<Array<BigInt>> {
281
- assert(this.kind == ValueKind.MATRIX, 'Ethereum value is not a matrix.')
282
278
  let valueMatrix = this.toMatrix()
283
279
  let out = new Array<Array<BigInt>>(valueMatrix.length)
284
280
  for (let i: i32 = 0; i < valueMatrix.length; i++) {
@@ -336,7 +332,11 @@ export namespace ethereum {
336
332
  }
337
333
 
338
334
  static fromMatrix(values: Array<Array<Value>>): Value {
339
- return new Value(ValueKind.MATRIX, changetype<u32>(values))
335
+ let innerOut = new Array<Value>(values.length)
336
+ for (let i: i32 = 0; i < innerOut.length; i++) {
337
+ innerOut[i] = Value.fromArray(values[i])
338
+ }
339
+ return Value.fromArray(innerOut)
340
340
  }
341
341
 
342
342
  static fromTupleArray(values: Array<Tuple>): Value {
@@ -86,6 +86,15 @@ export class Value {
86
86
  return changetype<Array<Value>>(this.data as u32)
87
87
  }
88
88
 
89
+ toMatrix(): Array<Array<Value>> {
90
+ let valueArray = this.toArray()
91
+ let out = new Array<Array<Value>>(valueArray.length)
92
+ for (let i: i32 = 0; i < valueArray.length; i++) {
93
+ out[i] = valueArray[i].toArray()
94
+ }
95
+ return out
96
+ }
97
+
89
98
  toBooleanArray(): Array<boolean> {
90
99
  let values = this.toArray()
91
100
  let output = new Array<boolean>(values.length)
@@ -140,6 +149,78 @@ export class Value {
140
149
  return output
141
150
  }
142
151
 
152
+ toBooleanMatrix(): Array<Array<boolean>> {
153
+ let valueMatrix = this.toMatrix()
154
+ let out = new Array<Array<boolean>>(valueMatrix.length)
155
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
156
+ out[i] = new Array<boolean>(valueMatrix[i].length)
157
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
158
+ out[i][j] = valueMatrix[i][j].toBoolean()
159
+ }
160
+ }
161
+ return out
162
+ }
163
+
164
+ toBytesMatrix(): Array<Array<Bytes>> {
165
+ let valueMatrix = this.toMatrix()
166
+ let out = new Array<Array<Bytes>>(valueMatrix.length)
167
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
168
+ out[i] = new Array<Bytes>(valueMatrix[i].length)
169
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
170
+ out[i][j] = valueMatrix[i][j].toBytes()
171
+ }
172
+ }
173
+ return out
174
+ }
175
+
176
+ toAddressMatrix(): Array<Array<Address>> {
177
+ let valueMatrix = this.toMatrix()
178
+ let out = new Array<Array<Address>>(valueMatrix.length)
179
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
180
+ out[i] = new Array<Address>(valueMatrix[i].length)
181
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
182
+ out[i][j] = valueMatrix[i][j].toAddress()
183
+ }
184
+ }
185
+ return out
186
+ }
187
+
188
+ toStringMatrix(): Array<Array<string>> {
189
+ let valueMatrix = this.toMatrix()
190
+ let out = new Array<Array<string>>(valueMatrix.length)
191
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
192
+ out[i] = new Array<string>(valueMatrix[i].length)
193
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
194
+ out[i][j] = valueMatrix[i][j].toString()
195
+ }
196
+ }
197
+ return out
198
+ }
199
+
200
+ toI32Matrix(): Array<Array<i32>> {
201
+ let valueMatrix = this.toMatrix()
202
+ let out = new Array<Array<i32>>(valueMatrix.length)
203
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
204
+ out[i] = new Array<i32>(valueMatrix[i].length)
205
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
206
+ out[i][j] = valueMatrix[i][j].toI32()
207
+ }
208
+ }
209
+ return out
210
+ }
211
+
212
+ toBigIntMatrix(): Array<Array<BigInt>> {
213
+ let valueMatrix = this.toMatrix()
214
+ let out = new Array<Array<BigInt>>(valueMatrix.length)
215
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
216
+ out[i] = new Array<BigInt>(valueMatrix[i].length)
217
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
218
+ out[i][j] = valueMatrix[i][j].toBigInt()
219
+ }
220
+ }
221
+ return out
222
+ }
223
+
143
224
  /** Return a string that indicates the kind of value `this` contains for
144
225
  * logging and error messages */
145
226
  displayKind(): string {
@@ -267,6 +348,69 @@ export class Value {
267
348
  static fromBigDecimal(n: BigDecimal): Value {
268
349
  return new Value(ValueKind.BIGDECIMAL, changetype<u32>(n))
269
350
  }
351
+
352
+ static fromMatrix(values: Array<Array<Value>>): Value {
353
+ let innerOut = new Array<Value>(values.length)
354
+ for (let i: i32 = 0; i < innerOut.length; i++) {
355
+ innerOut[i] = Value.fromArray(values[i])
356
+ }
357
+ return Value.fromArray(innerOut)
358
+ }
359
+
360
+ static fromBooleanMatrix(values: Array<Array<boolean>>): Value {
361
+ let out = new Array<Array<Value>>(values.length)
362
+ for (let i: i32 = 0; i < values.length; i++) {
363
+ out[i] = new Array<Value>(values[i].length)
364
+ for (let j: i32 = 0; j < values[i].length; j++) {
365
+ out[i][j] = Value.fromBoolean(values[i][j])
366
+ }
367
+ }
368
+ return Value.fromMatrix(out)
369
+ }
370
+
371
+ static fromBytesMatrix(values: Array<Array<Bytes>>): Value {
372
+ let out = new Array<Array<Value>>(values.length)
373
+ for (let i: i32 = 0; i < values.length; i++) {
374
+ out[i] = new Array<Value>(values[i].length)
375
+ for (let j: i32 = 0; j < values[i].length; j++) {
376
+ out[i][j] = Value.fromBytes(values[i][j])
377
+ }
378
+ }
379
+ return Value.fromMatrix(out)
380
+ }
381
+
382
+ static fromAddressMatrix(values: Array<Array<Address>>): Value {
383
+ let out = new Array<Array<Value>>(values.length)
384
+ for (let i: i32 = 0; i < values.length; i++) {
385
+ out[i] = new Array<Value>(values[i].length)
386
+ for (let j: i32 = 0; j < values[i].length; j++) {
387
+ out[i][j] = Value.fromAddress(values[i][j])
388
+ }
389
+ }
390
+ return Value.fromMatrix(out)
391
+ }
392
+
393
+ static fromStringMatrix(values: Array<Array<string>>): Value {
394
+ let out = new Array<Array<Value>>(values.length)
395
+ for (let i: i32 = 0; i < values.length; i++) {
396
+ out[i] = new Array<Value>(values[i].length)
397
+ for (let j: i32 = 0; j < values[i].length; j++) {
398
+ out[i][j] = Value.fromString(values[i][j])
399
+ }
400
+ }
401
+ return Value.fromMatrix(out)
402
+ }
403
+
404
+ static fromI32Matrix(values: Array<Array<i32>>): Value {
405
+ let out = new Array<Array<Value>>(values.length)
406
+ for (let i: i32 = 0; i < values.length; i++) {
407
+ out[i] = new Array<Value>(values[i].length)
408
+ for (let j: i32 = 0; j < values[i].length; j++) {
409
+ out[i][j] = Value.fromI32(values[i][j])
410
+ }
411
+ }
412
+ return Value.fromMatrix(out)
413
+ }
270
414
  }
271
415
 
272
416
  /** Type hint for JSON values. */
@@ -207,11 +207,13 @@ export enum TypeId {
207
207
  CosmosValidatorSetUpdates = 1559,
208
208
  CosmosValidatorUpdate = 1560,
209
209
  CosmosVersionParams = 1561,
210
+ CosmosMessageData = 1562,
211
+ CosmosTransactionContext = 1563,
210
212
  /*
211
213
  Continue to add more Cosmos type IDs here. e.g.:
212
214
  ```
213
- NextCosmosType = 1562,
214
- AnotherCosmosType = 1563,
215
+ NextCosmosType = 1564,
216
+ AnotherCosmosType = 1565,
215
217
  ...
216
218
  LastCosmosType = 2499,
217
219
  ```
@@ -547,6 +549,10 @@ export function id_of_type(typeId: TypeId): usize {
547
549
  return idof<cosmos.ValidatorUpdate>()
548
550
  case TypeId.CosmosVersionParams:
549
551
  return idof<cosmos.VersionParams>()
552
+ case TypeId.CosmosMessageData:
553
+ return idof<cosmos.MessageData>()
554
+ case TypeId.CosmosTransactionContext:
555
+ return idof<cosmos.TransactionContext>()
550
556
  /**
551
557
  * Arweave type ids
552
558
  */
@@ -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.28.0-alpha.0",
4
+ "version": "0.28.1",
5
5
  "module": "index.ts",
6
6
  "types": "index.ts",
7
7
  "main": "index.ts",
@@ -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.28.0-alpha.0",
12
+ "@graphprotocol/graph-ts": "0.28.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.28.0-alpha.0":
6
- version "0.28.0-alpha.0"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.28.0-alpha.0.tgz#2d687842c42a25b306e49591cecc413af5ded91f"
8
- integrity sha512-3ZaYh8Xs9cMGcfW8ft+HR0rpT1/SM3wRnUsyPHjPpdVaOykjRTz5noRKYkYFw8r6tdlC+xIWc34/Qp6RaT9SBg==
5
+ "@graphprotocol/graph-ts@0.28.1":
6
+ version "0.28.1"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.28.1.tgz#271affc77deb5a4a7c3f95d4b3b1daaa9818e51c"
8
+ integrity sha512-1wMLQ0cu84/6Ml3zcz9ya1zFzrDAzCj0dIGZ7Rz9upnRSXg5jjqU4DefO/OYrl2K2/OPso9hSAr6I4aue2pL1Q==
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.28.0-alpha.0"
10
+ "@graphprotocol/graph-ts": "0.28.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.28.0-alpha.0":
6
- version "0.28.0-alpha.0"
7
- resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.28.0-alpha.0.tgz#2d687842c42a25b306e49591cecc413af5ded91f"
8
- integrity sha512-3ZaYh8Xs9cMGcfW8ft+HR0rpT1/SM3wRnUsyPHjPpdVaOykjRTz5noRKYkYFw8r6tdlC+xIWc34/Qp6RaT9SBg==
5
+ "@graphprotocol/graph-ts@0.28.1":
6
+ version "0.28.1"
7
+ resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.28.1.tgz#271affc77deb5a4a7c3f95d4b3b1daaa9818e51c"
8
+ integrity sha512-1wMLQ0cu84/6Ml3zcz9ya1zFzrDAzCj0dIGZ7Rz9upnRSXg5jjqU4DefO/OYrl2K2/OPso9hSAr6I4aue2pL1Q==
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.34.0-alpha.0",
3
+ "version": "0.34.1",
4
4
  "license": "(Apache-2.0 OR MIT)",
5
5
  "description": "CLI for building for and deploying to The Graph",
6
6
  "dependencies": {
@@ -179,7 +179,6 @@ const ASSEMBLYSCRIPT_TO_ETHEREUM_VALUE = [
179
179
  code => `ethereum.Value.fromTupleArray(${code})`,
180
180
  ],
181
181
 
182
- // ethereumToAsc
183
182
  // Multi dimentional arrays
184
183
 
185
184
  [
@@ -18,13 +18,17 @@ const isTupleType = t => {
18
18
  }
19
19
 
20
20
  const containsTupleType = t => {
21
- return isTupleType(t) || isTupleArrayType(t)
21
+ return isTupleType(t) || isTupleArrayType(t) || isTupleMatrixType(t)
22
22
  }
23
23
 
24
24
  const isTupleArrayType = t => {
25
25
  return t.match(/^tuple\[([0-9]+)?\]$/)
26
26
  }
27
27
 
28
+ const isTupleMatrixType = t => {
29
+ return t.match(/^tuple\[([0-9]+)?\]\[([0-9]+)?\]$/)
30
+ }
31
+
28
32
  const unrollTuple = ({ path, index, value }) =>
29
33
  value.components.reduce((acc, component, index) => {
30
34
  let name = component.name || `value${index}`
@@ -44,5 +48,6 @@ module.exports = {
44
48
  disambiguateNames,
45
49
  isTupleType,
46
50
  isTupleArrayType,
51
+ isTupleMatrixType,
47
52
  unrollTuple,
48
53
  }
@@ -28,8 +28,14 @@ const withSpinner = async (text, errorText, warningText, f) => {
28
28
  try {
29
29
  let result = await f(spinner)
30
30
  if (typeof result === 'object') {
31
+ let hasError = Object.keys(result).indexOf('error') >= 0
31
32
  let hasWarning = Object.keys(result).indexOf('warning') >= 0
32
33
  let hasResult = Object.keys(result).indexOf('result') >= 0
34
+
35
+ if (hasError) {
36
+ spinner.fail(`${errorText}: ${result.error}`)
37
+ return hasResult ? result.result : result
38
+ }
33
39
  if (hasWarning && hasResult) {
34
40
  if (result.warning !== null) {
35
41
  spinner.warn(`${warningText}: ${result.warning}`)
@@ -24,6 +24,8 @@ const Protocol = require('../protocols')
24
24
  const protocolChoices = Array.from(Protocol.availableProtocols().keys())
25
25
  const availableNetworks = Protocol.availableNetworks()
26
26
 
27
+ const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum/gravatar'
28
+
27
29
  const HELP = `
28
30
  ${chalk.bold('graph init')} [options] [subgraph-name] [directory]
29
31
 
@@ -40,7 +42,7 @@ ${chalk.dim('Options:')}
40
42
  ${chalk.dim('Choose mode with one of:')}
41
43
 
42
44
  --from-contract <contract> Creates a scaffold based on an existing contract
43
- --from-example Creates a scaffold based on an example subgraph
45
+ --from-example [example] Creates a scaffold based on an example subgraph
44
46
 
45
47
  ${chalk.dim('Options for --from-contract:')}
46
48
 
@@ -106,7 +108,7 @@ const processInitForm = async (
106
108
  message: 'Product for which to initialize',
107
109
  choices: ['subgraph-studio', 'hosted-service'],
108
110
  skip: () =>
109
- protocol === 'near' ||
111
+ protocol === 'arweave' || protocol === 'cosmos' || protocol === 'near' ||
110
112
  product === 'subgraph-studio' ||
111
113
  product === 'hosted-service' ||
112
114
  studio !== undefined || node !== undefined,
@@ -280,9 +282,6 @@ const loadAbiFromFile = async (ABI, filename) => {
280
282
 
281
283
  module.exports = {
282
284
  description: 'Creates a new subgraph with basic scaffolding',
283
- options: {
284
- boolean: ['from-example'],
285
- },
286
285
  run: async toolbox => {
287
286
  // Obtain tools
288
287
  let { print, system } = toolbox
@@ -317,7 +316,6 @@ module.exports = {
317
316
  let subgraphName, directory
318
317
  try {
319
318
  ;[subgraphName, directory] = fixParameters(toolbox.parameters, {
320
- fromExample,
321
319
  allowSimpleName,
322
320
  help,
323
321
  h,
@@ -368,7 +366,7 @@ module.exports = {
368
366
  if (fromExample && subgraphName && directory) {
369
367
  return await initSubgraphFromExample(
370
368
  toolbox,
371
- { allowSimpleName, directory, subgraphName, studio, product },
369
+ { fromExample, allowSimpleName, directory, subgraphName, studio, product },
372
370
  { commands },
373
371
  )
374
372
  }
@@ -455,6 +453,7 @@ module.exports = {
455
453
  await initSubgraphFromExample(
456
454
  toolbox,
457
455
  {
456
+ fromExample: fromExample,
458
457
  subgraphName: inputs.subgraphName,
459
458
  directory: inputs.directory,
460
459
  studio: inputs.studio,
@@ -588,7 +587,7 @@ Make sure to visit the documentation on https://thegraph.com/docs/ for further i
588
587
 
589
588
  const initSubgraphFromExample = async (
590
589
  toolbox,
591
- { allowSimpleName, subgraphName, directory, studio, product },
590
+ { fromExample, allowSimpleName, subgraphName, directory, studio, product },
592
591
  { commands },
593
592
  ) => {
594
593
  let { filesystem, print, system } = toolbox
@@ -612,10 +611,32 @@ const initSubgraphFromExample = async (
612
611
  `Failed to clone example subgraph`,
613
612
  `Warnings while cloning example subgraph`,
614
613
  async spinner => {
615
- await system.run(
616
- `git clone http://github.com/graphprotocol/example-subgraph ${directory}`,
617
- )
618
- return true
614
+ // Create a temporary directory
615
+ const prefix = path.join(os.tmpdir(), 'example-subgraph-')
616
+ const tmpDir = fs.mkdtempSync(prefix)
617
+
618
+ try {
619
+ await system.run(
620
+ `git clone http://github.com/graphprotocol/example-subgraphs ${tmpDir}`
621
+ )
622
+
623
+ // If an example is not specified, use the default one
624
+ if (fromExample === undefined || fromExample === true) {
625
+ fromExample = DEFAULT_EXAMPLE_SUBGRAPH
626
+ }
627
+
628
+ const exampleSubgraphPath = path.join(tmpDir, fromExample);
629
+
630
+ if (!filesystem.exists(exampleSubgraphPath)) {
631
+ return { result: false, error: `Example not found: ${fromExample}` }
632
+ }
633
+
634
+ filesystem.copy(exampleSubgraphPath, directory)
635
+ return true
636
+ }
637
+ finally {
638
+ filesystem.remove(tmpDir)
639
+ }
619
640
  },
620
641
  )
621
642
  if (!cloned) {
@@ -42,10 +42,7 @@ type ContractMapping {
42
42
  blockHandlers: [BlockHandler!]
43
43
  eventHandlers: [EventHandler!]
44
44
  transactionHandlers: [TransactionHandler!]
45
- }
46
-
47
- type TransactionHandler {
48
- handler: String!
45
+ messageHandlers: [MessageHandler!]
49
46
  }
50
47
 
51
48
  type BlockHandler {
@@ -64,6 +61,15 @@ type EventHandler {
64
61
  handler: String!
65
62
  }
66
63
 
64
+ type TransactionHandler {
65
+ handler: String!
66
+ }
67
+
68
+ type MessageHandler {
69
+ message: String!
70
+ handler: String!
71
+ }
72
+
67
73
  type Graft {
68
74
  base: String!
69
75
  block: BigInt!
@@ -16,6 +16,7 @@ module.exports = class CosmosSubgraph {
16
16
  'blockHandlers',
17
17
  'eventHandlers',
18
18
  'transactionHandlers',
19
+ 'messageHandlers',
19
20
  ])
20
21
  }
21
22
  }
@@ -5,6 +5,7 @@ const path = require('path')
5
5
  const AbiCodeGenerator = require('./codegen/abi')
6
6
 
7
7
  const TUPLE_ARRAY_PATTERN = /^tuple\[([0-9]*)\]$/
8
+ const TUPLE_MATRIX_PATTERN = /^tuple\[([0-9]*)\]\[([0-9]*)\]$/
8
9
 
9
10
  const buildOldSignatureParameter = input => {
10
11
  return input.get('type') === 'tuple'
@@ -27,6 +28,13 @@ const buildSignatureParameter = input => {
27
28
  .get('components')
28
29
  .map(component => buildSignatureParameter(component))
29
30
  .join(',')})[${length ? length : ''}]`
31
+ } else if (input.get('type').match(TUPLE_MATRIX_PATTERN)) {
32
+ const length1 = input.get('type').match(TUPLE_MATRIX_PATTERN)[1]
33
+ const length2 = input.get('type').match(TUPLE_MATRIX_PATTERN)[2]
34
+ return `(${input.get('indexed') ? 'indexed ' : ''}${input
35
+ .get('components')
36
+ .map(component => buildSignatureParameter(component))
37
+ .join(',')})[${length1 ? length1 : ''}][${length2 ? length2 : ''}]`
30
38
  } else {
31
39
  return `${input.get('indexed') ? 'indexed ' : ''}${input.get('type')}`
32
40
  }
@@ -362,7 +362,11 @@ module.exports = class AbiCodeGenerator {
362
362
  let tupleGetter = tsCodegen.method(
363
363
  `get ${name}`,
364
364
  [],
365
- util.isTupleArrayType(type) ? `Array<${tupleClassName}>` : tupleClassName,
365
+ util.isTupleMatrixType(type)
366
+ ? `Array<Array<${tupleClassName}>>`
367
+ : util.isTupleArrayType(type)
368
+ ? `Array<${tupleClassName}>`
369
+ : tupleClassName,
366
370
  `
367
371
  return ${
368
372
  isTupleType ? `changetype<${tupleClassName}>(${returnValue})` : `${returnValue}`
@@ -686,6 +690,13 @@ module.exports = class AbiCodeGenerator {
686
690
  const type = inputOrOutput.get('type')
687
691
  return util.isTupleType(type)
688
692
  ? this._tupleTypeName(inputOrOutput, index, tupleParentType, this.abi.name)
693
+ : util.isTupleMatrixType(type)
694
+ ? `Array<Array<${this._tupleTypeName(
695
+ inputOrOutput,
696
+ index,
697
+ tupleParentType,
698
+ this.abi.name,
699
+ )}>>`
689
700
  : util.isTupleArrayType(type)
690
701
  ? `Array<${this._tupleTypeName(
691
702
  inputOrOutput,
@@ -53,7 +53,7 @@ module.exports = class Scaffold {
53
53
  },
54
54
  dependencies: {
55
55
  '@graphprotocol/graph-cli': GRAPH_CLI_VERSION,
56
- '@graphprotocol/graph-ts': `0.28.0-alpha.0`,
56
+ '@graphprotocol/graph-ts': `0.28.1`,
57
57
  },
58
58
  devDependencies: this.protocol.hasEvents() ? { 'matchstick-as': `0.5.0`} : undefined,
59
59
  }),
package/src/subgraph.js CHANGED
@@ -100,17 +100,18 @@ module.exports = class Subgraph {
100
100
  }
101
101
 
102
102
  static validateRepository(manifest, { resolveFile }) {
103
- return manifest.get('repository') !==
104
- 'https://github.com/graphprotocol/example-subgraph'
105
- ? immutable.List()
106
- : immutable.List().push(
103
+ const repository = manifest.get('repository')
104
+
105
+ return /^https:\/\/github\.com\/graphprotocol\/example-subgraphs?$/.test(repository)
106
+ ? immutable.List().push(
107
107
  immutable.fromJS({
108
108
  path: ['repository'],
109
109
  message: `\
110
- The repository is still set to https://github.com/graphprotocol/example-subgraph.
110
+ The repository is still set to ${repository}.
111
111
  Please replace it with a link to your subgraph source code.`,
112
112
  }),
113
113
  )
114
+ : immutable.List()
114
115
  }
115
116
 
116
117
  static validateDescription(manifest, { resolveFile }) {
@@ -15,6 +15,7 @@ describe('Init', () => {
15
15
  'ethereum',
16
16
  '--studio',
17
17
  '--from-example',
18
+ 'ethereum/gravatar',
18
19
  'user/example-subgraph',
19
20
  path.join(ethereumBaseDir, 'from-example'),
20
21
  ],