@graphprotocol/graph-cli 0.33.1 → 0.34.0

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.
Files changed (33) hide show
  1. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/README.md +1 -1
  2. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/ethereum.ts +200 -0
  3. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/global/global.ts +28 -28
  4. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/methods.txt +18 -0
  5. package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/package.json +1 -1
  6. package/examples/basic-event-handlers/node_modules/keccak/build/Makefile +342 -0
  7. package/examples/basic-event-handlers/node_modules/keccak/build/Release/.deps/Release/obj.target/keccak/src/addon.o.d.raw +69 -0
  8. package/examples/basic-event-handlers/node_modules/keccak/build/binding.Makefile +6 -0
  9. package/examples/basic-event-handlers/node_modules/keccak/build/config.gypi +27 -11
  10. package/examples/basic-event-handlers/node_modules/keccak/build/gyp-mac-tool +772 -0
  11. package/examples/basic-event-handlers/node_modules/keccak/build/keccak.target.mk +207 -0
  12. package/examples/basic-event-handlers/node_modules/websocket/build/Makefile +347 -0
  13. package/examples/basic-event-handlers/node_modules/websocket/build/Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw +67 -0
  14. package/examples/basic-event-handlers/node_modules/websocket/build/binding.Makefile +6 -0
  15. package/examples/basic-event-handlers/node_modules/websocket/build/bufferutil.target.mk +190 -0
  16. package/examples/basic-event-handlers/node_modules/websocket/build/config.gypi +23 -7
  17. package/examples/basic-event-handlers/node_modules/websocket/build/gyp-mac-tool +772 -0
  18. package/examples/basic-event-handlers/node_modules/websocket/build/validation.target.mk +190 -0
  19. package/examples/basic-event-handlers/package.json +1 -1
  20. package/examples/basic-event-handlers/yarn.lock +4 -4
  21. package/examples/example-subgraph/package.json +1 -1
  22. package/examples/example-subgraph/yarn.lock +4 -4
  23. package/package.json +1 -1
  24. package/src/codegen/types/conversions.js +100 -0
  25. package/src/codegen/types/index.test.js +347 -0
  26. package/src/codegen/util.js +6 -1
  27. package/src/command-helpers/spinner.js +6 -0
  28. package/src/commands/init.js +33 -12
  29. package/src/protocols/ethereum/abi.js +8 -0
  30. package/src/protocols/ethereum/codegen/abi.js +12 -1
  31. package/src/scaffold/index.js +1 -1
  32. package/src/subgraph.js +6 -5
  33. package/tests/cli/init.test.js +1 -0
@@ -59,7 +59,7 @@ Refer to the `helper-functions.ts` file in this repository for a few common func
59
59
 
60
60
  ## API
61
61
 
62
- Documentation on the API can be found [here](https://thegraph.com/docs/assemblyscript-api#api-reference).
62
+ Documentation on the API can be found [here](https://thegraph.com/docs/en/developer/assemblyscript-api/).
63
63
 
64
64
  For examples of `graph-ts` in use take a look at one of the following subgraphs:
65
65
  * https://github.com/graphprotocol/ens-subgraph
@@ -102,6 +102,15 @@ export namespace ethereum {
102
102
  return changetype<Tuple>(this.data as u32)
103
103
  }
104
104
 
105
+ toMatrix(): Array<Array<Value>> {
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
112
+ }
113
+
105
114
  toTupleArray<T extends Tuple>(): Array<T> {
106
115
  assert(
107
116
  this.kind == ValueKind.ARRAY || this.kind == ValueKind.FIXED_ARRAY,
@@ -115,6 +124,18 @@ export namespace ethereum {
115
124
  return out
116
125
  }
117
126
 
127
+ toTupleMatrix<T extends Tuple>(): Array<Array<T>> {
128
+ let valueMatrix = this.toMatrix()
129
+ let out = new Array<Array<T>>(valueMatrix.length)
130
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
131
+ out[i] = new Array<T>(valueMatrix[i].length)
132
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
133
+ out[i][j] = changetype<T>(valueMatrix[i][j].toTuple())
134
+ }
135
+ }
136
+ return out
137
+ }
138
+
118
139
  toBooleanArray(): Array<boolean> {
119
140
  assert(
120
141
  this.kind == ValueKind.ARRAY || this.kind == ValueKind.FIXED_ARRAY,
@@ -193,6 +214,78 @@ export namespace ethereum {
193
214
  return out
194
215
  }
195
216
 
217
+ toBooleanMatrix(): Array<Array<boolean>> {
218
+ let valueMatrix = this.toMatrix()
219
+ let out = new Array<Array<boolean>>(valueMatrix.length)
220
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
221
+ out[i] = new Array<boolean>(valueMatrix[i].length)
222
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
223
+ out[i][j] = valueMatrix[i][j].toBoolean()
224
+ }
225
+ }
226
+ return out
227
+ }
228
+
229
+ toBytesMatrix(): Array<Array<Bytes>> {
230
+ let valueMatrix = this.toMatrix()
231
+ let out = new Array<Array<Bytes>>(valueMatrix.length)
232
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
233
+ out[i] = new Array<Bytes>(valueMatrix[i].length)
234
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
235
+ out[i][j] = valueMatrix[i][j].toBytes()
236
+ }
237
+ }
238
+ return out
239
+ }
240
+
241
+ toAddressMatrix(): Array<Array<Address>> {
242
+ let valueMatrix = this.toMatrix()
243
+ let out = new Array<Array<Address>>(valueMatrix.length)
244
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
245
+ out[i] = new Array<Address>(valueMatrix[i].length)
246
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
247
+ out[i][j] = valueMatrix[i][j].toAddress()
248
+ }
249
+ }
250
+ return out
251
+ }
252
+
253
+ toStringMatrix(): Array<Array<string>> {
254
+ let valueMatrix = this.toMatrix()
255
+ let out = new Array<Array<string>>(valueMatrix.length)
256
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
257
+ out[i] = new Array<string>(valueMatrix[i].length)
258
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
259
+ out[i][j] = valueMatrix[i][j].toString()
260
+ }
261
+ }
262
+ return out
263
+ }
264
+
265
+ toI32Matrix(): Array<Array<i32>> {
266
+ let valueMatrix = this.toMatrix()
267
+ let out = new Array<Array<i32>>(valueMatrix.length)
268
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
269
+ out[i] = new Array<i32>(valueMatrix[i].length)
270
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
271
+ out[i][j] = valueMatrix[i][j].toI32()
272
+ }
273
+ }
274
+ return out
275
+ }
276
+
277
+ toBigIntMatrix(): Array<Array<BigInt>> {
278
+ let valueMatrix = this.toMatrix()
279
+ let out = new Array<Array<BigInt>>(valueMatrix.length)
280
+ for (let i: i32 = 0; i < valueMatrix.length; i++) {
281
+ out[i] = new Array<BigInt>(valueMatrix[i].length)
282
+ for (let j: i32 = 0; j < valueMatrix[i].length; j++) {
283
+ out[i][j] = valueMatrix[i][j].toBigInt()
284
+ }
285
+ }
286
+ return out
287
+ }
288
+
196
289
  static fromAddress(address: Address): Value {
197
290
  assert(address.length == 20, 'Address must contain exactly 20 bytes')
198
291
  return new Value(ValueKind.ADDRESS, changetype<u32>(address))
@@ -238,6 +331,14 @@ export namespace ethereum {
238
331
  return new Value(ValueKind.TUPLE, changetype<u32>(values))
239
332
  }
240
333
 
334
+ static fromMatrix(values: Array<Array<Value>>): Value {
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
+ }
341
+
241
342
  static fromTupleArray(values: Array<Tuple>): Value {
242
343
  let out = new Array<Value>(values.length)
243
344
  for (let i: i32 = 0; i < values.length; i++) {
@@ -246,6 +347,17 @@ export namespace ethereum {
246
347
  return Value.fromArray(out)
247
348
  }
248
349
 
350
+ static fromTupleMatrix(values: Array<Array<Tuple>>): Value {
351
+ let out = new Array<Array<Value>>(values.length)
352
+ for (let i: i32 = 0; i < values.length; i++) {
353
+ out[i] = new Array<Value>(values[i].length)
354
+ for (let j: i32 = 0; j < values[i].length; j++) {
355
+ out[i][j] = Value.fromTuple(values[i][j])
356
+ }
357
+ }
358
+ return Value.fromMatrix(out)
359
+ }
360
+
249
361
  static fromBooleanArray(values: Array<boolean>): Value {
250
362
  let out = new Array<Value>(values.length)
251
363
  for (let i: i32 = 0; i < values.length; i++) {
@@ -309,6 +421,94 @@ export namespace ethereum {
309
421
  }
310
422
  return Value.fromArray(out)
311
423
  }
424
+
425
+ static fromBooleanMatrix(values: Array<Array<boolean>>): Value {
426
+ let out = new Array<Array<Value>>(values.length)
427
+ for (let i: i32 = 0; i < values.length; i++) {
428
+ out[i] = new Array<Value>(values[i].length)
429
+ for (let j: i32 = 0; j < values[i].length; j++) {
430
+ out[i][j] = Value.fromBoolean(values[i][j])
431
+ }
432
+ }
433
+ return Value.fromMatrix(out)
434
+ }
435
+
436
+ static fromBytesMatrix(values: Array<Array<Bytes>>): Value {
437
+ let out = new Array<Array<Value>>(values.length)
438
+ for (let i: i32 = 0; i < values.length; i++) {
439
+ out[i] = new Array<Value>(values[i].length)
440
+ for (let j: i32 = 0; j < values[i].length; j++) {
441
+ out[i][j] = Value.fromBytes(values[i][j])
442
+ }
443
+ }
444
+ return Value.fromMatrix(out)
445
+ }
446
+
447
+ static fromFixedBytesMatrix(values: Array<Array<Bytes>>): Value {
448
+ let out = new Array<Array<Value>>(values.length)
449
+ for (let i: i32 = 0; i < values.length; i++) {
450
+ out[i] = new Array<Value>(values[i].length)
451
+ for (let j: i32 = 0; j < values[i].length; j++) {
452
+ out[i][j] = Value.fromFixedBytes(values[i][j])
453
+ }
454
+ }
455
+ return Value.fromMatrix(out)
456
+ }
457
+
458
+ static fromAddressMatrix(values: Array<Array<Address>>): Value {
459
+ let out = new Array<Array<Value>>(values.length)
460
+ for (let i: i32 = 0; i < values.length; i++) {
461
+ out[i] = new Array<Value>(values[i].length)
462
+ for (let j: i32 = 0; j < values[i].length; j++) {
463
+ out[i][j] = Value.fromAddress(values[i][j])
464
+ }
465
+ }
466
+ return Value.fromMatrix(out)
467
+ }
468
+
469
+ static fromStringMatrix(values: Array<Array<string>>): Value {
470
+ let out = new Array<Array<Value>>(values.length)
471
+ for (let i: i32 = 0; i < values.length; i++) {
472
+ out[i] = new Array<Value>(values[i].length)
473
+ for (let j: i32 = 0; j < values[i].length; j++) {
474
+ out[i][j] = Value.fromString(values[i][j])
475
+ }
476
+ }
477
+ return Value.fromMatrix(out)
478
+ }
479
+
480
+ static fromI32Matrix(values: Array<Array<i32>>): Value {
481
+ let out = new Array<Array<Value>>(values.length)
482
+ for (let i: i32 = 0; i < values.length; i++) {
483
+ out[i] = new Array<Value>(values[i].length)
484
+ for (let j: i32 = 0; j < values[i].length; j++) {
485
+ out[i][j] = Value.fromI32(values[i][j])
486
+ }
487
+ }
488
+ return Value.fromMatrix(out)
489
+ }
490
+
491
+ static fromSignedBigIntMatrix(values: Array<Array<BigInt>>): Value {
492
+ let out = new Array<Array<Value>>(values.length)
493
+ for (let i: i32 = 0; i < values.length; i++) {
494
+ out[i] = new Array<Value>(values[i].length)
495
+ for (let j: i32 = 0; j < values[i].length; j++) {
496
+ out[i][j] = Value.fromSignedBigInt(values[i][j])
497
+ }
498
+ }
499
+ return Value.fromMatrix(out)
500
+ }
501
+
502
+ static fromUnsignedBigIntMatrix(values: Array<Array<BigInt>>): Value {
503
+ let out = new Array<Array<Value>>(values.length)
504
+ for (let i: i32 = 0; i < values.length; i++) {
505
+ out[i] = new Array<Value>(values[i].length)
506
+ for (let j: i32 = 0; j < values[i].length; j++) {
507
+ out[i][j] = Value.fromUnsignedBigInt(values[i][j])
508
+ }
509
+ }
510
+ return Value.fromMatrix(out)
511
+ }
312
512
  }
313
513
 
314
514
  /**
@@ -146,22 +146,22 @@ export enum TypeId {
146
146
 
147
147
  // Reserved discriminant space for Cosmos type IDs: [1,500, 2,499]
148
148
  CosmosAny = 1500,
149
- CosmosArrayAny = 1501,
150
- CosmosArrayBytes = 1502,
151
- CosmosArrayCoin = 1503,
152
- CosmosArrayCommitSig = 1504,
153
- CosmosArrayEvent = 1505,
154
- CosmosArrayEventAttribute = 1506,
155
- CosmosArrayEvidence = 1507,
156
- CosmosArrayModeInfo = 1508,
157
- CosmosArraySignerInfo = 1509,
158
- CosmosArrayTxResult = 1510,
159
- CosmosArrayValidator = 1511,
160
- CosmosArrayValidatorUpdate = 1512,
149
+ CosmosAnyArray = 1501,
150
+ CosmosBytesArray = 1502,
151
+ CosmosCoinArray = 1503,
152
+ CosmosCommitSigArray = 1504,
153
+ CosmosEventArray = 1505,
154
+ CosmosEventAttributeArray = 1506,
155
+ CosmosEvidenceArray = 1507,
156
+ CosmosModeInfoArray = 1508,
157
+ CosmosSignerInfoArray = 1509,
158
+ CosmosTxResultArray = 1510,
159
+ CosmosValidatorArray = 1511,
160
+ CosmosValidatorUpdateArray = 1512,
161
161
  CosmosAuthInfo = 1513,
162
162
  CosmosBlock = 1514,
163
- CosmosBlockID = 1515,
164
- CosmosBlockIDFlagEnum = 1516,
163
+ CosmosBlockId = 1515,
164
+ CosmosBlockIdFlagEnum = 1516,
165
165
  CosmosBlockParams = 1517,
166
166
  CosmosCoin = 1518,
167
167
  CosmosCommit = 1519,
@@ -425,37 +425,37 @@ export function id_of_type(typeId: TypeId): usize {
425
425
  return idof<Array<ethereum.Log>>()
426
426
  case TypeId.CosmosAny:
427
427
  return idof<cosmos.Any>()
428
- case TypeId.CosmosArrayAny:
428
+ case TypeId.CosmosAnyArray:
429
429
  return idof<Array<cosmos.Any>>()
430
- case TypeId.CosmosArrayBytes:
430
+ case TypeId.CosmosBytesArray:
431
431
  return idof<Array<Bytes>>()
432
- case TypeId.CosmosArrayCoin:
432
+ case TypeId.CosmosCoinArray:
433
433
  return idof<Array<cosmos.Coin>>()
434
- case TypeId.CosmosArrayCommitSig:
434
+ case TypeId.CosmosCommitSigArray:
435
435
  return idof<Array<cosmos.CommitSig>>()
436
- case TypeId.CosmosArrayEvent:
436
+ case TypeId.CosmosEventArray:
437
437
  return idof<Array<cosmos.Event>>()
438
- case TypeId.CosmosArrayEventAttribute:
438
+ case TypeId.CosmosEventAttributeArray:
439
439
  return idof<Array<cosmos.EventAttribute>>()
440
- case TypeId.CosmosArrayEvidence:
440
+ case TypeId.CosmosEvidenceArray:
441
441
  return idof<Array<cosmos.Evidence>>()
442
- case TypeId.CosmosArrayModeInfo:
442
+ case TypeId.CosmosModeInfoArray:
443
443
  return idof<Array<cosmos.ModeInfo>>()
444
- case TypeId.CosmosArraySignerInfo:
444
+ case TypeId.CosmosSignerInfoArray:
445
445
  return idof<Array<cosmos.SignerInfo>>()
446
- case TypeId.CosmosArrayTxResult:
446
+ case TypeId.CosmosTxResultArray:
447
447
  return idof<Array<cosmos.TxResult>>()
448
- case TypeId.CosmosArrayValidator:
448
+ case TypeId.CosmosValidatorArray:
449
449
  return idof<Array<cosmos.Validator>>()
450
- case TypeId.CosmosArrayValidatorUpdate:
450
+ case TypeId.CosmosValidatorUpdateArray:
451
451
  return idof<Array<cosmos.ValidatorUpdate>>()
452
452
  case TypeId.CosmosAuthInfo:
453
453
  return idof<cosmos.AuthInfo>()
454
454
  case TypeId.CosmosBlock:
455
455
  return idof<cosmos.Block>()
456
- case TypeId.CosmosBlockID:
456
+ case TypeId.CosmosBlockId:
457
457
  return idof<cosmos.BlockID>()
458
- case TypeId.CosmosBlockIDFlagEnum:
458
+ case TypeId.CosmosBlockIdFlagEnum:
459
459
  return idof<Array<cosmos.BlockIDFlag>>()
460
460
  case TypeId.CosmosBlockParams:
461
461
  return idof<cosmos.BlockParams>()
@@ -0,0 +1,18 @@
1
+ toAddressMatrix
2
+ toBooleanMatrix
3
+ toBytesMatrix
4
+ toI32Matrix
5
+ toBigIntMatrix
6
+ toStringMatrix
7
+
8
+ fromAddressMatrix
9
+ fromBooleanMatrix
10
+ fromFixedBytesMatrix
11
+ fromBytesMatrix
12
+ fromI32Matrix
13
+ fromSignedBigIntMatrix
14
+ fromUnsignedBigIntMatrix
15
+ fromStringMatrix
16
+
17
+ fromBigIntMatrix
18
+ fromBigDecimalMatrix
@@ -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.27.0",
4
+ "version": "0.28.0",
5
5
  "module": "index.ts",
6
6
  "types": "index.ts",
7
7
  "main": "index.ts",