@graphprotocol/graph-cli 0.35.0-alpha.0 → 0.35.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.
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/cosmos.ts +23 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/value.ts +144 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/global/global.ts +8 -2
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/package.json +1 -1
- package/examples/basic-event-handlers/package.json +1 -1
- package/examples/basic-event-handlers/yarn.lock +4 -4
- package/examples/example-subgraph/package.json +1 -1
- package/examples/example-subgraph/yarn.lock +4 -4
- package/package.json +1 -1
- package/src/protocols/cosmos/manifest.graphql +10 -4
- package/src/protocols/cosmos/subgraph.js +1 -0
- package/src/scaffold/index.js +1 -1
|
@@ -19,13 +19,35 @@ export namespace cosmos {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export class EventData {
|
|
22
|
-
constructor(
|
|
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,
|
|
@@ -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 =
|
|
214
|
-
AnotherCosmosType =
|
|
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
|
*/
|
|
@@ -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.
|
|
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.
|
|
6
|
-
version "0.28.
|
|
7
|
-
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.28.
|
|
8
|
-
integrity sha512-
|
|
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
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
# yarn lockfile v1
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
"@graphprotocol/graph-ts@0.28.
|
|
6
|
-
version "0.28.
|
|
7
|
-
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.28.
|
|
8
|
-
integrity sha512-
|
|
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
|
@@ -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!
|
package/src/scaffold/index.js
CHANGED
|
@@ -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.
|
|
56
|
+
'@graphprotocol/graph-ts': `0.28.1`,
|
|
57
57
|
},
|
|
58
58
|
devDependencies: this.protocol.hasEvents() ? { 'matchstick-as': `0.5.0`} : undefined,
|
|
59
59
|
}),
|