@apibara/starknet 2.1.0-beta.5 → 2.1.0-beta.51

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/dist/index.mjs CHANGED
@@ -1,48 +1,29 @@
1
1
  import { StreamConfig } from '@apibara/protocol';
2
- import { Schema } from '@effect/schema';
2
+ import { MessageCodec, OptionalCodec, RequiredCodec, BigIntCodec, DateCodec, StringCodec, NumberCodec, ArrayCodec, OneOfCodec, Uint8ArrayCodec, BooleanCodec } from '@apibara/protocol/codec';
3
3
  import Long from 'long';
4
4
  import _m0 from 'protobufjs/minimal.js';
5
5
  import { keccak } from '@scure/starknet';
6
- import { parseBool, parseFelt252, parseU8, parseU16, parseU32, parseU64, parseU128, parseU256, parseContractAddress, ParseError, parseStruct, parseArray, parseSpan, parseOption, parseEmpty } from './parser.mjs';
6
+ import { parseBool, parseFelt252, parseU8, parseU16, parseU32, parseU64, parseU128, parseU256, parseBytes31, parseContractAddress, ParseError, parseStruct, parseArray, parseSpan, parseOption, parseEmpty, parseByteArray, parseEnum } from './parser.mjs';
7
7
 
8
- const _FieldElement = Schema.TemplateLiteral(
9
- Schema.Literal("0x"),
10
- Schema.String
11
- );
12
- const FieldElementProto = Schema.Struct({
13
- x0: Schema.BigIntFromSelf,
14
- x1: Schema.BigIntFromSelf,
15
- x2: Schema.BigIntFromSelf,
16
- x3: Schema.BigIntFromSelf
17
- });
18
- const FieldElement$1 = Schema.transform(FieldElementProto, _FieldElement, {
19
- decode(value) {
20
- const x0 = value.x0.toString(16).padStart(16, "0");
21
- const x1 = value.x1.toString(16).padStart(16, "0");
22
- const x2 = value.x2.toString(16).padStart(16, "0");
23
- const x3 = value.x3.toString(16).padStart(16, "0");
24
- return `0x${x0}${x1}${x2}${x3}`;
25
- },
26
- encode(value) {
27
- const bn = BigInt(value);
28
- const hex = bn.toString(16).padStart(64, "0");
29
- const s = hex.length;
30
- const x3 = BigInt(`0x${hex.slice(s - 16, s)}`);
31
- const x2 = BigInt(`0x${hex.slice(s - 32, s - 16)}`);
32
- const x1 = BigInt(`0x${hex.slice(s - 48, s - 32)}`);
33
- const x0 = BigInt(`0x${hex.slice(s - 64, s - 48)}`);
8
+ const MAX_U64 = 0xffffffffffffffffn;
9
+ const FieldElement$1 = {
10
+ encode(x) {
11
+ const bn = BigInt(x);
12
+ const x3 = bn & MAX_U64;
13
+ const x2 = bn >> 64n & MAX_U64;
14
+ const x1 = bn >> 128n & MAX_U64;
15
+ const x0 = bn >> 192n & MAX_U64;
34
16
  return { x0, x1, x2, x3 };
17
+ },
18
+ decode(p) {
19
+ const x0 = p.x0 ?? 0n;
20
+ const x1 = p.x1 ?? 0n;
21
+ const x2 = p.x2 ?? 0n;
22
+ const x3 = p.x3 ?? 0n;
23
+ const bn = x3 + (x2 << 64n) + (x1 << 128n) + (x0 << 192n);
24
+ return `0x${bn.toString(16).padStart(64, "0")}`;
35
25
  }
36
- });
37
- const feltToProto = Schema.encodeSync(FieldElement$1);
38
- const feltFromProto = Schema.decodeSync(FieldElement$1);
39
-
40
- function tag(tag2) {
41
- return Schema.Literal(tag2).pipe(
42
- Schema.propertySignature,
43
- Schema.fromKey("$case")
44
- );
45
- }
26
+ };
46
27
 
47
28
  const protobufPackage$2 = "starknet.v2";
48
29
  function createBaseFieldElement() {
@@ -434,6 +415,49 @@ function dataAvailabilityModeToJSON(object) {
434
415
  return "UNRECOGNIZED";
435
416
  }
436
417
  }
418
+ var CallType$1 = /* @__PURE__ */ ((CallType2) => {
419
+ CallType2[CallType2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
420
+ CallType2[CallType2["LIBRARY_CALL"] = 1] = "LIBRARY_CALL";
421
+ CallType2[CallType2["CALL"] = 2] = "CALL";
422
+ CallType2[CallType2["DELEGATE"] = 3] = "DELEGATE";
423
+ CallType2[CallType2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
424
+ return CallType2;
425
+ })(CallType$1 || {});
426
+ function callTypeFromJSON(object) {
427
+ switch (object) {
428
+ case 0:
429
+ case "CALL_TYPE_UNSPECIFIED":
430
+ return 0 /* UNSPECIFIED */;
431
+ case 1:
432
+ case "CALL_TYPE_LIBRARY_CALL":
433
+ return 1 /* LIBRARY_CALL */;
434
+ case 2:
435
+ case "CALL_TYPE_CALL":
436
+ return 2 /* CALL */;
437
+ case 3:
438
+ case "CALL_TYPE_DELEGATE":
439
+ return 3 /* DELEGATE */;
440
+ case -1:
441
+ case "UNRECOGNIZED":
442
+ default:
443
+ return -1 /* UNRECOGNIZED */;
444
+ }
445
+ }
446
+ function callTypeToJSON(object) {
447
+ switch (object) {
448
+ case 0 /* UNSPECIFIED */:
449
+ return "CALL_TYPE_UNSPECIFIED";
450
+ case 1 /* LIBRARY_CALL */:
451
+ return "CALL_TYPE_LIBRARY_CALL";
452
+ case 2 /* CALL */:
453
+ return "CALL_TYPE_CALL";
454
+ case 3 /* DELEGATE */:
455
+ return "CALL_TYPE_DELEGATE";
456
+ case -1 /* UNRECOGNIZED */:
457
+ default:
458
+ return "UNRECOGNIZED";
459
+ }
460
+ }
437
461
  function createBaseBlock() {
438
462
  return {
439
463
  header: void 0,
@@ -443,7 +467,8 @@ function createBaseBlock() {
443
467
  messages: [],
444
468
  storageDiffs: [],
445
469
  contractChanges: [],
446
- nonceUpdates: []
470
+ nonceUpdates: [],
471
+ traces: []
447
472
  };
448
473
  }
449
474
  const Block$1 = {
@@ -486,6 +511,11 @@ const Block$1 = {
486
511
  NonceUpdate$1.encode(v, writer.uint32(66).fork()).ldelim();
487
512
  }
488
513
  }
514
+ if (message.traces !== void 0 && message.traces.length !== 0) {
515
+ for (const v of message.traces) {
516
+ TransactionTrace$1.encode(v, writer.uint32(74).fork()).ldelim();
517
+ }
518
+ }
489
519
  return writer;
490
520
  },
491
521
  decode(input, length) {
@@ -543,6 +573,12 @@ const Block$1 = {
543
573
  }
544
574
  message.nonceUpdates.push(NonceUpdate$1.decode(reader, reader.uint32()));
545
575
  continue;
576
+ case 9:
577
+ if (tag !== 74) {
578
+ break;
579
+ }
580
+ message.traces.push(TransactionTrace$1.decode(reader, reader.uint32()));
581
+ continue;
546
582
  }
547
583
  if ((tag & 7) === 4 || tag === 0) {
548
584
  break;
@@ -560,7 +596,8 @@ const Block$1 = {
560
596
  messages: globalThis.Array.isArray(object?.messages) ? object.messages.map((e) => MessageToL1$1.fromJSON(e)) : [],
561
597
  storageDiffs: globalThis.Array.isArray(object?.storageDiffs) ? object.storageDiffs.map((e) => StorageDiff$1.fromJSON(e)) : [],
562
598
  contractChanges: globalThis.Array.isArray(object?.contractChanges) ? object.contractChanges.map((e) => ContractChange$1.fromJSON(e)) : [],
563
- nonceUpdates: globalThis.Array.isArray(object?.nonceUpdates) ? object.nonceUpdates.map((e) => NonceUpdate$1.fromJSON(e)) : []
599
+ nonceUpdates: globalThis.Array.isArray(object?.nonceUpdates) ? object.nonceUpdates.map((e) => NonceUpdate$1.fromJSON(e)) : [],
600
+ traces: globalThis.Array.isArray(object?.traces) ? object.traces.map((e) => TransactionTrace$1.fromJSON(e)) : []
564
601
  };
565
602
  },
566
603
  toJSON(message) {
@@ -589,6 +626,9 @@ const Block$1 = {
589
626
  if (message.nonceUpdates?.length) {
590
627
  obj.nonceUpdates = message.nonceUpdates.map((e) => NonceUpdate$1.toJSON(e));
591
628
  }
629
+ if (message.traces?.length) {
630
+ obj.traces = message.traces.map((e) => TransactionTrace$1.toJSON(e));
631
+ }
592
632
  return obj;
593
633
  },
594
634
  create(base) {
@@ -604,6 +644,7 @@ const Block$1 = {
604
644
  message.storageDiffs = object.storageDiffs?.map((e) => StorageDiff$1.fromPartial(e)) || [];
605
645
  message.contractChanges = object.contractChanges?.map((e) => ContractChange$1.fromPartial(e)) || [];
606
646
  message.nonceUpdates = object.nonceUpdates?.map((e) => NonceUpdate$1.fromPartial(e)) || [];
647
+ message.traces = object.traces?.map((e) => TransactionTrace$1.fromPartial(e)) || [];
607
648
  return message;
608
649
  }
609
650
  };
@@ -618,7 +659,8 @@ function createBaseBlockHeader() {
618
659
  starknetVersion: "",
619
660
  l1GasPrice: void 0,
620
661
  l1DataGasPrice: void 0,
621
- l1DataAvailabilityMode: 0
662
+ l1DataAvailabilityMode: 0,
663
+ l2GasPrice: void 0
622
664
  };
623
665
  }
624
666
  const BlockHeader$1 = {
@@ -656,6 +698,9 @@ const BlockHeader$1 = {
656
698
  if (message.l1DataAvailabilityMode !== void 0 && message.l1DataAvailabilityMode !== 0) {
657
699
  writer.uint32(80).int32(message.l1DataAvailabilityMode);
658
700
  }
701
+ if (message.l2GasPrice !== void 0) {
702
+ ResourcePrice$1.encode(message.l2GasPrice, writer.uint32(90).fork()).ldelim();
703
+ }
659
704
  return writer;
660
705
  },
661
706
  decode(input, length) {
@@ -725,6 +770,12 @@ const BlockHeader$1 = {
725
770
  }
726
771
  message.l1DataAvailabilityMode = reader.int32();
727
772
  continue;
773
+ case 11:
774
+ if (tag !== 90) {
775
+ break;
776
+ }
777
+ message.l2GasPrice = ResourcePrice$1.decode(reader, reader.uint32());
778
+ continue;
728
779
  }
729
780
  if ((tag & 7) === 4 || tag === 0) {
730
781
  break;
@@ -744,7 +795,8 @@ const BlockHeader$1 = {
744
795
  starknetVersion: isSet$1(object.starknetVersion) ? globalThis.String(object.starknetVersion) : "",
745
796
  l1GasPrice: isSet$1(object.l1GasPrice) ? ResourcePrice$1.fromJSON(object.l1GasPrice) : void 0,
746
797
  l1DataGasPrice: isSet$1(object.l1DataGasPrice) ? ResourcePrice$1.fromJSON(object.l1DataGasPrice) : void 0,
747
- l1DataAvailabilityMode: isSet$1(object.l1DataAvailabilityMode) ? l1DataAvailabilityModeFromJSON(object.l1DataAvailabilityMode) : 0
798
+ l1DataAvailabilityMode: isSet$1(object.l1DataAvailabilityMode) ? l1DataAvailabilityModeFromJSON(object.l1DataAvailabilityMode) : 0,
799
+ l2GasPrice: isSet$1(object.l2GasPrice) ? ResourcePrice$1.fromJSON(object.l2GasPrice) : void 0
748
800
  };
749
801
  },
750
802
  toJSON(message) {
@@ -779,6 +831,9 @@ const BlockHeader$1 = {
779
831
  if (message.l1DataAvailabilityMode !== void 0 && message.l1DataAvailabilityMode !== 0) {
780
832
  obj.l1DataAvailabilityMode = l1DataAvailabilityModeToJSON(message.l1DataAvailabilityMode);
781
833
  }
834
+ if (message.l2GasPrice !== void 0) {
835
+ obj.l2GasPrice = ResourcePrice$1.toJSON(message.l2GasPrice);
836
+ }
782
837
  return obj;
783
838
  },
784
839
  create(base) {
@@ -796,6 +851,7 @@ const BlockHeader$1 = {
796
851
  message.l1GasPrice = object.l1GasPrice !== void 0 && object.l1GasPrice !== null ? ResourcePrice$1.fromPartial(object.l1GasPrice) : void 0;
797
852
  message.l1DataGasPrice = object.l1DataGasPrice !== void 0 && object.l1DataGasPrice !== null ? ResourcePrice$1.fromPartial(object.l1DataGasPrice) : void 0;
798
853
  message.l1DataAvailabilityMode = object.l1DataAvailabilityMode ?? 0;
854
+ message.l2GasPrice = object.l2GasPrice !== void 0 && object.l2GasPrice !== null ? ResourcePrice$1.fromPartial(object.l2GasPrice) : void 0;
799
855
  return message;
800
856
  }
801
857
  };
@@ -4919,32 +4975,803 @@ const NonceUpdate$1 = {
4919
4975
  return message;
4920
4976
  }
4921
4977
  };
4922
- function bytesFromBase64(b64) {
4923
- if (globalThis.Buffer) {
4924
- return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
4925
- } else {
4926
- const bin = globalThis.atob(b64);
4927
- const arr = new Uint8Array(bin.length);
4928
- for (let i = 0; i < bin.length; ++i) {
4929
- arr[i] = bin.charCodeAt(i);
4978
+ function createBaseTransactionTrace() {
4979
+ return { filterIds: [], transactionIndex: 0, transactionHash: void 0, traceRoot: void 0 };
4980
+ }
4981
+ const TransactionTrace$1 = {
4982
+ encode(message, writer = _m0.Writer.create()) {
4983
+ if (message.filterIds !== void 0 && message.filterIds.length !== 0) {
4984
+ writer.uint32(10).fork();
4985
+ for (const v of message.filterIds) {
4986
+ writer.uint32(v);
4987
+ }
4988
+ writer.ldelim();
4930
4989
  }
4931
- return arr;
4990
+ if (message.transactionIndex !== void 0 && message.transactionIndex !== 0) {
4991
+ writer.uint32(16).uint32(message.transactionIndex);
4992
+ }
4993
+ if (message.transactionHash !== void 0) {
4994
+ FieldElement.encode(message.transactionHash, writer.uint32(26).fork()).ldelim();
4995
+ }
4996
+ switch (message.traceRoot?.$case) {
4997
+ case "invoke":
4998
+ InvokeTransactionTrace$1.encode(message.traceRoot.invoke, writer.uint32(34).fork()).ldelim();
4999
+ break;
5000
+ case "declare":
5001
+ DeclareTransactionTrace$1.encode(message.traceRoot.declare, writer.uint32(42).fork()).ldelim();
5002
+ break;
5003
+ case "deployAccount":
5004
+ DeployAccountTransactionTrace$1.encode(message.traceRoot.deployAccount, writer.uint32(50).fork()).ldelim();
5005
+ break;
5006
+ case "l1Handler":
5007
+ L1HandlerTransactionTrace$1.encode(message.traceRoot.l1Handler, writer.uint32(58).fork()).ldelim();
5008
+ break;
5009
+ }
5010
+ return writer;
5011
+ },
5012
+ decode(input, length) {
5013
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5014
+ let end = length === void 0 ? reader.len : reader.pos + length;
5015
+ const message = createBaseTransactionTrace();
5016
+ while (reader.pos < end) {
5017
+ const tag = reader.uint32();
5018
+ switch (tag >>> 3) {
5019
+ case 1:
5020
+ if (tag === 8) {
5021
+ message.filterIds.push(reader.uint32());
5022
+ continue;
5023
+ }
5024
+ if (tag === 10) {
5025
+ const end2 = reader.uint32() + reader.pos;
5026
+ while (reader.pos < end2) {
5027
+ message.filterIds.push(reader.uint32());
5028
+ }
5029
+ continue;
5030
+ }
5031
+ break;
5032
+ case 2:
5033
+ if (tag !== 16) {
5034
+ break;
5035
+ }
5036
+ message.transactionIndex = reader.uint32();
5037
+ continue;
5038
+ case 3:
5039
+ if (tag !== 26) {
5040
+ break;
5041
+ }
5042
+ message.transactionHash = FieldElement.decode(reader, reader.uint32());
5043
+ continue;
5044
+ case 4:
5045
+ if (tag !== 34) {
5046
+ break;
5047
+ }
5048
+ message.traceRoot = { $case: "invoke", invoke: InvokeTransactionTrace$1.decode(reader, reader.uint32()) };
5049
+ continue;
5050
+ case 5:
5051
+ if (tag !== 42) {
5052
+ break;
5053
+ }
5054
+ message.traceRoot = { $case: "declare", declare: DeclareTransactionTrace$1.decode(reader, reader.uint32()) };
5055
+ continue;
5056
+ case 6:
5057
+ if (tag !== 50) {
5058
+ break;
5059
+ }
5060
+ message.traceRoot = {
5061
+ $case: "deployAccount",
5062
+ deployAccount: DeployAccountTransactionTrace$1.decode(reader, reader.uint32())
5063
+ };
5064
+ continue;
5065
+ case 7:
5066
+ if (tag !== 58) {
5067
+ break;
5068
+ }
5069
+ message.traceRoot = {
5070
+ $case: "l1Handler",
5071
+ l1Handler: L1HandlerTransactionTrace$1.decode(reader, reader.uint32())
5072
+ };
5073
+ continue;
5074
+ }
5075
+ if ((tag & 7) === 4 || tag === 0) {
5076
+ break;
5077
+ }
5078
+ reader.skipType(tag & 7);
5079
+ }
5080
+ return message;
5081
+ },
5082
+ fromJSON(object) {
5083
+ return {
5084
+ filterIds: globalThis.Array.isArray(object?.filterIds) ? object.filterIds.map((e) => globalThis.Number(e)) : [],
5085
+ transactionIndex: isSet$1(object.transactionIndex) ? globalThis.Number(object.transactionIndex) : 0,
5086
+ transactionHash: isSet$1(object.transactionHash) ? FieldElement.fromJSON(object.transactionHash) : void 0,
5087
+ traceRoot: isSet$1(object.invoke) ? { $case: "invoke", invoke: InvokeTransactionTrace$1.fromJSON(object.invoke) } : isSet$1(object.declare) ? { $case: "declare", declare: DeclareTransactionTrace$1.fromJSON(object.declare) } : isSet$1(object.deployAccount) ? { $case: "deployAccount", deployAccount: DeployAccountTransactionTrace$1.fromJSON(object.deployAccount) } : isSet$1(object.l1Handler) ? { $case: "l1Handler", l1Handler: L1HandlerTransactionTrace$1.fromJSON(object.l1Handler) } : void 0
5088
+ };
5089
+ },
5090
+ toJSON(message) {
5091
+ const obj = {};
5092
+ if (message.filterIds?.length) {
5093
+ obj.filterIds = message.filterIds.map((e) => Math.round(e));
5094
+ }
5095
+ if (message.transactionIndex !== void 0 && message.transactionIndex !== 0) {
5096
+ obj.transactionIndex = Math.round(message.transactionIndex);
5097
+ }
5098
+ if (message.transactionHash !== void 0) {
5099
+ obj.transactionHash = FieldElement.toJSON(message.transactionHash);
5100
+ }
5101
+ if (message.traceRoot?.$case === "invoke") {
5102
+ obj.invoke = InvokeTransactionTrace$1.toJSON(message.traceRoot.invoke);
5103
+ }
5104
+ if (message.traceRoot?.$case === "declare") {
5105
+ obj.declare = DeclareTransactionTrace$1.toJSON(message.traceRoot.declare);
5106
+ }
5107
+ if (message.traceRoot?.$case === "deployAccount") {
5108
+ obj.deployAccount = DeployAccountTransactionTrace$1.toJSON(message.traceRoot.deployAccount);
5109
+ }
5110
+ if (message.traceRoot?.$case === "l1Handler") {
5111
+ obj.l1Handler = L1HandlerTransactionTrace$1.toJSON(message.traceRoot.l1Handler);
5112
+ }
5113
+ return obj;
5114
+ },
5115
+ create(base) {
5116
+ return TransactionTrace$1.fromPartial(base ?? {});
5117
+ },
5118
+ fromPartial(object) {
5119
+ const message = createBaseTransactionTrace();
5120
+ message.filterIds = object.filterIds?.map((e) => e) || [];
5121
+ message.transactionIndex = object.transactionIndex ?? 0;
5122
+ message.transactionHash = object.transactionHash !== void 0 && object.transactionHash !== null ? FieldElement.fromPartial(object.transactionHash) : void 0;
5123
+ if (object.traceRoot?.$case === "invoke" && object.traceRoot?.invoke !== void 0 && object.traceRoot?.invoke !== null) {
5124
+ message.traceRoot = { $case: "invoke", invoke: InvokeTransactionTrace$1.fromPartial(object.traceRoot.invoke) };
5125
+ }
5126
+ if (object.traceRoot?.$case === "declare" && object.traceRoot?.declare !== void 0 && object.traceRoot?.declare !== null) {
5127
+ message.traceRoot = { $case: "declare", declare: DeclareTransactionTrace$1.fromPartial(object.traceRoot.declare) };
5128
+ }
5129
+ if (object.traceRoot?.$case === "deployAccount" && object.traceRoot?.deployAccount !== void 0 && object.traceRoot?.deployAccount !== null) {
5130
+ message.traceRoot = {
5131
+ $case: "deployAccount",
5132
+ deployAccount: DeployAccountTransactionTrace$1.fromPartial(object.traceRoot.deployAccount)
5133
+ };
5134
+ }
5135
+ if (object.traceRoot?.$case === "l1Handler" && object.traceRoot?.l1Handler !== void 0 && object.traceRoot?.l1Handler !== null) {
5136
+ message.traceRoot = {
5137
+ $case: "l1Handler",
5138
+ l1Handler: L1HandlerTransactionTrace$1.fromPartial(object.traceRoot.l1Handler)
5139
+ };
5140
+ }
5141
+ return message;
4932
5142
  }
5143
+ };
5144
+ function createBaseInvokeTransactionTrace() {
5145
+ return { validateInvocation: void 0, executeInvocation: void 0, feeTransferInvocation: void 0 };
4933
5146
  }
4934
- function base64FromBytes(arr) {
4935
- if (globalThis.Buffer) {
4936
- return globalThis.Buffer.from(arr).toString("base64");
4937
- } else {
4938
- const bin = [];
4939
- arr.forEach((byte) => {
4940
- bin.push(globalThis.String.fromCharCode(byte));
4941
- });
4942
- return globalThis.btoa(bin.join(""));
5147
+ const InvokeTransactionTrace$1 = {
5148
+ encode(message, writer = _m0.Writer.create()) {
5149
+ if (message.validateInvocation !== void 0) {
5150
+ FunctionInvocation.encode(message.validateInvocation, writer.uint32(10).fork()).ldelim();
5151
+ }
5152
+ switch (message.executeInvocation?.$case) {
5153
+ case "success":
5154
+ FunctionInvocation.encode(message.executeInvocation.success, writer.uint32(18).fork()).ldelim();
5155
+ break;
5156
+ case "reverted":
5157
+ ExecutionReverted$1.encode(message.executeInvocation.reverted, writer.uint32(26).fork()).ldelim();
5158
+ break;
5159
+ }
5160
+ if (message.feeTransferInvocation !== void 0) {
5161
+ FunctionInvocation.encode(message.feeTransferInvocation, writer.uint32(34).fork()).ldelim();
5162
+ }
5163
+ return writer;
5164
+ },
5165
+ decode(input, length) {
5166
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5167
+ let end = length === void 0 ? reader.len : reader.pos + length;
5168
+ const message = createBaseInvokeTransactionTrace();
5169
+ while (reader.pos < end) {
5170
+ const tag = reader.uint32();
5171
+ switch (tag >>> 3) {
5172
+ case 1:
5173
+ if (tag !== 10) {
5174
+ break;
5175
+ }
5176
+ message.validateInvocation = FunctionInvocation.decode(reader, reader.uint32());
5177
+ continue;
5178
+ case 2:
5179
+ if (tag !== 18) {
5180
+ break;
5181
+ }
5182
+ message.executeInvocation = { $case: "success", success: FunctionInvocation.decode(reader, reader.uint32()) };
5183
+ continue;
5184
+ case 3:
5185
+ if (tag !== 26) {
5186
+ break;
5187
+ }
5188
+ message.executeInvocation = {
5189
+ $case: "reverted",
5190
+ reverted: ExecutionReverted$1.decode(reader, reader.uint32())
5191
+ };
5192
+ continue;
5193
+ case 4:
5194
+ if (tag !== 34) {
5195
+ break;
5196
+ }
5197
+ message.feeTransferInvocation = FunctionInvocation.decode(reader, reader.uint32());
5198
+ continue;
5199
+ }
5200
+ if ((tag & 7) === 4 || tag === 0) {
5201
+ break;
5202
+ }
5203
+ reader.skipType(tag & 7);
5204
+ }
5205
+ return message;
5206
+ },
5207
+ fromJSON(object) {
5208
+ return {
5209
+ validateInvocation: isSet$1(object.validateInvocation) ? FunctionInvocation.fromJSON(object.validateInvocation) : void 0,
5210
+ executeInvocation: isSet$1(object.success) ? { $case: "success", success: FunctionInvocation.fromJSON(object.success) } : isSet$1(object.reverted) ? { $case: "reverted", reverted: ExecutionReverted$1.fromJSON(object.reverted) } : void 0,
5211
+ feeTransferInvocation: isSet$1(object.feeTransferInvocation) ? FunctionInvocation.fromJSON(object.feeTransferInvocation) : void 0
5212
+ };
5213
+ },
5214
+ toJSON(message) {
5215
+ const obj = {};
5216
+ if (message.validateInvocation !== void 0) {
5217
+ obj.validateInvocation = FunctionInvocation.toJSON(message.validateInvocation);
5218
+ }
5219
+ if (message.executeInvocation?.$case === "success") {
5220
+ obj.success = FunctionInvocation.toJSON(message.executeInvocation.success);
5221
+ }
5222
+ if (message.executeInvocation?.$case === "reverted") {
5223
+ obj.reverted = ExecutionReverted$1.toJSON(message.executeInvocation.reverted);
5224
+ }
5225
+ if (message.feeTransferInvocation !== void 0) {
5226
+ obj.feeTransferInvocation = FunctionInvocation.toJSON(message.feeTransferInvocation);
5227
+ }
5228
+ return obj;
5229
+ },
5230
+ create(base) {
5231
+ return InvokeTransactionTrace$1.fromPartial(base ?? {});
5232
+ },
5233
+ fromPartial(object) {
5234
+ const message = createBaseInvokeTransactionTrace();
5235
+ message.validateInvocation = object.validateInvocation !== void 0 && object.validateInvocation !== null ? FunctionInvocation.fromPartial(object.validateInvocation) : void 0;
5236
+ if (object.executeInvocation?.$case === "success" && object.executeInvocation?.success !== void 0 && object.executeInvocation?.success !== null) {
5237
+ message.executeInvocation = {
5238
+ $case: "success",
5239
+ success: FunctionInvocation.fromPartial(object.executeInvocation.success)
5240
+ };
5241
+ }
5242
+ if (object.executeInvocation?.$case === "reverted" && object.executeInvocation?.reverted !== void 0 && object.executeInvocation?.reverted !== null) {
5243
+ message.executeInvocation = {
5244
+ $case: "reverted",
5245
+ reverted: ExecutionReverted$1.fromPartial(object.executeInvocation.reverted)
5246
+ };
5247
+ }
5248
+ message.feeTransferInvocation = object.feeTransferInvocation !== void 0 && object.feeTransferInvocation !== null ? FunctionInvocation.fromPartial(object.feeTransferInvocation) : void 0;
5249
+ return message;
4943
5250
  }
5251
+ };
5252
+ function createBaseDeclareTransactionTrace() {
5253
+ return { validateInvocation: void 0, feeTransferInvocation: void 0 };
4944
5254
  }
4945
- function toTimestamp(date) {
4946
- const seconds = BigInt(Math.trunc(date.getTime() / 1e3));
4947
- const nanos = date.getTime() % 1e3 * 1e6;
5255
+ const DeclareTransactionTrace$1 = {
5256
+ encode(message, writer = _m0.Writer.create()) {
5257
+ if (message.validateInvocation !== void 0) {
5258
+ FunctionInvocation.encode(message.validateInvocation, writer.uint32(10).fork()).ldelim();
5259
+ }
5260
+ if (message.feeTransferInvocation !== void 0) {
5261
+ FunctionInvocation.encode(message.feeTransferInvocation, writer.uint32(18).fork()).ldelim();
5262
+ }
5263
+ return writer;
5264
+ },
5265
+ decode(input, length) {
5266
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5267
+ let end = length === void 0 ? reader.len : reader.pos + length;
5268
+ const message = createBaseDeclareTransactionTrace();
5269
+ while (reader.pos < end) {
5270
+ const tag = reader.uint32();
5271
+ switch (tag >>> 3) {
5272
+ case 1:
5273
+ if (tag !== 10) {
5274
+ break;
5275
+ }
5276
+ message.validateInvocation = FunctionInvocation.decode(reader, reader.uint32());
5277
+ continue;
5278
+ case 2:
5279
+ if (tag !== 18) {
5280
+ break;
5281
+ }
5282
+ message.feeTransferInvocation = FunctionInvocation.decode(reader, reader.uint32());
5283
+ continue;
5284
+ }
5285
+ if ((tag & 7) === 4 || tag === 0) {
5286
+ break;
5287
+ }
5288
+ reader.skipType(tag & 7);
5289
+ }
5290
+ return message;
5291
+ },
5292
+ fromJSON(object) {
5293
+ return {
5294
+ validateInvocation: isSet$1(object.validateInvocation) ? FunctionInvocation.fromJSON(object.validateInvocation) : void 0,
5295
+ feeTransferInvocation: isSet$1(object.feeTransferInvocation) ? FunctionInvocation.fromJSON(object.feeTransferInvocation) : void 0
5296
+ };
5297
+ },
5298
+ toJSON(message) {
5299
+ const obj = {};
5300
+ if (message.validateInvocation !== void 0) {
5301
+ obj.validateInvocation = FunctionInvocation.toJSON(message.validateInvocation);
5302
+ }
5303
+ if (message.feeTransferInvocation !== void 0) {
5304
+ obj.feeTransferInvocation = FunctionInvocation.toJSON(message.feeTransferInvocation);
5305
+ }
5306
+ return obj;
5307
+ },
5308
+ create(base) {
5309
+ return DeclareTransactionTrace$1.fromPartial(base ?? {});
5310
+ },
5311
+ fromPartial(object) {
5312
+ const message = createBaseDeclareTransactionTrace();
5313
+ message.validateInvocation = object.validateInvocation !== void 0 && object.validateInvocation !== null ? FunctionInvocation.fromPartial(object.validateInvocation) : void 0;
5314
+ message.feeTransferInvocation = object.feeTransferInvocation !== void 0 && object.feeTransferInvocation !== null ? FunctionInvocation.fromPartial(object.feeTransferInvocation) : void 0;
5315
+ return message;
5316
+ }
5317
+ };
5318
+ function createBaseDeployAccountTransactionTrace() {
5319
+ return { validateInvocation: void 0, constructorInvocation: void 0, feeTransferInvocation: void 0 };
5320
+ }
5321
+ const DeployAccountTransactionTrace$1 = {
5322
+ encode(message, writer = _m0.Writer.create()) {
5323
+ if (message.validateInvocation !== void 0) {
5324
+ FunctionInvocation.encode(message.validateInvocation, writer.uint32(10).fork()).ldelim();
5325
+ }
5326
+ if (message.constructorInvocation !== void 0) {
5327
+ FunctionInvocation.encode(message.constructorInvocation, writer.uint32(18).fork()).ldelim();
5328
+ }
5329
+ if (message.feeTransferInvocation !== void 0) {
5330
+ FunctionInvocation.encode(message.feeTransferInvocation, writer.uint32(26).fork()).ldelim();
5331
+ }
5332
+ return writer;
5333
+ },
5334
+ decode(input, length) {
5335
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5336
+ let end = length === void 0 ? reader.len : reader.pos + length;
5337
+ const message = createBaseDeployAccountTransactionTrace();
5338
+ while (reader.pos < end) {
5339
+ const tag = reader.uint32();
5340
+ switch (tag >>> 3) {
5341
+ case 1:
5342
+ if (tag !== 10) {
5343
+ break;
5344
+ }
5345
+ message.validateInvocation = FunctionInvocation.decode(reader, reader.uint32());
5346
+ continue;
5347
+ case 2:
5348
+ if (tag !== 18) {
5349
+ break;
5350
+ }
5351
+ message.constructorInvocation = FunctionInvocation.decode(reader, reader.uint32());
5352
+ continue;
5353
+ case 3:
5354
+ if (tag !== 26) {
5355
+ break;
5356
+ }
5357
+ message.feeTransferInvocation = FunctionInvocation.decode(reader, reader.uint32());
5358
+ continue;
5359
+ }
5360
+ if ((tag & 7) === 4 || tag === 0) {
5361
+ break;
5362
+ }
5363
+ reader.skipType(tag & 7);
5364
+ }
5365
+ return message;
5366
+ },
5367
+ fromJSON(object) {
5368
+ return {
5369
+ validateInvocation: isSet$1(object.validateInvocation) ? FunctionInvocation.fromJSON(object.validateInvocation) : void 0,
5370
+ constructorInvocation: isSet$1(object.constructorInvocation) ? FunctionInvocation.fromJSON(object.constructorInvocation) : void 0,
5371
+ feeTransferInvocation: isSet$1(object.feeTransferInvocation) ? FunctionInvocation.fromJSON(object.feeTransferInvocation) : void 0
5372
+ };
5373
+ },
5374
+ toJSON(message) {
5375
+ const obj = {};
5376
+ if (message.validateInvocation !== void 0) {
5377
+ obj.validateInvocation = FunctionInvocation.toJSON(message.validateInvocation);
5378
+ }
5379
+ if (message.constructorInvocation !== void 0) {
5380
+ obj.constructorInvocation = FunctionInvocation.toJSON(message.constructorInvocation);
5381
+ }
5382
+ if (message.feeTransferInvocation !== void 0) {
5383
+ obj.feeTransferInvocation = FunctionInvocation.toJSON(message.feeTransferInvocation);
5384
+ }
5385
+ return obj;
5386
+ },
5387
+ create(base) {
5388
+ return DeployAccountTransactionTrace$1.fromPartial(base ?? {});
5389
+ },
5390
+ fromPartial(object) {
5391
+ const message = createBaseDeployAccountTransactionTrace();
5392
+ message.validateInvocation = object.validateInvocation !== void 0 && object.validateInvocation !== null ? FunctionInvocation.fromPartial(object.validateInvocation) : void 0;
5393
+ message.constructorInvocation = object.constructorInvocation !== void 0 && object.constructorInvocation !== null ? FunctionInvocation.fromPartial(object.constructorInvocation) : void 0;
5394
+ message.feeTransferInvocation = object.feeTransferInvocation !== void 0 && object.feeTransferInvocation !== null ? FunctionInvocation.fromPartial(object.feeTransferInvocation) : void 0;
5395
+ return message;
5396
+ }
5397
+ };
5398
+ function createBaseL1HandlerTransactionTrace() {
5399
+ return { functionInvocation: void 0 };
5400
+ }
5401
+ const L1HandlerTransactionTrace$1 = {
5402
+ encode(message, writer = _m0.Writer.create()) {
5403
+ if (message.functionInvocation !== void 0) {
5404
+ FunctionInvocation.encode(message.functionInvocation, writer.uint32(18).fork()).ldelim();
5405
+ }
5406
+ return writer;
5407
+ },
5408
+ decode(input, length) {
5409
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5410
+ let end = length === void 0 ? reader.len : reader.pos + length;
5411
+ const message = createBaseL1HandlerTransactionTrace();
5412
+ while (reader.pos < end) {
5413
+ const tag = reader.uint32();
5414
+ switch (tag >>> 3) {
5415
+ case 2:
5416
+ if (tag !== 18) {
5417
+ break;
5418
+ }
5419
+ message.functionInvocation = FunctionInvocation.decode(reader, reader.uint32());
5420
+ continue;
5421
+ }
5422
+ if ((tag & 7) === 4 || tag === 0) {
5423
+ break;
5424
+ }
5425
+ reader.skipType(tag & 7);
5426
+ }
5427
+ return message;
5428
+ },
5429
+ fromJSON(object) {
5430
+ return {
5431
+ functionInvocation: isSet$1(object.functionInvocation) ? FunctionInvocation.fromJSON(object.functionInvocation) : void 0
5432
+ };
5433
+ },
5434
+ toJSON(message) {
5435
+ const obj = {};
5436
+ if (message.functionInvocation !== void 0) {
5437
+ obj.functionInvocation = FunctionInvocation.toJSON(message.functionInvocation);
5438
+ }
5439
+ return obj;
5440
+ },
5441
+ create(base) {
5442
+ return L1HandlerTransactionTrace$1.fromPartial(base ?? {});
5443
+ },
5444
+ fromPartial(object) {
5445
+ const message = createBaseL1HandlerTransactionTrace();
5446
+ message.functionInvocation = object.functionInvocation !== void 0 && object.functionInvocation !== null ? FunctionInvocation.fromPartial(object.functionInvocation) : void 0;
5447
+ return message;
5448
+ }
5449
+ };
5450
+ function createBaseFunctionInvocation() {
5451
+ return {
5452
+ contractAddress: void 0,
5453
+ entryPointSelector: void 0,
5454
+ calldata: [],
5455
+ callerAddress: void 0,
5456
+ classHash: void 0,
5457
+ callType: 0,
5458
+ result: [],
5459
+ calls: [],
5460
+ events: [],
5461
+ messages: []
5462
+ };
5463
+ }
5464
+ const FunctionInvocation = {
5465
+ encode(message, writer = _m0.Writer.create()) {
5466
+ if (message.contractAddress !== void 0) {
5467
+ FieldElement.encode(message.contractAddress, writer.uint32(10).fork()).ldelim();
5468
+ }
5469
+ if (message.entryPointSelector !== void 0) {
5470
+ FieldElement.encode(message.entryPointSelector, writer.uint32(18).fork()).ldelim();
5471
+ }
5472
+ if (message.calldata !== void 0 && message.calldata.length !== 0) {
5473
+ for (const v of message.calldata) {
5474
+ FieldElement.encode(v, writer.uint32(26).fork()).ldelim();
5475
+ }
5476
+ }
5477
+ if (message.callerAddress !== void 0) {
5478
+ FieldElement.encode(message.callerAddress, writer.uint32(34).fork()).ldelim();
5479
+ }
5480
+ if (message.classHash !== void 0) {
5481
+ FieldElement.encode(message.classHash, writer.uint32(42).fork()).ldelim();
5482
+ }
5483
+ if (message.callType !== void 0 && message.callType !== 0) {
5484
+ writer.uint32(48).int32(message.callType);
5485
+ }
5486
+ if (message.result !== void 0 && message.result.length !== 0) {
5487
+ for (const v of message.result) {
5488
+ FieldElement.encode(v, writer.uint32(58).fork()).ldelim();
5489
+ }
5490
+ }
5491
+ if (message.calls !== void 0 && message.calls.length !== 0) {
5492
+ for (const v of message.calls) {
5493
+ FunctionInvocation.encode(v, writer.uint32(66).fork()).ldelim();
5494
+ }
5495
+ }
5496
+ if (message.events !== void 0 && message.events.length !== 0) {
5497
+ writer.uint32(74).fork();
5498
+ for (const v of message.events) {
5499
+ writer.uint32(v);
5500
+ }
5501
+ writer.ldelim();
5502
+ }
5503
+ if (message.messages !== void 0 && message.messages.length !== 0) {
5504
+ writer.uint32(82).fork();
5505
+ for (const v of message.messages) {
5506
+ writer.uint32(v);
5507
+ }
5508
+ writer.ldelim();
5509
+ }
5510
+ return writer;
5511
+ },
5512
+ decode(input, length) {
5513
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5514
+ let end = length === void 0 ? reader.len : reader.pos + length;
5515
+ const message = createBaseFunctionInvocation();
5516
+ while (reader.pos < end) {
5517
+ const tag = reader.uint32();
5518
+ switch (tag >>> 3) {
5519
+ case 1:
5520
+ if (tag !== 10) {
5521
+ break;
5522
+ }
5523
+ message.contractAddress = FieldElement.decode(reader, reader.uint32());
5524
+ continue;
5525
+ case 2:
5526
+ if (tag !== 18) {
5527
+ break;
5528
+ }
5529
+ message.entryPointSelector = FieldElement.decode(reader, reader.uint32());
5530
+ continue;
5531
+ case 3:
5532
+ if (tag !== 26) {
5533
+ break;
5534
+ }
5535
+ message.calldata.push(FieldElement.decode(reader, reader.uint32()));
5536
+ continue;
5537
+ case 4:
5538
+ if (tag !== 34) {
5539
+ break;
5540
+ }
5541
+ message.callerAddress = FieldElement.decode(reader, reader.uint32());
5542
+ continue;
5543
+ case 5:
5544
+ if (tag !== 42) {
5545
+ break;
5546
+ }
5547
+ message.classHash = FieldElement.decode(reader, reader.uint32());
5548
+ continue;
5549
+ case 6:
5550
+ if (tag !== 48) {
5551
+ break;
5552
+ }
5553
+ message.callType = reader.int32();
5554
+ continue;
5555
+ case 7:
5556
+ if (tag !== 58) {
5557
+ break;
5558
+ }
5559
+ message.result.push(FieldElement.decode(reader, reader.uint32()));
5560
+ continue;
5561
+ case 8:
5562
+ if (tag !== 66) {
5563
+ break;
5564
+ }
5565
+ message.calls.push(FunctionInvocation.decode(reader, reader.uint32()));
5566
+ continue;
5567
+ case 9:
5568
+ if (tag === 72) {
5569
+ message.events.push(reader.uint32());
5570
+ continue;
5571
+ }
5572
+ if (tag === 74) {
5573
+ const end2 = reader.uint32() + reader.pos;
5574
+ while (reader.pos < end2) {
5575
+ message.events.push(reader.uint32());
5576
+ }
5577
+ continue;
5578
+ }
5579
+ break;
5580
+ case 10:
5581
+ if (tag === 80) {
5582
+ message.messages.push(reader.uint32());
5583
+ continue;
5584
+ }
5585
+ if (tag === 82) {
5586
+ const end2 = reader.uint32() + reader.pos;
5587
+ while (reader.pos < end2) {
5588
+ message.messages.push(reader.uint32());
5589
+ }
5590
+ continue;
5591
+ }
5592
+ break;
5593
+ }
5594
+ if ((tag & 7) === 4 || tag === 0) {
5595
+ break;
5596
+ }
5597
+ reader.skipType(tag & 7);
5598
+ }
5599
+ return message;
5600
+ },
5601
+ fromJSON(object) {
5602
+ return {
5603
+ contractAddress: isSet$1(object.contractAddress) ? FieldElement.fromJSON(object.contractAddress) : void 0,
5604
+ entryPointSelector: isSet$1(object.entryPointSelector) ? FieldElement.fromJSON(object.entryPointSelector) : void 0,
5605
+ calldata: globalThis.Array.isArray(object?.calldata) ? object.calldata.map((e) => FieldElement.fromJSON(e)) : [],
5606
+ callerAddress: isSet$1(object.callerAddress) ? FieldElement.fromJSON(object.callerAddress) : void 0,
5607
+ classHash: isSet$1(object.classHash) ? FieldElement.fromJSON(object.classHash) : void 0,
5608
+ callType: isSet$1(object.callType) ? callTypeFromJSON(object.callType) : 0,
5609
+ result: globalThis.Array.isArray(object?.result) ? object.result.map((e) => FieldElement.fromJSON(e)) : [],
5610
+ calls: globalThis.Array.isArray(object?.calls) ? object.calls.map((e) => FunctionInvocation.fromJSON(e)) : [],
5611
+ events: globalThis.Array.isArray(object?.events) ? object.events.map((e) => globalThis.Number(e)) : [],
5612
+ messages: globalThis.Array.isArray(object?.messages) ? object.messages.map((e) => globalThis.Number(e)) : []
5613
+ };
5614
+ },
5615
+ toJSON(message) {
5616
+ const obj = {};
5617
+ if (message.contractAddress !== void 0) {
5618
+ obj.contractAddress = FieldElement.toJSON(message.contractAddress);
5619
+ }
5620
+ if (message.entryPointSelector !== void 0) {
5621
+ obj.entryPointSelector = FieldElement.toJSON(message.entryPointSelector);
5622
+ }
5623
+ if (message.calldata?.length) {
5624
+ obj.calldata = message.calldata.map((e) => FieldElement.toJSON(e));
5625
+ }
5626
+ if (message.callerAddress !== void 0) {
5627
+ obj.callerAddress = FieldElement.toJSON(message.callerAddress);
5628
+ }
5629
+ if (message.classHash !== void 0) {
5630
+ obj.classHash = FieldElement.toJSON(message.classHash);
5631
+ }
5632
+ if (message.callType !== void 0 && message.callType !== 0) {
5633
+ obj.callType = callTypeToJSON(message.callType);
5634
+ }
5635
+ if (message.result?.length) {
5636
+ obj.result = message.result.map((e) => FieldElement.toJSON(e));
5637
+ }
5638
+ if (message.calls?.length) {
5639
+ obj.calls = message.calls.map((e) => FunctionInvocation.toJSON(e));
5640
+ }
5641
+ if (message.events?.length) {
5642
+ obj.events = message.events.map((e) => Math.round(e));
5643
+ }
5644
+ if (message.messages?.length) {
5645
+ obj.messages = message.messages.map((e) => Math.round(e));
5646
+ }
5647
+ return obj;
5648
+ },
5649
+ create(base) {
5650
+ return FunctionInvocation.fromPartial(base ?? {});
5651
+ },
5652
+ fromPartial(object) {
5653
+ const message = createBaseFunctionInvocation();
5654
+ message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? FieldElement.fromPartial(object.contractAddress) : void 0;
5655
+ message.entryPointSelector = object.entryPointSelector !== void 0 && object.entryPointSelector !== null ? FieldElement.fromPartial(object.entryPointSelector) : void 0;
5656
+ message.calldata = object.calldata?.map((e) => FieldElement.fromPartial(e)) || [];
5657
+ message.callerAddress = object.callerAddress !== void 0 && object.callerAddress !== null ? FieldElement.fromPartial(object.callerAddress) : void 0;
5658
+ message.classHash = object.classHash !== void 0 && object.classHash !== null ? FieldElement.fromPartial(object.classHash) : void 0;
5659
+ message.callType = object.callType ?? 0;
5660
+ message.result = object.result?.map((e) => FieldElement.fromPartial(e)) || [];
5661
+ message.calls = object.calls?.map((e) => FunctionInvocation.fromPartial(e)) || [];
5662
+ message.events = object.events?.map((e) => e) || [];
5663
+ message.messages = object.messages?.map((e) => e) || [];
5664
+ return message;
5665
+ }
5666
+ };
5667
+ function createBaseFunctionCall() {
5668
+ return { contractAddress: void 0, entryPointSelector: void 0, calldata: [] };
5669
+ }
5670
+ const FunctionCall = {
5671
+ encode(message, writer = _m0.Writer.create()) {
5672
+ if (message.contractAddress !== void 0) {
5673
+ FieldElement.encode(message.contractAddress, writer.uint32(10).fork()).ldelim();
5674
+ }
5675
+ if (message.entryPointSelector !== void 0) {
5676
+ FieldElement.encode(message.entryPointSelector, writer.uint32(18).fork()).ldelim();
5677
+ }
5678
+ if (message.calldata !== void 0 && message.calldata.length !== 0) {
5679
+ for (const v of message.calldata) {
5680
+ FieldElement.encode(v, writer.uint32(26).fork()).ldelim();
5681
+ }
5682
+ }
5683
+ return writer;
5684
+ },
5685
+ decode(input, length) {
5686
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5687
+ let end = length === void 0 ? reader.len : reader.pos + length;
5688
+ const message = createBaseFunctionCall();
5689
+ while (reader.pos < end) {
5690
+ const tag = reader.uint32();
5691
+ switch (tag >>> 3) {
5692
+ case 1:
5693
+ if (tag !== 10) {
5694
+ break;
5695
+ }
5696
+ message.contractAddress = FieldElement.decode(reader, reader.uint32());
5697
+ continue;
5698
+ case 2:
5699
+ if (tag !== 18) {
5700
+ break;
5701
+ }
5702
+ message.entryPointSelector = FieldElement.decode(reader, reader.uint32());
5703
+ continue;
5704
+ case 3:
5705
+ if (tag !== 26) {
5706
+ break;
5707
+ }
5708
+ message.calldata.push(FieldElement.decode(reader, reader.uint32()));
5709
+ continue;
5710
+ }
5711
+ if ((tag & 7) === 4 || tag === 0) {
5712
+ break;
5713
+ }
5714
+ reader.skipType(tag & 7);
5715
+ }
5716
+ return message;
5717
+ },
5718
+ fromJSON(object) {
5719
+ return {
5720
+ contractAddress: isSet$1(object.contractAddress) ? FieldElement.fromJSON(object.contractAddress) : void 0,
5721
+ entryPointSelector: isSet$1(object.entryPointSelector) ? FieldElement.fromJSON(object.entryPointSelector) : void 0,
5722
+ calldata: globalThis.Array.isArray(object?.calldata) ? object.calldata.map((e) => FieldElement.fromJSON(e)) : []
5723
+ };
5724
+ },
5725
+ toJSON(message) {
5726
+ const obj = {};
5727
+ if (message.contractAddress !== void 0) {
5728
+ obj.contractAddress = FieldElement.toJSON(message.contractAddress);
5729
+ }
5730
+ if (message.entryPointSelector !== void 0) {
5731
+ obj.entryPointSelector = FieldElement.toJSON(message.entryPointSelector);
5732
+ }
5733
+ if (message.calldata?.length) {
5734
+ obj.calldata = message.calldata.map((e) => FieldElement.toJSON(e));
5735
+ }
5736
+ return obj;
5737
+ },
5738
+ create(base) {
5739
+ return FunctionCall.fromPartial(base ?? {});
5740
+ },
5741
+ fromPartial(object) {
5742
+ const message = createBaseFunctionCall();
5743
+ message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? FieldElement.fromPartial(object.contractAddress) : void 0;
5744
+ message.entryPointSelector = object.entryPointSelector !== void 0 && object.entryPointSelector !== null ? FieldElement.fromPartial(object.entryPointSelector) : void 0;
5745
+ message.calldata = object.calldata?.map((e) => FieldElement.fromPartial(e)) || [];
5746
+ return message;
5747
+ }
5748
+ };
5749
+ function bytesFromBase64(b64) {
5750
+ if (globalThis.Buffer) {
5751
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
5752
+ } else {
5753
+ const bin = globalThis.atob(b64);
5754
+ const arr = new Uint8Array(bin.length);
5755
+ for (let i = 0; i < bin.length; ++i) {
5756
+ arr[i] = bin.charCodeAt(i);
5757
+ }
5758
+ return arr;
5759
+ }
5760
+ }
5761
+ function base64FromBytes(arr) {
5762
+ if (globalThis.Buffer) {
5763
+ return globalThis.Buffer.from(arr).toString("base64");
5764
+ } else {
5765
+ const bin = [];
5766
+ arr.forEach((byte) => {
5767
+ bin.push(globalThis.String.fromCharCode(byte));
5768
+ });
5769
+ return globalThis.btoa(bin.join(""));
5770
+ }
5771
+ }
5772
+ function toTimestamp(date) {
5773
+ const seconds = BigInt(Math.trunc(date.getTime() / 1e3));
5774
+ const nanos = date.getTime() % 1e3 * 1e6;
4948
5775
  return { seconds, nanos };
4949
5776
  }
4950
5777
  function fromTimestamp(t) {
@@ -4976,17 +5803,20 @@ const data = {
4976
5803
  __proto__: null,
4977
5804
  Block: Block$1,
4978
5805
  BlockHeader: BlockHeader$1,
5806
+ CallType: CallType$1,
4979
5807
  ComputationResources: ComputationResources$1,
4980
5808
  ContractChange: ContractChange$1,
4981
5809
  DataAvailabilityMode: DataAvailabilityMode$1,
4982
5810
  DataAvailabilityResources: DataAvailabilityResources$1,
4983
5811
  DeclareTransactionReceipt: DeclareTransactionReceipt$1,
5812
+ DeclareTransactionTrace: DeclareTransactionTrace$1,
4984
5813
  DeclareTransactionV0: DeclareTransactionV0$1,
4985
5814
  DeclareTransactionV1: DeclareTransactionV1$1,
4986
5815
  DeclareTransactionV2: DeclareTransactionV2$1,
4987
5816
  DeclareTransactionV3: DeclareTransactionV3$1,
4988
5817
  DeclaredClass: DeclaredClass$1,
4989
5818
  DeployAccountTransactionReceipt: DeployAccountTransactionReceipt$1,
5819
+ DeployAccountTransactionTrace: DeployAccountTransactionTrace$1,
4990
5820
  DeployAccountTransactionV1: DeployAccountTransactionV1$1,
4991
5821
  DeployAccountTransactionV3: DeployAccountTransactionV3$1,
4992
5822
  DeployTransaction: DeployTransaction$1,
@@ -4998,13 +5828,17 @@ const data = {
4998
5828
  ExecutionStatus: ExecutionStatus,
4999
5829
  ExecutionSucceeded: ExecutionSucceeded$1,
5000
5830
  FeePayment: FeePayment$1,
5831
+ FunctionCall: FunctionCall,
5832
+ FunctionInvocation: FunctionInvocation,
5001
5833
  InvokeTransactionReceipt: InvokeTransactionReceipt$1,
5834
+ InvokeTransactionTrace: InvokeTransactionTrace$1,
5002
5835
  InvokeTransactionV0: InvokeTransactionV0$1,
5003
5836
  InvokeTransactionV1: InvokeTransactionV1$1,
5004
5837
  InvokeTransactionV3: InvokeTransactionV3$1,
5005
5838
  L1DataAvailabilityMode: L1DataAvailabilityMode$1,
5006
5839
  L1HandlerTransaction: L1HandlerTransaction$1,
5007
5840
  L1HandlerTransactionReceipt: L1HandlerTransactionReceipt$1,
5841
+ L1HandlerTransactionTrace: L1HandlerTransactionTrace$1,
5008
5842
  MessageToL1: MessageToL1$1,
5009
5843
  NonceUpdate: NonceUpdate$1,
5010
5844
  PriceUnit: PriceUnit$1,
@@ -5019,7 +5853,10 @@ const data = {
5019
5853
  TransactionReceipt: TransactionReceipt$1,
5020
5854
  TransactionReceiptMeta: TransactionReceiptMeta$1,
5021
5855
  TransactionStatus: TransactionStatus$1,
5856
+ TransactionTrace: TransactionTrace$1,
5022
5857
  Uint128: Uint128,
5858
+ callTypeFromJSON: callTypeFromJSON,
5859
+ callTypeToJSON: callTypeToJSON,
5023
5860
  dataAvailabilityModeFromJSON: dataAvailabilityModeFromJSON,
5024
5861
  dataAvailabilityModeToJSON: dataAvailabilityModeToJSON,
5025
5862
  executionStatusFromJSON: executionStatusFromJSON,
@@ -5286,7 +6123,8 @@ function createBaseEventFilter() {
5286
6123
  includeTransaction: void 0,
5287
6124
  includeReceipt: void 0,
5288
6125
  includeMessages: void 0,
5289
- includeSiblings: void 0
6126
+ includeSiblings: void 0,
6127
+ includeTransactionTrace: void 0
5290
6128
  };
5291
6129
  }
5292
6130
  const EventFilter$1 = {
@@ -5320,6 +6158,9 @@ const EventFilter$1 = {
5320
6158
  if (message.includeSiblings !== void 0) {
5321
6159
  writer.uint32(72).bool(message.includeSiblings);
5322
6160
  }
6161
+ if (message.includeTransactionTrace !== void 0) {
6162
+ writer.uint32(80).bool(message.includeTransactionTrace);
6163
+ }
5323
6164
  return writer;
5324
6165
  },
5325
6166
  decode(input, length) {
@@ -5383,6 +6224,12 @@ const EventFilter$1 = {
5383
6224
  }
5384
6225
  message.includeSiblings = reader.bool();
5385
6226
  continue;
6227
+ case 10:
6228
+ if (tag !== 80) {
6229
+ break;
6230
+ }
6231
+ message.includeTransactionTrace = reader.bool();
6232
+ continue;
5386
6233
  }
5387
6234
  if ((tag & 7) === 4 || tag === 0) {
5388
6235
  break;
@@ -5401,7 +6248,8 @@ const EventFilter$1 = {
5401
6248
  includeTransaction: isSet(object.includeTransaction) ? globalThis.Boolean(object.includeTransaction) : void 0,
5402
6249
  includeReceipt: isSet(object.includeReceipt) ? globalThis.Boolean(object.includeReceipt) : void 0,
5403
6250
  includeMessages: isSet(object.includeMessages) ? globalThis.Boolean(object.includeMessages) : void 0,
5404
- includeSiblings: isSet(object.includeSiblings) ? globalThis.Boolean(object.includeSiblings) : void 0
6251
+ includeSiblings: isSet(object.includeSiblings) ? globalThis.Boolean(object.includeSiblings) : void 0,
6252
+ includeTransactionTrace: isSet(object.includeTransactionTrace) ? globalThis.Boolean(object.includeTransactionTrace) : void 0
5405
6253
  };
5406
6254
  },
5407
6255
  toJSON(message) {
@@ -5433,6 +6281,9 @@ const EventFilter$1 = {
5433
6281
  if (message.includeSiblings !== void 0) {
5434
6282
  obj.includeSiblings = message.includeSiblings;
5435
6283
  }
6284
+ if (message.includeTransactionTrace !== void 0) {
6285
+ obj.includeTransactionTrace = message.includeTransactionTrace;
6286
+ }
5436
6287
  return obj;
5437
6288
  },
5438
6289
  create(base) {
@@ -5449,6 +6300,7 @@ const EventFilter$1 = {
5449
6300
  message.includeReceipt = object.includeReceipt ?? void 0;
5450
6301
  message.includeMessages = object.includeMessages ?? void 0;
5451
6302
  message.includeSiblings = object.includeSiblings ?? void 0;
6303
+ message.includeTransactionTrace = object.includeTransactionTrace ?? void 0;
5452
6304
  return message;
5453
6305
  }
5454
6306
  };
@@ -5511,7 +6363,8 @@ function createBaseMessageToL1Filter() {
5511
6363
  includeTransaction: void 0,
5512
6364
  includeReceipt: void 0,
5513
6365
  includeEvents: void 0,
5514
- includeSiblings: void 0
6366
+ includeSiblings: void 0,
6367
+ includeTransactionTrace: void 0
5515
6368
  };
5516
6369
  }
5517
6370
  const MessageToL1Filter$1 = {
@@ -5540,6 +6393,9 @@ const MessageToL1Filter$1 = {
5540
6393
  if (message.includeSiblings !== void 0) {
5541
6394
  writer.uint32(64).bool(message.includeSiblings);
5542
6395
  }
6396
+ if (message.includeTransactionTrace !== void 0) {
6397
+ writer.uint32(72).bool(message.includeTransactionTrace);
6398
+ }
5543
6399
  return writer;
5544
6400
  },
5545
6401
  decode(input, length) {
@@ -5597,6 +6453,12 @@ const MessageToL1Filter$1 = {
5597
6453
  }
5598
6454
  message.includeSiblings = reader.bool();
5599
6455
  continue;
6456
+ case 9:
6457
+ if (tag !== 72) {
6458
+ break;
6459
+ }
6460
+ message.includeTransactionTrace = reader.bool();
6461
+ continue;
5600
6462
  }
5601
6463
  if ((tag & 7) === 4 || tag === 0) {
5602
6464
  break;
@@ -5614,7 +6476,8 @@ const MessageToL1Filter$1 = {
5614
6476
  includeTransaction: isSet(object.includeTransaction) ? globalThis.Boolean(object.includeTransaction) : void 0,
5615
6477
  includeReceipt: isSet(object.includeReceipt) ? globalThis.Boolean(object.includeReceipt) : void 0,
5616
6478
  includeEvents: isSet(object.includeEvents) ? globalThis.Boolean(object.includeEvents) : void 0,
5617
- includeSiblings: isSet(object.includeSiblings) ? globalThis.Boolean(object.includeSiblings) : void 0
6479
+ includeSiblings: isSet(object.includeSiblings) ? globalThis.Boolean(object.includeSiblings) : void 0,
6480
+ includeTransactionTrace: isSet(object.includeTransactionTrace) ? globalThis.Boolean(object.includeTransactionTrace) : void 0
5618
6481
  };
5619
6482
  },
5620
6483
  toJSON(message) {
@@ -5643,6 +6506,9 @@ const MessageToL1Filter$1 = {
5643
6506
  if (message.includeSiblings !== void 0) {
5644
6507
  obj.includeSiblings = message.includeSiblings;
5645
6508
  }
6509
+ if (message.includeTransactionTrace !== void 0) {
6510
+ obj.includeTransactionTrace = message.includeTransactionTrace;
6511
+ }
5646
6512
  return obj;
5647
6513
  },
5648
6514
  create(base) {
@@ -5658,6 +6524,7 @@ const MessageToL1Filter$1 = {
5658
6524
  message.includeReceipt = object.includeReceipt ?? void 0;
5659
6525
  message.includeEvents = object.includeEvents ?? void 0;
5660
6526
  message.includeSiblings = object.includeSiblings ?? void 0;
6527
+ message.includeTransactionTrace = object.includeTransactionTrace ?? void 0;
5661
6528
  return message;
5662
6529
  }
5663
6530
  };
@@ -5668,7 +6535,8 @@ function createBaseTransactionFilter() {
5668
6535
  includeReceipt: void 0,
5669
6536
  includeEvents: void 0,
5670
6537
  includeMessages: void 0,
5671
- inner: void 0
6538
+ inner: void 0,
6539
+ includeTrace: void 0
5672
6540
  };
5673
6541
  }
5674
6542
  const TransactionFilter$1 = {
@@ -5723,6 +6591,9 @@ const TransactionFilter$1 = {
5723
6591
  DeployAccountV3TransactionFilter$1.encode(message.inner.deployAccountV3, writer.uint32(130).fork()).ldelim();
5724
6592
  break;
5725
6593
  }
6594
+ if (message.includeTrace !== void 0) {
6595
+ writer.uint32(136).bool(message.includeTrace);
6596
+ }
5726
6597
  return writer;
5727
6598
  },
5728
6599
  decode(input, length) {
@@ -5834,6 +6705,12 @@ const TransactionFilter$1 = {
5834
6705
  deployAccountV3: DeployAccountV3TransactionFilter$1.decode(reader, reader.uint32())
5835
6706
  };
5836
6707
  continue;
6708
+ case 17:
6709
+ if (tag !== 136) {
6710
+ break;
6711
+ }
6712
+ message.includeTrace = reader.bool();
6713
+ continue;
5837
6714
  }
5838
6715
  if ((tag & 7) === 4 || tag === 0) {
5839
6716
  break;
@@ -5855,7 +6732,8 @@ const TransactionFilter$1 = {
5855
6732
  } : isSet(object.deployAccountV3) ? {
5856
6733
  $case: "deployAccountV3",
5857
6734
  deployAccountV3: DeployAccountV3TransactionFilter$1.fromJSON(object.deployAccountV3)
5858
- } : void 0
6735
+ } : void 0,
6736
+ includeTrace: isSet(object.includeTrace) ? globalThis.Boolean(object.includeTrace) : void 0
5859
6737
  };
5860
6738
  },
5861
6739
  toJSON(message) {
@@ -5908,6 +6786,9 @@ const TransactionFilter$1 = {
5908
6786
  if (message.inner?.$case === "deployAccountV3") {
5909
6787
  obj.deployAccountV3 = DeployAccountV3TransactionFilter$1.toJSON(message.inner.deployAccountV3);
5910
6788
  }
6789
+ if (message.includeTrace !== void 0) {
6790
+ obj.includeTrace = message.includeTrace;
6791
+ }
5911
6792
  return obj;
5912
6793
  },
5913
6794
  create(base) {
@@ -5959,6 +6840,7 @@ const TransactionFilter$1 = {
5959
6840
  deployAccountV3: DeployAccountV3TransactionFilter$1.fromPartial(object.inner.deployAccountV3)
5960
6841
  };
5961
6842
  }
6843
+ message.includeTrace = object.includeTrace ?? void 0;
5962
6844
  return message;
5963
6845
  }
5964
6846
  };
@@ -6746,651 +7628,643 @@ const index = {
6746
7628
  filter: filter
6747
7629
  };
6748
7630
 
6749
- const ResourcePrice = Schema.Struct({
6750
- priceInFri: Schema.optional(FieldElement$1),
6751
- priceInWei: Schema.optional(FieldElement$1)
7631
+ const ResourcePrice = MessageCodec({
7632
+ priceInFri: OptionalCodec(FieldElement$1),
7633
+ priceInWei: OptionalCodec(FieldElement$1)
6752
7634
  });
6753
- const L1DataAvailabilityMode = Schema.transform(
6754
- Schema.Enums(L1DataAvailabilityMode$1),
6755
- Schema.Literal("blob", "calldata", "unknown"),
6756
- {
6757
- decode(value) {
6758
- const enumMap = {
6759
- [L1DataAvailabilityMode$1.CALLDATA]: "calldata",
6760
- [L1DataAvailabilityMode$1.BLOB]: "blob",
6761
- [L1DataAvailabilityMode$1.UNSPECIFIED]: "unknown",
6762
- [L1DataAvailabilityMode$1.UNRECOGNIZED]: "unknown"
6763
- };
6764
- return enumMap[value] ?? "unknown";
6765
- },
6766
- encode(value) {
6767
- throw new Error("encode: not implemented");
6768
- }
7635
+ const L1DataAvailabilityMode = {
7636
+ encode(x) {
7637
+ switch (x) {
7638
+ case "calldata":
7639
+ return L1DataAvailabilityMode$1.CALLDATA;
7640
+ case "blob":
7641
+ return L1DataAvailabilityMode$1.BLOB;
7642
+ case "unknown":
7643
+ return L1DataAvailabilityMode$1.UNSPECIFIED;
7644
+ default:
7645
+ return L1DataAvailabilityMode$1.UNRECOGNIZED;
7646
+ }
7647
+ },
7648
+ decode(p) {
7649
+ const enumMap = {
7650
+ [L1DataAvailabilityMode$1.CALLDATA]: "calldata",
7651
+ [L1DataAvailabilityMode$1.BLOB]: "blob",
7652
+ [L1DataAvailabilityMode$1.UNSPECIFIED]: "unknown",
7653
+ [L1DataAvailabilityMode$1.UNRECOGNIZED]: "unknown"
7654
+ };
7655
+ return enumMap[p] ?? "unknown";
6769
7656
  }
6770
- );
6771
- const TransactionStatus = Schema.transform(
6772
- Schema.Enums(TransactionStatus$1),
6773
- Schema.Literal("unknown", "succeeded", "reverted"),
6774
- {
6775
- decode(value) {
6776
- const enumMap = {
6777
- [TransactionStatus$1.SUCCEEDED]: "succeeded",
6778
- [TransactionStatus$1.REVERTED]: "reverted",
6779
- [TransactionStatus$1.UNSPECIFIED]: "unknown",
6780
- [TransactionStatus$1.UNRECOGNIZED]: "unknown"
6781
- };
6782
- return enumMap[value] ?? "unknown";
6783
- },
6784
- encode(value) {
6785
- throw new Error("encode: not implemented");
6786
- }
7657
+ };
7658
+ const TransactionStatus = {
7659
+ encode(x) {
7660
+ switch (x) {
7661
+ case "succeeded":
7662
+ return TransactionStatus$1.SUCCEEDED;
7663
+ case "reverted":
7664
+ return TransactionStatus$1.REVERTED;
7665
+ case "unknown":
7666
+ return TransactionStatus$1.UNSPECIFIED;
7667
+ default:
7668
+ return TransactionStatus$1.UNRECOGNIZED;
7669
+ }
7670
+ },
7671
+ decode(p) {
7672
+ const enumMap = {
7673
+ [TransactionStatus$1.SUCCEEDED]: "succeeded",
7674
+ [TransactionStatus$1.REVERTED]: "reverted",
7675
+ [TransactionStatus$1.UNSPECIFIED]: "unknown",
7676
+ [TransactionStatus$1.UNRECOGNIZED]: "unknown"
7677
+ };
7678
+ return enumMap[p] ?? "unknown";
6787
7679
  }
6788
- );
6789
- const U128 = Schema.transform(
6790
- Schema.Struct({
6791
- x0: Schema.BigIntFromSelf,
6792
- x1: Schema.BigIntFromSelf
6793
- }),
6794
- Schema.BigIntFromSelf,
6795
- {
6796
- decode(value) {
6797
- const low = value.x0.toString(16).padStart(16, "0");
6798
- const high = value.x1.toString(16).padStart(16, "0");
6799
- return BigInt(`0x${low}${high}`);
6800
- },
6801
- encode(value) {
6802
- throw new Error("encode: not implemented");
6803
- }
7680
+ };
7681
+ const U128 = {
7682
+ // TODO: double check if this is correct
7683
+ encode(x) {
7684
+ const low = x.toString(16).padStart(16, "0");
7685
+ const high = (x >> 128n).toString(16).padStart(16, "0");
7686
+ return { x0: BigInt(`0x${low}`), x1: BigInt(`0x${high}`) };
7687
+ },
7688
+ decode(p) {
7689
+ const low = (p.x0 ?? 0n).toString(16).padStart(16, "0");
7690
+ const high = (p.x1 ?? 0n).toString(16).padStart(16, "0");
7691
+ return BigInt(`0x${low}${high}`);
6804
7692
  }
6805
- );
6806
- const ResourceBounds = Schema.Struct({
6807
- maxAmount: Schema.BigIntFromSelf,
6808
- maxPricePerUnit: U128
7693
+ };
7694
+ const ResourceBounds = MessageCodec({
7695
+ maxAmount: RequiredCodec(BigIntCodec),
7696
+ maxPricePerUnit: RequiredCodec(U128)
6809
7697
  });
6810
- const ResourceBoundsMapping = Schema.Struct({
6811
- l1Gas: ResourceBounds,
6812
- l2Gas: ResourceBounds
7698
+ const ResourceBoundsMapping = MessageCodec({
7699
+ l1Gas: RequiredCodec(ResourceBounds),
7700
+ l2Gas: RequiredCodec(ResourceBounds)
6813
7701
  });
6814
- const DataAvailabilityMode = Schema.transform(
6815
- Schema.Enums(DataAvailabilityMode$1),
6816
- Schema.Literal("l1", "l2", "unknown"),
6817
- {
6818
- decode(value) {
6819
- const enumMap = {
6820
- [DataAvailabilityMode$1.L1]: "l1",
6821
- [DataAvailabilityMode$1.L2]: "l2",
6822
- [DataAvailabilityMode$1.UNSPECIFIED]: "unknown",
6823
- [DataAvailabilityMode$1.UNRECOGNIZED]: "unknown"
6824
- };
6825
- return enumMap[value] ?? "unknown";
6826
- },
6827
- encode(value) {
6828
- throw new Error("encode: not implemented");
6829
- }
7702
+ const DataAvailabilityMode = {
7703
+ encode(x) {
7704
+ switch (x) {
7705
+ case "l1":
7706
+ return DataAvailabilityMode$1.L1;
7707
+ case "l2":
7708
+ return DataAvailabilityMode$1.L2;
7709
+ case "unknown":
7710
+ return DataAvailabilityMode$1.UNSPECIFIED;
7711
+ default:
7712
+ return DataAvailabilityMode$1.UNRECOGNIZED;
7713
+ }
7714
+ },
7715
+ decode(p) {
7716
+ const enumMap = {
7717
+ [DataAvailabilityMode$1.L1]: "l1",
7718
+ [DataAvailabilityMode$1.L2]: "l2",
7719
+ [DataAvailabilityMode$1.UNSPECIFIED]: "unknown",
7720
+ [DataAvailabilityMode$1.UNRECOGNIZED]: "unknown"
7721
+ };
7722
+ return enumMap[p] ?? "unknown";
6830
7723
  }
6831
- );
6832
- const BlockHeader = Schema.Struct({
6833
- blockHash: Schema.optional(FieldElement$1),
6834
- parentBlockHash: FieldElement$1,
6835
- blockNumber: Schema.BigIntFromSelf,
6836
- sequencerAddress: FieldElement$1,
6837
- newRoot: Schema.optional(FieldElement$1),
6838
- timestamp: Schema.DateFromSelf,
6839
- starknetVersion: Schema.String,
6840
- l1GasPrice: ResourcePrice,
6841
- l1DataGasPrice: ResourcePrice,
6842
- l1DataAvailabilityMode: L1DataAvailabilityMode
7724
+ };
7725
+ const BlockHeader = MessageCodec({
7726
+ blockHash: OptionalCodec(FieldElement$1),
7727
+ parentBlockHash: RequiredCodec(FieldElement$1),
7728
+ blockNumber: RequiredCodec(BigIntCodec),
7729
+ sequencerAddress: RequiredCodec(FieldElement$1),
7730
+ newRoot: OptionalCodec(FieldElement$1),
7731
+ timestamp: RequiredCodec(DateCodec),
7732
+ starknetVersion: RequiredCodec(StringCodec),
7733
+ l1GasPrice: RequiredCodec(ResourcePrice),
7734
+ l1DataGasPrice: RequiredCodec(ResourcePrice),
7735
+ l1DataAvailabilityMode: RequiredCodec(L1DataAvailabilityMode),
7736
+ l2GasPrice: OptionalCodec(ResourcePrice)
6843
7737
  });
6844
- const TransactionMeta = Schema.Struct({
6845
- transactionIndex: Schema.Number,
6846
- transactionHash: FieldElement$1,
6847
- transactionStatus: TransactionStatus
7738
+ const TransactionMeta = MessageCodec({
7739
+ transactionIndex: RequiredCodec(NumberCodec),
7740
+ transactionHash: RequiredCodec(FieldElement$1),
7741
+ transactionStatus: RequiredCodec(TransactionStatus)
6848
7742
  });
6849
- const InvokeTransactionV0 = Schema.Struct({
6850
- _tag: tag("invokeV0"),
6851
- invokeV0: Schema.Struct({
6852
- maxFee: FieldElement$1,
6853
- signature: Schema.Array(FieldElement$1),
6854
- contractAddress: FieldElement$1,
6855
- entryPointSelector: FieldElement$1,
6856
- calldata: Schema.Array(FieldElement$1)
6857
- })
7743
+ const InvokeTransactionV0 = MessageCodec({
7744
+ maxFee: RequiredCodec(FieldElement$1),
7745
+ signature: ArrayCodec(FieldElement$1),
7746
+ contractAddress: RequiredCodec(FieldElement$1),
7747
+ entryPointSelector: RequiredCodec(FieldElement$1),
7748
+ calldata: ArrayCodec(FieldElement$1)
6858
7749
  });
6859
- const InvokeTransactionV1 = Schema.Struct({
6860
- _tag: tag("invokeV1"),
6861
- invokeV1: Schema.Struct({
6862
- senderAddress: FieldElement$1,
6863
- calldata: Schema.Array(FieldElement$1),
6864
- maxFee: FieldElement$1,
6865
- signature: Schema.Array(FieldElement$1),
6866
- nonce: FieldElement$1
6867
- })
7750
+ const InvokeTransactionV1 = MessageCodec({
7751
+ senderAddress: RequiredCodec(FieldElement$1),
7752
+ calldata: ArrayCodec(FieldElement$1),
7753
+ maxFee: RequiredCodec(FieldElement$1),
7754
+ signature: ArrayCodec(FieldElement$1),
7755
+ nonce: RequiredCodec(FieldElement$1)
6868
7756
  });
6869
- const InvokeTransactionV3 = Schema.Struct({
6870
- _tag: tag("invokeV3"),
6871
- invokeV3: Schema.Struct({
6872
- senderAddress: FieldElement$1,
6873
- calldata: Schema.Array(FieldElement$1),
6874
- signature: Schema.Array(FieldElement$1),
6875
- nonce: FieldElement$1,
6876
- resourceBounds: ResourceBoundsMapping,
6877
- tip: Schema.BigIntFromSelf,
6878
- paymasterData: Schema.Array(FieldElement$1),
6879
- accountDeploymentData: Schema.Array(FieldElement$1),
6880
- nonceDataAvailabilityMode: DataAvailabilityMode,
6881
- feeDataAvailabilityMode: DataAvailabilityMode
6882
- })
7757
+ const InvokeTransactionV3 = MessageCodec({
7758
+ senderAddress: RequiredCodec(FieldElement$1),
7759
+ calldata: ArrayCodec(FieldElement$1),
7760
+ signature: ArrayCodec(FieldElement$1),
7761
+ nonce: RequiredCodec(FieldElement$1),
7762
+ resourceBounds: RequiredCodec(ResourceBoundsMapping),
7763
+ tip: RequiredCodec(BigIntCodec),
7764
+ paymasterData: ArrayCodec(FieldElement$1),
7765
+ accountDeploymentData: ArrayCodec(FieldElement$1),
7766
+ nonceDataAvailabilityMode: RequiredCodec(DataAvailabilityMode),
7767
+ feeDataAvailabilityMode: RequiredCodec(DataAvailabilityMode)
6883
7768
  });
6884
- const L1HandlerTransaction = Schema.Struct({
6885
- _tag: tag("l1Handler"),
6886
- l1Handler: Schema.Struct({
6887
- nonce: Schema.BigIntFromSelf,
6888
- contractAddress: FieldElement$1,
6889
- entryPointSelector: FieldElement$1,
6890
- calldata: Schema.Array(FieldElement$1)
6891
- })
7769
+ const L1HandlerTransaction = MessageCodec({
7770
+ nonce: RequiredCodec(BigIntCodec),
7771
+ contractAddress: RequiredCodec(FieldElement$1),
7772
+ entryPointSelector: RequiredCodec(FieldElement$1),
7773
+ calldata: ArrayCodec(FieldElement$1)
6892
7774
  });
6893
- const DeployTransaction = Schema.Struct({
6894
- _tag: tag("deploy"),
6895
- deploy: Schema.Struct({
6896
- contractAddressSalt: FieldElement$1,
6897
- constructorCalldata: Schema.Array(FieldElement$1),
6898
- classHash: FieldElement$1
6899
- })
7775
+ const DeployTransaction = MessageCodec({
7776
+ contractAddressSalt: RequiredCodec(FieldElement$1),
7777
+ constructorCalldata: ArrayCodec(FieldElement$1),
7778
+ classHash: RequiredCodec(FieldElement$1)
6900
7779
  });
6901
- const DeclareTransactionV0 = Schema.Struct({
6902
- _tag: tag("declareV0"),
6903
- declareV0: Schema.Struct({
6904
- senderAddress: FieldElement$1,
6905
- maxFee: FieldElement$1,
6906
- signature: Schema.Array(FieldElement$1),
6907
- classHash: FieldElement$1
6908
- })
7780
+ const DeclareTransactionV0 = MessageCodec({
7781
+ senderAddress: RequiredCodec(FieldElement$1),
7782
+ maxFee: RequiredCodec(FieldElement$1),
7783
+ signature: ArrayCodec(FieldElement$1),
7784
+ classHash: RequiredCodec(FieldElement$1)
6909
7785
  });
6910
- const DeclareTransactionV1 = Schema.Struct({
6911
- _tag: tag("declareV1"),
6912
- declareV1: Schema.Struct({
6913
- senderAddress: FieldElement$1,
6914
- maxFee: FieldElement$1,
6915
- signature: Schema.Array(FieldElement$1),
6916
- nonce: FieldElement$1,
6917
- classHash: FieldElement$1
6918
- })
7786
+ const DeclareTransactionV1 = MessageCodec({
7787
+ senderAddress: RequiredCodec(FieldElement$1),
7788
+ maxFee: RequiredCodec(FieldElement$1),
7789
+ signature: ArrayCodec(FieldElement$1),
7790
+ nonce: RequiredCodec(FieldElement$1),
7791
+ classHash: RequiredCodec(FieldElement$1)
6919
7792
  });
6920
- const DeclareTransactionV2 = Schema.Struct({
6921
- _tag: tag("declareV2"),
6922
- declareV2: Schema.Struct({
6923
- senderAddress: FieldElement$1,
6924
- compiledClassHash: FieldElement$1,
6925
- maxFee: FieldElement$1,
6926
- signature: Schema.Array(FieldElement$1),
6927
- nonce: FieldElement$1,
6928
- classHash: FieldElement$1
6929
- })
7793
+ const DeclareTransactionV2 = MessageCodec({
7794
+ senderAddress: RequiredCodec(FieldElement$1),
7795
+ compiledClassHash: RequiredCodec(FieldElement$1),
7796
+ maxFee: RequiredCodec(FieldElement$1),
7797
+ signature: ArrayCodec(FieldElement$1),
7798
+ nonce: RequiredCodec(FieldElement$1),
7799
+ classHash: RequiredCodec(FieldElement$1)
6930
7800
  });
6931
- const DeclareTransactionV3 = Schema.Struct({
6932
- _tag: tag("declareV3"),
6933
- declareV3: Schema.Struct({
6934
- senderAddress: FieldElement$1,
6935
- compiledClassHash: FieldElement$1,
6936
- signature: Schema.Array(FieldElement$1),
6937
- nonce: FieldElement$1,
6938
- classHash: FieldElement$1,
6939
- resourceBounds: ResourceBoundsMapping,
6940
- tip: Schema.BigIntFromSelf,
6941
- paymasterData: Schema.Array(FieldElement$1),
6942
- accountDeploymentData: Schema.Array(FieldElement$1),
6943
- nonceDataAvailabilityMode: DataAvailabilityMode,
6944
- feeDataAvailabilityMode: DataAvailabilityMode
6945
- })
7801
+ const DeclareTransactionV3 = MessageCodec({
7802
+ senderAddress: RequiredCodec(FieldElement$1),
7803
+ compiledClassHash: RequiredCodec(FieldElement$1),
7804
+ signature: ArrayCodec(FieldElement$1),
7805
+ nonce: RequiredCodec(FieldElement$1),
7806
+ classHash: RequiredCodec(FieldElement$1),
7807
+ resourceBounds: RequiredCodec(ResourceBoundsMapping),
7808
+ tip: RequiredCodec(BigIntCodec),
7809
+ paymasterData: ArrayCodec(FieldElement$1),
7810
+ accountDeploymentData: ArrayCodec(FieldElement$1),
7811
+ nonceDataAvailabilityMode: RequiredCodec(DataAvailabilityMode),
7812
+ feeDataAvailabilityMode: RequiredCodec(DataAvailabilityMode)
6946
7813
  });
6947
- const DeployAccountTransactionV1 = Schema.Struct({
6948
- _tag: tag("deployAccountV1"),
6949
- deployAccountV1: Schema.Struct({
6950
- maxFee: FieldElement$1,
6951
- signature: Schema.Array(FieldElement$1),
6952
- nonce: FieldElement$1,
6953
- contractAddressSalt: FieldElement$1,
6954
- constructorCalldata: Schema.Array(FieldElement$1),
6955
- classHash: FieldElement$1
6956
- })
7814
+ const DeployAccountTransactionV1 = MessageCodec({
7815
+ maxFee: RequiredCodec(FieldElement$1),
7816
+ signature: ArrayCodec(FieldElement$1),
7817
+ nonce: RequiredCodec(FieldElement$1),
7818
+ contractAddressSalt: RequiredCodec(FieldElement$1),
7819
+ constructorCalldata: ArrayCodec(FieldElement$1),
7820
+ classHash: RequiredCodec(FieldElement$1)
6957
7821
  });
6958
- const DeployAccountTransactionV3 = Schema.Struct({
6959
- _tag: tag("deployAccountV3"),
6960
- deployAccountV3: Schema.Struct({
6961
- signature: Schema.Array(FieldElement$1),
6962
- nonce: FieldElement$1,
6963
- contractAddressSalt: FieldElement$1,
6964
- constructorCalldata: Schema.Array(FieldElement$1),
6965
- classHash: FieldElement$1,
6966
- resourceBounds: ResourceBoundsMapping,
6967
- tip: Schema.BigIntFromSelf,
6968
- paymasterData: Schema.Array(FieldElement$1),
6969
- nonceDataAvailabilityMode: DataAvailabilityMode,
6970
- feeDataAvailabilityMode: DataAvailabilityMode
6971
- })
7822
+ const DeployAccountTransactionV3 = MessageCodec({
7823
+ signature: ArrayCodec(FieldElement$1),
7824
+ nonce: RequiredCodec(FieldElement$1),
7825
+ contractAddressSalt: RequiredCodec(FieldElement$1),
7826
+ constructorCalldata: ArrayCodec(FieldElement$1),
7827
+ classHash: RequiredCodec(FieldElement$1),
7828
+ resourceBounds: RequiredCodec(ResourceBoundsMapping),
7829
+ tip: RequiredCodec(BigIntCodec),
7830
+ paymasterData: ArrayCodec(FieldElement$1),
7831
+ nonceDataAvailabilityMode: RequiredCodec(DataAvailabilityMode),
7832
+ feeDataAvailabilityMode: RequiredCodec(DataAvailabilityMode)
6972
7833
  });
6973
- const Transaction = Schema.Struct({
6974
- filterIds: Schema.Array(Schema.Number),
6975
- meta: TransactionMeta,
6976
- transaction: Schema.Union(
6977
- InvokeTransactionV0,
6978
- InvokeTransactionV1,
6979
- InvokeTransactionV3,
6980
- L1HandlerTransaction,
6981
- DeployTransaction,
6982
- DeclareTransactionV0,
6983
- DeclareTransactionV1,
6984
- DeclareTransactionV2,
6985
- DeclareTransactionV3,
6986
- DeployAccountTransactionV1,
6987
- DeployAccountTransactionV3
7834
+ const Transaction = MessageCodec({
7835
+ filterIds: ArrayCodec(NumberCodec),
7836
+ meta: RequiredCodec(TransactionMeta),
7837
+ transaction: RequiredCodec(
7838
+ OneOfCodec({
7839
+ invokeV0: InvokeTransactionV0,
7840
+ invokeV1: InvokeTransactionV1,
7841
+ invokeV3: InvokeTransactionV3,
7842
+ l1Handler: L1HandlerTransaction,
7843
+ deploy: DeployTransaction,
7844
+ declareV0: DeclareTransactionV0,
7845
+ declareV1: DeclareTransactionV1,
7846
+ declareV2: DeclareTransactionV2,
7847
+ declareV3: DeclareTransactionV3,
7848
+ deployAccountV1: DeployAccountTransactionV1,
7849
+ deployAccountV3: DeployAccountTransactionV3
7850
+ })
6988
7851
  )
6989
7852
  });
6990
- const PriceUnit = Schema.transform(
6991
- Schema.Enums(PriceUnit$1),
6992
- Schema.Literal("wei", "fri", "unknown"),
6993
- {
6994
- decode(value) {
6995
- const enumMap = {
6996
- [PriceUnit$1.WEI]: "wei",
6997
- [PriceUnit$1.FRI]: "fri",
6998
- [PriceUnit$1.UNSPECIFIED]: "unknown",
6999
- [PriceUnit$1.UNRECOGNIZED]: "unknown"
7000
- };
7001
- return enumMap[value] ?? "unknown";
7002
- },
7003
- encode(value) {
7004
- throw new Error("encode: not implemented");
7005
- }
7853
+ const PriceUnit = {
7854
+ encode(x) {
7855
+ switch (x) {
7856
+ case "wei":
7857
+ return PriceUnit$1.WEI;
7858
+ case "fri":
7859
+ return PriceUnit$1.FRI;
7860
+ case "unknown":
7861
+ return PriceUnit$1.UNSPECIFIED;
7862
+ default:
7863
+ return PriceUnit$1.UNRECOGNIZED;
7864
+ }
7865
+ },
7866
+ decode(p) {
7867
+ const enumMap = {
7868
+ [PriceUnit$1.WEI]: "wei",
7869
+ [PriceUnit$1.FRI]: "fri",
7870
+ [PriceUnit$1.UNSPECIFIED]: "unknown",
7871
+ [PriceUnit$1.UNRECOGNIZED]: "unknown"
7872
+ };
7873
+ return enumMap[p] ?? "unknown";
7006
7874
  }
7007
- );
7008
- const FeePayment = Schema.Struct({
7009
- amount: FieldElement$1,
7010
- unit: PriceUnit
7011
- });
7012
- const ComputationResources = Schema.Struct({
7013
- steps: Schema.BigIntFromSelf,
7014
- memoryHoles: Schema.optional(Schema.BigIntFromSelf),
7015
- rangeCheckBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
7016
- pedersenBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
7017
- poseidonBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
7018
- ecOpBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
7019
- ecdsaBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
7020
- bitwiseBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
7021
- keccakBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
7022
- segmentArenaBuiltin: Schema.optional(Schema.BigIntFromSelf)
7023
- });
7024
- const DataAvailabilityResources = Schema.Struct({
7025
- l1Gas: Schema.BigIntFromSelf,
7026
- l1DataGas: Schema.BigIntFromSelf
7027
- });
7028
- const ExecutionResources = Schema.Struct({
7029
- computation: ComputationResources,
7030
- dataAvailability: DataAvailabilityResources
7875
+ };
7876
+ const FeePayment = MessageCodec({
7877
+ amount: RequiredCodec(FieldElement$1),
7878
+ unit: RequiredCodec(PriceUnit)
7031
7879
  });
7032
- const ExecutionSucceeded = Schema.Struct({
7033
- _tag: tag("succeeded"),
7034
- succeeded: Schema.Struct({})
7880
+ const ComputationResources = MessageCodec({
7881
+ steps: RequiredCodec(BigIntCodec),
7882
+ memoryHoles: OptionalCodec(BigIntCodec),
7883
+ rangeCheckBuiltinApplications: OptionalCodec(BigIntCodec),
7884
+ pedersenBuiltinApplications: OptionalCodec(BigIntCodec),
7885
+ poseidonBuiltinApplications: OptionalCodec(BigIntCodec),
7886
+ ecOpBuiltinApplications: OptionalCodec(BigIntCodec),
7887
+ ecdsaBuiltinApplications: OptionalCodec(BigIntCodec),
7888
+ bitwiseBuiltinApplications: OptionalCodec(BigIntCodec),
7889
+ keccakBuiltinApplications: OptionalCodec(BigIntCodec),
7890
+ segmentArenaBuiltin: OptionalCodec(BigIntCodec)
7035
7891
  });
7036
- const ExecutionReverted = Schema.Struct({
7037
- _tag: tag("reverted"),
7038
- reverted: Schema.Struct({
7039
- reason: Schema.optional(Schema.String)
7040
- })
7892
+ const DataAvailabilityResources = MessageCodec({
7893
+ l1Gas: RequiredCodec(BigIntCodec),
7894
+ l1DataGas: RequiredCodec(BigIntCodec)
7041
7895
  });
7042
- const TransactionReceiptMeta = Schema.Struct({
7043
- transactionIndex: Schema.Number,
7044
- transactionHash: FieldElement$1,
7045
- actualFee: FeePayment,
7046
- executionResources: ExecutionResources,
7047
- executionResult: Schema.Union(ExecutionSucceeded, ExecutionReverted)
7896
+ const ExecutionResources = MessageCodec({
7897
+ computation: RequiredCodec(ComputationResources),
7898
+ dataAvailability: RequiredCodec(DataAvailabilityResources)
7048
7899
  });
7049
- const InvokeTransactionReceipt = Schema.Struct({
7050
- _tag: tag("invoke"),
7051
- invoke: Schema.Struct({})
7900
+ const ExecutionSucceeded = MessageCodec({});
7901
+ const ExecutionReverted = MessageCodec({
7902
+ reason: OptionalCodec(StringCodec)
7052
7903
  });
7053
- const L1HandlerTransactionReceipt = Schema.Struct({
7054
- _tag: tag("l1Handler"),
7055
- l1Handler: Schema.Struct({
7056
- messageHash: Schema.Uint8ArrayFromSelf
7057
- })
7904
+ const TransactionReceiptMeta = MessageCodec({
7905
+ transactionIndex: RequiredCodec(NumberCodec),
7906
+ transactionHash: RequiredCodec(FieldElement$1),
7907
+ actualFee: RequiredCodec(FeePayment),
7908
+ executionResources: RequiredCodec(ExecutionResources),
7909
+ executionResult: RequiredCodec(
7910
+ OneOfCodec({
7911
+ succeeded: ExecutionSucceeded,
7912
+ reverted: ExecutionReverted
7913
+ })
7914
+ )
7058
7915
  });
7059
- const DeclareTransactionReceipt = Schema.Struct({
7060
- _tag: tag("declare"),
7061
- declare: Schema.Struct({})
7916
+ const InvokeTransactionReceipt = MessageCodec({});
7917
+ const L1HandlerTransactionReceipt = MessageCodec({
7918
+ messageHash: RequiredCodec(Uint8ArrayCodec)
7062
7919
  });
7063
- const DeployTransactionReceipt = Schema.Struct({
7064
- _tag: tag("deploy"),
7065
- deploy: Schema.Struct({
7066
- contractAddress: FieldElement$1
7067
- })
7920
+ const DeclareTransactionReceipt = MessageCodec({});
7921
+ const DeployTransactionReceipt = MessageCodec({
7922
+ contractAddress: RequiredCodec(FieldElement$1)
7068
7923
  });
7069
- const DeployAccountTransactionReceipt = Schema.Struct({
7070
- _tag: tag("deployAccount"),
7071
- deployAccount: Schema.Struct({
7072
- contractAddress: FieldElement$1
7073
- })
7924
+ const DeployAccountTransactionReceipt = MessageCodec({
7925
+ contractAddress: RequiredCodec(FieldElement$1)
7074
7926
  });
7075
- const TransactionReceipt = Schema.Struct({
7076
- filterIds: Schema.Array(Schema.Number),
7077
- meta: TransactionReceiptMeta,
7078
- receipt: Schema.Union(
7079
- InvokeTransactionReceipt,
7080
- L1HandlerTransactionReceipt,
7081
- DeclareTransactionReceipt,
7082
- DeployTransactionReceipt,
7083
- DeployAccountTransactionReceipt
7927
+ const TransactionReceipt = MessageCodec({
7928
+ filterIds: ArrayCodec(NumberCodec),
7929
+ meta: RequiredCodec(TransactionReceiptMeta),
7930
+ receipt: RequiredCodec(
7931
+ OneOfCodec({
7932
+ invoke: InvokeTransactionReceipt,
7933
+ l1Handler: L1HandlerTransactionReceipt,
7934
+ declare: DeclareTransactionReceipt,
7935
+ deploy: DeployTransactionReceipt,
7936
+ deployAccount: DeployAccountTransactionReceipt
7937
+ })
7084
7938
  )
7085
7939
  });
7086
- const Event = Schema.Struct({
7087
- filterIds: Schema.Array(Schema.Number),
7088
- address: FieldElement$1,
7089
- keys: Schema.Array(FieldElement$1),
7090
- data: Schema.Array(FieldElement$1),
7091
- eventIndex: Schema.Number,
7092
- transactionIndex: Schema.Number,
7093
- transactionHash: FieldElement$1,
7094
- transactionStatus: TransactionStatus,
7095
- eventIndexInTransaction: Schema.Number
7940
+ const Event = MessageCodec({
7941
+ filterIds: ArrayCodec(NumberCodec),
7942
+ address: RequiredCodec(FieldElement$1),
7943
+ keys: ArrayCodec(FieldElement$1),
7944
+ data: ArrayCodec(FieldElement$1),
7945
+ eventIndex: RequiredCodec(NumberCodec),
7946
+ transactionIndex: RequiredCodec(NumberCodec),
7947
+ transactionHash: RequiredCodec(FieldElement$1),
7948
+ transactionStatus: RequiredCodec(TransactionStatus),
7949
+ eventIndexInTransaction: RequiredCodec(NumberCodec)
7096
7950
  });
7097
- const MessageToL1 = Schema.Struct({
7098
- filterIds: Schema.Array(Schema.Number),
7099
- fromAddress: FieldElement$1,
7100
- toAddress: FieldElement$1,
7101
- payload: Schema.Array(FieldElement$1),
7102
- messageIndex: Schema.Number,
7103
- transactionIndex: Schema.Number,
7104
- transactionHash: FieldElement$1,
7105
- transactionStatus: TransactionStatus,
7106
- messageIndexInTransaction: Schema.Number
7951
+ const MessageToL1 = MessageCodec({
7952
+ filterIds: ArrayCodec(NumberCodec),
7953
+ fromAddress: RequiredCodec(FieldElement$1),
7954
+ toAddress: RequiredCodec(FieldElement$1),
7955
+ payload: ArrayCodec(FieldElement$1),
7956
+ messageIndex: RequiredCodec(NumberCodec),
7957
+ transactionIndex: RequiredCodec(NumberCodec),
7958
+ transactionHash: RequiredCodec(FieldElement$1),
7959
+ transactionStatus: RequiredCodec(TransactionStatus),
7960
+ messageIndexInTransaction: RequiredCodec(NumberCodec)
7107
7961
  });
7108
- const StorageEntry = Schema.Struct({
7109
- key: FieldElement$1,
7110
- value: FieldElement$1
7962
+ const StorageEntry = MessageCodec({
7963
+ key: RequiredCodec(FieldElement$1),
7964
+ value: RequiredCodec(FieldElement$1)
7111
7965
  });
7112
- const StorageDiff = Schema.Struct({
7113
- filterIds: Schema.Array(Schema.Number),
7114
- contractAddress: FieldElement$1,
7115
- storageEntries: Schema.Array(StorageEntry)
7966
+ const StorageDiff = MessageCodec({
7967
+ filterIds: ArrayCodec(NumberCodec),
7968
+ contractAddress: RequiredCodec(FieldElement$1),
7969
+ storageEntries: ArrayCodec(StorageEntry)
7116
7970
  });
7117
- const DeclaredClass = Schema.Struct({
7118
- _tag: tag("declaredClass"),
7119
- declaredClass: Schema.Struct({
7120
- classHash: Schema.optional(FieldElement$1),
7121
- compiledClassHash: Schema.optional(FieldElement$1)
7122
- })
7971
+ const DeclaredClass = MessageCodec({
7972
+ classHash: OptionalCodec(FieldElement$1),
7973
+ compiledClassHash: OptionalCodec(FieldElement$1)
7123
7974
  });
7124
- const ReplacedClass = Schema.Struct({
7125
- _tag: tag("replacedClass"),
7126
- replacedClass: Schema.Struct({
7127
- contractAddress: Schema.optional(FieldElement$1),
7128
- classHash: Schema.optional(FieldElement$1)
7129
- })
7975
+ const ReplacedClass = MessageCodec({
7976
+ contractAddress: OptionalCodec(FieldElement$1),
7977
+ classHash: OptionalCodec(FieldElement$1)
7130
7978
  });
7131
- const DeployedContract = Schema.Struct({
7132
- _tag: tag("deployedContract"),
7133
- deployedContract: Schema.Struct({
7134
- contractAddress: Schema.optional(FieldElement$1),
7135
- classHash: Schema.optional(FieldElement$1)
7136
- })
7979
+ const DeployedContract = MessageCodec({
7980
+ contractAddress: OptionalCodec(FieldElement$1),
7981
+ classHash: OptionalCodec(FieldElement$1)
7137
7982
  });
7138
- const ContractChange = Schema.Struct({
7139
- filterIds: Schema.Array(Schema.Number),
7140
- change: Schema.Union(DeclaredClass, ReplacedClass, DeployedContract)
7141
- });
7142
- const NonceUpdate = Schema.Struct({
7143
- filterIds: Schema.Array(Schema.Number),
7144
- contractAddress: FieldElement$1,
7145
- nonce: FieldElement$1
7983
+ const ContractChange = MessageCodec({
7984
+ filterIds: ArrayCodec(NumberCodec),
7985
+ change: RequiredCodec(
7986
+ OneOfCodec({
7987
+ declaredClass: DeclaredClass,
7988
+ replacedClass: ReplacedClass,
7989
+ deployedContract: DeployedContract
7990
+ })
7991
+ )
7146
7992
  });
7147
- const Block = Schema.Struct({
7148
- header: BlockHeader,
7149
- transactions: Schema.Array(Transaction),
7150
- receipts: Schema.Array(TransactionReceipt),
7151
- events: Schema.Array(Event),
7152
- messages: Schema.Array(MessageToL1),
7153
- storageDiffs: Schema.Array(StorageDiff),
7154
- contractChanges: Schema.Array(ContractChange),
7155
- nonceUpdates: Schema.Array(NonceUpdate)
7993
+ const NonceUpdate = MessageCodec({
7994
+ filterIds: ArrayCodec(NumberCodec),
7995
+ contractAddress: RequiredCodec(FieldElement$1),
7996
+ nonce: RequiredCodec(FieldElement$1)
7156
7997
  });
7157
- const BlockFromBytes = Schema.transform(
7158
- Schema.Uint8ArrayFromSelf,
7159
- Schema.NullOr(Block),
7160
- {
7161
- strict: false,
7162
- decode(value) {
7163
- if (value.length === 0) {
7164
- return null;
7165
- }
7166
- return Block$1.decode(value);
7167
- },
7168
- encode(value) {
7169
- if (value === null) {
7170
- return new Uint8Array();
7171
- }
7172
- return Block$1.encode(value).finish();
7173
- }
7174
- }
7175
- );
7176
-
7177
- const HeaderFilter = Schema.transform(
7178
- Schema.Enums(HeaderFilter$1),
7179
- Schema.Literal("always", "on_data", "on_data_or_on_new_block", "unknown"),
7180
- {
7181
- decode(value) {
7182
- const enumMap = {
7183
- [HeaderFilter$1.ALWAYS]: "always",
7184
- [HeaderFilter$1.ON_DATA]: "on_data",
7185
- [HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK]: "on_data_or_on_new_block",
7186
- [HeaderFilter$1.UNSPECIFIED]: "unknown",
7187
- [HeaderFilter$1.UNRECOGNIZED]: "unknown"
7188
- };
7189
- return enumMap[value] ?? "unknown";
7190
- },
7191
- encode(value) {
7192
- switch (value) {
7193
- case "always":
7194
- return HeaderFilter$1.ALWAYS;
7195
- case "on_data":
7196
- return HeaderFilter$1.ON_DATA;
7197
- case "on_data_or_on_new_block":
7198
- return HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK;
7199
- default:
7200
- return HeaderFilter$1.UNSPECIFIED;
7201
- }
7202
- }
7203
- }
7204
- );
7205
- const Key = Schema.transform(
7206
- Schema.Struct({ value: Schema.UndefinedOr(FieldElementProto) }),
7207
- Schema.NullOr(FieldElement$1),
7208
- {
7209
- decode({ value }) {
7210
- if (value === void 0) {
7211
- return null;
7212
- }
7213
- return value;
7214
- },
7215
- encode(value) {
7216
- if (value === null) {
7217
- return { value: void 0 };
7218
- }
7219
- return { value };
7220
- }
7221
- }
7222
- );
7223
- const TransactionStatusFilter = Schema.transform(
7224
- Schema.Enums(TransactionStatusFilter$1),
7225
- Schema.Literal("succeeded", "reverted", "all", "unknown"),
7226
- {
7227
- decode(value) {
7228
- const enumMap = {
7229
- [TransactionStatusFilter$1.SUCCEEDED]: "succeeded",
7230
- [TransactionStatusFilter$1.REVERTED]: "reverted",
7231
- [TransactionStatusFilter$1.ALL]: "all",
7232
- [TransactionStatusFilter$1.UNSPECIFIED]: "unknown",
7233
- [TransactionStatusFilter$1.UNRECOGNIZED]: "unknown"
7234
- };
7235
- return enumMap[value] ?? "unknown";
7236
- },
7237
- encode(value) {
7238
- switch (value) {
7239
- case "succeeded":
7240
- return TransactionStatusFilter$1.SUCCEEDED;
7241
- case "reverted":
7242
- return TransactionStatusFilter$1.REVERTED;
7243
- case "all":
7244
- return TransactionStatusFilter$1.ALL;
7245
- default:
7246
- return TransactionStatusFilter$1.UNSPECIFIED;
7247
- }
7248
- }
7998
+ const CallType = {
7999
+ encode(x) {
8000
+ switch (x) {
8001
+ case "libraryCall":
8002
+ return CallType$1.LIBRARY_CALL;
8003
+ case "call":
8004
+ return CallType$1.CALL;
8005
+ case "delegate":
8006
+ return CallType$1.DELEGATE;
8007
+ case "unknown":
8008
+ return CallType$1.UNSPECIFIED;
8009
+ default:
8010
+ return CallType$1.UNRECOGNIZED;
8011
+ }
8012
+ },
8013
+ decode(p) {
8014
+ const enumMap = {
8015
+ [CallType$1.LIBRARY_CALL]: "libraryCall",
8016
+ [CallType$1.CALL]: "call",
8017
+ [CallType$1.DELEGATE]: "delegate",
8018
+ [CallType$1.UNSPECIFIED]: "unknown",
8019
+ [CallType$1.UNRECOGNIZED]: "unknown"
8020
+ };
8021
+ return enumMap[p] ?? "unknown";
7249
8022
  }
7250
- );
7251
- const EventFilter = Schema.Struct({
7252
- id: Schema.optional(Schema.Number),
7253
- address: Schema.optional(FieldElement$1),
7254
- keys: Schema.optional(Schema.Array(Key)),
7255
- strict: Schema.optional(Schema.Boolean),
7256
- transactionStatus: Schema.optional(TransactionStatusFilter),
7257
- includeTransaction: Schema.optional(Schema.Boolean),
7258
- includeReceipt: Schema.optional(Schema.Boolean),
7259
- includeMessages: Schema.optional(Schema.Boolean),
7260
- includeSiblings: Schema.optional(Schema.Boolean)
7261
- });
7262
- const MessageToL1Filter = Schema.Struct({
7263
- id: Schema.optional(Schema.Number),
7264
- fromAddress: Schema.optional(FieldElement$1),
7265
- toAddress: Schema.optional(FieldElement$1),
7266
- transactionStatus: Schema.optional(TransactionStatusFilter),
7267
- includeTransaction: Schema.optional(Schema.Boolean),
7268
- includeReceipt: Schema.optional(Schema.Boolean),
7269
- includeEvents: Schema.optional(Schema.Boolean)
7270
- });
7271
- const InvokeTransactionV0Filter = Schema.Struct({
7272
- _tag: tag("invokeV0"),
7273
- invokeV0: Schema.Struct({})
7274
- });
7275
- const InvokeTransactionV1Filter = Schema.Struct({
7276
- _tag: tag("invokeV1"),
7277
- invokeV1: Schema.Struct({})
8023
+ };
8024
+ const _FunctionInvocationCodec = MessageCodec({
8025
+ contractAddress: RequiredCodec(FieldElement$1),
8026
+ entryPointSelector: RequiredCodec(FieldElement$1),
8027
+ calldata: ArrayCodec(FieldElement$1),
8028
+ callerAddress: RequiredCodec(FieldElement$1),
8029
+ classHash: RequiredCodec(FieldElement$1),
8030
+ callType: RequiredCodec(CallType),
8031
+ result: ArrayCodec(FieldElement$1),
8032
+ events: ArrayCodec(NumberCodec),
8033
+ messages: ArrayCodec(NumberCodec)
7278
8034
  });
7279
- const InvokeTransactionV3Filter = Schema.Struct({
7280
- _tag: tag("invokeV3"),
7281
- invokeV3: Schema.Struct({})
8035
+ const FunctionInvocationCodec = {
8036
+ encode(x) {
8037
+ const { calls, ...rest } = x;
8038
+ const encodedCalls = calls.map(FunctionInvocationCodec.encode);
8039
+ const encodedRest = _FunctionInvocationCodec.encode(rest);
8040
+ return { calls: encodedCalls, ...encodedRest };
8041
+ },
8042
+ decode(p) {
8043
+ const { calls = [], ...rest } = p;
8044
+ const decodedCalls = calls.map(FunctionInvocationCodec.decode);
8045
+ const decodedRest = _FunctionInvocationCodec.decode(rest);
8046
+ return { ...decodedRest, calls: decodedCalls };
8047
+ }
8048
+ };
8049
+ const ExecuteInvocationSuccess = FunctionInvocationCodec;
8050
+ const ExecuteInvocationReverted = MessageCodec({
8051
+ reason: OptionalCodec(StringCodec)
7282
8052
  });
7283
- const DeployTransactionFilter = Schema.Struct({
7284
- _tag: tag("deploy"),
7285
- deploy: Schema.Struct({})
8053
+ const InvokeTransactionTrace = MessageCodec({
8054
+ validateInvocation: OptionalCodec(FunctionInvocationCodec),
8055
+ executeInvocation: RequiredCodec(
8056
+ OneOfCodec({
8057
+ success: ExecuteInvocationSuccess,
8058
+ reverted: ExecuteInvocationReverted
8059
+ })
8060
+ ),
8061
+ feeTransferInvocation: OptionalCodec(FunctionInvocationCodec)
7286
8062
  });
7287
- const DeclareV0TransactionFilter = Schema.Struct({
7288
- _tag: tag("declareV0"),
7289
- declareV0: Schema.Struct({})
8063
+ const DeclareTransactionTrace = MessageCodec({
8064
+ validateInvocation: OptionalCodec(FunctionInvocationCodec),
8065
+ feeTransferInvocation: OptionalCodec(FunctionInvocationCodec)
7290
8066
  });
7291
- const DeclareV1TransactionFilter = Schema.Struct({
7292
- _tag: tag("declareV1"),
7293
- declareV1: Schema.Struct({})
8067
+ const DeployAccountTransactionTrace = MessageCodec({
8068
+ validateInvocation: OptionalCodec(FunctionInvocationCodec),
8069
+ constructorInvocation: OptionalCodec(FunctionInvocationCodec),
8070
+ feeTransferInvocation: OptionalCodec(FunctionInvocationCodec)
7294
8071
  });
7295
- const DeclareV2TransactionFilter = Schema.Struct({
7296
- _tag: tag("declareV2"),
7297
- declareV2: Schema.Struct({})
8072
+ const L1HandlerTransactionTrace = MessageCodec({
8073
+ functionInvocation: OptionalCodec(FunctionInvocationCodec)
7298
8074
  });
7299
- const DeclareV3TransactionFilter = Schema.Struct({
7300
- _tag: tag("declareV3"),
7301
- declareV3: Schema.Struct({})
8075
+ const TransactionTrace = MessageCodec({
8076
+ filterIds: ArrayCodec(NumberCodec),
8077
+ transactionIndex: RequiredCodec(NumberCodec),
8078
+ transactionHash: RequiredCodec(FieldElement$1),
8079
+ traceRoot: RequiredCodec(
8080
+ OneOfCodec({
8081
+ invoke: InvokeTransactionTrace,
8082
+ declare: DeclareTransactionTrace,
8083
+ deployAccount: DeployAccountTransactionTrace,
8084
+ l1Handler: L1HandlerTransactionTrace
8085
+ })
8086
+ )
7302
8087
  });
7303
- const L1HandlerTransactionFilter = Schema.Struct({
7304
- _tag: tag("l1Handler"),
7305
- l1Handler: Schema.Struct({})
8088
+ const Block = MessageCodec({
8089
+ header: RequiredCodec(BlockHeader),
8090
+ transactions: ArrayCodec(Transaction),
8091
+ receipts: ArrayCodec(TransactionReceipt),
8092
+ events: ArrayCodec(Event),
8093
+ messages: ArrayCodec(MessageToL1),
8094
+ traces: ArrayCodec(TransactionTrace),
8095
+ storageDiffs: ArrayCodec(StorageDiff),
8096
+ contractChanges: ArrayCodec(ContractChange),
8097
+ nonceUpdates: ArrayCodec(NonceUpdate)
7306
8098
  });
7307
- const DeployAccountV1TransactionFilter = Schema.Struct({
7308
- _tag: tag("deployAccountV1"),
7309
- deployAccountV1: Schema.Struct({})
8099
+ const BlockFromBytes = {
8100
+ encode(x) {
8101
+ const block = Block.encode(x);
8102
+ return Block$1.encode(block).finish();
8103
+ },
8104
+ decode(p) {
8105
+ const block = Block$1.decode(p);
8106
+ return Block.decode(block);
8107
+ }
8108
+ };
8109
+
8110
+ const HeaderFilter = {
8111
+ encode(x) {
8112
+ switch (x) {
8113
+ case "always":
8114
+ return HeaderFilter$1.ALWAYS;
8115
+ case "on_data":
8116
+ return HeaderFilter$1.ON_DATA;
8117
+ case "on_data_or_on_new_block":
8118
+ return HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK;
8119
+ default:
8120
+ return HeaderFilter$1.UNSPECIFIED;
8121
+ }
8122
+ },
8123
+ decode(p) {
8124
+ const enumMap = {
8125
+ [HeaderFilter$1.ALWAYS]: "always",
8126
+ [HeaderFilter$1.ON_DATA]: "on_data",
8127
+ [HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK]: "on_data_or_on_new_block",
8128
+ [HeaderFilter$1.UNSPECIFIED]: "unknown",
8129
+ [HeaderFilter$1.UNRECOGNIZED]: "unknown"
8130
+ };
8131
+ return enumMap[p] ?? "unknown";
8132
+ }
8133
+ };
8134
+ const Key = {
8135
+ encode(x) {
8136
+ if (x === null) {
8137
+ return { value: void 0 };
8138
+ }
8139
+ return { value: FieldElement$1.encode(x) };
8140
+ },
8141
+ decode(p) {
8142
+ if (p.value === void 0) {
8143
+ return null;
8144
+ }
8145
+ return FieldElement$1.decode(p.value);
8146
+ }
8147
+ };
8148
+ const TransactionStatusFilter = {
8149
+ encode(x) {
8150
+ switch (x) {
8151
+ case "succeeded":
8152
+ return TransactionStatusFilter$1.SUCCEEDED;
8153
+ case "reverted":
8154
+ return TransactionStatusFilter$1.REVERTED;
8155
+ case "all":
8156
+ return TransactionStatusFilter$1.ALL;
8157
+ default:
8158
+ return TransactionStatusFilter$1.UNSPECIFIED;
8159
+ }
8160
+ },
8161
+ decode(p) {
8162
+ const enumMap = {
8163
+ [TransactionStatusFilter$1.SUCCEEDED]: "succeeded",
8164
+ [TransactionStatusFilter$1.REVERTED]: "reverted",
8165
+ [TransactionStatusFilter$1.ALL]: "all",
8166
+ [TransactionStatusFilter$1.UNSPECIFIED]: "unknown",
8167
+ [TransactionStatusFilter$1.UNRECOGNIZED]: "unknown"
8168
+ };
8169
+ return enumMap[p] ?? "unknown";
8170
+ }
8171
+ };
8172
+ const EventFilter = MessageCodec({
8173
+ id: OptionalCodec(NumberCodec),
8174
+ address: OptionalCodec(FieldElement$1),
8175
+ keys: OptionalCodec(ArrayCodec(Key)),
8176
+ strict: OptionalCodec(BooleanCodec),
8177
+ transactionStatus: OptionalCodec(TransactionStatusFilter),
8178
+ includeTransaction: OptionalCodec(BooleanCodec),
8179
+ includeReceipt: OptionalCodec(BooleanCodec),
8180
+ includeMessages: OptionalCodec(BooleanCodec),
8181
+ includeSiblings: OptionalCodec(BooleanCodec),
8182
+ includeTransactionTrace: OptionalCodec(BooleanCodec)
7310
8183
  });
7311
- const DeployAccountV3TransactionFilter = Schema.Struct({
7312
- _tag: tag("deployAccountV3"),
7313
- deployAccountV3: Schema.Struct({})
8184
+ const MessageToL1Filter = MessageCodec({
8185
+ id: OptionalCodec(NumberCodec),
8186
+ fromAddress: OptionalCodec(FieldElement$1),
8187
+ toAddress: OptionalCodec(FieldElement$1),
8188
+ transactionStatus: OptionalCodec(TransactionStatusFilter),
8189
+ includeTransaction: OptionalCodec(BooleanCodec),
8190
+ includeReceipt: OptionalCodec(BooleanCodec),
8191
+ includeEvents: OptionalCodec(BooleanCodec),
8192
+ includeTransactionTrace: OptionalCodec(BooleanCodec)
7314
8193
  });
7315
- const TransactionFilter = Schema.Struct({
7316
- id: Schema.optional(Schema.Number),
7317
- transactionStatus: Schema.optional(TransactionStatusFilter),
7318
- includeReceipt: Schema.optional(Schema.Boolean),
7319
- includeMessages: Schema.optional(Schema.Boolean),
7320
- includeEvents: Schema.optional(Schema.Boolean),
7321
- transactionType: Schema.optional(
7322
- Schema.Union(
7323
- InvokeTransactionV0Filter,
7324
- InvokeTransactionV1Filter,
7325
- InvokeTransactionV3Filter,
7326
- DeployTransactionFilter,
7327
- DeclareV0TransactionFilter,
7328
- DeclareV1TransactionFilter,
7329
- DeclareV2TransactionFilter,
7330
- DeclareV3TransactionFilter,
7331
- DeclareV3TransactionFilter,
7332
- L1HandlerTransactionFilter,
7333
- DeployAccountV1TransactionFilter,
7334
- DeployAccountV3TransactionFilter
7335
- )
8194
+ const InvokeTransactionV0Filter = MessageCodec({});
8195
+ const InvokeTransactionV1Filter = MessageCodec({});
8196
+ const InvokeTransactionV3Filter = MessageCodec({});
8197
+ const DeployTransactionFilter = MessageCodec({});
8198
+ const DeclareV0TransactionFilter = MessageCodec({});
8199
+ const DeclareV1TransactionFilter = MessageCodec({});
8200
+ const DeclareV2TransactionFilter = MessageCodec({});
8201
+ const DeclareV3TransactionFilter = MessageCodec({});
8202
+ const L1HandlerTransactionFilter = MessageCodec({});
8203
+ const DeployAccountV1TransactionFilter = MessageCodec({});
8204
+ const DeployAccountV3TransactionFilter = MessageCodec({});
8205
+ const TransactionFilter = MessageCodec({
8206
+ id: OptionalCodec(NumberCodec),
8207
+ transactionStatus: OptionalCodec(TransactionStatusFilter),
8208
+ includeReceipt: OptionalCodec(BooleanCodec),
8209
+ includeMessages: OptionalCodec(BooleanCodec),
8210
+ includeEvents: OptionalCodec(BooleanCodec),
8211
+ includeTrace: OptionalCodec(BooleanCodec),
8212
+ transactionType: OptionalCodec(
8213
+ OneOfCodec({
8214
+ invokeV0: InvokeTransactionV0Filter,
8215
+ invokeV1: InvokeTransactionV1Filter,
8216
+ invokeV3: InvokeTransactionV3Filter,
8217
+ deploy: DeployTransactionFilter,
8218
+ declareV0: DeclareV0TransactionFilter,
8219
+ declareV1: DeclareV1TransactionFilter,
8220
+ declareV2: DeclareV2TransactionFilter,
8221
+ declareV3: DeclareV3TransactionFilter,
8222
+ l1Handler: L1HandlerTransactionFilter,
8223
+ deployAccountV1: DeployAccountV1TransactionFilter,
8224
+ deployAccountV3: DeployAccountV3TransactionFilter
8225
+ })
7336
8226
  )
7337
8227
  });
7338
- const StorageDiffFilter = Schema.Struct({
7339
- id: Schema.optional(Schema.Number),
7340
- contractAddress: Schema.optional(FieldElement$1)
7341
- });
7342
- const DeclaredClassFilter = Schema.Struct({
7343
- _tag: tag("declaredClass"),
7344
- declaredClass: Schema.Struct({})
8228
+ const StorageDiffFilter = MessageCodec({
8229
+ id: OptionalCodec(NumberCodec),
8230
+ contractAddress: OptionalCodec(FieldElement$1)
7345
8231
  });
7346
- const ReplacedClassFilter = Schema.Struct({
7347
- _tag: tag("replacedClass"),
7348
- replacedClass: Schema.Struct({})
7349
- });
7350
- const DeployedContractFilter = Schema.Struct({
7351
- _tag: tag("deployedContract"),
7352
- deployedContract: Schema.Struct({})
7353
- });
7354
- const ContractChangeFilter = Schema.Struct({
7355
- id: Schema.optional(Schema.Number),
7356
- change: Schema.optional(
7357
- Schema.Union(
7358
- DeclaredClassFilter,
7359
- ReplacedClassFilter,
7360
- DeployedContractFilter
7361
- )
8232
+ const DeclaredClassFilter = MessageCodec({});
8233
+ const ReplacedClassFilter = MessageCodec({});
8234
+ const DeployedContractFilter = MessageCodec({});
8235
+ const ContractChangeFilter = MessageCodec({
8236
+ id: OptionalCodec(NumberCodec),
8237
+ change: OptionalCodec(
8238
+ OneOfCodec({
8239
+ declaredClass: DeclaredClassFilter,
8240
+ replacedClass: ReplacedClassFilter,
8241
+ deployedContract: DeployedContractFilter
8242
+ })
7362
8243
  )
7363
8244
  });
7364
- const NonceUpdateFilter = Schema.Struct({
7365
- id: Schema.optional(Schema.Number),
7366
- contractAddress: Schema.optional(FieldElement$1)
8245
+ const NonceUpdateFilter = MessageCodec({
8246
+ id: OptionalCodec(NumberCodec),
8247
+ contractAddress: OptionalCodec(FieldElement$1)
7367
8248
  });
7368
- const Filter = Schema.Struct({
7369
- header: Schema.optional(HeaderFilter),
7370
- transactions: Schema.optional(Schema.Array(TransactionFilter)),
7371
- events: Schema.optional(Schema.Array(EventFilter)),
7372
- messages: Schema.optional(Schema.Array(MessageToL1Filter)),
7373
- storageDiffs: Schema.optional(Schema.Array(StorageDiffFilter)),
7374
- contractChanges: Schema.optional(Schema.Array(ContractChangeFilter)),
7375
- nonceUpdates: Schema.optional(Schema.Array(NonceUpdateFilter))
8249
+ const Filter = MessageCodec({
8250
+ header: OptionalCodec(HeaderFilter),
8251
+ transactions: OptionalCodec(ArrayCodec(TransactionFilter)),
8252
+ events: OptionalCodec(ArrayCodec(EventFilter)),
8253
+ messages: OptionalCodec(ArrayCodec(MessageToL1Filter)),
8254
+ storageDiffs: OptionalCodec(ArrayCodec(StorageDiffFilter)),
8255
+ contractChanges: OptionalCodec(ArrayCodec(ContractChangeFilter)),
8256
+ nonceUpdates: OptionalCodec(ArrayCodec(NonceUpdateFilter))
7376
8257
  });
7377
- const filterToProto = Schema.encodeSync(Filter);
7378
- const filterFromProto = Schema.decodeSync(Filter);
7379
- const FilterFromBytes = Schema.transform(
7380
- Schema.Uint8ArrayFromSelf,
7381
- Filter,
7382
- {
7383
- strict: false,
7384
- decode(value) {
7385
- return Filter$1.decode(value);
7386
- },
7387
- encode(value) {
7388
- return Filter$1.encode(value).finish();
7389
- }
8258
+ const FilterFromBytes = {
8259
+ encode(x) {
8260
+ const filter = Filter.encode(x);
8261
+ return Filter$1.encode(filter).finish();
8262
+ },
8263
+ decode(p) {
8264
+ const filter = Filter$1.decode(p);
8265
+ return Filter.decode(filter);
7390
8266
  }
7391
- );
7392
- const filterToBytes = Schema.encodeSync(FilterFromBytes);
7393
- const filterFromBytes = Schema.decodeSync(FilterFromBytes);
8267
+ };
7394
8268
  function mergeFilter(a, b) {
7395
8269
  const header = mergeHeaderFilter(a.header, b.header);
7396
8270
  return {
@@ -7477,6 +8351,7 @@ const PrimitiveTypeParsers = {
7477
8351
  "core::integer::u64": parseU64,
7478
8352
  "core::integer::u128": parseU128,
7479
8353
  "core::integer::u256": parseU256,
8354
+ "core::bytes_31::bytes31": parseBytes31,
7480
8355
  "core::starknet::contract_address::ContractAddress": parseContractAddress
7481
8356
  };
7482
8357
  function isPrimitiveType(type) {
@@ -7503,6 +8378,19 @@ function getOptionType(type) {
7503
8378
  function isEmptyType(type) {
7504
8379
  return type === "()";
7505
8380
  }
8381
+ function isByteArray(type) {
8382
+ return type === "core::byte_array::ByteArray";
8383
+ }
8384
+
8385
+ function isEventAbi(item) {
8386
+ return item.type === "event";
8387
+ }
8388
+ function isStructEventAbi(item) {
8389
+ return isEventAbi(item) && item.kind === "struct";
8390
+ }
8391
+ function isEnumEventAbi(item) {
8392
+ return isEventAbi(item) && item.kind === "enum";
8393
+ }
7506
8394
 
7507
8395
  class DecodeEventError extends Error {
7508
8396
  constructor(message) {
@@ -7515,50 +8403,120 @@ function decodeEvent(args) {
7515
8403
  const eventAbi = abi.find(
7516
8404
  (item) => item.name === eventName && item.type === "event"
7517
8405
  );
7518
- if (!eventAbi || eventAbi.type !== "event") {
8406
+ if (!eventAbi || !isEventAbi(eventAbi)) {
7519
8407
  if (strict) {
7520
8408
  throw new DecodeEventError(`Event ${eventName} not found in ABI`);
7521
8409
  }
7522
8410
  return null;
7523
8411
  }
7524
- if (eventAbi.kind === "enum") {
7525
- throw new DecodeEventError("enum: not implemented");
8412
+ try {
8413
+ if (isStructEventAbi(eventAbi)) {
8414
+ return decodeStructEvent(abi, eventAbi, event, eventName);
8415
+ }
8416
+ if (isEnumEventAbi(eventAbi)) {
8417
+ return decodeEnumEvent(abi, eventAbi, event, eventName);
8418
+ }
8419
+ throw new DecodeEventError(
8420
+ `Unsupported event kind: ${eventAbi?.kind}`
8421
+ );
8422
+ } catch (error) {
8423
+ if ((error instanceof DecodeEventError || error instanceof ParseError) && !strict) {
8424
+ return null;
8425
+ }
8426
+ throw error;
7526
8427
  }
8428
+ }
8429
+ function decodeStructEvent(abi, eventAbi, event, eventName) {
7527
8430
  const selector = BigInt(getEventSelector(eventName));
7528
8431
  if (event.keys && selector !== BigInt(event.keys[0]) || !event.keys) {
7529
- if (strict) {
7530
- throw new DecodeEventError(
7531
- `Selector mismatch. Expected ${selector}, got ${event.keys?.[0]}`
7532
- );
7533
- }
7534
- return null;
8432
+ throw new DecodeEventError(
8433
+ `Selector mismatch. Expected ${selector}, got ${event.keys?.[0]}`
8434
+ );
7535
8435
  }
7536
8436
  const keysAbi = eventAbi.members.filter((m) => m.kind === "key");
7537
8437
  const dataAbi = eventAbi.members.filter((m) => m.kind === "data");
7538
- try {
7539
- const keysParser = compileEventMembers(abi, keysAbi);
7540
- const dataParser = compileEventMembers(abi, dataAbi);
7541
- const keysWithoutSelector = event.keys?.slice(1) ?? [];
7542
- const { out: decodedKeys } = keysParser(keysWithoutSelector, 0);
7543
- const { out: decodedData } = dataParser(event.data ?? [], 0);
7544
- const decoded = {
7545
- ...decodedKeys,
7546
- ...decodedData
7547
- };
7548
- return {
7549
- ...event,
7550
- eventName,
7551
- args: decoded
7552
- };
7553
- } catch (error) {
7554
- if (error instanceof DecodeEventError && !strict) {
7555
- return null;
8438
+ const keysParser = compileEventMembers(abi, keysAbi);
8439
+ const dataParser = compileEventMembers(abi, dataAbi);
8440
+ const keysWithoutSelector = event.keys?.slice(1) ?? [];
8441
+ const { out: decodedKeys } = keysParser(keysWithoutSelector, 0);
8442
+ const { out: decodedData } = dataParser(event.data ?? [], 0);
8443
+ const decoded = {
8444
+ ...decodedKeys,
8445
+ ...decodedData
8446
+ };
8447
+ return {
8448
+ ...event,
8449
+ eventName,
8450
+ args: decoded
8451
+ };
8452
+ }
8453
+ function decodeEnumEvent(abi, eventAbi, event, eventName) {
8454
+ if (!event.keys || event.keys.length === 0) {
8455
+ throw new DecodeEventError(
8456
+ "Event has no keys; cannot determine variant selector"
8457
+ );
8458
+ }
8459
+ const variants = eventAbi.variants;
8460
+ const variantSelector = event.keys[0];
8461
+ const selectorToVariant = buildVariantSelectorMap(abi, variants);
8462
+ const matchingVariant = selectorToVariant[variantSelector];
8463
+ if (!matchingVariant) {
8464
+ throw new DecodeEventError(
8465
+ `No matching variant found for selector: ${variantSelector}`
8466
+ );
8467
+ }
8468
+ const structEventAbi = abi.find(
8469
+ (item) => item.name === matchingVariant.variant.type && item.type === "event"
8470
+ );
8471
+ if (!structEventAbi || !isStructEventAbi(structEventAbi)) {
8472
+ throw new DecodeEventError(
8473
+ `Nested event type not found or not a struct: ${matchingVariant.variant.type}`
8474
+ );
8475
+ }
8476
+ const decodedStruct = decodeStructEvent(
8477
+ abi,
8478
+ structEventAbi,
8479
+ event,
8480
+ matchingVariant.variant.name
8481
+ );
8482
+ return {
8483
+ ...event,
8484
+ eventName,
8485
+ args: {
8486
+ _tag: matchingVariant.variant.name,
8487
+ [matchingVariant.variant.name]: decodedStruct.args
7556
8488
  }
7557
- if (error instanceof ParseError && !strict) {
7558
- return null;
8489
+ };
8490
+ }
8491
+ function buildVariantSelectorMap(abi, variants) {
8492
+ const selectorMap = {};
8493
+ for (const variant of variants) {
8494
+ if (variant.kind === "nested") {
8495
+ const selector = getEventSelector(variant.name);
8496
+ selectorMap[selector] = { variant, path: [variant.name] };
8497
+ } else if (variant.kind === "flat") {
8498
+ const flatEventName = variant.type;
8499
+ const flatEventAbi = abi.find(
8500
+ (item) => item.name === flatEventName && item.type === "event"
8501
+ );
8502
+ if (!flatEventAbi) {
8503
+ continue;
8504
+ }
8505
+ if (isEnumEventAbi(flatEventAbi)) {
8506
+ const nestedMap = buildVariantSelectorMap(abi, flatEventAbi.variants);
8507
+ for (const [
8508
+ nestedSelector,
8509
+ { variant: nestedVariant, path: nestedPath }
8510
+ ] of Object.entries(nestedMap)) {
8511
+ selectorMap[nestedSelector] = {
8512
+ variant: nestedVariant,
8513
+ path: [variant.name, ...nestedPath]
8514
+ };
8515
+ }
8516
+ }
7559
8517
  }
7560
- throw error;
7561
8518
  }
8519
+ return selectorMap;
7562
8520
  }
7563
8521
  function compileEventMembers(abi, members) {
7564
8522
  return compileStructParser(abi, members);
@@ -7582,6 +8540,9 @@ function compileTypeParser(abi, type) {
7582
8540
  if (isEmptyType(type)) {
7583
8541
  return parseEmpty;
7584
8542
  }
8543
+ if (isByteArray(type)) {
8544
+ return parseByteArray;
8545
+ }
7585
8546
  const typeAbi = abi.find((item) => item.name === type);
7586
8547
  if (!typeAbi) {
7587
8548
  throw new DecodeEventError(`Type ${type} not found in ABI`);
@@ -7590,8 +8551,9 @@ function compileTypeParser(abi, type) {
7590
8551
  case "struct": {
7591
8552
  return compileStructParser(abi, typeAbi.members);
7592
8553
  }
7593
- case "enum":
7594
- throw new DecodeEventError("enum: not implemented");
8554
+ case "enum": {
8555
+ return compileEnumParser(abi, typeAbi);
8556
+ }
7595
8557
  default:
7596
8558
  throw new DecodeEventError(`Invalid type ${typeAbi.type}`);
7597
8559
  }
@@ -7606,11 +8568,23 @@ function compileStructParser(abi, members) {
7606
8568
  }
7607
8569
  return parseStruct(parsers);
7608
8570
  }
8571
+ function compileEnumParser(abi, enumAbi) {
8572
+ const parsers = {};
8573
+ for (const [index, variant] of enumAbi.variants.entries()) {
8574
+ parsers[variant.name] = {
8575
+ index,
8576
+ parser: compileTypeParser(abi, variant.type)
8577
+ };
8578
+ }
8579
+ return parseEnum(parsers);
8580
+ }
7609
8581
 
7610
8582
  const StarknetStream = new StreamConfig(
7611
8583
  FilterFromBytes,
7612
8584
  BlockFromBytes,
7613
- mergeFilter
8585
+ mergeFilter,
8586
+ "starknet"
7614
8587
  );
7615
8588
 
7616
- export { Block, BlockFromBytes, BlockHeader, ComputationResources, ContractChange, ContractChangeFilter, DataAvailabilityMode, DataAvailabilityResources, DeclareTransactionReceipt, DeclareTransactionV0, DeclareTransactionV1, DeclareTransactionV2, DeclareTransactionV3, DeclareV0TransactionFilter, DeclareV1TransactionFilter, DeclareV2TransactionFilter, DeclareV3TransactionFilter, DeclaredClass, DeclaredClassFilter, DecodeEventError, DeployAccountTransactionReceipt, DeployAccountTransactionV1, DeployAccountTransactionV3, DeployAccountV1TransactionFilter, DeployAccountV3TransactionFilter, DeployTransaction, DeployTransactionFilter, DeployTransactionReceipt, DeployedContract, DeployedContractFilter, Event, EventFilter, ExecutionResources, ExecutionReverted, ExecutionSucceeded, FeePayment, FieldElement$1 as FieldElement, FieldElementProto, Filter, FilterFromBytes, HeaderFilter, InvokeTransactionReceipt, InvokeTransactionV0, InvokeTransactionV0Filter, InvokeTransactionV1, InvokeTransactionV1Filter, InvokeTransactionV3, InvokeTransactionV3Filter, Key, L1DataAvailabilityMode, L1HandlerTransaction, L1HandlerTransactionFilter, L1HandlerTransactionReceipt, MessageToL1, MessageToL1Filter, NonceUpdate, NonceUpdateFilter, PriceUnit, ReplacedClass, ReplacedClassFilter, ResourceBounds, ResourceBoundsMapping, ResourcePrice, StarknetStream, StorageDiff, StorageDiffFilter, StorageEntry, Transaction, TransactionFilter, TransactionMeta, TransactionReceipt, TransactionReceiptMeta, TransactionStatus, TransactionStatusFilter, U128, decodeEvent, feltFromProto, feltToProto, filterFromBytes, filterFromProto, filterToBytes, filterToProto, getBigIntSelector, getEventSelector, getReceipt, getSelector, getTransaction, mergeFilter, index as proto };
8589
+ export { Block, BlockFromBytes, BlockHeader, CallType, ComputationResources, ContractChange, ContractChangeFilter, DataAvailabilityMode, DataAvailabilityResources, DeclareTransactionReceipt, DeclareTransactionTrace, DeclareTransactionV0, DeclareTransactionV1, DeclareTransactionV2, DeclareTransactionV3, DeclareV0TransactionFilter, DeclareV1TransactionFilter, DeclareV2TransactionFilter, DeclareV3TransactionFilter, DeclaredClass, DeclaredClassFilter, DecodeEventError, DeployAccountTransactionReceipt, DeployAccountTransactionTrace, DeployAccountTransactionV1, DeployAccountTransactionV3, DeployAccountV1TransactionFilter, DeployAccountV3TransactionFilter, DeployTransaction, DeployTransactionFilter, DeployTransactionReceipt, DeployedContract, DeployedContractFilter, Event, EventFilter, ExecuteInvocationReverted, ExecuteInvocationSuccess, ExecutionResources, ExecutionReverted, ExecutionSucceeded, FeePayment, FieldElement$1 as FieldElement, Filter, FilterFromBytes, HeaderFilter, InvokeTransactionReceipt, InvokeTransactionTrace, InvokeTransactionV0, InvokeTransactionV0Filter, InvokeTransactionV1, InvokeTransactionV1Filter, InvokeTransactionV3, InvokeTransactionV3Filter, Key, L1DataAvailabilityMode, L1HandlerTransaction, L1HandlerTransactionFilter, L1HandlerTransactionReceipt, L1HandlerTransactionTrace, MessageToL1, MessageToL1Filter, NonceUpdate, NonceUpdateFilter, PriceUnit, ReplacedClass, ReplacedClassFilter, ResourceBounds, ResourceBoundsMapping, ResourcePrice, StarknetStream, StorageDiff, StorageDiffFilter, StorageEntry, Transaction, TransactionFilter, TransactionMeta, TransactionReceipt, TransactionReceiptMeta, TransactionStatus, TransactionStatusFilter, TransactionTrace, U128, decodeEvent, getBigIntSelector, getEventSelector, getReceipt, getSelector, getTransaction, mergeFilter, index as proto };
8590
+ //# sourceMappingURL=index.mjs.map