@apibara/starknet 0.1.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.
@@ -0,0 +1,1725 @@
1
+ /* eslint-disable */
2
+ import Long from "long";
3
+ import _m0 from "protobufjs/minimal";
4
+ import { Timestamp } from "./google/protobuf/timestamp";
5
+
6
+ export const protobufPackage = "apibara.starknet.v1alpha1";
7
+
8
+ /** # Apibara StarkNet Support */
9
+
10
+ /** Status of a transaction. */
11
+ export enum TransactionStatus {
12
+ TRANSACTION_STATUS_UNSPECIFIED = 0,
13
+ TRANSACTION_STATUS_RECEIVED = 1,
14
+ TRANSACTION_STATUS_PENDING = 2,
15
+ TRANSACTION_STATUS_ACCEPTED_ON_L2 = 3,
16
+ TRANSACTION_STATUS_ACCEPTED_ON_L1 = 4,
17
+ TRANSACTION_STATUS_REJECTED = 5,
18
+ UNRECOGNIZED = -1,
19
+ }
20
+
21
+ export function transactionStatusFromJSON(object: any): TransactionStatus {
22
+ switch (object) {
23
+ case 0:
24
+ case "TRANSACTION_STATUS_UNSPECIFIED":
25
+ return TransactionStatus.TRANSACTION_STATUS_UNSPECIFIED;
26
+ case 1:
27
+ case "TRANSACTION_STATUS_RECEIVED":
28
+ return TransactionStatus.TRANSACTION_STATUS_RECEIVED;
29
+ case 2:
30
+ case "TRANSACTION_STATUS_PENDING":
31
+ return TransactionStatus.TRANSACTION_STATUS_PENDING;
32
+ case 3:
33
+ case "TRANSACTION_STATUS_ACCEPTED_ON_L2":
34
+ return TransactionStatus.TRANSACTION_STATUS_ACCEPTED_ON_L2;
35
+ case 4:
36
+ case "TRANSACTION_STATUS_ACCEPTED_ON_L1":
37
+ return TransactionStatus.TRANSACTION_STATUS_ACCEPTED_ON_L1;
38
+ case 5:
39
+ case "TRANSACTION_STATUS_REJECTED":
40
+ return TransactionStatus.TRANSACTION_STATUS_REJECTED;
41
+ case -1:
42
+ case "UNRECOGNIZED":
43
+ default:
44
+ return TransactionStatus.UNRECOGNIZED;
45
+ }
46
+ }
47
+
48
+ export function transactionStatusToJSON(object: TransactionStatus): string {
49
+ switch (object) {
50
+ case TransactionStatus.TRANSACTION_STATUS_UNSPECIFIED:
51
+ return "TRANSACTION_STATUS_UNSPECIFIED";
52
+ case TransactionStatus.TRANSACTION_STATUS_RECEIVED:
53
+ return "TRANSACTION_STATUS_RECEIVED";
54
+ case TransactionStatus.TRANSACTION_STATUS_PENDING:
55
+ return "TRANSACTION_STATUS_PENDING";
56
+ case TransactionStatus.TRANSACTION_STATUS_ACCEPTED_ON_L2:
57
+ return "TRANSACTION_STATUS_ACCEPTED_ON_L2";
58
+ case TransactionStatus.TRANSACTION_STATUS_ACCEPTED_ON_L1:
59
+ return "TRANSACTION_STATUS_ACCEPTED_ON_L1";
60
+ case TransactionStatus.TRANSACTION_STATUS_REJECTED:
61
+ return "TRANSACTION_STATUS_REJECTED";
62
+ case TransactionStatus.UNRECOGNIZED:
63
+ default:
64
+ return "UNRECOGNIZED";
65
+ }
66
+ }
67
+
68
+ /** A StarkNet block. */
69
+ export interface Block {
70
+ blockHash: BlockHash | undefined;
71
+ parentBlockHash: BlockHash | undefined;
72
+ blockNumber: number;
73
+ sequencerAddress: Uint8Array;
74
+ stateRoot: Uint8Array;
75
+ gasPrice: Uint8Array;
76
+ timestamp: Date | undefined;
77
+ starknetVersion: string;
78
+ transactions: Transaction[];
79
+ transactionReceipts: TransactionReceipt[];
80
+ }
81
+
82
+ /** The hash of a StarkNet block. */
83
+ export interface BlockHash {
84
+ hash: Uint8Array;
85
+ }
86
+
87
+ export interface Transaction {
88
+ invoke: InvokeTransaction | undefined;
89
+ deploy: DeployTransaction | undefined;
90
+ declare: DeclareTransaction | undefined;
91
+ l1Handler: L1HandlerTransaction | undefined;
92
+ deployAccount: DeployAccountTransaction | undefined;
93
+ }
94
+
95
+ export interface TransactionCommon {
96
+ hash: Uint8Array;
97
+ maxFee: Uint8Array;
98
+ signature: Uint8Array[];
99
+ nonce: Uint8Array;
100
+ version: Uint8Array;
101
+ }
102
+
103
+ export interface InvokeTransaction {
104
+ common: TransactionCommon | undefined;
105
+ contractAddress: Uint8Array;
106
+ entryPointSelector: Uint8Array;
107
+ calldata: Uint8Array[];
108
+ }
109
+
110
+ export interface DeclareTransaction {
111
+ common: TransactionCommon | undefined;
112
+ classHash: Uint8Array;
113
+ senderAddress: Uint8Array;
114
+ }
115
+
116
+ export interface DeployTransaction {
117
+ common: TransactionCommon | undefined;
118
+ constructorCalldata: Uint8Array[];
119
+ contractAddress: Uint8Array;
120
+ contractAddressSalt: Uint8Array;
121
+ classHash: Uint8Array;
122
+ }
123
+
124
+ export interface L1HandlerTransaction {
125
+ common: TransactionCommon | undefined;
126
+ contractAddress: Uint8Array;
127
+ entryPointSelector: Uint8Array;
128
+ calldata: Uint8Array[];
129
+ }
130
+
131
+ export interface DeployAccountTransaction {
132
+ common: TransactionCommon | undefined;
133
+ constructorCalldata: Uint8Array[];
134
+ contractAddress: Uint8Array;
135
+ contractAddressSalt: Uint8Array;
136
+ classHash: Uint8Array;
137
+ }
138
+
139
+ export interface TransactionReceipt {
140
+ transactionHash: Uint8Array;
141
+ transactionIndex: number;
142
+ actualFee: Uint8Array;
143
+ executionResources: ExecutionResources | undefined;
144
+ l1ToL2ConsumedMessage: L1ToL2Message | undefined;
145
+ l2ToL1Messages: L2ToL1Message[];
146
+ events: Event[];
147
+ }
148
+
149
+ export interface ExecutionResources {
150
+ nSteps: number;
151
+ nMemoryHoles: number;
152
+ builtinInstanceCounter: BuiltinInstanceCounter | undefined;
153
+ }
154
+
155
+ export interface BuiltinInstanceCounter {
156
+ pedersenBuiltin?: number | undefined;
157
+ rangeCheckBuiltin?: number | undefined;
158
+ bitwiseBuiltin?: number | undefined;
159
+ outputBuiltin?: number | undefined;
160
+ ecdsaBuiltin?: number | undefined;
161
+ ecOpBuiltin?: number | undefined;
162
+ }
163
+
164
+ export interface L1ToL2Message {
165
+ fromAddress: Uint8Array;
166
+ toAddress: Uint8Array;
167
+ selector: Uint8Array;
168
+ payload: Uint8Array[];
169
+ nonce: Uint8Array;
170
+ }
171
+
172
+ export interface L2ToL1Message {
173
+ fromAddress: Uint8Array;
174
+ toAddress: Uint8Array;
175
+ payload: Uint8Array[];
176
+ }
177
+
178
+ export interface Event {
179
+ fromAddress: Uint8Array;
180
+ keys: Uint8Array[];
181
+ data: Uint8Array[];
182
+ }
183
+
184
+ function createBaseBlock(): Block {
185
+ return {
186
+ blockHash: undefined,
187
+ parentBlockHash: undefined,
188
+ blockNumber: 0,
189
+ sequencerAddress: new Uint8Array(),
190
+ stateRoot: new Uint8Array(),
191
+ gasPrice: new Uint8Array(),
192
+ timestamp: undefined,
193
+ starknetVersion: "",
194
+ transactions: [],
195
+ transactionReceipts: [],
196
+ };
197
+ }
198
+
199
+ export const Block = {
200
+ encode(message: Block, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
201
+ if (message.blockHash !== undefined) {
202
+ BlockHash.encode(message.blockHash, writer.uint32(10).fork()).ldelim();
203
+ }
204
+ if (message.parentBlockHash !== undefined) {
205
+ BlockHash.encode(message.parentBlockHash, writer.uint32(18).fork()).ldelim();
206
+ }
207
+ if (message.blockNumber !== 0) {
208
+ writer.uint32(24).uint64(message.blockNumber);
209
+ }
210
+ if (message.sequencerAddress.length !== 0) {
211
+ writer.uint32(34).bytes(message.sequencerAddress);
212
+ }
213
+ if (message.stateRoot.length !== 0) {
214
+ writer.uint32(42).bytes(message.stateRoot);
215
+ }
216
+ if (message.gasPrice.length !== 0) {
217
+ writer.uint32(50).bytes(message.gasPrice);
218
+ }
219
+ if (message.timestamp !== undefined) {
220
+ Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(58).fork()).ldelim();
221
+ }
222
+ if (message.starknetVersion !== "") {
223
+ writer.uint32(66).string(message.starknetVersion);
224
+ }
225
+ for (const v of message.transactions) {
226
+ Transaction.encode(v!, writer.uint32(74).fork()).ldelim();
227
+ }
228
+ for (const v of message.transactionReceipts) {
229
+ TransactionReceipt.encode(v!, writer.uint32(82).fork()).ldelim();
230
+ }
231
+ return writer;
232
+ },
233
+
234
+ decode(input: _m0.Reader | Uint8Array, length?: number): Block {
235
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
236
+ let end = length === undefined ? reader.len : reader.pos + length;
237
+ const message = createBaseBlock();
238
+ while (reader.pos < end) {
239
+ const tag = reader.uint32();
240
+ switch (tag >>> 3) {
241
+ case 1:
242
+ message.blockHash = BlockHash.decode(reader, reader.uint32());
243
+ break;
244
+ case 2:
245
+ message.parentBlockHash = BlockHash.decode(reader, reader.uint32());
246
+ break;
247
+ case 3:
248
+ message.blockNumber = longToNumber(reader.uint64() as Long);
249
+ break;
250
+ case 4:
251
+ message.sequencerAddress = reader.bytes();
252
+ break;
253
+ case 5:
254
+ message.stateRoot = reader.bytes();
255
+ break;
256
+ case 6:
257
+ message.gasPrice = reader.bytes();
258
+ break;
259
+ case 7:
260
+ message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
261
+ break;
262
+ case 8:
263
+ message.starknetVersion = reader.string();
264
+ break;
265
+ case 9:
266
+ message.transactions.push(Transaction.decode(reader, reader.uint32()));
267
+ break;
268
+ case 10:
269
+ message.transactionReceipts.push(TransactionReceipt.decode(reader, reader.uint32()));
270
+ break;
271
+ default:
272
+ reader.skipType(tag & 7);
273
+ break;
274
+ }
275
+ }
276
+ return message;
277
+ },
278
+
279
+ fromJSON(object: any): Block {
280
+ return {
281
+ blockHash: isSet(object.blockHash) ? BlockHash.fromJSON(object.blockHash) : undefined,
282
+ parentBlockHash: isSet(object.parentBlockHash) ? BlockHash.fromJSON(object.parentBlockHash) : undefined,
283
+ blockNumber: isSet(object.blockNumber) ? Number(object.blockNumber) : 0,
284
+ sequencerAddress: isSet(object.sequencerAddress) ? bytesFromBase64(object.sequencerAddress) : new Uint8Array(),
285
+ stateRoot: isSet(object.stateRoot) ? bytesFromBase64(object.stateRoot) : new Uint8Array(),
286
+ gasPrice: isSet(object.gasPrice) ? bytesFromBase64(object.gasPrice) : new Uint8Array(),
287
+ timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,
288
+ starknetVersion: isSet(object.starknetVersion) ? String(object.starknetVersion) : "",
289
+ transactions: Array.isArray(object?.transactions)
290
+ ? object.transactions.map((e: any) => Transaction.fromJSON(e))
291
+ : [],
292
+ transactionReceipts: Array.isArray(object?.transactionReceipts)
293
+ ? object.transactionReceipts.map((e: any) => TransactionReceipt.fromJSON(e))
294
+ : [],
295
+ };
296
+ },
297
+
298
+ toJSON(message: Block): unknown {
299
+ const obj: any = {};
300
+ message.blockHash !== undefined &&
301
+ (obj.blockHash = message.blockHash ? BlockHash.toJSON(message.blockHash) : undefined);
302
+ message.parentBlockHash !== undefined &&
303
+ (obj.parentBlockHash = message.parentBlockHash ? BlockHash.toJSON(message.parentBlockHash) : undefined);
304
+ message.blockNumber !== undefined && (obj.blockNumber = Math.round(message.blockNumber));
305
+ message.sequencerAddress !== undefined &&
306
+ (obj.sequencerAddress = base64FromBytes(
307
+ message.sequencerAddress !== undefined ? message.sequencerAddress : new Uint8Array(),
308
+ ));
309
+ message.stateRoot !== undefined &&
310
+ (obj.stateRoot = base64FromBytes(message.stateRoot !== undefined ? message.stateRoot : new Uint8Array()));
311
+ message.gasPrice !== undefined &&
312
+ (obj.gasPrice = base64FromBytes(message.gasPrice !== undefined ? message.gasPrice : new Uint8Array()));
313
+ message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString());
314
+ message.starknetVersion !== undefined && (obj.starknetVersion = message.starknetVersion);
315
+ if (message.transactions) {
316
+ obj.transactions = message.transactions.map((e) => e ? Transaction.toJSON(e) : undefined);
317
+ } else {
318
+ obj.transactions = [];
319
+ }
320
+ if (message.transactionReceipts) {
321
+ obj.transactionReceipts = message.transactionReceipts.map((e) => e ? TransactionReceipt.toJSON(e) : undefined);
322
+ } else {
323
+ obj.transactionReceipts = [];
324
+ }
325
+ return obj;
326
+ },
327
+
328
+ fromPartial<I extends Exact<DeepPartial<Block>, I>>(object: I): Block {
329
+ const message = createBaseBlock();
330
+ message.blockHash = (object.blockHash !== undefined && object.blockHash !== null)
331
+ ? BlockHash.fromPartial(object.blockHash)
332
+ : undefined;
333
+ message.parentBlockHash = (object.parentBlockHash !== undefined && object.parentBlockHash !== null)
334
+ ? BlockHash.fromPartial(object.parentBlockHash)
335
+ : undefined;
336
+ message.blockNumber = object.blockNumber ?? 0;
337
+ message.sequencerAddress = object.sequencerAddress ?? new Uint8Array();
338
+ message.stateRoot = object.stateRoot ?? new Uint8Array();
339
+ message.gasPrice = object.gasPrice ?? new Uint8Array();
340
+ message.timestamp = object.timestamp ?? undefined;
341
+ message.starknetVersion = object.starknetVersion ?? "";
342
+ message.transactions = object.transactions?.map((e) => Transaction.fromPartial(e)) || [];
343
+ message.transactionReceipts = object.transactionReceipts?.map((e) => TransactionReceipt.fromPartial(e)) || [];
344
+ return message;
345
+ },
346
+ };
347
+
348
+ function createBaseBlockHash(): BlockHash {
349
+ return { hash: new Uint8Array() };
350
+ }
351
+
352
+ export const BlockHash = {
353
+ encode(message: BlockHash, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
354
+ if (message.hash.length !== 0) {
355
+ writer.uint32(10).bytes(message.hash);
356
+ }
357
+ return writer;
358
+ },
359
+
360
+ decode(input: _m0.Reader | Uint8Array, length?: number): BlockHash {
361
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
362
+ let end = length === undefined ? reader.len : reader.pos + length;
363
+ const message = createBaseBlockHash();
364
+ while (reader.pos < end) {
365
+ const tag = reader.uint32();
366
+ switch (tag >>> 3) {
367
+ case 1:
368
+ message.hash = reader.bytes();
369
+ break;
370
+ default:
371
+ reader.skipType(tag & 7);
372
+ break;
373
+ }
374
+ }
375
+ return message;
376
+ },
377
+
378
+ fromJSON(object: any): BlockHash {
379
+ return { hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array() };
380
+ },
381
+
382
+ toJSON(message: BlockHash): unknown {
383
+ const obj: any = {};
384
+ message.hash !== undefined &&
385
+ (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array()));
386
+ return obj;
387
+ },
388
+
389
+ fromPartial<I extends Exact<DeepPartial<BlockHash>, I>>(object: I): BlockHash {
390
+ const message = createBaseBlockHash();
391
+ message.hash = object.hash ?? new Uint8Array();
392
+ return message;
393
+ },
394
+ };
395
+
396
+ function createBaseTransaction(): Transaction {
397
+ return { invoke: undefined, deploy: undefined, declare: undefined, l1Handler: undefined, deployAccount: undefined };
398
+ }
399
+
400
+ export const Transaction = {
401
+ encode(message: Transaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
402
+ if (message.invoke !== undefined) {
403
+ InvokeTransaction.encode(message.invoke, writer.uint32(10).fork()).ldelim();
404
+ }
405
+ if (message.deploy !== undefined) {
406
+ DeployTransaction.encode(message.deploy, writer.uint32(18).fork()).ldelim();
407
+ }
408
+ if (message.declare !== undefined) {
409
+ DeclareTransaction.encode(message.declare, writer.uint32(26).fork()).ldelim();
410
+ }
411
+ if (message.l1Handler !== undefined) {
412
+ L1HandlerTransaction.encode(message.l1Handler, writer.uint32(34).fork()).ldelim();
413
+ }
414
+ if (message.deployAccount !== undefined) {
415
+ DeployAccountTransaction.encode(message.deployAccount, writer.uint32(42).fork()).ldelim();
416
+ }
417
+ return writer;
418
+ },
419
+
420
+ decode(input: _m0.Reader | Uint8Array, length?: number): Transaction {
421
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
422
+ let end = length === undefined ? reader.len : reader.pos + length;
423
+ const message = createBaseTransaction();
424
+ while (reader.pos < end) {
425
+ const tag = reader.uint32();
426
+ switch (tag >>> 3) {
427
+ case 1:
428
+ message.invoke = InvokeTransaction.decode(reader, reader.uint32());
429
+ break;
430
+ case 2:
431
+ message.deploy = DeployTransaction.decode(reader, reader.uint32());
432
+ break;
433
+ case 3:
434
+ message.declare = DeclareTransaction.decode(reader, reader.uint32());
435
+ break;
436
+ case 4:
437
+ message.l1Handler = L1HandlerTransaction.decode(reader, reader.uint32());
438
+ break;
439
+ case 5:
440
+ message.deployAccount = DeployAccountTransaction.decode(reader, reader.uint32());
441
+ break;
442
+ default:
443
+ reader.skipType(tag & 7);
444
+ break;
445
+ }
446
+ }
447
+ return message;
448
+ },
449
+
450
+ fromJSON(object: any): Transaction {
451
+ return {
452
+ invoke: isSet(object.invoke) ? InvokeTransaction.fromJSON(object.invoke) : undefined,
453
+ deploy: isSet(object.deploy) ? DeployTransaction.fromJSON(object.deploy) : undefined,
454
+ declare: isSet(object.declare) ? DeclareTransaction.fromJSON(object.declare) : undefined,
455
+ l1Handler: isSet(object.l1Handler) ? L1HandlerTransaction.fromJSON(object.l1Handler) : undefined,
456
+ deployAccount: isSet(object.deployAccount) ? DeployAccountTransaction.fromJSON(object.deployAccount) : undefined,
457
+ };
458
+ },
459
+
460
+ toJSON(message: Transaction): unknown {
461
+ const obj: any = {};
462
+ message.invoke !== undefined &&
463
+ (obj.invoke = message.invoke ? InvokeTransaction.toJSON(message.invoke) : undefined);
464
+ message.deploy !== undefined &&
465
+ (obj.deploy = message.deploy ? DeployTransaction.toJSON(message.deploy) : undefined);
466
+ message.declare !== undefined &&
467
+ (obj.declare = message.declare ? DeclareTransaction.toJSON(message.declare) : undefined);
468
+ message.l1Handler !== undefined &&
469
+ (obj.l1Handler = message.l1Handler ? L1HandlerTransaction.toJSON(message.l1Handler) : undefined);
470
+ message.deployAccount !== undefined &&
471
+ (obj.deployAccount = message.deployAccount ? DeployAccountTransaction.toJSON(message.deployAccount) : undefined);
472
+ return obj;
473
+ },
474
+
475
+ fromPartial<I extends Exact<DeepPartial<Transaction>, I>>(object: I): Transaction {
476
+ const message = createBaseTransaction();
477
+ message.invoke = (object.invoke !== undefined && object.invoke !== null)
478
+ ? InvokeTransaction.fromPartial(object.invoke)
479
+ : undefined;
480
+ message.deploy = (object.deploy !== undefined && object.deploy !== null)
481
+ ? DeployTransaction.fromPartial(object.deploy)
482
+ : undefined;
483
+ message.declare = (object.declare !== undefined && object.declare !== null)
484
+ ? DeclareTransaction.fromPartial(object.declare)
485
+ : undefined;
486
+ message.l1Handler = (object.l1Handler !== undefined && object.l1Handler !== null)
487
+ ? L1HandlerTransaction.fromPartial(object.l1Handler)
488
+ : undefined;
489
+ message.deployAccount = (object.deployAccount !== undefined && object.deployAccount !== null)
490
+ ? DeployAccountTransaction.fromPartial(object.deployAccount)
491
+ : undefined;
492
+ return message;
493
+ },
494
+ };
495
+
496
+ function createBaseTransactionCommon(): TransactionCommon {
497
+ return {
498
+ hash: new Uint8Array(),
499
+ maxFee: new Uint8Array(),
500
+ signature: [],
501
+ nonce: new Uint8Array(),
502
+ version: new Uint8Array(),
503
+ };
504
+ }
505
+
506
+ export const TransactionCommon = {
507
+ encode(message: TransactionCommon, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
508
+ if (message.hash.length !== 0) {
509
+ writer.uint32(10).bytes(message.hash);
510
+ }
511
+ if (message.maxFee.length !== 0) {
512
+ writer.uint32(18).bytes(message.maxFee);
513
+ }
514
+ for (const v of message.signature) {
515
+ writer.uint32(26).bytes(v!);
516
+ }
517
+ if (message.nonce.length !== 0) {
518
+ writer.uint32(34).bytes(message.nonce);
519
+ }
520
+ if (message.version.length !== 0) {
521
+ writer.uint32(42).bytes(message.version);
522
+ }
523
+ return writer;
524
+ },
525
+
526
+ decode(input: _m0.Reader | Uint8Array, length?: number): TransactionCommon {
527
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
528
+ let end = length === undefined ? reader.len : reader.pos + length;
529
+ const message = createBaseTransactionCommon();
530
+ while (reader.pos < end) {
531
+ const tag = reader.uint32();
532
+ switch (tag >>> 3) {
533
+ case 1:
534
+ message.hash = reader.bytes();
535
+ break;
536
+ case 2:
537
+ message.maxFee = reader.bytes();
538
+ break;
539
+ case 3:
540
+ message.signature.push(reader.bytes());
541
+ break;
542
+ case 4:
543
+ message.nonce = reader.bytes();
544
+ break;
545
+ case 5:
546
+ message.version = reader.bytes();
547
+ break;
548
+ default:
549
+ reader.skipType(tag & 7);
550
+ break;
551
+ }
552
+ }
553
+ return message;
554
+ },
555
+
556
+ fromJSON(object: any): TransactionCommon {
557
+ return {
558
+ hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(),
559
+ maxFee: isSet(object.maxFee) ? bytesFromBase64(object.maxFee) : new Uint8Array(),
560
+ signature: Array.isArray(object?.signature) ? object.signature.map((e: any) => bytesFromBase64(e)) : [],
561
+ nonce: isSet(object.nonce) ? bytesFromBase64(object.nonce) : new Uint8Array(),
562
+ version: isSet(object.version) ? bytesFromBase64(object.version) : new Uint8Array(),
563
+ };
564
+ },
565
+
566
+ toJSON(message: TransactionCommon): unknown {
567
+ const obj: any = {};
568
+ message.hash !== undefined &&
569
+ (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array()));
570
+ message.maxFee !== undefined &&
571
+ (obj.maxFee = base64FromBytes(message.maxFee !== undefined ? message.maxFee : new Uint8Array()));
572
+ if (message.signature) {
573
+ obj.signature = message.signature.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array()));
574
+ } else {
575
+ obj.signature = [];
576
+ }
577
+ message.nonce !== undefined &&
578
+ (obj.nonce = base64FromBytes(message.nonce !== undefined ? message.nonce : new Uint8Array()));
579
+ message.version !== undefined &&
580
+ (obj.version = base64FromBytes(message.version !== undefined ? message.version : new Uint8Array()));
581
+ return obj;
582
+ },
583
+
584
+ fromPartial<I extends Exact<DeepPartial<TransactionCommon>, I>>(object: I): TransactionCommon {
585
+ const message = createBaseTransactionCommon();
586
+ message.hash = object.hash ?? new Uint8Array();
587
+ message.maxFee = object.maxFee ?? new Uint8Array();
588
+ message.signature = object.signature?.map((e) => e) || [];
589
+ message.nonce = object.nonce ?? new Uint8Array();
590
+ message.version = object.version ?? new Uint8Array();
591
+ return message;
592
+ },
593
+ };
594
+
595
+ function createBaseInvokeTransaction(): InvokeTransaction {
596
+ return { common: undefined, contractAddress: new Uint8Array(), entryPointSelector: new Uint8Array(), calldata: [] };
597
+ }
598
+
599
+ export const InvokeTransaction = {
600
+ encode(message: InvokeTransaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
601
+ if (message.common !== undefined) {
602
+ TransactionCommon.encode(message.common, writer.uint32(10).fork()).ldelim();
603
+ }
604
+ if (message.contractAddress.length !== 0) {
605
+ writer.uint32(18).bytes(message.contractAddress);
606
+ }
607
+ if (message.entryPointSelector.length !== 0) {
608
+ writer.uint32(26).bytes(message.entryPointSelector);
609
+ }
610
+ for (const v of message.calldata) {
611
+ writer.uint32(34).bytes(v!);
612
+ }
613
+ return writer;
614
+ },
615
+
616
+ decode(input: _m0.Reader | Uint8Array, length?: number): InvokeTransaction {
617
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
618
+ let end = length === undefined ? reader.len : reader.pos + length;
619
+ const message = createBaseInvokeTransaction();
620
+ while (reader.pos < end) {
621
+ const tag = reader.uint32();
622
+ switch (tag >>> 3) {
623
+ case 1:
624
+ message.common = TransactionCommon.decode(reader, reader.uint32());
625
+ break;
626
+ case 2:
627
+ message.contractAddress = reader.bytes();
628
+ break;
629
+ case 3:
630
+ message.entryPointSelector = reader.bytes();
631
+ break;
632
+ case 4:
633
+ message.calldata.push(reader.bytes());
634
+ break;
635
+ default:
636
+ reader.skipType(tag & 7);
637
+ break;
638
+ }
639
+ }
640
+ return message;
641
+ },
642
+
643
+ fromJSON(object: any): InvokeTransaction {
644
+ return {
645
+ common: isSet(object.common) ? TransactionCommon.fromJSON(object.common) : undefined,
646
+ contractAddress: isSet(object.contractAddress) ? bytesFromBase64(object.contractAddress) : new Uint8Array(),
647
+ entryPointSelector: isSet(object.entryPointSelector)
648
+ ? bytesFromBase64(object.entryPointSelector)
649
+ : new Uint8Array(),
650
+ calldata: Array.isArray(object?.calldata) ? object.calldata.map((e: any) => bytesFromBase64(e)) : [],
651
+ };
652
+ },
653
+
654
+ toJSON(message: InvokeTransaction): unknown {
655
+ const obj: any = {};
656
+ message.common !== undefined &&
657
+ (obj.common = message.common ? TransactionCommon.toJSON(message.common) : undefined);
658
+ message.contractAddress !== undefined &&
659
+ (obj.contractAddress = base64FromBytes(
660
+ message.contractAddress !== undefined ? message.contractAddress : new Uint8Array(),
661
+ ));
662
+ message.entryPointSelector !== undefined &&
663
+ (obj.entryPointSelector = base64FromBytes(
664
+ message.entryPointSelector !== undefined ? message.entryPointSelector : new Uint8Array(),
665
+ ));
666
+ if (message.calldata) {
667
+ obj.calldata = message.calldata.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array()));
668
+ } else {
669
+ obj.calldata = [];
670
+ }
671
+ return obj;
672
+ },
673
+
674
+ fromPartial<I extends Exact<DeepPartial<InvokeTransaction>, I>>(object: I): InvokeTransaction {
675
+ const message = createBaseInvokeTransaction();
676
+ message.common = (object.common !== undefined && object.common !== null)
677
+ ? TransactionCommon.fromPartial(object.common)
678
+ : undefined;
679
+ message.contractAddress = object.contractAddress ?? new Uint8Array();
680
+ message.entryPointSelector = object.entryPointSelector ?? new Uint8Array();
681
+ message.calldata = object.calldata?.map((e) => e) || [];
682
+ return message;
683
+ },
684
+ };
685
+
686
+ function createBaseDeclareTransaction(): DeclareTransaction {
687
+ return { common: undefined, classHash: new Uint8Array(), senderAddress: new Uint8Array() };
688
+ }
689
+
690
+ export const DeclareTransaction = {
691
+ encode(message: DeclareTransaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
692
+ if (message.common !== undefined) {
693
+ TransactionCommon.encode(message.common, writer.uint32(10).fork()).ldelim();
694
+ }
695
+ if (message.classHash.length !== 0) {
696
+ writer.uint32(18).bytes(message.classHash);
697
+ }
698
+ if (message.senderAddress.length !== 0) {
699
+ writer.uint32(26).bytes(message.senderAddress);
700
+ }
701
+ return writer;
702
+ },
703
+
704
+ decode(input: _m0.Reader | Uint8Array, length?: number): DeclareTransaction {
705
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
706
+ let end = length === undefined ? reader.len : reader.pos + length;
707
+ const message = createBaseDeclareTransaction();
708
+ while (reader.pos < end) {
709
+ const tag = reader.uint32();
710
+ switch (tag >>> 3) {
711
+ case 1:
712
+ message.common = TransactionCommon.decode(reader, reader.uint32());
713
+ break;
714
+ case 2:
715
+ message.classHash = reader.bytes();
716
+ break;
717
+ case 3:
718
+ message.senderAddress = reader.bytes();
719
+ break;
720
+ default:
721
+ reader.skipType(tag & 7);
722
+ break;
723
+ }
724
+ }
725
+ return message;
726
+ },
727
+
728
+ fromJSON(object: any): DeclareTransaction {
729
+ return {
730
+ common: isSet(object.common) ? TransactionCommon.fromJSON(object.common) : undefined,
731
+ classHash: isSet(object.classHash) ? bytesFromBase64(object.classHash) : new Uint8Array(),
732
+ senderAddress: isSet(object.senderAddress) ? bytesFromBase64(object.senderAddress) : new Uint8Array(),
733
+ };
734
+ },
735
+
736
+ toJSON(message: DeclareTransaction): unknown {
737
+ const obj: any = {};
738
+ message.common !== undefined &&
739
+ (obj.common = message.common ? TransactionCommon.toJSON(message.common) : undefined);
740
+ message.classHash !== undefined &&
741
+ (obj.classHash = base64FromBytes(message.classHash !== undefined ? message.classHash : new Uint8Array()));
742
+ message.senderAddress !== undefined &&
743
+ (obj.senderAddress = base64FromBytes(
744
+ message.senderAddress !== undefined ? message.senderAddress : new Uint8Array(),
745
+ ));
746
+ return obj;
747
+ },
748
+
749
+ fromPartial<I extends Exact<DeepPartial<DeclareTransaction>, I>>(object: I): DeclareTransaction {
750
+ const message = createBaseDeclareTransaction();
751
+ message.common = (object.common !== undefined && object.common !== null)
752
+ ? TransactionCommon.fromPartial(object.common)
753
+ : undefined;
754
+ message.classHash = object.classHash ?? new Uint8Array();
755
+ message.senderAddress = object.senderAddress ?? new Uint8Array();
756
+ return message;
757
+ },
758
+ };
759
+
760
+ function createBaseDeployTransaction(): DeployTransaction {
761
+ return {
762
+ common: undefined,
763
+ constructorCalldata: [],
764
+ contractAddress: new Uint8Array(),
765
+ contractAddressSalt: new Uint8Array(),
766
+ classHash: new Uint8Array(),
767
+ };
768
+ }
769
+
770
+ export const DeployTransaction = {
771
+ encode(message: DeployTransaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
772
+ if (message.common !== undefined) {
773
+ TransactionCommon.encode(message.common, writer.uint32(10).fork()).ldelim();
774
+ }
775
+ for (const v of message.constructorCalldata) {
776
+ writer.uint32(18).bytes(v!);
777
+ }
778
+ if (message.contractAddress.length !== 0) {
779
+ writer.uint32(26).bytes(message.contractAddress);
780
+ }
781
+ if (message.contractAddressSalt.length !== 0) {
782
+ writer.uint32(34).bytes(message.contractAddressSalt);
783
+ }
784
+ if (message.classHash.length !== 0) {
785
+ writer.uint32(42).bytes(message.classHash);
786
+ }
787
+ return writer;
788
+ },
789
+
790
+ decode(input: _m0.Reader | Uint8Array, length?: number): DeployTransaction {
791
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
792
+ let end = length === undefined ? reader.len : reader.pos + length;
793
+ const message = createBaseDeployTransaction();
794
+ while (reader.pos < end) {
795
+ const tag = reader.uint32();
796
+ switch (tag >>> 3) {
797
+ case 1:
798
+ message.common = TransactionCommon.decode(reader, reader.uint32());
799
+ break;
800
+ case 2:
801
+ message.constructorCalldata.push(reader.bytes());
802
+ break;
803
+ case 3:
804
+ message.contractAddress = reader.bytes();
805
+ break;
806
+ case 4:
807
+ message.contractAddressSalt = reader.bytes();
808
+ break;
809
+ case 5:
810
+ message.classHash = reader.bytes();
811
+ break;
812
+ default:
813
+ reader.skipType(tag & 7);
814
+ break;
815
+ }
816
+ }
817
+ return message;
818
+ },
819
+
820
+ fromJSON(object: any): DeployTransaction {
821
+ return {
822
+ common: isSet(object.common) ? TransactionCommon.fromJSON(object.common) : undefined,
823
+ constructorCalldata: Array.isArray(object?.constructorCalldata)
824
+ ? object.constructorCalldata.map((e: any) => bytesFromBase64(e))
825
+ : [],
826
+ contractAddress: isSet(object.contractAddress) ? bytesFromBase64(object.contractAddress) : new Uint8Array(),
827
+ contractAddressSalt: isSet(object.contractAddressSalt)
828
+ ? bytesFromBase64(object.contractAddressSalt)
829
+ : new Uint8Array(),
830
+ classHash: isSet(object.classHash) ? bytesFromBase64(object.classHash) : new Uint8Array(),
831
+ };
832
+ },
833
+
834
+ toJSON(message: DeployTransaction): unknown {
835
+ const obj: any = {};
836
+ message.common !== undefined &&
837
+ (obj.common = message.common ? TransactionCommon.toJSON(message.common) : undefined);
838
+ if (message.constructorCalldata) {
839
+ obj.constructorCalldata = message.constructorCalldata.map((e) =>
840
+ base64FromBytes(e !== undefined ? e : new Uint8Array())
841
+ );
842
+ } else {
843
+ obj.constructorCalldata = [];
844
+ }
845
+ message.contractAddress !== undefined &&
846
+ (obj.contractAddress = base64FromBytes(
847
+ message.contractAddress !== undefined ? message.contractAddress : new Uint8Array(),
848
+ ));
849
+ message.contractAddressSalt !== undefined &&
850
+ (obj.contractAddressSalt = base64FromBytes(
851
+ message.contractAddressSalt !== undefined ? message.contractAddressSalt : new Uint8Array(),
852
+ ));
853
+ message.classHash !== undefined &&
854
+ (obj.classHash = base64FromBytes(message.classHash !== undefined ? message.classHash : new Uint8Array()));
855
+ return obj;
856
+ },
857
+
858
+ fromPartial<I extends Exact<DeepPartial<DeployTransaction>, I>>(object: I): DeployTransaction {
859
+ const message = createBaseDeployTransaction();
860
+ message.common = (object.common !== undefined && object.common !== null)
861
+ ? TransactionCommon.fromPartial(object.common)
862
+ : undefined;
863
+ message.constructorCalldata = object.constructorCalldata?.map((e) => e) || [];
864
+ message.contractAddress = object.contractAddress ?? new Uint8Array();
865
+ message.contractAddressSalt = object.contractAddressSalt ?? new Uint8Array();
866
+ message.classHash = object.classHash ?? new Uint8Array();
867
+ return message;
868
+ },
869
+ };
870
+
871
+ function createBaseL1HandlerTransaction(): L1HandlerTransaction {
872
+ return { common: undefined, contractAddress: new Uint8Array(), entryPointSelector: new Uint8Array(), calldata: [] };
873
+ }
874
+
875
+ export const L1HandlerTransaction = {
876
+ encode(message: L1HandlerTransaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
877
+ if (message.common !== undefined) {
878
+ TransactionCommon.encode(message.common, writer.uint32(10).fork()).ldelim();
879
+ }
880
+ if (message.contractAddress.length !== 0) {
881
+ writer.uint32(18).bytes(message.contractAddress);
882
+ }
883
+ if (message.entryPointSelector.length !== 0) {
884
+ writer.uint32(26).bytes(message.entryPointSelector);
885
+ }
886
+ for (const v of message.calldata) {
887
+ writer.uint32(34).bytes(v!);
888
+ }
889
+ return writer;
890
+ },
891
+
892
+ decode(input: _m0.Reader | Uint8Array, length?: number): L1HandlerTransaction {
893
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
894
+ let end = length === undefined ? reader.len : reader.pos + length;
895
+ const message = createBaseL1HandlerTransaction();
896
+ while (reader.pos < end) {
897
+ const tag = reader.uint32();
898
+ switch (tag >>> 3) {
899
+ case 1:
900
+ message.common = TransactionCommon.decode(reader, reader.uint32());
901
+ break;
902
+ case 2:
903
+ message.contractAddress = reader.bytes();
904
+ break;
905
+ case 3:
906
+ message.entryPointSelector = reader.bytes();
907
+ break;
908
+ case 4:
909
+ message.calldata.push(reader.bytes());
910
+ break;
911
+ default:
912
+ reader.skipType(tag & 7);
913
+ break;
914
+ }
915
+ }
916
+ return message;
917
+ },
918
+
919
+ fromJSON(object: any): L1HandlerTransaction {
920
+ return {
921
+ common: isSet(object.common) ? TransactionCommon.fromJSON(object.common) : undefined,
922
+ contractAddress: isSet(object.contractAddress) ? bytesFromBase64(object.contractAddress) : new Uint8Array(),
923
+ entryPointSelector: isSet(object.entryPointSelector)
924
+ ? bytesFromBase64(object.entryPointSelector)
925
+ : new Uint8Array(),
926
+ calldata: Array.isArray(object?.calldata) ? object.calldata.map((e: any) => bytesFromBase64(e)) : [],
927
+ };
928
+ },
929
+
930
+ toJSON(message: L1HandlerTransaction): unknown {
931
+ const obj: any = {};
932
+ message.common !== undefined &&
933
+ (obj.common = message.common ? TransactionCommon.toJSON(message.common) : undefined);
934
+ message.contractAddress !== undefined &&
935
+ (obj.contractAddress = base64FromBytes(
936
+ message.contractAddress !== undefined ? message.contractAddress : new Uint8Array(),
937
+ ));
938
+ message.entryPointSelector !== undefined &&
939
+ (obj.entryPointSelector = base64FromBytes(
940
+ message.entryPointSelector !== undefined ? message.entryPointSelector : new Uint8Array(),
941
+ ));
942
+ if (message.calldata) {
943
+ obj.calldata = message.calldata.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array()));
944
+ } else {
945
+ obj.calldata = [];
946
+ }
947
+ return obj;
948
+ },
949
+
950
+ fromPartial<I extends Exact<DeepPartial<L1HandlerTransaction>, I>>(object: I): L1HandlerTransaction {
951
+ const message = createBaseL1HandlerTransaction();
952
+ message.common = (object.common !== undefined && object.common !== null)
953
+ ? TransactionCommon.fromPartial(object.common)
954
+ : undefined;
955
+ message.contractAddress = object.contractAddress ?? new Uint8Array();
956
+ message.entryPointSelector = object.entryPointSelector ?? new Uint8Array();
957
+ message.calldata = object.calldata?.map((e) => e) || [];
958
+ return message;
959
+ },
960
+ };
961
+
962
+ function createBaseDeployAccountTransaction(): DeployAccountTransaction {
963
+ return {
964
+ common: undefined,
965
+ constructorCalldata: [],
966
+ contractAddress: new Uint8Array(),
967
+ contractAddressSalt: new Uint8Array(),
968
+ classHash: new Uint8Array(),
969
+ };
970
+ }
971
+
972
+ export const DeployAccountTransaction = {
973
+ encode(message: DeployAccountTransaction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
974
+ if (message.common !== undefined) {
975
+ TransactionCommon.encode(message.common, writer.uint32(10).fork()).ldelim();
976
+ }
977
+ for (const v of message.constructorCalldata) {
978
+ writer.uint32(18).bytes(v!);
979
+ }
980
+ if (message.contractAddress.length !== 0) {
981
+ writer.uint32(26).bytes(message.contractAddress);
982
+ }
983
+ if (message.contractAddressSalt.length !== 0) {
984
+ writer.uint32(34).bytes(message.contractAddressSalt);
985
+ }
986
+ if (message.classHash.length !== 0) {
987
+ writer.uint32(42).bytes(message.classHash);
988
+ }
989
+ return writer;
990
+ },
991
+
992
+ decode(input: _m0.Reader | Uint8Array, length?: number): DeployAccountTransaction {
993
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
994
+ let end = length === undefined ? reader.len : reader.pos + length;
995
+ const message = createBaseDeployAccountTransaction();
996
+ while (reader.pos < end) {
997
+ const tag = reader.uint32();
998
+ switch (tag >>> 3) {
999
+ case 1:
1000
+ message.common = TransactionCommon.decode(reader, reader.uint32());
1001
+ break;
1002
+ case 2:
1003
+ message.constructorCalldata.push(reader.bytes());
1004
+ break;
1005
+ case 3:
1006
+ message.contractAddress = reader.bytes();
1007
+ break;
1008
+ case 4:
1009
+ message.contractAddressSalt = reader.bytes();
1010
+ break;
1011
+ case 5:
1012
+ message.classHash = reader.bytes();
1013
+ break;
1014
+ default:
1015
+ reader.skipType(tag & 7);
1016
+ break;
1017
+ }
1018
+ }
1019
+ return message;
1020
+ },
1021
+
1022
+ fromJSON(object: any): DeployAccountTransaction {
1023
+ return {
1024
+ common: isSet(object.common) ? TransactionCommon.fromJSON(object.common) : undefined,
1025
+ constructorCalldata: Array.isArray(object?.constructorCalldata)
1026
+ ? object.constructorCalldata.map((e: any) => bytesFromBase64(e))
1027
+ : [],
1028
+ contractAddress: isSet(object.contractAddress) ? bytesFromBase64(object.contractAddress) : new Uint8Array(),
1029
+ contractAddressSalt: isSet(object.contractAddressSalt)
1030
+ ? bytesFromBase64(object.contractAddressSalt)
1031
+ : new Uint8Array(),
1032
+ classHash: isSet(object.classHash) ? bytesFromBase64(object.classHash) : new Uint8Array(),
1033
+ };
1034
+ },
1035
+
1036
+ toJSON(message: DeployAccountTransaction): unknown {
1037
+ const obj: any = {};
1038
+ message.common !== undefined &&
1039
+ (obj.common = message.common ? TransactionCommon.toJSON(message.common) : undefined);
1040
+ if (message.constructorCalldata) {
1041
+ obj.constructorCalldata = message.constructorCalldata.map((e) =>
1042
+ base64FromBytes(e !== undefined ? e : new Uint8Array())
1043
+ );
1044
+ } else {
1045
+ obj.constructorCalldata = [];
1046
+ }
1047
+ message.contractAddress !== undefined &&
1048
+ (obj.contractAddress = base64FromBytes(
1049
+ message.contractAddress !== undefined ? message.contractAddress : new Uint8Array(),
1050
+ ));
1051
+ message.contractAddressSalt !== undefined &&
1052
+ (obj.contractAddressSalt = base64FromBytes(
1053
+ message.contractAddressSalt !== undefined ? message.contractAddressSalt : new Uint8Array(),
1054
+ ));
1055
+ message.classHash !== undefined &&
1056
+ (obj.classHash = base64FromBytes(message.classHash !== undefined ? message.classHash : new Uint8Array()));
1057
+ return obj;
1058
+ },
1059
+
1060
+ fromPartial<I extends Exact<DeepPartial<DeployAccountTransaction>, I>>(object: I): DeployAccountTransaction {
1061
+ const message = createBaseDeployAccountTransaction();
1062
+ message.common = (object.common !== undefined && object.common !== null)
1063
+ ? TransactionCommon.fromPartial(object.common)
1064
+ : undefined;
1065
+ message.constructorCalldata = object.constructorCalldata?.map((e) => e) || [];
1066
+ message.contractAddress = object.contractAddress ?? new Uint8Array();
1067
+ message.contractAddressSalt = object.contractAddressSalt ?? new Uint8Array();
1068
+ message.classHash = object.classHash ?? new Uint8Array();
1069
+ return message;
1070
+ },
1071
+ };
1072
+
1073
+ function createBaseTransactionReceipt(): TransactionReceipt {
1074
+ return {
1075
+ transactionHash: new Uint8Array(),
1076
+ transactionIndex: 0,
1077
+ actualFee: new Uint8Array(),
1078
+ executionResources: undefined,
1079
+ l1ToL2ConsumedMessage: undefined,
1080
+ l2ToL1Messages: [],
1081
+ events: [],
1082
+ };
1083
+ }
1084
+
1085
+ export const TransactionReceipt = {
1086
+ encode(message: TransactionReceipt, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
1087
+ if (message.transactionHash.length !== 0) {
1088
+ writer.uint32(10).bytes(message.transactionHash);
1089
+ }
1090
+ if (message.transactionIndex !== 0) {
1091
+ writer.uint32(16).uint64(message.transactionIndex);
1092
+ }
1093
+ if (message.actualFee.length !== 0) {
1094
+ writer.uint32(26).bytes(message.actualFee);
1095
+ }
1096
+ if (message.executionResources !== undefined) {
1097
+ ExecutionResources.encode(message.executionResources, writer.uint32(34).fork()).ldelim();
1098
+ }
1099
+ if (message.l1ToL2ConsumedMessage !== undefined) {
1100
+ L1ToL2Message.encode(message.l1ToL2ConsumedMessage, writer.uint32(42).fork()).ldelim();
1101
+ }
1102
+ for (const v of message.l2ToL1Messages) {
1103
+ L2ToL1Message.encode(v!, writer.uint32(50).fork()).ldelim();
1104
+ }
1105
+ for (const v of message.events) {
1106
+ Event.encode(v!, writer.uint32(58).fork()).ldelim();
1107
+ }
1108
+ return writer;
1109
+ },
1110
+
1111
+ decode(input: _m0.Reader | Uint8Array, length?: number): TransactionReceipt {
1112
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
1113
+ let end = length === undefined ? reader.len : reader.pos + length;
1114
+ const message = createBaseTransactionReceipt();
1115
+ while (reader.pos < end) {
1116
+ const tag = reader.uint32();
1117
+ switch (tag >>> 3) {
1118
+ case 1:
1119
+ message.transactionHash = reader.bytes();
1120
+ break;
1121
+ case 2:
1122
+ message.transactionIndex = longToNumber(reader.uint64() as Long);
1123
+ break;
1124
+ case 3:
1125
+ message.actualFee = reader.bytes();
1126
+ break;
1127
+ case 4:
1128
+ message.executionResources = ExecutionResources.decode(reader, reader.uint32());
1129
+ break;
1130
+ case 5:
1131
+ message.l1ToL2ConsumedMessage = L1ToL2Message.decode(reader, reader.uint32());
1132
+ break;
1133
+ case 6:
1134
+ message.l2ToL1Messages.push(L2ToL1Message.decode(reader, reader.uint32()));
1135
+ break;
1136
+ case 7:
1137
+ message.events.push(Event.decode(reader, reader.uint32()));
1138
+ break;
1139
+ default:
1140
+ reader.skipType(tag & 7);
1141
+ break;
1142
+ }
1143
+ }
1144
+ return message;
1145
+ },
1146
+
1147
+ fromJSON(object: any): TransactionReceipt {
1148
+ return {
1149
+ transactionHash: isSet(object.transactionHash) ? bytesFromBase64(object.transactionHash) : new Uint8Array(),
1150
+ transactionIndex: isSet(object.transactionIndex) ? Number(object.transactionIndex) : 0,
1151
+ actualFee: isSet(object.actualFee) ? bytesFromBase64(object.actualFee) : new Uint8Array(),
1152
+ executionResources: isSet(object.executionResources)
1153
+ ? ExecutionResources.fromJSON(object.executionResources)
1154
+ : undefined,
1155
+ l1ToL2ConsumedMessage: isSet(object.l1ToL2ConsumedMessage)
1156
+ ? L1ToL2Message.fromJSON(object.l1ToL2ConsumedMessage)
1157
+ : undefined,
1158
+ l2ToL1Messages: Array.isArray(object?.l2ToL1Messages)
1159
+ ? object.l2ToL1Messages.map((e: any) => L2ToL1Message.fromJSON(e))
1160
+ : [],
1161
+ events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromJSON(e)) : [],
1162
+ };
1163
+ },
1164
+
1165
+ toJSON(message: TransactionReceipt): unknown {
1166
+ const obj: any = {};
1167
+ message.transactionHash !== undefined &&
1168
+ (obj.transactionHash = base64FromBytes(
1169
+ message.transactionHash !== undefined ? message.transactionHash : new Uint8Array(),
1170
+ ));
1171
+ message.transactionIndex !== undefined && (obj.transactionIndex = Math.round(message.transactionIndex));
1172
+ message.actualFee !== undefined &&
1173
+ (obj.actualFee = base64FromBytes(message.actualFee !== undefined ? message.actualFee : new Uint8Array()));
1174
+ message.executionResources !== undefined && (obj.executionResources = message.executionResources
1175
+ ? ExecutionResources.toJSON(message.executionResources)
1176
+ : undefined);
1177
+ message.l1ToL2ConsumedMessage !== undefined && (obj.l1ToL2ConsumedMessage = message.l1ToL2ConsumedMessage
1178
+ ? L1ToL2Message.toJSON(message.l1ToL2ConsumedMessage)
1179
+ : undefined);
1180
+ if (message.l2ToL1Messages) {
1181
+ obj.l2ToL1Messages = message.l2ToL1Messages.map((e) => e ? L2ToL1Message.toJSON(e) : undefined);
1182
+ } else {
1183
+ obj.l2ToL1Messages = [];
1184
+ }
1185
+ if (message.events) {
1186
+ obj.events = message.events.map((e) => e ? Event.toJSON(e) : undefined);
1187
+ } else {
1188
+ obj.events = [];
1189
+ }
1190
+ return obj;
1191
+ },
1192
+
1193
+ fromPartial<I extends Exact<DeepPartial<TransactionReceipt>, I>>(object: I): TransactionReceipt {
1194
+ const message = createBaseTransactionReceipt();
1195
+ message.transactionHash = object.transactionHash ?? new Uint8Array();
1196
+ message.transactionIndex = object.transactionIndex ?? 0;
1197
+ message.actualFee = object.actualFee ?? new Uint8Array();
1198
+ message.executionResources = (object.executionResources !== undefined && object.executionResources !== null)
1199
+ ? ExecutionResources.fromPartial(object.executionResources)
1200
+ : undefined;
1201
+ message.l1ToL2ConsumedMessage =
1202
+ (object.l1ToL2ConsumedMessage !== undefined && object.l1ToL2ConsumedMessage !== null)
1203
+ ? L1ToL2Message.fromPartial(object.l1ToL2ConsumedMessage)
1204
+ : undefined;
1205
+ message.l2ToL1Messages = object.l2ToL1Messages?.map((e) => L2ToL1Message.fromPartial(e)) || [];
1206
+ message.events = object.events?.map((e) => Event.fromPartial(e)) || [];
1207
+ return message;
1208
+ },
1209
+ };
1210
+
1211
+ function createBaseExecutionResources(): ExecutionResources {
1212
+ return { nSteps: 0, nMemoryHoles: 0, builtinInstanceCounter: undefined };
1213
+ }
1214
+
1215
+ export const ExecutionResources = {
1216
+ encode(message: ExecutionResources, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
1217
+ if (message.nSteps !== 0) {
1218
+ writer.uint32(8).uint64(message.nSteps);
1219
+ }
1220
+ if (message.nMemoryHoles !== 0) {
1221
+ writer.uint32(16).uint64(message.nMemoryHoles);
1222
+ }
1223
+ if (message.builtinInstanceCounter !== undefined) {
1224
+ BuiltinInstanceCounter.encode(message.builtinInstanceCounter, writer.uint32(26).fork()).ldelim();
1225
+ }
1226
+ return writer;
1227
+ },
1228
+
1229
+ decode(input: _m0.Reader | Uint8Array, length?: number): ExecutionResources {
1230
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
1231
+ let end = length === undefined ? reader.len : reader.pos + length;
1232
+ const message = createBaseExecutionResources();
1233
+ while (reader.pos < end) {
1234
+ const tag = reader.uint32();
1235
+ switch (tag >>> 3) {
1236
+ case 1:
1237
+ message.nSteps = longToNumber(reader.uint64() as Long);
1238
+ break;
1239
+ case 2:
1240
+ message.nMemoryHoles = longToNumber(reader.uint64() as Long);
1241
+ break;
1242
+ case 3:
1243
+ message.builtinInstanceCounter = BuiltinInstanceCounter.decode(reader, reader.uint32());
1244
+ break;
1245
+ default:
1246
+ reader.skipType(tag & 7);
1247
+ break;
1248
+ }
1249
+ }
1250
+ return message;
1251
+ },
1252
+
1253
+ fromJSON(object: any): ExecutionResources {
1254
+ return {
1255
+ nSteps: isSet(object.nSteps) ? Number(object.nSteps) : 0,
1256
+ nMemoryHoles: isSet(object.nMemoryHoles) ? Number(object.nMemoryHoles) : 0,
1257
+ builtinInstanceCounter: isSet(object.builtinInstanceCounter)
1258
+ ? BuiltinInstanceCounter.fromJSON(object.builtinInstanceCounter)
1259
+ : undefined,
1260
+ };
1261
+ },
1262
+
1263
+ toJSON(message: ExecutionResources): unknown {
1264
+ const obj: any = {};
1265
+ message.nSteps !== undefined && (obj.nSteps = Math.round(message.nSteps));
1266
+ message.nMemoryHoles !== undefined && (obj.nMemoryHoles = Math.round(message.nMemoryHoles));
1267
+ message.builtinInstanceCounter !== undefined && (obj.builtinInstanceCounter = message.builtinInstanceCounter
1268
+ ? BuiltinInstanceCounter.toJSON(message.builtinInstanceCounter)
1269
+ : undefined);
1270
+ return obj;
1271
+ },
1272
+
1273
+ fromPartial<I extends Exact<DeepPartial<ExecutionResources>, I>>(object: I): ExecutionResources {
1274
+ const message = createBaseExecutionResources();
1275
+ message.nSteps = object.nSteps ?? 0;
1276
+ message.nMemoryHoles = object.nMemoryHoles ?? 0;
1277
+ message.builtinInstanceCounter =
1278
+ (object.builtinInstanceCounter !== undefined && object.builtinInstanceCounter !== null)
1279
+ ? BuiltinInstanceCounter.fromPartial(object.builtinInstanceCounter)
1280
+ : undefined;
1281
+ return message;
1282
+ },
1283
+ };
1284
+
1285
+ function createBaseBuiltinInstanceCounter(): BuiltinInstanceCounter {
1286
+ return {
1287
+ pedersenBuiltin: undefined,
1288
+ rangeCheckBuiltin: undefined,
1289
+ bitwiseBuiltin: undefined,
1290
+ outputBuiltin: undefined,
1291
+ ecdsaBuiltin: undefined,
1292
+ ecOpBuiltin: undefined,
1293
+ };
1294
+ }
1295
+
1296
+ export const BuiltinInstanceCounter = {
1297
+ encode(message: BuiltinInstanceCounter, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
1298
+ if (message.pedersenBuiltin !== undefined) {
1299
+ writer.uint32(8).uint64(message.pedersenBuiltin);
1300
+ }
1301
+ if (message.rangeCheckBuiltin !== undefined) {
1302
+ writer.uint32(16).uint64(message.rangeCheckBuiltin);
1303
+ }
1304
+ if (message.bitwiseBuiltin !== undefined) {
1305
+ writer.uint32(24).uint64(message.bitwiseBuiltin);
1306
+ }
1307
+ if (message.outputBuiltin !== undefined) {
1308
+ writer.uint32(32).uint64(message.outputBuiltin);
1309
+ }
1310
+ if (message.ecdsaBuiltin !== undefined) {
1311
+ writer.uint32(40).uint64(message.ecdsaBuiltin);
1312
+ }
1313
+ if (message.ecOpBuiltin !== undefined) {
1314
+ writer.uint32(48).uint64(message.ecOpBuiltin);
1315
+ }
1316
+ return writer;
1317
+ },
1318
+
1319
+ decode(input: _m0.Reader | Uint8Array, length?: number): BuiltinInstanceCounter {
1320
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
1321
+ let end = length === undefined ? reader.len : reader.pos + length;
1322
+ const message = createBaseBuiltinInstanceCounter();
1323
+ while (reader.pos < end) {
1324
+ const tag = reader.uint32();
1325
+ switch (tag >>> 3) {
1326
+ case 1:
1327
+ message.pedersenBuiltin = longToNumber(reader.uint64() as Long);
1328
+ break;
1329
+ case 2:
1330
+ message.rangeCheckBuiltin = longToNumber(reader.uint64() as Long);
1331
+ break;
1332
+ case 3:
1333
+ message.bitwiseBuiltin = longToNumber(reader.uint64() as Long);
1334
+ break;
1335
+ case 4:
1336
+ message.outputBuiltin = longToNumber(reader.uint64() as Long);
1337
+ break;
1338
+ case 5:
1339
+ message.ecdsaBuiltin = longToNumber(reader.uint64() as Long);
1340
+ break;
1341
+ case 6:
1342
+ message.ecOpBuiltin = longToNumber(reader.uint64() as Long);
1343
+ break;
1344
+ default:
1345
+ reader.skipType(tag & 7);
1346
+ break;
1347
+ }
1348
+ }
1349
+ return message;
1350
+ },
1351
+
1352
+ fromJSON(object: any): BuiltinInstanceCounter {
1353
+ return {
1354
+ pedersenBuiltin: isSet(object.pedersenBuiltin) ? Number(object.pedersenBuiltin) : undefined,
1355
+ rangeCheckBuiltin: isSet(object.rangeCheckBuiltin) ? Number(object.rangeCheckBuiltin) : undefined,
1356
+ bitwiseBuiltin: isSet(object.bitwiseBuiltin) ? Number(object.bitwiseBuiltin) : undefined,
1357
+ outputBuiltin: isSet(object.outputBuiltin) ? Number(object.outputBuiltin) : undefined,
1358
+ ecdsaBuiltin: isSet(object.ecdsaBuiltin) ? Number(object.ecdsaBuiltin) : undefined,
1359
+ ecOpBuiltin: isSet(object.ecOpBuiltin) ? Number(object.ecOpBuiltin) : undefined,
1360
+ };
1361
+ },
1362
+
1363
+ toJSON(message: BuiltinInstanceCounter): unknown {
1364
+ const obj: any = {};
1365
+ message.pedersenBuiltin !== undefined && (obj.pedersenBuiltin = Math.round(message.pedersenBuiltin));
1366
+ message.rangeCheckBuiltin !== undefined && (obj.rangeCheckBuiltin = Math.round(message.rangeCheckBuiltin));
1367
+ message.bitwiseBuiltin !== undefined && (obj.bitwiseBuiltin = Math.round(message.bitwiseBuiltin));
1368
+ message.outputBuiltin !== undefined && (obj.outputBuiltin = Math.round(message.outputBuiltin));
1369
+ message.ecdsaBuiltin !== undefined && (obj.ecdsaBuiltin = Math.round(message.ecdsaBuiltin));
1370
+ message.ecOpBuiltin !== undefined && (obj.ecOpBuiltin = Math.round(message.ecOpBuiltin));
1371
+ return obj;
1372
+ },
1373
+
1374
+ fromPartial<I extends Exact<DeepPartial<BuiltinInstanceCounter>, I>>(object: I): BuiltinInstanceCounter {
1375
+ const message = createBaseBuiltinInstanceCounter();
1376
+ message.pedersenBuiltin = object.pedersenBuiltin ?? undefined;
1377
+ message.rangeCheckBuiltin = object.rangeCheckBuiltin ?? undefined;
1378
+ message.bitwiseBuiltin = object.bitwiseBuiltin ?? undefined;
1379
+ message.outputBuiltin = object.outputBuiltin ?? undefined;
1380
+ message.ecdsaBuiltin = object.ecdsaBuiltin ?? undefined;
1381
+ message.ecOpBuiltin = object.ecOpBuiltin ?? undefined;
1382
+ return message;
1383
+ },
1384
+ };
1385
+
1386
+ function createBaseL1ToL2Message(): L1ToL2Message {
1387
+ return {
1388
+ fromAddress: new Uint8Array(),
1389
+ toAddress: new Uint8Array(),
1390
+ selector: new Uint8Array(),
1391
+ payload: [],
1392
+ nonce: new Uint8Array(),
1393
+ };
1394
+ }
1395
+
1396
+ export const L1ToL2Message = {
1397
+ encode(message: L1ToL2Message, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
1398
+ if (message.fromAddress.length !== 0) {
1399
+ writer.uint32(10).bytes(message.fromAddress);
1400
+ }
1401
+ if (message.toAddress.length !== 0) {
1402
+ writer.uint32(18).bytes(message.toAddress);
1403
+ }
1404
+ if (message.selector.length !== 0) {
1405
+ writer.uint32(26).bytes(message.selector);
1406
+ }
1407
+ for (const v of message.payload) {
1408
+ writer.uint32(34).bytes(v!);
1409
+ }
1410
+ if (message.nonce.length !== 0) {
1411
+ writer.uint32(42).bytes(message.nonce);
1412
+ }
1413
+ return writer;
1414
+ },
1415
+
1416
+ decode(input: _m0.Reader | Uint8Array, length?: number): L1ToL2Message {
1417
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
1418
+ let end = length === undefined ? reader.len : reader.pos + length;
1419
+ const message = createBaseL1ToL2Message();
1420
+ while (reader.pos < end) {
1421
+ const tag = reader.uint32();
1422
+ switch (tag >>> 3) {
1423
+ case 1:
1424
+ message.fromAddress = reader.bytes();
1425
+ break;
1426
+ case 2:
1427
+ message.toAddress = reader.bytes();
1428
+ break;
1429
+ case 3:
1430
+ message.selector = reader.bytes();
1431
+ break;
1432
+ case 4:
1433
+ message.payload.push(reader.bytes());
1434
+ break;
1435
+ case 5:
1436
+ message.nonce = reader.bytes();
1437
+ break;
1438
+ default:
1439
+ reader.skipType(tag & 7);
1440
+ break;
1441
+ }
1442
+ }
1443
+ return message;
1444
+ },
1445
+
1446
+ fromJSON(object: any): L1ToL2Message {
1447
+ return {
1448
+ fromAddress: isSet(object.fromAddress) ? bytesFromBase64(object.fromAddress) : new Uint8Array(),
1449
+ toAddress: isSet(object.toAddress) ? bytesFromBase64(object.toAddress) : new Uint8Array(),
1450
+ selector: isSet(object.selector) ? bytesFromBase64(object.selector) : new Uint8Array(),
1451
+ payload: Array.isArray(object?.payload) ? object.payload.map((e: any) => bytesFromBase64(e)) : [],
1452
+ nonce: isSet(object.nonce) ? bytesFromBase64(object.nonce) : new Uint8Array(),
1453
+ };
1454
+ },
1455
+
1456
+ toJSON(message: L1ToL2Message): unknown {
1457
+ const obj: any = {};
1458
+ message.fromAddress !== undefined &&
1459
+ (obj.fromAddress = base64FromBytes(message.fromAddress !== undefined ? message.fromAddress : new Uint8Array()));
1460
+ message.toAddress !== undefined &&
1461
+ (obj.toAddress = base64FromBytes(message.toAddress !== undefined ? message.toAddress : new Uint8Array()));
1462
+ message.selector !== undefined &&
1463
+ (obj.selector = base64FromBytes(message.selector !== undefined ? message.selector : new Uint8Array()));
1464
+ if (message.payload) {
1465
+ obj.payload = message.payload.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array()));
1466
+ } else {
1467
+ obj.payload = [];
1468
+ }
1469
+ message.nonce !== undefined &&
1470
+ (obj.nonce = base64FromBytes(message.nonce !== undefined ? message.nonce : new Uint8Array()));
1471
+ return obj;
1472
+ },
1473
+
1474
+ fromPartial<I extends Exact<DeepPartial<L1ToL2Message>, I>>(object: I): L1ToL2Message {
1475
+ const message = createBaseL1ToL2Message();
1476
+ message.fromAddress = object.fromAddress ?? new Uint8Array();
1477
+ message.toAddress = object.toAddress ?? new Uint8Array();
1478
+ message.selector = object.selector ?? new Uint8Array();
1479
+ message.payload = object.payload?.map((e) => e) || [];
1480
+ message.nonce = object.nonce ?? new Uint8Array();
1481
+ return message;
1482
+ },
1483
+ };
1484
+
1485
+ function createBaseL2ToL1Message(): L2ToL1Message {
1486
+ return { fromAddress: new Uint8Array(), toAddress: new Uint8Array(), payload: [] };
1487
+ }
1488
+
1489
+ export const L2ToL1Message = {
1490
+ encode(message: L2ToL1Message, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
1491
+ if (message.fromAddress.length !== 0) {
1492
+ writer.uint32(10).bytes(message.fromAddress);
1493
+ }
1494
+ if (message.toAddress.length !== 0) {
1495
+ writer.uint32(18).bytes(message.toAddress);
1496
+ }
1497
+ for (const v of message.payload) {
1498
+ writer.uint32(26).bytes(v!);
1499
+ }
1500
+ return writer;
1501
+ },
1502
+
1503
+ decode(input: _m0.Reader | Uint8Array, length?: number): L2ToL1Message {
1504
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
1505
+ let end = length === undefined ? reader.len : reader.pos + length;
1506
+ const message = createBaseL2ToL1Message();
1507
+ while (reader.pos < end) {
1508
+ const tag = reader.uint32();
1509
+ switch (tag >>> 3) {
1510
+ case 1:
1511
+ message.fromAddress = reader.bytes();
1512
+ break;
1513
+ case 2:
1514
+ message.toAddress = reader.bytes();
1515
+ break;
1516
+ case 3:
1517
+ message.payload.push(reader.bytes());
1518
+ break;
1519
+ default:
1520
+ reader.skipType(tag & 7);
1521
+ break;
1522
+ }
1523
+ }
1524
+ return message;
1525
+ },
1526
+
1527
+ fromJSON(object: any): L2ToL1Message {
1528
+ return {
1529
+ fromAddress: isSet(object.fromAddress) ? bytesFromBase64(object.fromAddress) : new Uint8Array(),
1530
+ toAddress: isSet(object.toAddress) ? bytesFromBase64(object.toAddress) : new Uint8Array(),
1531
+ payload: Array.isArray(object?.payload) ? object.payload.map((e: any) => bytesFromBase64(e)) : [],
1532
+ };
1533
+ },
1534
+
1535
+ toJSON(message: L2ToL1Message): unknown {
1536
+ const obj: any = {};
1537
+ message.fromAddress !== undefined &&
1538
+ (obj.fromAddress = base64FromBytes(message.fromAddress !== undefined ? message.fromAddress : new Uint8Array()));
1539
+ message.toAddress !== undefined &&
1540
+ (obj.toAddress = base64FromBytes(message.toAddress !== undefined ? message.toAddress : new Uint8Array()));
1541
+ if (message.payload) {
1542
+ obj.payload = message.payload.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array()));
1543
+ } else {
1544
+ obj.payload = [];
1545
+ }
1546
+ return obj;
1547
+ },
1548
+
1549
+ fromPartial<I extends Exact<DeepPartial<L2ToL1Message>, I>>(object: I): L2ToL1Message {
1550
+ const message = createBaseL2ToL1Message();
1551
+ message.fromAddress = object.fromAddress ?? new Uint8Array();
1552
+ message.toAddress = object.toAddress ?? new Uint8Array();
1553
+ message.payload = object.payload?.map((e) => e) || [];
1554
+ return message;
1555
+ },
1556
+ };
1557
+
1558
+ function createBaseEvent(): Event {
1559
+ return { fromAddress: new Uint8Array(), keys: [], data: [] };
1560
+ }
1561
+
1562
+ export const Event = {
1563
+ encode(message: Event, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
1564
+ if (message.fromAddress.length !== 0) {
1565
+ writer.uint32(10).bytes(message.fromAddress);
1566
+ }
1567
+ for (const v of message.keys) {
1568
+ writer.uint32(18).bytes(v!);
1569
+ }
1570
+ for (const v of message.data) {
1571
+ writer.uint32(26).bytes(v!);
1572
+ }
1573
+ return writer;
1574
+ },
1575
+
1576
+ decode(input: _m0.Reader | Uint8Array, length?: number): Event {
1577
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
1578
+ let end = length === undefined ? reader.len : reader.pos + length;
1579
+ const message = createBaseEvent();
1580
+ while (reader.pos < end) {
1581
+ const tag = reader.uint32();
1582
+ switch (tag >>> 3) {
1583
+ case 1:
1584
+ message.fromAddress = reader.bytes();
1585
+ break;
1586
+ case 2:
1587
+ message.keys.push(reader.bytes());
1588
+ break;
1589
+ case 3:
1590
+ message.data.push(reader.bytes());
1591
+ break;
1592
+ default:
1593
+ reader.skipType(tag & 7);
1594
+ break;
1595
+ }
1596
+ }
1597
+ return message;
1598
+ },
1599
+
1600
+ fromJSON(object: any): Event {
1601
+ return {
1602
+ fromAddress: isSet(object.fromAddress) ? bytesFromBase64(object.fromAddress) : new Uint8Array(),
1603
+ keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => bytesFromBase64(e)) : [],
1604
+ data: Array.isArray(object?.data) ? object.data.map((e: any) => bytesFromBase64(e)) : [],
1605
+ };
1606
+ },
1607
+
1608
+ toJSON(message: Event): unknown {
1609
+ const obj: any = {};
1610
+ message.fromAddress !== undefined &&
1611
+ (obj.fromAddress = base64FromBytes(message.fromAddress !== undefined ? message.fromAddress : new Uint8Array()));
1612
+ if (message.keys) {
1613
+ obj.keys = message.keys.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array()));
1614
+ } else {
1615
+ obj.keys = [];
1616
+ }
1617
+ if (message.data) {
1618
+ obj.data = message.data.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array()));
1619
+ } else {
1620
+ obj.data = [];
1621
+ }
1622
+ return obj;
1623
+ },
1624
+
1625
+ fromPartial<I extends Exact<DeepPartial<Event>, I>>(object: I): Event {
1626
+ const message = createBaseEvent();
1627
+ message.fromAddress = object.fromAddress ?? new Uint8Array();
1628
+ message.keys = object.keys?.map((e) => e) || [];
1629
+ message.data = object.data?.map((e) => e) || [];
1630
+ return message;
1631
+ },
1632
+ };
1633
+
1634
+ declare var self: any | undefined;
1635
+ declare var window: any | undefined;
1636
+ declare var global: any | undefined;
1637
+ var globalThis: any = (() => {
1638
+ if (typeof globalThis !== "undefined") {
1639
+ return globalThis;
1640
+ }
1641
+ if (typeof self !== "undefined") {
1642
+ return self;
1643
+ }
1644
+ if (typeof window !== "undefined") {
1645
+ return window;
1646
+ }
1647
+ if (typeof global !== "undefined") {
1648
+ return global;
1649
+ }
1650
+ throw "Unable to locate global object";
1651
+ })();
1652
+
1653
+ function bytesFromBase64(b64: string): Uint8Array {
1654
+ if (globalThis.Buffer) {
1655
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
1656
+ } else {
1657
+ const bin = globalThis.atob(b64);
1658
+ const arr = new Uint8Array(bin.length);
1659
+ for (let i = 0; i < bin.length; ++i) {
1660
+ arr[i] = bin.charCodeAt(i);
1661
+ }
1662
+ return arr;
1663
+ }
1664
+ }
1665
+
1666
+ function base64FromBytes(arr: Uint8Array): string {
1667
+ if (globalThis.Buffer) {
1668
+ return globalThis.Buffer.from(arr).toString("base64");
1669
+ } else {
1670
+ const bin: string[] = [];
1671
+ arr.forEach((byte) => {
1672
+ bin.push(String.fromCharCode(byte));
1673
+ });
1674
+ return globalThis.btoa(bin.join(""));
1675
+ }
1676
+ }
1677
+
1678
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
1679
+
1680
+ export type DeepPartial<T> = T extends Builtin ? T
1681
+ : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
1682
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
1683
+ : Partial<T>;
1684
+
1685
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
1686
+ export type Exact<P, I extends P> = P extends Builtin ? P
1687
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
1688
+
1689
+ function toTimestamp(date: Date): Timestamp {
1690
+ const seconds = date.getTime() / 1_000;
1691
+ const nanos = (date.getTime() % 1_000) * 1_000_000;
1692
+ return { seconds, nanos };
1693
+ }
1694
+
1695
+ function fromTimestamp(t: Timestamp): Date {
1696
+ let millis = t.seconds * 1_000;
1697
+ millis += t.nanos / 1_000_000;
1698
+ return new Date(millis);
1699
+ }
1700
+
1701
+ function fromJsonTimestamp(o: any): Date {
1702
+ if (o instanceof Date) {
1703
+ return o;
1704
+ } else if (typeof o === "string") {
1705
+ return new Date(o);
1706
+ } else {
1707
+ return fromTimestamp(Timestamp.fromJSON(o));
1708
+ }
1709
+ }
1710
+
1711
+ function longToNumber(long: Long): number {
1712
+ if (long.gt(Number.MAX_SAFE_INTEGER)) {
1713
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
1714
+ }
1715
+ return long.toNumber();
1716
+ }
1717
+
1718
+ if (_m0.util.Long !== Long) {
1719
+ _m0.util.Long = Long as any;
1720
+ _m0.configure();
1721
+ }
1722
+
1723
+ function isSet(value: any): boolean {
1724
+ return value !== null && value !== undefined;
1725
+ }