@graphprotocol/graph-cli 0.26.0 → 0.28.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.
- package/README.md +6 -6
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/ethereum.ts +1 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/tendermint.ts +554 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/collections.ts +52 -2
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/numbers.ts +11 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/value.ts +47 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/global/global.ts +150 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/index.ts +2 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/package.json +2 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/test.js +2 -0
- package/examples/basic-event-handlers/package.json +5 -5
- package/examples/basic-event-handlers/yarn.lock +12 -12
- package/examples/example-subgraph/package.json +1 -1
- package/examples/example-subgraph/yarn.lock +4 -4
- package/package.json +27 -24
- package/src/codegen/schema.js +104 -25
- package/src/codegen/schema.test.js +3 -7
- package/src/commands/codegen.js +1 -1
- package/src/commands/deploy.js +4 -2
- package/src/commands/init.js +3 -0
- package/src/commands/test.js +82 -59
- package/src/protocols/ethereum/codegen/abi.js +72 -2
- package/src/protocols/ethereum/manifest.graphql +92 -0
- package/src/protocols/index.js +51 -7
- package/src/protocols/near/manifest.graphql +57 -0
- package/src/protocols/tendermint/manifest.graphql +64 -0
- package/src/protocols/tendermint/subgraph.js +20 -0
- package/src/scaffold/index.js +1 -1
- package/src/subgraph.js +22 -13
- package/src/validation/manifest.js +29 -8
- package/src/validation/schema.js +120 -119
- package/tests/cli/validation/example-values-found.stderr +2 -2
- package/tests/cli/validation/invalid-manifest/subgraph.yaml +2 -1
- package/tests/cli/validation/invalid-manifest-cannot-infer-protocol/subgraph.yaml +12 -0
- package/tests/cli/validation/invalid-manifest-cannot-infer-protocol.stderr +5 -0
- package/tests/cli/validation/invalid-manifest.stderr +0 -3
- package/tests/cli/validation.test.js +8 -0
- package/manifest-schema.graphql +0 -122
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# The Graph CLI (graph-cli)
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@graphprotocol/graph-cli)
|
|
4
|
-
[](https://travis-ci.org/graphprotocol/graph-cli)
|
|
5
5
|
|
|
6
6
|
## The Graph Command Line Interface
|
|
7
7
|
|
|
@@ -57,9 +57,9 @@ If you are ready to dive into the details of building a subgraph from scratch, t
|
|
|
57
57
|
|
|
58
58
|
The steps to create a new version of the `graph-cli` are:
|
|
59
59
|
|
|
60
|
-
1. Decide which version number you'll be rolling out. You can check the differences between the current `
|
|
60
|
+
1. Decide which version number you'll be rolling out. You can check the differences between the current `main` branch and the latest release.
|
|
61
61
|
2. Create a PR with the commit generated by `npm version <VERSION> [<PREID>]`.
|
|
62
|
-
3. Once that's approved and merged to `
|
|
62
|
+
3. Once that's approved and merged to `main`, you can publish it to `npm` and push the git tags as well.
|
|
63
63
|
4. Last but not least, create a Github Release refering to the pushed git tag, linking to the PRs involved.
|
|
64
64
|
|
|
65
65
|
Helpful links:
|
|
@@ -84,7 +84,7 @@ npm version minor
|
|
|
84
84
|
git push --set-upstream <REMOTE> <BRANCH>
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
Once that's approved and merged, you can update your local `
|
|
87
|
+
Once that's approved and merged, you can update your local `main` and:
|
|
88
88
|
|
|
89
89
|
```
|
|
90
90
|
npm publish
|
|
@@ -106,7 +106,7 @@ npm version preminor --preid alpha
|
|
|
106
106
|
git push --set-upstream <REMOTE> <BRANCH>
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
Once that's approved and merged, you can update your local `
|
|
109
|
+
Once that's approved and merged, you can update your local `main` and:
|
|
110
110
|
|
|
111
111
|
```
|
|
112
112
|
npm publish --tag alpha
|
|
@@ -128,7 +128,7 @@ npm version prerelease --preid alpha
|
|
|
128
128
|
git push --set-upstream <REMOTE> <BRANCH>
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
Once that's approved and merged, you can update your local `
|
|
131
|
+
Once that's approved and merged, you can update your local `main` and:
|
|
132
132
|
|
|
133
133
|
```
|
|
134
134
|
npm publish --tag alpha
|
package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/tendermint.ts
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import '../common/eager_offset'
|
|
2
|
+
import { Bytes } from '../common/collections'
|
|
3
|
+
|
|
4
|
+
export namespace tendermint {
|
|
5
|
+
export enum SignedMsgType {
|
|
6
|
+
SIGNED_MSG_TYPE_UNKNOWN = 0,
|
|
7
|
+
SIGNED_MSG_TYPE_PREVOTE = 1,
|
|
8
|
+
SIGNED_MSG_TYPE_PRECOMMIT = 2,
|
|
9
|
+
SIGNED_MSG_TYPE_PROPOSAL = 32,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export enum BlockIDFlag {
|
|
13
|
+
BLOCK_ID_FLAG_UNKNOWN = 0,
|
|
14
|
+
BLOCK_ID_FLAG_ABSENT = 1,
|
|
15
|
+
BLOCK_ID_FLAG_COMMIT = 2,
|
|
16
|
+
BLOCK_ID_FLAG_NIL = 3,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class EventList {
|
|
20
|
+
public newBlock: EventBlock
|
|
21
|
+
public transaction: Array<EventTx>
|
|
22
|
+
public validatorSetUpdates: EventValidatorSetUpdates
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
newBlock: EventBlock,
|
|
26
|
+
transaction: Array<EventTx>,
|
|
27
|
+
validatorSetUpdates: EventValidatorSetUpdates,
|
|
28
|
+
) {
|
|
29
|
+
this.newBlock = newBlock
|
|
30
|
+
this.transaction = transaction
|
|
31
|
+
this.validatorSetUpdates = validatorSetUpdates
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class EventData {
|
|
36
|
+
public event: Event
|
|
37
|
+
public block: EventBlock
|
|
38
|
+
|
|
39
|
+
constructor(event: Event, block: EventBlock) {
|
|
40
|
+
this.event = event
|
|
41
|
+
this.block = block
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class Block {
|
|
46
|
+
public header: Header
|
|
47
|
+
public data: Data
|
|
48
|
+
public evidence: EvidenceList
|
|
49
|
+
public lastCommit: Commit
|
|
50
|
+
|
|
51
|
+
constructor(header: Header, data: Data, evidence: EvidenceList, lastCommit: Commit) {
|
|
52
|
+
this.header = header
|
|
53
|
+
this.data = data
|
|
54
|
+
this.evidence = evidence
|
|
55
|
+
this.lastCommit = lastCommit
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class BlockID {
|
|
60
|
+
public hash: Bytes
|
|
61
|
+
public partSetHeader: PartSetHeader
|
|
62
|
+
|
|
63
|
+
constructor(hash: Bytes, partSetHeader: PartSetHeader) {
|
|
64
|
+
this.hash = hash
|
|
65
|
+
this.partSetHeader = partSetHeader
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class BlockParams {
|
|
70
|
+
public maxBytes: i64
|
|
71
|
+
public maxGas: i64
|
|
72
|
+
|
|
73
|
+
constructor(maxBytes: i64, maxGas: i64) {
|
|
74
|
+
this.maxBytes = maxBytes
|
|
75
|
+
this.maxGas = maxGas
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class Commit {
|
|
80
|
+
public height: i64
|
|
81
|
+
public round: i32
|
|
82
|
+
public blockId: BlockID
|
|
83
|
+
public signatures: Array<CommitSig>
|
|
84
|
+
|
|
85
|
+
constructor(height: i64, round: i32, blockId: BlockID, signatures: Array<CommitSig>) {
|
|
86
|
+
this.height = height
|
|
87
|
+
this.round = round
|
|
88
|
+
this.blockId = blockId
|
|
89
|
+
this.signatures = signatures
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class CommitSig {
|
|
94
|
+
public blockIdFlag: BlockIDFlag
|
|
95
|
+
public validatorAddress: Bytes
|
|
96
|
+
public timestamp: Timestamp
|
|
97
|
+
public signature: Bytes
|
|
98
|
+
|
|
99
|
+
constructor(
|
|
100
|
+
blockIdFlag: BlockIDFlag,
|
|
101
|
+
validatorAddress: Bytes,
|
|
102
|
+
timestamp: Timestamp,
|
|
103
|
+
signature: Bytes,
|
|
104
|
+
) {
|
|
105
|
+
this.blockIdFlag = blockIdFlag
|
|
106
|
+
this.validatorAddress = validatorAddress
|
|
107
|
+
this.timestamp = timestamp
|
|
108
|
+
this.signature = signature
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class Consensus {
|
|
113
|
+
public block: u64
|
|
114
|
+
public app: u64
|
|
115
|
+
|
|
116
|
+
constructor(block: u64, app: u64) {
|
|
117
|
+
this.block = block
|
|
118
|
+
this.app = app
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class ConsensusParams {
|
|
123
|
+
public block: BlockParams
|
|
124
|
+
public evidence: EvidenceParams
|
|
125
|
+
public validator: ValidatorParams
|
|
126
|
+
public version: VersionParams
|
|
127
|
+
|
|
128
|
+
constructor(
|
|
129
|
+
block: BlockParams,
|
|
130
|
+
evidence: EvidenceParams,
|
|
131
|
+
validator: ValidatorParams,
|
|
132
|
+
version: VersionParams,
|
|
133
|
+
) {
|
|
134
|
+
this.block = block
|
|
135
|
+
this.evidence = evidence
|
|
136
|
+
this.validator = validator
|
|
137
|
+
this.version = version
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export class Data {
|
|
142
|
+
public txs: Array<Bytes>
|
|
143
|
+
|
|
144
|
+
constructor(txs: Array<Bytes>) {
|
|
145
|
+
this.txs = txs
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export class Duration {
|
|
150
|
+
public seconds: i64
|
|
151
|
+
public nanos: i32
|
|
152
|
+
|
|
153
|
+
constructor(seconds: i64, nanos: i32) {
|
|
154
|
+
this.seconds = seconds
|
|
155
|
+
this.nanos = nanos
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export class DuplicateVoteEvidence {
|
|
160
|
+
public voteA: EventVote
|
|
161
|
+
public voteB: EventVote
|
|
162
|
+
public totalVotingPower: i64
|
|
163
|
+
public validatorPower: i64
|
|
164
|
+
public timestamp: Timestamp
|
|
165
|
+
|
|
166
|
+
constructor(
|
|
167
|
+
voteA: EventVote,
|
|
168
|
+
voteB: EventVote,
|
|
169
|
+
totalVotingPower: i64,
|
|
170
|
+
validatorPower: i64,
|
|
171
|
+
timestamp: Timestamp,
|
|
172
|
+
) {
|
|
173
|
+
this.voteA = voteA
|
|
174
|
+
this.voteB = voteB
|
|
175
|
+
this.totalVotingPower = totalVotingPower
|
|
176
|
+
this.validatorPower = validatorPower
|
|
177
|
+
this.timestamp = timestamp
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export class Event {
|
|
182
|
+
public eventType: string
|
|
183
|
+
public attributes: Array<EventAttribute>
|
|
184
|
+
|
|
185
|
+
constructor(eventType: string, attributes: Array<EventAttribute>) {
|
|
186
|
+
this.eventType = eventType
|
|
187
|
+
this.attributes = attributes
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export class EventAttribute {
|
|
192
|
+
public key: string
|
|
193
|
+
public value: string
|
|
194
|
+
public index: bool
|
|
195
|
+
|
|
196
|
+
constructor(key: string, value: string, index: bool) {
|
|
197
|
+
this.key = key
|
|
198
|
+
this.value = value
|
|
199
|
+
this.index = index
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export class EventBlock {
|
|
204
|
+
public block: Block
|
|
205
|
+
public blockId: BlockID
|
|
206
|
+
public resultBeginBlock: ResponseBeginBlock
|
|
207
|
+
public resultEndBlock: ResponseEndBlock
|
|
208
|
+
|
|
209
|
+
constructor(
|
|
210
|
+
block: Block,
|
|
211
|
+
blockId: BlockID,
|
|
212
|
+
resultBeginBlock: ResponseBeginBlock,
|
|
213
|
+
resultEndBlock: ResponseEndBlock,
|
|
214
|
+
) {
|
|
215
|
+
this.block = block
|
|
216
|
+
this.blockId = blockId
|
|
217
|
+
this.resultBeginBlock = resultBeginBlock
|
|
218
|
+
this.resultEndBlock = resultEndBlock
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export class EventTx {
|
|
223
|
+
public txResult: TxResult
|
|
224
|
+
|
|
225
|
+
constructor(txResult: TxResult) {
|
|
226
|
+
this.txResult = txResult
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export class EventValidatorSetUpdates {
|
|
231
|
+
public validatorUpdates: Array<Validator>
|
|
232
|
+
|
|
233
|
+
constructor(validatorUpdates: Array<Validator>) {
|
|
234
|
+
this.validatorUpdates = validatorUpdates
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export class EventVote {
|
|
239
|
+
public eventVoteType: SignedMsgType
|
|
240
|
+
public height: u64
|
|
241
|
+
public round: i32
|
|
242
|
+
public blockId: BlockID
|
|
243
|
+
public timestamp: Timestamp
|
|
244
|
+
public validatorAddress: Bytes
|
|
245
|
+
public validatorIndex: i32
|
|
246
|
+
public signature: Bytes
|
|
247
|
+
|
|
248
|
+
constructor(
|
|
249
|
+
eventVoteType: SignedMsgType,
|
|
250
|
+
height: u64,
|
|
251
|
+
round: i32,
|
|
252
|
+
blockId: BlockID,
|
|
253
|
+
timestamp: Timestamp,
|
|
254
|
+
validatorAddress: Bytes,
|
|
255
|
+
validatorIndex: i32,
|
|
256
|
+
signature: Bytes,
|
|
257
|
+
) {
|
|
258
|
+
this.eventVoteType = eventVoteType
|
|
259
|
+
this.height = height
|
|
260
|
+
this.round = round
|
|
261
|
+
this.blockId = blockId
|
|
262
|
+
this.timestamp = timestamp
|
|
263
|
+
this.validatorAddress = validatorAddress
|
|
264
|
+
this.validatorIndex = validatorIndex
|
|
265
|
+
this.signature = signature
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export class Evidence {
|
|
270
|
+
public duplicateVoteEvidence: DuplicateVoteEvidence
|
|
271
|
+
public lightClientAttackEvidence: LightClientAttackEvidence
|
|
272
|
+
|
|
273
|
+
constructor(
|
|
274
|
+
duplicateVoteEvidence: DuplicateVoteEvidence,
|
|
275
|
+
lightClientAttackEvidence: LightClientAttackEvidence,
|
|
276
|
+
) {
|
|
277
|
+
this.duplicateVoteEvidence = duplicateVoteEvidence
|
|
278
|
+
this.lightClientAttackEvidence = lightClientAttackEvidence
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export class EvidenceList {
|
|
283
|
+
public evidence: Array<Evidence>
|
|
284
|
+
|
|
285
|
+
constructor(evidence: Array<Evidence>) {
|
|
286
|
+
this.evidence = evidence
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export class EvidenceParams {
|
|
291
|
+
public maxAgeNumBlocks: i64
|
|
292
|
+
public maxAgeDuration: Duration
|
|
293
|
+
public maxBytes: i64
|
|
294
|
+
|
|
295
|
+
constructor(maxAgeNumBlocks: i64, maxAgeDuration: Duration, maxBytes: i64) {
|
|
296
|
+
this.maxAgeNumBlocks = maxAgeNumBlocks
|
|
297
|
+
this.maxAgeDuration = maxAgeDuration
|
|
298
|
+
this.maxBytes = maxBytes
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export class Header {
|
|
303
|
+
public version: Consensus
|
|
304
|
+
public chainId: string
|
|
305
|
+
public height: u64
|
|
306
|
+
public time: Timestamp
|
|
307
|
+
public lastBlockId: BlockID
|
|
308
|
+
public lastCommitHash: Bytes
|
|
309
|
+
public dataHash: Bytes
|
|
310
|
+
public validatorsHash: Bytes
|
|
311
|
+
public nextValidatorsHash: Bytes
|
|
312
|
+
public consensusHash: Bytes
|
|
313
|
+
public appHash: Bytes
|
|
314
|
+
public lastResultsHash: Bytes
|
|
315
|
+
public evidenceHash: Bytes
|
|
316
|
+
public proposerAddress: Bytes
|
|
317
|
+
|
|
318
|
+
constructor(
|
|
319
|
+
version: Consensus,
|
|
320
|
+
chainId: string,
|
|
321
|
+
height: u64,
|
|
322
|
+
time: Timestamp,
|
|
323
|
+
lastBlockId: BlockID,
|
|
324
|
+
lastCommitHash: Bytes,
|
|
325
|
+
dataHash: Bytes,
|
|
326
|
+
validatorsHash: Bytes,
|
|
327
|
+
nextValidatorsHash: Bytes,
|
|
328
|
+
consensusHash: Bytes,
|
|
329
|
+
appHash: Bytes,
|
|
330
|
+
lastResultsHash: Bytes,
|
|
331
|
+
evidenceHash: Bytes,
|
|
332
|
+
proposerAddress: Bytes,
|
|
333
|
+
) {
|
|
334
|
+
this.version = version
|
|
335
|
+
this.chainId = chainId
|
|
336
|
+
this.height = height
|
|
337
|
+
this.time = time
|
|
338
|
+
this.lastBlockId = lastBlockId
|
|
339
|
+
this.lastCommitHash = lastCommitHash
|
|
340
|
+
this.dataHash = dataHash
|
|
341
|
+
this.validatorsHash = validatorsHash
|
|
342
|
+
this.nextValidatorsHash = nextValidatorsHash
|
|
343
|
+
this.consensusHash = consensusHash
|
|
344
|
+
this.appHash = appHash
|
|
345
|
+
this.lastResultsHash = lastResultsHash
|
|
346
|
+
this.evidenceHash = evidenceHash
|
|
347
|
+
this.proposerAddress = proposerAddress
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export class LightBlock {
|
|
352
|
+
public signedHeader: SignedHeader
|
|
353
|
+
public validatorSet: ValidatorSet
|
|
354
|
+
|
|
355
|
+
constructor(signedHeader: SignedHeader, validatorSet: ValidatorSet) {
|
|
356
|
+
this.signedHeader = signedHeader
|
|
357
|
+
this.validatorSet = validatorSet
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export class LightClientAttackEvidence {
|
|
362
|
+
public conflictingBlock: LightBlock
|
|
363
|
+
public commonHeight: i64
|
|
364
|
+
public byzantineValidators: Array<Validator>
|
|
365
|
+
public totalVotingPower: i64
|
|
366
|
+
public timestamp: Timestamp
|
|
367
|
+
|
|
368
|
+
constructor(
|
|
369
|
+
conflictingBlock: LightBlock,
|
|
370
|
+
commonHeight: i64,
|
|
371
|
+
byzantineValidators: Array<Validator>,
|
|
372
|
+
totalVotingPower: i64,
|
|
373
|
+
timestamp: Timestamp,
|
|
374
|
+
) {
|
|
375
|
+
this.conflictingBlock = conflictingBlock
|
|
376
|
+
this.commonHeight = commonHeight
|
|
377
|
+
this.byzantineValidators = byzantineValidators
|
|
378
|
+
this.totalVotingPower = totalVotingPower
|
|
379
|
+
this.timestamp = timestamp
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export class PublicKey {
|
|
384
|
+
public ed25519: Bytes
|
|
385
|
+
public secp256k1: Bytes
|
|
386
|
+
|
|
387
|
+
constructor(ed25519: Bytes, secp256k1: Bytes) {
|
|
388
|
+
this.ed25519 = ed25519
|
|
389
|
+
this.secp256k1 = secp256k1
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export class PartSetHeader {
|
|
394
|
+
public total: u32
|
|
395
|
+
public hash: Bytes
|
|
396
|
+
|
|
397
|
+
constructor(total: u32, hash: Bytes) {
|
|
398
|
+
this.total = total
|
|
399
|
+
this.hash = hash
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export class ResponseBeginBlock {
|
|
404
|
+
public events: Array<Event>
|
|
405
|
+
|
|
406
|
+
constructor(events: Array<Event>) {
|
|
407
|
+
this.events = events
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export class ResponseEndBlock {
|
|
412
|
+
public validatorUpdates: Array<ValidatorUpdate>
|
|
413
|
+
public consensusParamUpdates: ConsensusParams
|
|
414
|
+
public events: Array<Event>
|
|
415
|
+
|
|
416
|
+
constructor(
|
|
417
|
+
validatorUpdates: Array<ValidatorUpdate>,
|
|
418
|
+
consensusParamUpdates: ConsensusParams,
|
|
419
|
+
events: Array<Event>,
|
|
420
|
+
) {
|
|
421
|
+
this.validatorUpdates = validatorUpdates
|
|
422
|
+
this.consensusParamUpdates = consensusParamUpdates
|
|
423
|
+
this.events = events
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export class ResponseDeliverTx {
|
|
428
|
+
public code: u32
|
|
429
|
+
public data: Bytes
|
|
430
|
+
public log: string
|
|
431
|
+
public info: string
|
|
432
|
+
public gasWanted: i64
|
|
433
|
+
public gasUsed: i64
|
|
434
|
+
public events: Array<Event>
|
|
435
|
+
public codespace: string
|
|
436
|
+
|
|
437
|
+
constructor(
|
|
438
|
+
code: u32,
|
|
439
|
+
data: Bytes,
|
|
440
|
+
log: string,
|
|
441
|
+
info: string,
|
|
442
|
+
gasWanted: i64,
|
|
443
|
+
gasUsed: i64,
|
|
444
|
+
events: Array<Event>,
|
|
445
|
+
codespace: string,
|
|
446
|
+
) {
|
|
447
|
+
this.code = code
|
|
448
|
+
this.data = data
|
|
449
|
+
this.log = log
|
|
450
|
+
this.info = info
|
|
451
|
+
this.gasWanted = gasWanted
|
|
452
|
+
this.gasUsed = gasUsed
|
|
453
|
+
this.events = events
|
|
454
|
+
this.codespace = codespace
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export class SignedHeader {
|
|
459
|
+
public header: Header
|
|
460
|
+
public commit: Commit
|
|
461
|
+
|
|
462
|
+
constructor(header: Header, commit: Commit) {
|
|
463
|
+
this.header = header
|
|
464
|
+
this.commit = commit
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export class Timestamp {
|
|
469
|
+
public seconds: i64
|
|
470
|
+
public nanos: i32
|
|
471
|
+
|
|
472
|
+
constructor(seconds: i64, nanos: i32) {
|
|
473
|
+
this.seconds = seconds
|
|
474
|
+
this.nanos = nanos
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export class TxResult {
|
|
479
|
+
public height: u64
|
|
480
|
+
public index: u32
|
|
481
|
+
public tx: Bytes
|
|
482
|
+
public result: ResponseDeliverTx
|
|
483
|
+
|
|
484
|
+
constructor(height: u64, index: u32, tx: Bytes, result: ResponseDeliverTx) {
|
|
485
|
+
this.height = height
|
|
486
|
+
this.index = index
|
|
487
|
+
this.tx = tx
|
|
488
|
+
this.result = result
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export class Validator {
|
|
493
|
+
public address: Bytes
|
|
494
|
+
public pubKey: PublicKey
|
|
495
|
+
public votingPower: i64
|
|
496
|
+
public proposerPriority: i64
|
|
497
|
+
|
|
498
|
+
constructor(
|
|
499
|
+
address: Bytes,
|
|
500
|
+
pubKey: PublicKey,
|
|
501
|
+
votingPower: i64,
|
|
502
|
+
proposerPriority: i64,
|
|
503
|
+
) {
|
|
504
|
+
this.address = address
|
|
505
|
+
this.pubKey = pubKey
|
|
506
|
+
this.votingPower = votingPower
|
|
507
|
+
this.proposerPriority = proposerPriority
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export class ValidatorParams {
|
|
512
|
+
public pubKeyTypes: Array<string>
|
|
513
|
+
|
|
514
|
+
constructor(pubKeyTypes: Array<string>) {
|
|
515
|
+
this.pubKeyTypes = pubKeyTypes
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export class ValidatorSet {
|
|
520
|
+
public validators: Array<Validator>
|
|
521
|
+
public proposer: Validator
|
|
522
|
+
public totalVotingPower: i64
|
|
523
|
+
|
|
524
|
+
constructor(
|
|
525
|
+
validators: Array<Validator>,
|
|
526
|
+
proposer: Validator,
|
|
527
|
+
totalVotingPower: i64,
|
|
528
|
+
) {
|
|
529
|
+
this.validators = validators
|
|
530
|
+
this.proposer = proposer
|
|
531
|
+
this.totalVotingPower = totalVotingPower
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export class ValidatorUpdate {
|
|
536
|
+
public address: Bytes
|
|
537
|
+
public pubKey: PublicKey
|
|
538
|
+
public power: i64
|
|
539
|
+
|
|
540
|
+
constructor(address: Bytes, pubKey: PublicKey, power: i64) {
|
|
541
|
+
this.address = address
|
|
542
|
+
this.pubKey = pubKey
|
|
543
|
+
this.power = power
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export class VersionParams {
|
|
548
|
+
public appVersion: u64
|
|
549
|
+
|
|
550
|
+
constructor(appVersion: u64) {
|
|
551
|
+
this.appVersion = appVersion
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/collections.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigInt, BigDecimal } from './numbers'
|
|
1
|
+
import { BigInt, BigDecimal, Address } from './numbers'
|
|
2
2
|
import { Value } from './value'
|
|
3
3
|
import { typeConversion } from './conversion'
|
|
4
4
|
|
|
@@ -67,7 +67,9 @@ export class ByteArray extends Uint8Array {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* Convert the string `hex` which must consist of an even number of
|
|
71
|
+
* hexadecimal digits to a `ByteArray`. The string `hex` can optionally
|
|
72
|
+
* start with '0x'
|
|
71
73
|
*/
|
|
72
74
|
static fromHexString(hex: string): ByteArray {
|
|
73
75
|
assert(hex.length % 2 == 0, 'input ' + hex + ' has odd length')
|
|
@@ -165,6 +167,21 @@ export class ByteArray extends Uint8Array {
|
|
|
165
167
|
return x
|
|
166
168
|
}
|
|
167
169
|
|
|
170
|
+
/** Create a new `ByteArray` that consist of `this` directly followed by
|
|
171
|
+
* the bytes from `other` */
|
|
172
|
+
concat(other: ByteArray): ByteArray {
|
|
173
|
+
let newArray = new ByteArray(this.length + other.length)
|
|
174
|
+
newArray.set(this, 0)
|
|
175
|
+
newArray.set(other, this.length)
|
|
176
|
+
return newArray
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Create a new `ByteArray` that consists of `this` directly followed by
|
|
180
|
+
* the representation of `other` as bytes */
|
|
181
|
+
concatI32(other: i32): ByteArray {
|
|
182
|
+
return this.concat(ByteArray.fromI32(other))
|
|
183
|
+
}
|
|
184
|
+
|
|
168
185
|
/**
|
|
169
186
|
* Interprets the byte array as a little-endian I64.
|
|
170
187
|
* Throws in case of overflow.
|
|
@@ -268,13 +285,34 @@ export class Bytes extends ByteArray {
|
|
|
268
285
|
return changetype<Bytes>(uint8Array)
|
|
269
286
|
}
|
|
270
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Convert the string `hex` which must consist of an even number of
|
|
290
|
+
* hexadecimal digits to a `ByteArray`. The string `hex` can optionally
|
|
291
|
+
* start with '0x'
|
|
292
|
+
*/
|
|
293
|
+
static fromHexString(str: string): Bytes {
|
|
294
|
+
return changetype<Bytes>(ByteArray.fromHexString(str))
|
|
295
|
+
}
|
|
296
|
+
|
|
271
297
|
static fromUTF8(str: string): Bytes {
|
|
272
298
|
return Bytes.fromByteArray(ByteArray.fromUTF8(str))
|
|
273
299
|
}
|
|
274
300
|
|
|
301
|
+
static fromI32(i: i32): Bytes {
|
|
302
|
+
return changetype<Bytes>(ByteArray.fromI32(i))
|
|
303
|
+
}
|
|
304
|
+
|
|
275
305
|
static empty(): Bytes {
|
|
276
306
|
return changetype<Bytes>(ByteArray.empty())
|
|
277
307
|
}
|
|
308
|
+
|
|
309
|
+
concat(other: Bytes): Bytes {
|
|
310
|
+
return changetype<Bytes>(super.concat(other))
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
concatI32(other: i32): Bytes {
|
|
314
|
+
return changetype<Bytes>(super.concat(ByteArray.fromI32(other)))
|
|
315
|
+
}
|
|
278
316
|
}
|
|
279
317
|
|
|
280
318
|
/**
|
|
@@ -318,6 +356,12 @@ export class TypedMap<K, V> {
|
|
|
318
356
|
return null
|
|
319
357
|
}
|
|
320
358
|
|
|
359
|
+
mustGetEntry(key: K): TypedMapEntry<K, V> {
|
|
360
|
+
const entry = this.getEntry(key)
|
|
361
|
+
assert(entry != null, `Entry for key ${key} does not exist in TypedMap`)
|
|
362
|
+
return entry!
|
|
363
|
+
}
|
|
364
|
+
|
|
321
365
|
get(key: K): V | null {
|
|
322
366
|
for (let i: i32 = 0; i < this.entries.length; i++) {
|
|
323
367
|
if (this.entries[i].key == key) {
|
|
@@ -327,6 +371,12 @@ export class TypedMap<K, V> {
|
|
|
327
371
|
return null
|
|
328
372
|
}
|
|
329
373
|
|
|
374
|
+
mustGet(key: K): V {
|
|
375
|
+
const value = this.get(key)
|
|
376
|
+
assert(value != null, `Value for key ${key} does not exist in TypedMap`)
|
|
377
|
+
return value!
|
|
378
|
+
}
|
|
379
|
+
|
|
330
380
|
isSet(key: K): bool {
|
|
331
381
|
for (let i: i32 = 0; i < this.entries.length; i++) {
|
|
332
382
|
if (this.entries[i].key == key) {
|