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