datai-sdk 1.1.1 → 1.1.3

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.
@@ -0,0 +1,13 @@
1
+ # The Graph TypeScript Library (graph-ts) adapted to Extism PDK
2
+
3
+ ## License
4
+
5
+ Copyright © 2018 Graph Protocol, Inc. and contributors.
6
+
7
+ The Graph TypeScript library is dual-licensed under the [MIT license](LICENSE-MIT) and the
8
+ [Apache License, Version 2.0](LICENSE-APACHE).
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under the License is
11
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
+ implied. See the License for the specific language governing permissions and limitations under the
13
+ License.
@@ -0,0 +1,82 @@
1
+ import '../common/eager_offset';
2
+ import { Bytes } from '../common/collections';
3
+
4
+ // Most types from this namespace are direct mappings or adaptations from:
5
+ // https://github.com/ChainSafe/firehose-arweave/blob/master/proto/sf/arweave/type/v1/type.proto
6
+ export namespace arweave {
7
+ /**
8
+ * A key-value pair for arbitrary metadata
9
+ */
10
+ export class Tag {
11
+ constructor(
12
+ public name: Bytes,
13
+ public value: Bytes,
14
+ ) {}
15
+ }
16
+
17
+ export class ProofOfAccess {
18
+ constructor(
19
+ public option: string,
20
+ public txPath: Bytes,
21
+ public dataPath: Bytes,
22
+ public chunk: Bytes,
23
+ ) {}
24
+ }
25
+
26
+ /**
27
+ * An Arweave block.
28
+ */
29
+ export class Block {
30
+ constructor(
31
+ public timestamp: u64,
32
+ public lastRetarget: u64,
33
+ public height: u64,
34
+ public indepHash: Bytes,
35
+ public nonce: Bytes,
36
+ public previousBlock: Bytes,
37
+ public diff: Bytes,
38
+ public hash: Bytes,
39
+ public txRoot: Bytes,
40
+ public txs: Bytes[],
41
+ public walletList: Bytes,
42
+ public rewardAddr: Bytes,
43
+ public tags: Tag[],
44
+ public rewardPool: Bytes,
45
+ public weaveSize: Bytes,
46
+ public blockSize: Bytes,
47
+ public cumulativeDiff: Bytes,
48
+ public hashListMerkle: Bytes,
49
+ public poa: ProofOfAccess,
50
+ ) {}
51
+ }
52
+
53
+ /**
54
+ * An Arweave transaction
55
+ */
56
+ export class Transaction {
57
+ constructor(
58
+ public format: u32,
59
+ public id: Bytes,
60
+ public lastTx: Bytes,
61
+ public owner: Bytes,
62
+ public tags: Tag[],
63
+ public target: Bytes,
64
+ public quantity: Bytes,
65
+ public data: Bytes,
66
+ public dataSize: Bytes,
67
+ public dataRoot: Bytes,
68
+ public signature: Bytes,
69
+ public reward: Bytes,
70
+ ) {}
71
+ }
72
+
73
+ /**
74
+ * An Arweave transaction with block ptr
75
+ */
76
+ export class TransactionWithBlockPtr {
77
+ constructor(
78
+ public tx: Transaction,
79
+ public block: Block,
80
+ ) {}
81
+ }
82
+ }
@@ -0,0 +1,426 @@
1
+ import '../common/eager_offset';
2
+ import { Bytes } from '../common/collections';
3
+
4
+ export namespace cosmos {
5
+ export class Block {
6
+ constructor(
7
+ public header: Header,
8
+ public evidence: EvidenceList,
9
+ public lastCommit: Commit,
10
+ public resultBeginBlock: ResponseBeginBlock,
11
+ public resultEndBlock: ResponseEndBlock,
12
+ public transactions: Array<TxResult>,
13
+ public validatorUpdates: Array<Validator>,
14
+ ) {}
15
+ }
16
+
17
+ export class HeaderOnlyBlock {
18
+ constructor(public header: Header) {}
19
+ }
20
+
21
+ export class EventData {
22
+ constructor(
23
+ public event: Event,
24
+ public block: HeaderOnlyBlock,
25
+ public tx: TransactionContext,
26
+ ) {}
27
+ }
28
+
29
+ export class TransactionData {
30
+ constructor(
31
+ public tx: TxResult,
32
+ public block: HeaderOnlyBlock,
33
+ ) {}
34
+ }
35
+
36
+ export class MessageData {
37
+ constructor(
38
+ public message: Any,
39
+ public block: HeaderOnlyBlock,
40
+ public tx: TransactionContext,
41
+ ) {}
42
+ }
43
+
44
+ export class TransactionContext {
45
+ constructor(
46
+ public hash: Bytes,
47
+ public index: u32,
48
+ public code: u32,
49
+ public gasWanted: i64,
50
+ public gasUsed: i64,
51
+ ) {}
52
+ }
53
+
54
+ export class Header {
55
+ constructor(
56
+ public version: Consensus,
57
+ public chainId: string,
58
+ public height: u64,
59
+ public time: Timestamp,
60
+ public lastBlockId: BlockID,
61
+ public lastCommitHash: Bytes,
62
+ public dataHash: Bytes,
63
+ public validatorsHash: Bytes,
64
+ public nextValidatorsHash: Bytes,
65
+ public consensusHash: Bytes,
66
+ public appHash: Bytes,
67
+ public lastResultsHash: Bytes,
68
+ public evidenceHash: Bytes,
69
+ public proposerAddress: Bytes,
70
+ public hash: Bytes,
71
+ ) {}
72
+ }
73
+
74
+ export class Consensus {
75
+ constructor(
76
+ public block: u64,
77
+ public app: u64,
78
+ ) {}
79
+ }
80
+
81
+ export class Timestamp {
82
+ constructor(
83
+ public seconds: i64,
84
+ public nanos: i32,
85
+ ) {}
86
+ }
87
+
88
+ export class BlockID {
89
+ constructor(
90
+ public hash: Bytes,
91
+ public partSetHeader: PartSetHeader,
92
+ ) {}
93
+ }
94
+
95
+ export class PartSetHeader {
96
+ constructor(
97
+ public total: u32,
98
+ public hash: Bytes,
99
+ ) {}
100
+ }
101
+
102
+ export class EvidenceList {
103
+ constructor(public evidence: Array<Evidence>) {}
104
+ }
105
+
106
+ export class Evidence {
107
+ constructor(
108
+ public duplicateVoteEvidence: DuplicateVoteEvidence,
109
+ public lightClientAttackEvidence: LightClientAttackEvidence,
110
+ ) {}
111
+ }
112
+
113
+ export class DuplicateVoteEvidence {
114
+ constructor(
115
+ public voteA: EventVote,
116
+ public voteB: EventVote,
117
+ public totalVotingPower: i64,
118
+ public validatorPower: i64,
119
+ public timestamp: Timestamp,
120
+ ) {}
121
+ }
122
+
123
+ export class EventVote {
124
+ constructor(
125
+ public eventVoteType: SignedMsgType,
126
+ public height: u64,
127
+ public round: i32,
128
+ public blockId: BlockID,
129
+ public timestamp: Timestamp,
130
+ public validatorAddress: Bytes,
131
+ public validatorIndex: i32,
132
+ public signature: Bytes,
133
+ ) {}
134
+ }
135
+
136
+ export enum SignedMsgType {
137
+ SIGNED_MSG_TYPE_UNKNOWN = 0,
138
+ SIGNED_MSG_TYPE_PREVOTE = 1,
139
+ SIGNED_MSG_TYPE_PRECOMMIT = 2,
140
+ SIGNED_MSG_TYPE_PROPOSAL = 32,
141
+ }
142
+
143
+ export class LightClientAttackEvidence {
144
+ constructor(
145
+ public conflictingBlock: LightBlock,
146
+ public commonHeight: i64,
147
+ public byzantineValidators: Array<Validator>,
148
+ public totalVotingPower: i64,
149
+ public timestamp: Timestamp,
150
+ ) {}
151
+ }
152
+
153
+ export class LightBlock {
154
+ constructor(
155
+ public signedHeader: SignedHeader,
156
+ public validatorSet: ValidatorSet,
157
+ ) {}
158
+ }
159
+
160
+ export class SignedHeader {
161
+ constructor(
162
+ public header: Header,
163
+ public commit: Commit,
164
+ ) {}
165
+ }
166
+
167
+ export class Commit {
168
+ constructor(
169
+ public height: i64,
170
+ public round: i32,
171
+ public blockId: BlockID,
172
+ public signatures: Array<CommitSig>,
173
+ ) {}
174
+ }
175
+
176
+ export class CommitSig {
177
+ constructor(
178
+ public blockIdFlag: BlockIDFlag,
179
+ public validatorAddress: Bytes,
180
+ public timestamp: Timestamp,
181
+ public signature: Bytes,
182
+ ) {}
183
+ }
184
+
185
+ export enum BlockIDFlag {
186
+ BLOCK_ID_FLAG_UNKNOWN = 0,
187
+ BLOCK_ID_FLAG_ABSENT = 1,
188
+ BLOCK_ID_FLAG_COMMIT = 2,
189
+ BLOCK_ID_FLAG_NIL = 3,
190
+ }
191
+
192
+ export class ValidatorSet {
193
+ constructor(
194
+ public validators: Array<Validator>,
195
+ public proposer: Validator,
196
+ public totalVotingPower: i64,
197
+ ) {}
198
+ }
199
+
200
+ export class Validator {
201
+ constructor(
202
+ public address: Bytes,
203
+ public pubKey: PublicKey,
204
+ public votingPower: i64,
205
+ public proposerPriority: i64,
206
+ ) {}
207
+ }
208
+
209
+ export class PublicKey {
210
+ constructor(
211
+ public ed25519: Bytes,
212
+ public secp256k1: Bytes,
213
+ ) {}
214
+ }
215
+
216
+ export class ResponseBeginBlock {
217
+ constructor(public events: Array<Event>) {}
218
+ }
219
+
220
+ export class Event {
221
+ constructor(
222
+ public eventType: string,
223
+ public attributes: Array<EventAttribute>,
224
+ ) {}
225
+
226
+ getAttribute(key: string): EventAttribute | null {
227
+ for (let i = 0; i < this.attributes.length; i++) {
228
+ if (this.attributes[i].key == key) {
229
+ return this.attributes[i];
230
+ }
231
+ }
232
+ return null;
233
+ }
234
+
235
+ getAttributeValue(key: string): string {
236
+ const attribute = this.getAttribute(key);
237
+ return attribute ? attribute.value : '';
238
+ }
239
+ }
240
+
241
+ export class EventAttribute {
242
+ constructor(
243
+ public key: string,
244
+ public value: string,
245
+ public index: bool,
246
+ ) {}
247
+ }
248
+
249
+ export class ResponseEndBlock {
250
+ constructor(
251
+ public validatorUpdates: Array<ValidatorUpdate>,
252
+ public consensusParamUpdates: ConsensusParams,
253
+ public events: Array<Event>,
254
+ ) {}
255
+ }
256
+
257
+ export class ValidatorUpdate {
258
+ constructor(
259
+ public address: Bytes,
260
+ public pubKey: PublicKey,
261
+ public power: i64,
262
+ ) {}
263
+ }
264
+
265
+ export class ConsensusParams {
266
+ constructor(
267
+ public block: BlockParams,
268
+ public evidence: EvidenceParams,
269
+ public validator: ValidatorParams,
270
+ public version: VersionParams,
271
+ ) {}
272
+ }
273
+
274
+ export class BlockParams {
275
+ constructor(
276
+ public maxBytes: i64,
277
+ public maxGas: i64,
278
+ ) {}
279
+ }
280
+
281
+ export class EvidenceParams {
282
+ constructor(
283
+ public maxAgeNumBlocks: i64,
284
+ public maxAgeDuration: Duration,
285
+ public maxBytes: i64,
286
+ ) {}
287
+ }
288
+
289
+ export class Duration {
290
+ constructor(
291
+ public seconds: i64,
292
+ public nanos: i32,
293
+ ) {}
294
+ }
295
+
296
+ export class ValidatorParams {
297
+ constructor(public pubKeyTypes: Array<string>) {}
298
+ }
299
+
300
+ export class VersionParams {
301
+ constructor(public appVersion: u64) {}
302
+ }
303
+
304
+ export class TxResult {
305
+ constructor(
306
+ public height: u64,
307
+ public index: u32,
308
+ public tx: Tx,
309
+ public result: ResponseDeliverTx,
310
+ public hash: Bytes,
311
+ ) {}
312
+ }
313
+
314
+ export class Tx {
315
+ constructor(
316
+ public body: TxBody,
317
+ public authInfo: AuthInfo,
318
+ public signatures: Array<Bytes>,
319
+ ) {}
320
+ }
321
+
322
+ export class TxBody {
323
+ constructor(
324
+ public messages: Array<Any>,
325
+ public memo: string,
326
+ public timeoutHeight: u64,
327
+ public extensionOptions: Array<Any>,
328
+ public nonCriticalExtensionOptions: Array<Any>,
329
+ ) {}
330
+ }
331
+
332
+ export class Any {
333
+ constructor(
334
+ public typeUrl: string,
335
+ public value: Bytes,
336
+ ) {}
337
+ }
338
+
339
+ export class AuthInfo {
340
+ constructor(
341
+ public signerInfos: Array<SignerInfo>,
342
+ public fee: Fee,
343
+ public tip: Tip,
344
+ ) {}
345
+ }
346
+
347
+ export class SignerInfo {
348
+ constructor(
349
+ public publicKey: Any,
350
+ public modeInfo: ModeInfo,
351
+ public sequence: u64,
352
+ ) {}
353
+ }
354
+
355
+ export class ModeInfo {
356
+ constructor(
357
+ public single: ModeInfoSingle,
358
+ public multi: ModeInfoMulti,
359
+ ) {}
360
+ }
361
+
362
+ export class ModeInfoSingle {
363
+ constructor(public mode: SignMode) {}
364
+ }
365
+
366
+ export enum SignMode {
367
+ SIGN_MODE_UNSPECIFIED = 0,
368
+ SIGN_MODE_DIRECT = 1,
369
+ SIGN_MODE_TEXTUAL = 2,
370
+ SIGN_MODE_LEGACY_AMINO_JSON = 127,
371
+ }
372
+
373
+ export class ModeInfoMulti {
374
+ constructor(
375
+ public bitarray: CompactBitArray,
376
+ public modeInfos: Array<ModeInfo>,
377
+ ) {}
378
+ }
379
+
380
+ export class CompactBitArray {
381
+ constructor(
382
+ public extraBitsStored: u32,
383
+ public elems: Bytes,
384
+ ) {}
385
+ }
386
+
387
+ export class Fee {
388
+ constructor(
389
+ public amount: Array<Coin>,
390
+ public gasLimit: u64,
391
+ public payer: string,
392
+ public granter: string,
393
+ ) {}
394
+ }
395
+
396
+ export class Coin {
397
+ constructor(
398
+ public denom: string,
399
+ public amount: string,
400
+ ) {}
401
+ }
402
+
403
+ export class Tip {
404
+ constructor(
405
+ public amount: Array<Coin>,
406
+ public tipper: string,
407
+ ) {}
408
+ }
409
+
410
+ export class ResponseDeliverTx {
411
+ constructor(
412
+ public code: u32,
413
+ public data: Bytes,
414
+ public log: string,
415
+ public info: string,
416
+ public gasWanted: i64,
417
+ public gasUsed: i64,
418
+ public events: Array<Event>,
419
+ public codespace: string,
420
+ ) {}
421
+ }
422
+
423
+ export class ValidatorSetUpdates {
424
+ constructor(public validatorUpdates: Array<Validator>) {}
425
+ }
426
+ }