@apibara/starknet 2.1.0-beta.4 → 2.1.0-beta.41

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
  };
@@ -4926,39 +4967,810 @@ const NonceUpdate$1 = {
4926
4967
  return message;
4927
4968
  }
4928
4969
  };
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);
4970
+ function createBaseTransactionTrace() {
4971
+ return { filterIds: [], transactionIndex: 0, transactionHash: void 0, traceRoot: void 0 };
4972
+ }
4973
+ const TransactionTrace$1 = {
4974
+ encode(message, writer = _m0__default.Writer.create()) {
4975
+ if (message.filterIds !== void 0 && message.filterIds.length !== 0) {
4976
+ writer.uint32(10).fork();
4977
+ for (const v of message.filterIds) {
4978
+ writer.uint32(v);
4979
+ }
4980
+ writer.ldelim();
4937
4981
  }
4938
- return arr;
4982
+ if (message.transactionIndex !== void 0 && message.transactionIndex !== 0) {
4983
+ writer.uint32(16).uint32(message.transactionIndex);
4984
+ }
4985
+ if (message.transactionHash !== void 0) {
4986
+ FieldElement.encode(message.transactionHash, writer.uint32(26).fork()).ldelim();
4987
+ }
4988
+ switch (message.traceRoot?.$case) {
4989
+ case "invoke":
4990
+ InvokeTransactionTrace$1.encode(message.traceRoot.invoke, writer.uint32(34).fork()).ldelim();
4991
+ break;
4992
+ case "declare":
4993
+ DeclareTransactionTrace$1.encode(message.traceRoot.declare, writer.uint32(42).fork()).ldelim();
4994
+ break;
4995
+ case "deployAccount":
4996
+ DeployAccountTransactionTrace$1.encode(message.traceRoot.deployAccount, writer.uint32(50).fork()).ldelim();
4997
+ break;
4998
+ case "l1Handler":
4999
+ L1HandlerTransactionTrace$1.encode(message.traceRoot.l1Handler, writer.uint32(58).fork()).ldelim();
5000
+ break;
5001
+ }
5002
+ return writer;
5003
+ },
5004
+ decode(input, length) {
5005
+ const reader = input instanceof _m0__default.Reader ? input : _m0__default.Reader.create(input);
5006
+ let end = length === void 0 ? reader.len : reader.pos + length;
5007
+ const message = createBaseTransactionTrace();
5008
+ while (reader.pos < end) {
5009
+ const tag = reader.uint32();
5010
+ switch (tag >>> 3) {
5011
+ case 1:
5012
+ if (tag === 8) {
5013
+ message.filterIds.push(reader.uint32());
5014
+ continue;
5015
+ }
5016
+ if (tag === 10) {
5017
+ const end2 = reader.uint32() + reader.pos;
5018
+ while (reader.pos < end2) {
5019
+ message.filterIds.push(reader.uint32());
5020
+ }
5021
+ continue;
5022
+ }
5023
+ break;
5024
+ case 2:
5025
+ if (tag !== 16) {
5026
+ break;
5027
+ }
5028
+ message.transactionIndex = reader.uint32();
5029
+ continue;
5030
+ case 3:
5031
+ if (tag !== 26) {
5032
+ break;
5033
+ }
5034
+ message.transactionHash = FieldElement.decode(reader, reader.uint32());
5035
+ continue;
5036
+ case 4:
5037
+ if (tag !== 34) {
5038
+ break;
5039
+ }
5040
+ message.traceRoot = { $case: "invoke", invoke: InvokeTransactionTrace$1.decode(reader, reader.uint32()) };
5041
+ continue;
5042
+ case 5:
5043
+ if (tag !== 42) {
5044
+ break;
5045
+ }
5046
+ message.traceRoot = { $case: "declare", declare: DeclareTransactionTrace$1.decode(reader, reader.uint32()) };
5047
+ continue;
5048
+ case 6:
5049
+ if (tag !== 50) {
5050
+ break;
5051
+ }
5052
+ message.traceRoot = {
5053
+ $case: "deployAccount",
5054
+ deployAccount: DeployAccountTransactionTrace$1.decode(reader, reader.uint32())
5055
+ };
5056
+ continue;
5057
+ case 7:
5058
+ if (tag !== 58) {
5059
+ break;
5060
+ }
5061
+ message.traceRoot = {
5062
+ $case: "l1Handler",
5063
+ l1Handler: L1HandlerTransactionTrace$1.decode(reader, reader.uint32())
5064
+ };
5065
+ continue;
5066
+ }
5067
+ if ((tag & 7) === 4 || tag === 0) {
5068
+ break;
5069
+ }
5070
+ reader.skipType(tag & 7);
5071
+ }
5072
+ return message;
5073
+ },
5074
+ fromJSON(object) {
5075
+ return {
5076
+ filterIds: globalThis.Array.isArray(object?.filterIds) ? object.filterIds.map((e) => globalThis.Number(e)) : [],
5077
+ transactionIndex: isSet$1(object.transactionIndex) ? globalThis.Number(object.transactionIndex) : 0,
5078
+ transactionHash: isSet$1(object.transactionHash) ? FieldElement.fromJSON(object.transactionHash) : void 0,
5079
+ 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
5080
+ };
5081
+ },
5082
+ toJSON(message) {
5083
+ const obj = {};
5084
+ if (message.filterIds?.length) {
5085
+ obj.filterIds = message.filterIds.map((e) => Math.round(e));
5086
+ }
5087
+ if (message.transactionIndex !== void 0 && message.transactionIndex !== 0) {
5088
+ obj.transactionIndex = Math.round(message.transactionIndex);
5089
+ }
5090
+ if (message.transactionHash !== void 0) {
5091
+ obj.transactionHash = FieldElement.toJSON(message.transactionHash);
5092
+ }
5093
+ if (message.traceRoot?.$case === "invoke") {
5094
+ obj.invoke = InvokeTransactionTrace$1.toJSON(message.traceRoot.invoke);
5095
+ }
5096
+ if (message.traceRoot?.$case === "declare") {
5097
+ obj.declare = DeclareTransactionTrace$1.toJSON(message.traceRoot.declare);
5098
+ }
5099
+ if (message.traceRoot?.$case === "deployAccount") {
5100
+ obj.deployAccount = DeployAccountTransactionTrace$1.toJSON(message.traceRoot.deployAccount);
5101
+ }
5102
+ if (message.traceRoot?.$case === "l1Handler") {
5103
+ obj.l1Handler = L1HandlerTransactionTrace$1.toJSON(message.traceRoot.l1Handler);
5104
+ }
5105
+ return obj;
5106
+ },
5107
+ create(base) {
5108
+ return TransactionTrace$1.fromPartial(base ?? {});
5109
+ },
5110
+ fromPartial(object) {
5111
+ const message = createBaseTransactionTrace();
5112
+ message.filterIds = object.filterIds?.map((e) => e) || [];
5113
+ message.transactionIndex = object.transactionIndex ?? 0;
5114
+ message.transactionHash = object.transactionHash !== void 0 && object.transactionHash !== null ? FieldElement.fromPartial(object.transactionHash) : void 0;
5115
+ if (object.traceRoot?.$case === "invoke" && object.traceRoot?.invoke !== void 0 && object.traceRoot?.invoke !== null) {
5116
+ message.traceRoot = { $case: "invoke", invoke: InvokeTransactionTrace$1.fromPartial(object.traceRoot.invoke) };
5117
+ }
5118
+ if (object.traceRoot?.$case === "declare" && object.traceRoot?.declare !== void 0 && object.traceRoot?.declare !== null) {
5119
+ message.traceRoot = { $case: "declare", declare: DeclareTransactionTrace$1.fromPartial(object.traceRoot.declare) };
5120
+ }
5121
+ if (object.traceRoot?.$case === "deployAccount" && object.traceRoot?.deployAccount !== void 0 && object.traceRoot?.deployAccount !== null) {
5122
+ message.traceRoot = {
5123
+ $case: "deployAccount",
5124
+ deployAccount: DeployAccountTransactionTrace$1.fromPartial(object.traceRoot.deployAccount)
5125
+ };
5126
+ }
5127
+ if (object.traceRoot?.$case === "l1Handler" && object.traceRoot?.l1Handler !== void 0 && object.traceRoot?.l1Handler !== null) {
5128
+ message.traceRoot = {
5129
+ $case: "l1Handler",
5130
+ l1Handler: L1HandlerTransactionTrace$1.fromPartial(object.traceRoot.l1Handler)
5131
+ };
5132
+ }
5133
+ return message;
4939
5134
  }
5135
+ };
5136
+ function createBaseInvokeTransactionTrace() {
5137
+ return { validateInvocation: void 0, executeInvocation: void 0, feeTransferInvocation: void 0 };
4940
5138
  }
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(""));
5139
+ const InvokeTransactionTrace$1 = {
5140
+ encode(message, writer = _m0__default.Writer.create()) {
5141
+ if (message.validateInvocation !== void 0) {
5142
+ FunctionInvocation.encode(message.validateInvocation, writer.uint32(10).fork()).ldelim();
5143
+ }
5144
+ switch (message.executeInvocation?.$case) {
5145
+ case "success":
5146
+ FunctionInvocation.encode(message.executeInvocation.success, writer.uint32(18).fork()).ldelim();
5147
+ break;
5148
+ case "reverted":
5149
+ ExecutionReverted$1.encode(message.executeInvocation.reverted, writer.uint32(26).fork()).ldelim();
5150
+ break;
5151
+ }
5152
+ if (message.feeTransferInvocation !== void 0) {
5153
+ FunctionInvocation.encode(message.feeTransferInvocation, writer.uint32(34).fork()).ldelim();
5154
+ }
5155
+ return writer;
5156
+ },
5157
+ decode(input, length) {
5158
+ const reader = input instanceof _m0__default.Reader ? input : _m0__default.Reader.create(input);
5159
+ let end = length === void 0 ? reader.len : reader.pos + length;
5160
+ const message = createBaseInvokeTransactionTrace();
5161
+ while (reader.pos < end) {
5162
+ const tag = reader.uint32();
5163
+ switch (tag >>> 3) {
5164
+ case 1:
5165
+ if (tag !== 10) {
5166
+ break;
5167
+ }
5168
+ message.validateInvocation = FunctionInvocation.decode(reader, reader.uint32());
5169
+ continue;
5170
+ case 2:
5171
+ if (tag !== 18) {
5172
+ break;
5173
+ }
5174
+ message.executeInvocation = { $case: "success", success: FunctionInvocation.decode(reader, reader.uint32()) };
5175
+ continue;
5176
+ case 3:
5177
+ if (tag !== 26) {
5178
+ break;
5179
+ }
5180
+ message.executeInvocation = {
5181
+ $case: "reverted",
5182
+ reverted: ExecutionReverted$1.decode(reader, reader.uint32())
5183
+ };
5184
+ continue;
5185
+ case 4:
5186
+ if (tag !== 34) {
5187
+ break;
5188
+ }
5189
+ message.feeTransferInvocation = FunctionInvocation.decode(reader, reader.uint32());
5190
+ continue;
5191
+ }
5192
+ if ((tag & 7) === 4 || tag === 0) {
5193
+ break;
5194
+ }
5195
+ reader.skipType(tag & 7);
5196
+ }
5197
+ return message;
5198
+ },
5199
+ fromJSON(object) {
5200
+ return {
5201
+ validateInvocation: isSet$1(object.validateInvocation) ? FunctionInvocation.fromJSON(object.validateInvocation) : void 0,
5202
+ 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,
5203
+ feeTransferInvocation: isSet$1(object.feeTransferInvocation) ? FunctionInvocation.fromJSON(object.feeTransferInvocation) : void 0
5204
+ };
5205
+ },
5206
+ toJSON(message) {
5207
+ const obj = {};
5208
+ if (message.validateInvocation !== void 0) {
5209
+ obj.validateInvocation = FunctionInvocation.toJSON(message.validateInvocation);
5210
+ }
5211
+ if (message.executeInvocation?.$case === "success") {
5212
+ obj.success = FunctionInvocation.toJSON(message.executeInvocation.success);
5213
+ }
5214
+ if (message.executeInvocation?.$case === "reverted") {
5215
+ obj.reverted = ExecutionReverted$1.toJSON(message.executeInvocation.reverted);
5216
+ }
5217
+ if (message.feeTransferInvocation !== void 0) {
5218
+ obj.feeTransferInvocation = FunctionInvocation.toJSON(message.feeTransferInvocation);
5219
+ }
5220
+ return obj;
5221
+ },
5222
+ create(base) {
5223
+ return InvokeTransactionTrace$1.fromPartial(base ?? {});
5224
+ },
5225
+ fromPartial(object) {
5226
+ const message = createBaseInvokeTransactionTrace();
5227
+ message.validateInvocation = object.validateInvocation !== void 0 && object.validateInvocation !== null ? FunctionInvocation.fromPartial(object.validateInvocation) : void 0;
5228
+ if (object.executeInvocation?.$case === "success" && object.executeInvocation?.success !== void 0 && object.executeInvocation?.success !== null) {
5229
+ message.executeInvocation = {
5230
+ $case: "success",
5231
+ success: FunctionInvocation.fromPartial(object.executeInvocation.success)
5232
+ };
5233
+ }
5234
+ if (object.executeInvocation?.$case === "reverted" && object.executeInvocation?.reverted !== void 0 && object.executeInvocation?.reverted !== null) {
5235
+ message.executeInvocation = {
5236
+ $case: "reverted",
5237
+ reverted: ExecutionReverted$1.fromPartial(object.executeInvocation.reverted)
5238
+ };
5239
+ }
5240
+ message.feeTransferInvocation = object.feeTransferInvocation !== void 0 && object.feeTransferInvocation !== null ? FunctionInvocation.fromPartial(object.feeTransferInvocation) : void 0;
5241
+ return message;
4950
5242
  }
5243
+ };
5244
+ function createBaseDeclareTransactionTrace() {
5245
+ return { validateInvocation: void 0, feeTransferInvocation: void 0 };
5246
+ }
5247
+ const DeclareTransactionTrace$1 = {
5248
+ encode(message, writer = _m0__default.Writer.create()) {
5249
+ if (message.validateInvocation !== void 0) {
5250
+ FunctionInvocation.encode(message.validateInvocation, writer.uint32(10).fork()).ldelim();
5251
+ }
5252
+ if (message.feeTransferInvocation !== void 0) {
5253
+ FunctionInvocation.encode(message.feeTransferInvocation, writer.uint32(18).fork()).ldelim();
5254
+ }
5255
+ return writer;
5256
+ },
5257
+ decode(input, length) {
5258
+ const reader = input instanceof _m0__default.Reader ? input : _m0__default.Reader.create(input);
5259
+ let end = length === void 0 ? reader.len : reader.pos + length;
5260
+ const message = createBaseDeclareTransactionTrace();
5261
+ while (reader.pos < end) {
5262
+ const tag = reader.uint32();
5263
+ switch (tag >>> 3) {
5264
+ case 1:
5265
+ if (tag !== 10) {
5266
+ break;
5267
+ }
5268
+ message.validateInvocation = FunctionInvocation.decode(reader, reader.uint32());
5269
+ continue;
5270
+ case 2:
5271
+ if (tag !== 18) {
5272
+ break;
5273
+ }
5274
+ message.feeTransferInvocation = FunctionInvocation.decode(reader, reader.uint32());
5275
+ continue;
5276
+ }
5277
+ if ((tag & 7) === 4 || tag === 0) {
5278
+ break;
5279
+ }
5280
+ reader.skipType(tag & 7);
5281
+ }
5282
+ return message;
5283
+ },
5284
+ fromJSON(object) {
5285
+ return {
5286
+ validateInvocation: isSet$1(object.validateInvocation) ? FunctionInvocation.fromJSON(object.validateInvocation) : void 0,
5287
+ feeTransferInvocation: isSet$1(object.feeTransferInvocation) ? FunctionInvocation.fromJSON(object.feeTransferInvocation) : void 0
5288
+ };
5289
+ },
5290
+ toJSON(message) {
5291
+ const obj = {};
5292
+ if (message.validateInvocation !== void 0) {
5293
+ obj.validateInvocation = FunctionInvocation.toJSON(message.validateInvocation);
5294
+ }
5295
+ if (message.feeTransferInvocation !== void 0) {
5296
+ obj.feeTransferInvocation = FunctionInvocation.toJSON(message.feeTransferInvocation);
5297
+ }
5298
+ return obj;
5299
+ },
5300
+ create(base) {
5301
+ return DeclareTransactionTrace$1.fromPartial(base ?? {});
5302
+ },
5303
+ fromPartial(object) {
5304
+ const message = createBaseDeclareTransactionTrace();
5305
+ message.validateInvocation = object.validateInvocation !== void 0 && object.validateInvocation !== null ? FunctionInvocation.fromPartial(object.validateInvocation) : void 0;
5306
+ message.feeTransferInvocation = object.feeTransferInvocation !== void 0 && object.feeTransferInvocation !== null ? FunctionInvocation.fromPartial(object.feeTransferInvocation) : void 0;
5307
+ return message;
5308
+ }
5309
+ };
5310
+ function createBaseDeployAccountTransactionTrace() {
5311
+ return { validateInvocation: void 0, constructorInvocation: void 0, feeTransferInvocation: void 0 };
5312
+ }
5313
+ const DeployAccountTransactionTrace$1 = {
5314
+ encode(message, writer = _m0__default.Writer.create()) {
5315
+ if (message.validateInvocation !== void 0) {
5316
+ FunctionInvocation.encode(message.validateInvocation, writer.uint32(10).fork()).ldelim();
5317
+ }
5318
+ if (message.constructorInvocation !== void 0) {
5319
+ FunctionInvocation.encode(message.constructorInvocation, writer.uint32(18).fork()).ldelim();
5320
+ }
5321
+ if (message.feeTransferInvocation !== void 0) {
5322
+ FunctionInvocation.encode(message.feeTransferInvocation, writer.uint32(26).fork()).ldelim();
5323
+ }
5324
+ return writer;
5325
+ },
5326
+ decode(input, length) {
5327
+ const reader = input instanceof _m0__default.Reader ? input : _m0__default.Reader.create(input);
5328
+ let end = length === void 0 ? reader.len : reader.pos + length;
5329
+ const message = createBaseDeployAccountTransactionTrace();
5330
+ while (reader.pos < end) {
5331
+ const tag = reader.uint32();
5332
+ switch (tag >>> 3) {
5333
+ case 1:
5334
+ if (tag !== 10) {
5335
+ break;
5336
+ }
5337
+ message.validateInvocation = FunctionInvocation.decode(reader, reader.uint32());
5338
+ continue;
5339
+ case 2:
5340
+ if (tag !== 18) {
5341
+ break;
5342
+ }
5343
+ message.constructorInvocation = FunctionInvocation.decode(reader, reader.uint32());
5344
+ continue;
5345
+ case 3:
5346
+ if (tag !== 26) {
5347
+ break;
5348
+ }
5349
+ message.feeTransferInvocation = FunctionInvocation.decode(reader, reader.uint32());
5350
+ continue;
5351
+ }
5352
+ if ((tag & 7) === 4 || tag === 0) {
5353
+ break;
5354
+ }
5355
+ reader.skipType(tag & 7);
5356
+ }
5357
+ return message;
5358
+ },
5359
+ fromJSON(object) {
5360
+ return {
5361
+ validateInvocation: isSet$1(object.validateInvocation) ? FunctionInvocation.fromJSON(object.validateInvocation) : void 0,
5362
+ constructorInvocation: isSet$1(object.constructorInvocation) ? FunctionInvocation.fromJSON(object.constructorInvocation) : void 0,
5363
+ feeTransferInvocation: isSet$1(object.feeTransferInvocation) ? FunctionInvocation.fromJSON(object.feeTransferInvocation) : void 0
5364
+ };
5365
+ },
5366
+ toJSON(message) {
5367
+ const obj = {};
5368
+ if (message.validateInvocation !== void 0) {
5369
+ obj.validateInvocation = FunctionInvocation.toJSON(message.validateInvocation);
5370
+ }
5371
+ if (message.constructorInvocation !== void 0) {
5372
+ obj.constructorInvocation = FunctionInvocation.toJSON(message.constructorInvocation);
5373
+ }
5374
+ if (message.feeTransferInvocation !== void 0) {
5375
+ obj.feeTransferInvocation = FunctionInvocation.toJSON(message.feeTransferInvocation);
5376
+ }
5377
+ return obj;
5378
+ },
5379
+ create(base) {
5380
+ return DeployAccountTransactionTrace$1.fromPartial(base ?? {});
5381
+ },
5382
+ fromPartial(object) {
5383
+ const message = createBaseDeployAccountTransactionTrace();
5384
+ message.validateInvocation = object.validateInvocation !== void 0 && object.validateInvocation !== null ? FunctionInvocation.fromPartial(object.validateInvocation) : void 0;
5385
+ message.constructorInvocation = object.constructorInvocation !== void 0 && object.constructorInvocation !== null ? FunctionInvocation.fromPartial(object.constructorInvocation) : void 0;
5386
+ message.feeTransferInvocation = object.feeTransferInvocation !== void 0 && object.feeTransferInvocation !== null ? FunctionInvocation.fromPartial(object.feeTransferInvocation) : void 0;
5387
+ return message;
5388
+ }
5389
+ };
5390
+ function createBaseL1HandlerTransactionTrace() {
5391
+ return { functionInvocation: void 0 };
5392
+ }
5393
+ const L1HandlerTransactionTrace$1 = {
5394
+ encode(message, writer = _m0__default.Writer.create()) {
5395
+ if (message.functionInvocation !== void 0) {
5396
+ FunctionInvocation.encode(message.functionInvocation, writer.uint32(18).fork()).ldelim();
5397
+ }
5398
+ return writer;
5399
+ },
5400
+ decode(input, length) {
5401
+ const reader = input instanceof _m0__default.Reader ? input : _m0__default.Reader.create(input);
5402
+ let end = length === void 0 ? reader.len : reader.pos + length;
5403
+ const message = createBaseL1HandlerTransactionTrace();
5404
+ while (reader.pos < end) {
5405
+ const tag = reader.uint32();
5406
+ switch (tag >>> 3) {
5407
+ case 2:
5408
+ if (tag !== 18) {
5409
+ break;
5410
+ }
5411
+ message.functionInvocation = FunctionInvocation.decode(reader, reader.uint32());
5412
+ continue;
5413
+ }
5414
+ if ((tag & 7) === 4 || tag === 0) {
5415
+ break;
5416
+ }
5417
+ reader.skipType(tag & 7);
5418
+ }
5419
+ return message;
5420
+ },
5421
+ fromJSON(object) {
5422
+ return {
5423
+ functionInvocation: isSet$1(object.functionInvocation) ? FunctionInvocation.fromJSON(object.functionInvocation) : void 0
5424
+ };
5425
+ },
5426
+ toJSON(message) {
5427
+ const obj = {};
5428
+ if (message.functionInvocation !== void 0) {
5429
+ obj.functionInvocation = FunctionInvocation.toJSON(message.functionInvocation);
5430
+ }
5431
+ return obj;
5432
+ },
5433
+ create(base) {
5434
+ return L1HandlerTransactionTrace$1.fromPartial(base ?? {});
5435
+ },
5436
+ fromPartial(object) {
5437
+ const message = createBaseL1HandlerTransactionTrace();
5438
+ message.functionInvocation = object.functionInvocation !== void 0 && object.functionInvocation !== null ? FunctionInvocation.fromPartial(object.functionInvocation) : void 0;
5439
+ return message;
5440
+ }
5441
+ };
5442
+ function createBaseFunctionInvocation() {
5443
+ return {
5444
+ contractAddress: void 0,
5445
+ entryPointSelector: void 0,
5446
+ calldata: [],
5447
+ callerAddress: void 0,
5448
+ classHash: void 0,
5449
+ callType: 0,
5450
+ result: [],
5451
+ calls: [],
5452
+ events: [],
5453
+ messages: []
5454
+ };
5455
+ }
5456
+ const FunctionInvocation = {
5457
+ encode(message, writer = _m0__default.Writer.create()) {
5458
+ if (message.contractAddress !== void 0) {
5459
+ FieldElement.encode(message.contractAddress, writer.uint32(10).fork()).ldelim();
5460
+ }
5461
+ if (message.entryPointSelector !== void 0) {
5462
+ FieldElement.encode(message.entryPointSelector, writer.uint32(18).fork()).ldelim();
5463
+ }
5464
+ if (message.calldata !== void 0 && message.calldata.length !== 0) {
5465
+ for (const v of message.calldata) {
5466
+ FieldElement.encode(v, writer.uint32(26).fork()).ldelim();
5467
+ }
5468
+ }
5469
+ if (message.callerAddress !== void 0) {
5470
+ FieldElement.encode(message.callerAddress, writer.uint32(34).fork()).ldelim();
5471
+ }
5472
+ if (message.classHash !== void 0) {
5473
+ FieldElement.encode(message.classHash, writer.uint32(42).fork()).ldelim();
5474
+ }
5475
+ if (message.callType !== void 0 && message.callType !== 0) {
5476
+ writer.uint32(48).int32(message.callType);
5477
+ }
5478
+ if (message.result !== void 0 && message.result.length !== 0) {
5479
+ for (const v of message.result) {
5480
+ FieldElement.encode(v, writer.uint32(58).fork()).ldelim();
5481
+ }
5482
+ }
5483
+ if (message.calls !== void 0 && message.calls.length !== 0) {
5484
+ for (const v of message.calls) {
5485
+ FunctionInvocation.encode(v, writer.uint32(66).fork()).ldelim();
5486
+ }
5487
+ }
5488
+ if (message.events !== void 0 && message.events.length !== 0) {
5489
+ writer.uint32(74).fork();
5490
+ for (const v of message.events) {
5491
+ writer.uint32(v);
5492
+ }
5493
+ writer.ldelim();
5494
+ }
5495
+ if (message.messages !== void 0 && message.messages.length !== 0) {
5496
+ writer.uint32(82).fork();
5497
+ for (const v of message.messages) {
5498
+ writer.uint32(v);
5499
+ }
5500
+ writer.ldelim();
5501
+ }
5502
+ return writer;
5503
+ },
5504
+ decode(input, length) {
5505
+ const reader = input instanceof _m0__default.Reader ? input : _m0__default.Reader.create(input);
5506
+ let end = length === void 0 ? reader.len : reader.pos + length;
5507
+ const message = createBaseFunctionInvocation();
5508
+ while (reader.pos < end) {
5509
+ const tag = reader.uint32();
5510
+ switch (tag >>> 3) {
5511
+ case 1:
5512
+ if (tag !== 10) {
5513
+ break;
5514
+ }
5515
+ message.contractAddress = FieldElement.decode(reader, reader.uint32());
5516
+ continue;
5517
+ case 2:
5518
+ if (tag !== 18) {
5519
+ break;
5520
+ }
5521
+ message.entryPointSelector = FieldElement.decode(reader, reader.uint32());
5522
+ continue;
5523
+ case 3:
5524
+ if (tag !== 26) {
5525
+ break;
5526
+ }
5527
+ message.calldata.push(FieldElement.decode(reader, reader.uint32()));
5528
+ continue;
5529
+ case 4:
5530
+ if (tag !== 34) {
5531
+ break;
5532
+ }
5533
+ message.callerAddress = FieldElement.decode(reader, reader.uint32());
5534
+ continue;
5535
+ case 5:
5536
+ if (tag !== 42) {
5537
+ break;
5538
+ }
5539
+ message.classHash = FieldElement.decode(reader, reader.uint32());
5540
+ continue;
5541
+ case 6:
5542
+ if (tag !== 48) {
5543
+ break;
5544
+ }
5545
+ message.callType = reader.int32();
5546
+ continue;
5547
+ case 7:
5548
+ if (tag !== 58) {
5549
+ break;
5550
+ }
5551
+ message.result.push(FieldElement.decode(reader, reader.uint32()));
5552
+ continue;
5553
+ case 8:
5554
+ if (tag !== 66) {
5555
+ break;
5556
+ }
5557
+ message.calls.push(FunctionInvocation.decode(reader, reader.uint32()));
5558
+ continue;
5559
+ case 9:
5560
+ if (tag === 72) {
5561
+ message.events.push(reader.uint32());
5562
+ continue;
5563
+ }
5564
+ if (tag === 74) {
5565
+ const end2 = reader.uint32() + reader.pos;
5566
+ while (reader.pos < end2) {
5567
+ message.events.push(reader.uint32());
5568
+ }
5569
+ continue;
5570
+ }
5571
+ break;
5572
+ case 10:
5573
+ if (tag === 80) {
5574
+ message.messages.push(reader.uint32());
5575
+ continue;
5576
+ }
5577
+ if (tag === 82) {
5578
+ const end2 = reader.uint32() + reader.pos;
5579
+ while (reader.pos < end2) {
5580
+ message.messages.push(reader.uint32());
5581
+ }
5582
+ continue;
5583
+ }
5584
+ break;
5585
+ }
5586
+ if ((tag & 7) === 4 || tag === 0) {
5587
+ break;
5588
+ }
5589
+ reader.skipType(tag & 7);
5590
+ }
5591
+ return message;
5592
+ },
5593
+ fromJSON(object) {
5594
+ return {
5595
+ contractAddress: isSet$1(object.contractAddress) ? FieldElement.fromJSON(object.contractAddress) : void 0,
5596
+ entryPointSelector: isSet$1(object.entryPointSelector) ? FieldElement.fromJSON(object.entryPointSelector) : void 0,
5597
+ calldata: globalThis.Array.isArray(object?.calldata) ? object.calldata.map((e) => FieldElement.fromJSON(e)) : [],
5598
+ callerAddress: isSet$1(object.callerAddress) ? FieldElement.fromJSON(object.callerAddress) : void 0,
5599
+ classHash: isSet$1(object.classHash) ? FieldElement.fromJSON(object.classHash) : void 0,
5600
+ callType: isSet$1(object.callType) ? callTypeFromJSON(object.callType) : 0,
5601
+ result: globalThis.Array.isArray(object?.result) ? object.result.map((e) => FieldElement.fromJSON(e)) : [],
5602
+ calls: globalThis.Array.isArray(object?.calls) ? object.calls.map((e) => FunctionInvocation.fromJSON(e)) : [],
5603
+ events: globalThis.Array.isArray(object?.events) ? object.events.map((e) => globalThis.Number(e)) : [],
5604
+ messages: globalThis.Array.isArray(object?.messages) ? object.messages.map((e) => globalThis.Number(e)) : []
5605
+ };
5606
+ },
5607
+ toJSON(message) {
5608
+ const obj = {};
5609
+ if (message.contractAddress !== void 0) {
5610
+ obj.contractAddress = FieldElement.toJSON(message.contractAddress);
5611
+ }
5612
+ if (message.entryPointSelector !== void 0) {
5613
+ obj.entryPointSelector = FieldElement.toJSON(message.entryPointSelector);
5614
+ }
5615
+ if (message.calldata?.length) {
5616
+ obj.calldata = message.calldata.map((e) => FieldElement.toJSON(e));
5617
+ }
5618
+ if (message.callerAddress !== void 0) {
5619
+ obj.callerAddress = FieldElement.toJSON(message.callerAddress);
5620
+ }
5621
+ if (message.classHash !== void 0) {
5622
+ obj.classHash = FieldElement.toJSON(message.classHash);
5623
+ }
5624
+ if (message.callType !== void 0 && message.callType !== 0) {
5625
+ obj.callType = callTypeToJSON(message.callType);
5626
+ }
5627
+ if (message.result?.length) {
5628
+ obj.result = message.result.map((e) => FieldElement.toJSON(e));
5629
+ }
5630
+ if (message.calls?.length) {
5631
+ obj.calls = message.calls.map((e) => FunctionInvocation.toJSON(e));
5632
+ }
5633
+ if (message.events?.length) {
5634
+ obj.events = message.events.map((e) => Math.round(e));
5635
+ }
5636
+ if (message.messages?.length) {
5637
+ obj.messages = message.messages.map((e) => Math.round(e));
5638
+ }
5639
+ return obj;
5640
+ },
5641
+ create(base) {
5642
+ return FunctionInvocation.fromPartial(base ?? {});
5643
+ },
5644
+ fromPartial(object) {
5645
+ const message = createBaseFunctionInvocation();
5646
+ message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? FieldElement.fromPartial(object.contractAddress) : void 0;
5647
+ message.entryPointSelector = object.entryPointSelector !== void 0 && object.entryPointSelector !== null ? FieldElement.fromPartial(object.entryPointSelector) : void 0;
5648
+ message.calldata = object.calldata?.map((e) => FieldElement.fromPartial(e)) || [];
5649
+ message.callerAddress = object.callerAddress !== void 0 && object.callerAddress !== null ? FieldElement.fromPartial(object.callerAddress) : void 0;
5650
+ message.classHash = object.classHash !== void 0 && object.classHash !== null ? FieldElement.fromPartial(object.classHash) : void 0;
5651
+ message.callType = object.callType ?? 0;
5652
+ message.result = object.result?.map((e) => FieldElement.fromPartial(e)) || [];
5653
+ message.calls = object.calls?.map((e) => FunctionInvocation.fromPartial(e)) || [];
5654
+ message.events = object.events?.map((e) => e) || [];
5655
+ message.messages = object.messages?.map((e) => e) || [];
5656
+ return message;
5657
+ }
5658
+ };
5659
+ function createBaseFunctionCall() {
5660
+ return { contractAddress: void 0, entryPointSelector: void 0, calldata: [] };
5661
+ }
5662
+ const FunctionCall = {
5663
+ encode(message, writer = _m0__default.Writer.create()) {
5664
+ if (message.contractAddress !== void 0) {
5665
+ FieldElement.encode(message.contractAddress, writer.uint32(10).fork()).ldelim();
5666
+ }
5667
+ if (message.entryPointSelector !== void 0) {
5668
+ FieldElement.encode(message.entryPointSelector, writer.uint32(18).fork()).ldelim();
5669
+ }
5670
+ if (message.calldata !== void 0 && message.calldata.length !== 0) {
5671
+ for (const v of message.calldata) {
5672
+ FieldElement.encode(v, writer.uint32(26).fork()).ldelim();
5673
+ }
5674
+ }
5675
+ return writer;
5676
+ },
5677
+ decode(input, length) {
5678
+ const reader = input instanceof _m0__default.Reader ? input : _m0__default.Reader.create(input);
5679
+ let end = length === void 0 ? reader.len : reader.pos + length;
5680
+ const message = createBaseFunctionCall();
5681
+ while (reader.pos < end) {
5682
+ const tag = reader.uint32();
5683
+ switch (tag >>> 3) {
5684
+ case 1:
5685
+ if (tag !== 10) {
5686
+ break;
5687
+ }
5688
+ message.contractAddress = FieldElement.decode(reader, reader.uint32());
5689
+ continue;
5690
+ case 2:
5691
+ if (tag !== 18) {
5692
+ break;
5693
+ }
5694
+ message.entryPointSelector = FieldElement.decode(reader, reader.uint32());
5695
+ continue;
5696
+ case 3:
5697
+ if (tag !== 26) {
5698
+ break;
5699
+ }
5700
+ message.calldata.push(FieldElement.decode(reader, reader.uint32()));
5701
+ continue;
5702
+ }
5703
+ if ((tag & 7) === 4 || tag === 0) {
5704
+ break;
5705
+ }
5706
+ reader.skipType(tag & 7);
5707
+ }
5708
+ return message;
5709
+ },
5710
+ fromJSON(object) {
5711
+ return {
5712
+ contractAddress: isSet$1(object.contractAddress) ? FieldElement.fromJSON(object.contractAddress) : void 0,
5713
+ entryPointSelector: isSet$1(object.entryPointSelector) ? FieldElement.fromJSON(object.entryPointSelector) : void 0,
5714
+ calldata: globalThis.Array.isArray(object?.calldata) ? object.calldata.map((e) => FieldElement.fromJSON(e)) : []
5715
+ };
5716
+ },
5717
+ toJSON(message) {
5718
+ const obj = {};
5719
+ if (message.contractAddress !== void 0) {
5720
+ obj.contractAddress = FieldElement.toJSON(message.contractAddress);
5721
+ }
5722
+ if (message.entryPointSelector !== void 0) {
5723
+ obj.entryPointSelector = FieldElement.toJSON(message.entryPointSelector);
5724
+ }
5725
+ if (message.calldata?.length) {
5726
+ obj.calldata = message.calldata.map((e) => FieldElement.toJSON(e));
5727
+ }
5728
+ return obj;
5729
+ },
5730
+ create(base) {
5731
+ return FunctionCall.fromPartial(base ?? {});
5732
+ },
5733
+ fromPartial(object) {
5734
+ const message = createBaseFunctionCall();
5735
+ message.contractAddress = object.contractAddress !== void 0 && object.contractAddress !== null ? FieldElement.fromPartial(object.contractAddress) : void 0;
5736
+ message.entryPointSelector = object.entryPointSelector !== void 0 && object.entryPointSelector !== null ? FieldElement.fromPartial(object.entryPointSelector) : void 0;
5737
+ message.calldata = object.calldata?.map((e) => FieldElement.fromPartial(e)) || [];
5738
+ return message;
5739
+ }
5740
+ };
5741
+ function bytesFromBase64(b64) {
5742
+ if (globalThis.Buffer) {
5743
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
5744
+ } else {
5745
+ const bin = globalThis.atob(b64);
5746
+ const arr = new Uint8Array(bin.length);
5747
+ for (let i = 0; i < bin.length; ++i) {
5748
+ arr[i] = bin.charCodeAt(i);
5749
+ }
5750
+ return arr;
5751
+ }
5752
+ }
5753
+ function base64FromBytes(arr) {
5754
+ if (globalThis.Buffer) {
5755
+ return globalThis.Buffer.from(arr).toString("base64");
5756
+ } else {
5757
+ const bin = [];
5758
+ arr.forEach((byte) => {
5759
+ bin.push(globalThis.String.fromCharCode(byte));
5760
+ });
5761
+ return globalThis.btoa(bin.join(""));
5762
+ }
5763
+ }
5764
+ function toTimestamp(date) {
5765
+ const seconds = BigInt(Math.trunc(date.getTime() / 1e3));
5766
+ const nanos = date.getTime() % 1e3 * 1e6;
5767
+ return { seconds, nanos };
5768
+ }
5769
+ function fromTimestamp(t) {
5770
+ let millis = (globalThis.Number(t.seconds?.toString()) || 0) * 1e3;
5771
+ millis += (t.nanos || 0) / 1e6;
5772
+ return new globalThis.Date(millis);
4951
5773
  }
4952
- function toTimestamp(date) {
4953
- const seconds = BigInt(Math.trunc(date.getTime() / 1e3));
4954
- const nanos = date.getTime() % 1e3 * 1e6;
4955
- return { seconds, nanos };
4956
- }
4957
- function fromTimestamp(t) {
4958
- let millis = (globalThis.Number(t.seconds?.toString()) || 0) * 1e3;
4959
- millis += (t.nanos || 0) / 1e6;
4960
- return new globalThis.Date(millis);
4961
- }
4962
5774
  function fromJsonTimestamp(o) {
4963
5775
  if (o instanceof globalThis.Date) {
4964
5776
  return o;
@@ -4983,17 +5795,20 @@ const data = {
4983
5795
  __proto__: null,
4984
5796
  Block: Block$1,
4985
5797
  BlockHeader: BlockHeader$1,
5798
+ CallType: CallType$1,
4986
5799
  ComputationResources: ComputationResources$1,
4987
5800
  ContractChange: ContractChange$1,
4988
5801
  DataAvailabilityMode: DataAvailabilityMode$1,
4989
5802
  DataAvailabilityResources: DataAvailabilityResources$1,
4990
5803
  DeclareTransactionReceipt: DeclareTransactionReceipt$1,
5804
+ DeclareTransactionTrace: DeclareTransactionTrace$1,
4991
5805
  DeclareTransactionV0: DeclareTransactionV0$1,
4992
5806
  DeclareTransactionV1: DeclareTransactionV1$1,
4993
5807
  DeclareTransactionV2: DeclareTransactionV2$1,
4994
5808
  DeclareTransactionV3: DeclareTransactionV3$1,
4995
5809
  DeclaredClass: DeclaredClass$1,
4996
5810
  DeployAccountTransactionReceipt: DeployAccountTransactionReceipt$1,
5811
+ DeployAccountTransactionTrace: DeployAccountTransactionTrace$1,
4997
5812
  DeployAccountTransactionV1: DeployAccountTransactionV1$1,
4998
5813
  DeployAccountTransactionV3: DeployAccountTransactionV3$1,
4999
5814
  DeployTransaction: DeployTransaction$1,
@@ -5005,13 +5820,17 @@ const data = {
5005
5820
  ExecutionStatus: ExecutionStatus,
5006
5821
  ExecutionSucceeded: ExecutionSucceeded$1,
5007
5822
  FeePayment: FeePayment$1,
5823
+ FunctionCall: FunctionCall,
5824
+ FunctionInvocation: FunctionInvocation,
5008
5825
  InvokeTransactionReceipt: InvokeTransactionReceipt$1,
5826
+ InvokeTransactionTrace: InvokeTransactionTrace$1,
5009
5827
  InvokeTransactionV0: InvokeTransactionV0$1,
5010
5828
  InvokeTransactionV1: InvokeTransactionV1$1,
5011
5829
  InvokeTransactionV3: InvokeTransactionV3$1,
5012
5830
  L1DataAvailabilityMode: L1DataAvailabilityMode$1,
5013
5831
  L1HandlerTransaction: L1HandlerTransaction$1,
5014
5832
  L1HandlerTransactionReceipt: L1HandlerTransactionReceipt$1,
5833
+ L1HandlerTransactionTrace: L1HandlerTransactionTrace$1,
5015
5834
  MessageToL1: MessageToL1$1,
5016
5835
  NonceUpdate: NonceUpdate$1,
5017
5836
  PriceUnit: PriceUnit$1,
@@ -5026,7 +5845,10 @@ const data = {
5026
5845
  TransactionReceipt: TransactionReceipt$1,
5027
5846
  TransactionReceiptMeta: TransactionReceiptMeta$1,
5028
5847
  TransactionStatus: TransactionStatus$1,
5848
+ TransactionTrace: TransactionTrace$1,
5029
5849
  Uint128: Uint128,
5850
+ callTypeFromJSON: callTypeFromJSON,
5851
+ callTypeToJSON: callTypeToJSON,
5030
5852
  dataAvailabilityModeFromJSON: dataAvailabilityModeFromJSON,
5031
5853
  dataAvailabilityModeToJSON: dataAvailabilityModeToJSON,
5032
5854
  executionStatusFromJSON: executionStatusFromJSON,
@@ -5293,7 +6115,8 @@ function createBaseEventFilter() {
5293
6115
  includeTransaction: void 0,
5294
6116
  includeReceipt: void 0,
5295
6117
  includeMessages: void 0,
5296
- includeSiblings: void 0
6118
+ includeSiblings: void 0,
6119
+ includeTransactionTrace: void 0
5297
6120
  };
5298
6121
  }
5299
6122
  const EventFilter$1 = {
@@ -5327,6 +6150,9 @@ const EventFilter$1 = {
5327
6150
  if (message.includeSiblings !== void 0) {
5328
6151
  writer.uint32(72).bool(message.includeSiblings);
5329
6152
  }
6153
+ if (message.includeTransactionTrace !== void 0) {
6154
+ writer.uint32(80).bool(message.includeTransactionTrace);
6155
+ }
5330
6156
  return writer;
5331
6157
  },
5332
6158
  decode(input, length) {
@@ -5390,6 +6216,12 @@ const EventFilter$1 = {
5390
6216
  }
5391
6217
  message.includeSiblings = reader.bool();
5392
6218
  continue;
6219
+ case 10:
6220
+ if (tag !== 80) {
6221
+ break;
6222
+ }
6223
+ message.includeTransactionTrace = reader.bool();
6224
+ continue;
5393
6225
  }
5394
6226
  if ((tag & 7) === 4 || tag === 0) {
5395
6227
  break;
@@ -5408,7 +6240,8 @@ const EventFilter$1 = {
5408
6240
  includeTransaction: isSet(object.includeTransaction) ? globalThis.Boolean(object.includeTransaction) : void 0,
5409
6241
  includeReceipt: isSet(object.includeReceipt) ? globalThis.Boolean(object.includeReceipt) : void 0,
5410
6242
  includeMessages: isSet(object.includeMessages) ? globalThis.Boolean(object.includeMessages) : void 0,
5411
- includeSiblings: isSet(object.includeSiblings) ? globalThis.Boolean(object.includeSiblings) : void 0
6243
+ includeSiblings: isSet(object.includeSiblings) ? globalThis.Boolean(object.includeSiblings) : void 0,
6244
+ includeTransactionTrace: isSet(object.includeTransactionTrace) ? globalThis.Boolean(object.includeTransactionTrace) : void 0
5412
6245
  };
5413
6246
  },
5414
6247
  toJSON(message) {
@@ -5440,6 +6273,9 @@ const EventFilter$1 = {
5440
6273
  if (message.includeSiblings !== void 0) {
5441
6274
  obj.includeSiblings = message.includeSiblings;
5442
6275
  }
6276
+ if (message.includeTransactionTrace !== void 0) {
6277
+ obj.includeTransactionTrace = message.includeTransactionTrace;
6278
+ }
5443
6279
  return obj;
5444
6280
  },
5445
6281
  create(base) {
@@ -5456,6 +6292,7 @@ const EventFilter$1 = {
5456
6292
  message.includeReceipt = object.includeReceipt ?? void 0;
5457
6293
  message.includeMessages = object.includeMessages ?? void 0;
5458
6294
  message.includeSiblings = object.includeSiblings ?? void 0;
6295
+ message.includeTransactionTrace = object.includeTransactionTrace ?? void 0;
5459
6296
  return message;
5460
6297
  }
5461
6298
  };
@@ -5518,7 +6355,8 @@ function createBaseMessageToL1Filter() {
5518
6355
  includeTransaction: void 0,
5519
6356
  includeReceipt: void 0,
5520
6357
  includeEvents: void 0,
5521
- includeSiblings: void 0
6358
+ includeSiblings: void 0,
6359
+ includeTransactionTrace: void 0
5522
6360
  };
5523
6361
  }
5524
6362
  const MessageToL1Filter$1 = {
@@ -5547,6 +6385,9 @@ const MessageToL1Filter$1 = {
5547
6385
  if (message.includeSiblings !== void 0) {
5548
6386
  writer.uint32(64).bool(message.includeSiblings);
5549
6387
  }
6388
+ if (message.includeTransactionTrace !== void 0) {
6389
+ writer.uint32(72).bool(message.includeTransactionTrace);
6390
+ }
5550
6391
  return writer;
5551
6392
  },
5552
6393
  decode(input, length) {
@@ -5604,6 +6445,12 @@ const MessageToL1Filter$1 = {
5604
6445
  }
5605
6446
  message.includeSiblings = reader.bool();
5606
6447
  continue;
6448
+ case 9:
6449
+ if (tag !== 72) {
6450
+ break;
6451
+ }
6452
+ message.includeTransactionTrace = reader.bool();
6453
+ continue;
5607
6454
  }
5608
6455
  if ((tag & 7) === 4 || tag === 0) {
5609
6456
  break;
@@ -5621,7 +6468,8 @@ const MessageToL1Filter$1 = {
5621
6468
  includeTransaction: isSet(object.includeTransaction) ? globalThis.Boolean(object.includeTransaction) : void 0,
5622
6469
  includeReceipt: isSet(object.includeReceipt) ? globalThis.Boolean(object.includeReceipt) : void 0,
5623
6470
  includeEvents: isSet(object.includeEvents) ? globalThis.Boolean(object.includeEvents) : void 0,
5624
- includeSiblings: isSet(object.includeSiblings) ? globalThis.Boolean(object.includeSiblings) : void 0
6471
+ includeSiblings: isSet(object.includeSiblings) ? globalThis.Boolean(object.includeSiblings) : void 0,
6472
+ includeTransactionTrace: isSet(object.includeTransactionTrace) ? globalThis.Boolean(object.includeTransactionTrace) : void 0
5625
6473
  };
5626
6474
  },
5627
6475
  toJSON(message) {
@@ -5650,6 +6498,9 @@ const MessageToL1Filter$1 = {
5650
6498
  if (message.includeSiblings !== void 0) {
5651
6499
  obj.includeSiblings = message.includeSiblings;
5652
6500
  }
6501
+ if (message.includeTransactionTrace !== void 0) {
6502
+ obj.includeTransactionTrace = message.includeTransactionTrace;
6503
+ }
5653
6504
  return obj;
5654
6505
  },
5655
6506
  create(base) {
@@ -5665,6 +6516,7 @@ const MessageToL1Filter$1 = {
5665
6516
  message.includeReceipt = object.includeReceipt ?? void 0;
5666
6517
  message.includeEvents = object.includeEvents ?? void 0;
5667
6518
  message.includeSiblings = object.includeSiblings ?? void 0;
6519
+ message.includeTransactionTrace = object.includeTransactionTrace ?? void 0;
5668
6520
  return message;
5669
6521
  }
5670
6522
  };
@@ -5675,7 +6527,8 @@ function createBaseTransactionFilter() {
5675
6527
  includeReceipt: void 0,
5676
6528
  includeEvents: void 0,
5677
6529
  includeMessages: void 0,
5678
- inner: void 0
6530
+ inner: void 0,
6531
+ includeTrace: void 0
5679
6532
  };
5680
6533
  }
5681
6534
  const TransactionFilter$1 = {
@@ -5730,6 +6583,9 @@ const TransactionFilter$1 = {
5730
6583
  DeployAccountV3TransactionFilter$1.encode(message.inner.deployAccountV3, writer.uint32(130).fork()).ldelim();
5731
6584
  break;
5732
6585
  }
6586
+ if (message.includeTrace !== void 0) {
6587
+ writer.uint32(136).bool(message.includeTrace);
6588
+ }
5733
6589
  return writer;
5734
6590
  },
5735
6591
  decode(input, length) {
@@ -5841,6 +6697,12 @@ const TransactionFilter$1 = {
5841
6697
  deployAccountV3: DeployAccountV3TransactionFilter$1.decode(reader, reader.uint32())
5842
6698
  };
5843
6699
  continue;
6700
+ case 17:
6701
+ if (tag !== 136) {
6702
+ break;
6703
+ }
6704
+ message.includeTrace = reader.bool();
6705
+ continue;
5844
6706
  }
5845
6707
  if ((tag & 7) === 4 || tag === 0) {
5846
6708
  break;
@@ -5862,7 +6724,8 @@ const TransactionFilter$1 = {
5862
6724
  } : isSet(object.deployAccountV3) ? {
5863
6725
  $case: "deployAccountV3",
5864
6726
  deployAccountV3: DeployAccountV3TransactionFilter$1.fromJSON(object.deployAccountV3)
5865
- } : void 0
6727
+ } : void 0,
6728
+ includeTrace: isSet(object.includeTrace) ? globalThis.Boolean(object.includeTrace) : void 0
5866
6729
  };
5867
6730
  },
5868
6731
  toJSON(message) {
@@ -5915,6 +6778,9 @@ const TransactionFilter$1 = {
5915
6778
  if (message.inner?.$case === "deployAccountV3") {
5916
6779
  obj.deployAccountV3 = DeployAccountV3TransactionFilter$1.toJSON(message.inner.deployAccountV3);
5917
6780
  }
6781
+ if (message.includeTrace !== void 0) {
6782
+ obj.includeTrace = message.includeTrace;
6783
+ }
5918
6784
  return obj;
5919
6785
  },
5920
6786
  create(base) {
@@ -5966,6 +6832,7 @@ const TransactionFilter$1 = {
5966
6832
  deployAccountV3: DeployAccountV3TransactionFilter$1.fromPartial(object.inner.deployAccountV3)
5967
6833
  };
5968
6834
  }
6835
+ message.includeTrace = object.includeTrace ?? void 0;
5969
6836
  return message;
5970
6837
  }
5971
6838
  };
@@ -6753,651 +7620,642 @@ const index = {
6753
7620
  filter: filter
6754
7621
  };
6755
7622
 
6756
- const ResourcePrice = schema.Schema.Struct({
6757
- priceInFri: schema.Schema.optional(FieldElement$1),
6758
- priceInWei: schema.Schema.optional(FieldElement$1)
7623
+ const ResourcePrice = codec.MessageCodec({
7624
+ priceInFri: codec.OptionalCodec(FieldElement$1),
7625
+ priceInWei: codec.OptionalCodec(FieldElement$1)
6759
7626
  });
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
- }
7627
+ const L1DataAvailabilityMode = {
7628
+ encode(x) {
7629
+ switch (x) {
7630
+ case "calldata":
7631
+ return L1DataAvailabilityMode$1.CALLDATA;
7632
+ case "blob":
7633
+ return L1DataAvailabilityMode$1.BLOB;
7634
+ case "unknown":
7635
+ return L1DataAvailabilityMode$1.UNSPECIFIED;
7636
+ default:
7637
+ return L1DataAvailabilityMode$1.UNRECOGNIZED;
7638
+ }
7639
+ },
7640
+ decode(p) {
7641
+ const enumMap = {
7642
+ [L1DataAvailabilityMode$1.CALLDATA]: "calldata",
7643
+ [L1DataAvailabilityMode$1.BLOB]: "blob",
7644
+ [L1DataAvailabilityMode$1.UNSPECIFIED]: "unknown",
7645
+ [L1DataAvailabilityMode$1.UNRECOGNIZED]: "unknown"
7646
+ };
7647
+ return enumMap[p] ?? "unknown";
6776
7648
  }
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
- }
7649
+ };
7650
+ const TransactionStatus = {
7651
+ encode(x) {
7652
+ switch (x) {
7653
+ case "succeeded":
7654
+ return TransactionStatus$1.SUCCEEDED;
7655
+ case "reverted":
7656
+ return TransactionStatus$1.REVERTED;
7657
+ case "unknown":
7658
+ return TransactionStatus$1.UNSPECIFIED;
7659
+ default:
7660
+ return TransactionStatus$1.UNRECOGNIZED;
7661
+ }
7662
+ },
7663
+ decode(p) {
7664
+ const enumMap = {
7665
+ [TransactionStatus$1.SUCCEEDED]: "succeeded",
7666
+ [TransactionStatus$1.REVERTED]: "reverted",
7667
+ [TransactionStatus$1.UNSPECIFIED]: "unknown",
7668
+ [TransactionStatus$1.UNRECOGNIZED]: "unknown"
7669
+ };
7670
+ return enumMap[p] ?? "unknown";
6794
7671
  }
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
- }
7672
+ };
7673
+ const U128 = {
7674
+ // TODO: double check if this is correct
7675
+ encode(x) {
7676
+ const low = x.toString(16).padStart(16, "0");
7677
+ const high = (x >> 128n).toString(16).padStart(16, "0");
7678
+ return { x0: BigInt(`0x${low}`), x1: BigInt(`0x${high}`) };
7679
+ },
7680
+ decode(p) {
7681
+ const low = (p.x0 ?? 0n).toString(16).padStart(16, "0");
7682
+ const high = (p.x1 ?? 0n).toString(16).padStart(16, "0");
7683
+ return BigInt(`0x${low}${high}`);
6811
7684
  }
6812
- );
6813
- const ResourceBounds = schema.Schema.Struct({
6814
- maxAmount: schema.Schema.BigIntFromSelf,
6815
- maxPricePerUnit: U128
7685
+ };
7686
+ const ResourceBounds = codec.MessageCodec({
7687
+ maxAmount: codec.RequiredCodec(codec.BigIntCodec),
7688
+ maxPricePerUnit: codec.RequiredCodec(U128)
6816
7689
  });
6817
- const ResourceBoundsMapping = schema.Schema.Struct({
6818
- l1Gas: ResourceBounds,
6819
- l2Gas: ResourceBounds
7690
+ const ResourceBoundsMapping = codec.MessageCodec({
7691
+ l1Gas: codec.RequiredCodec(ResourceBounds),
7692
+ l2Gas: codec.RequiredCodec(ResourceBounds)
6820
7693
  });
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
- }
7694
+ const DataAvailabilityMode = {
7695
+ encode(x) {
7696
+ switch (x) {
7697
+ case "l1":
7698
+ return DataAvailabilityMode$1.L1;
7699
+ case "l2":
7700
+ return DataAvailabilityMode$1.L2;
7701
+ case "unknown":
7702
+ return DataAvailabilityMode$1.UNSPECIFIED;
7703
+ default:
7704
+ return DataAvailabilityMode$1.UNRECOGNIZED;
7705
+ }
7706
+ },
7707
+ decode(p) {
7708
+ const enumMap = {
7709
+ [DataAvailabilityMode$1.L1]: "l1",
7710
+ [DataAvailabilityMode$1.L2]: "l2",
7711
+ [DataAvailabilityMode$1.UNSPECIFIED]: "unknown",
7712
+ [DataAvailabilityMode$1.UNRECOGNIZED]: "unknown"
7713
+ };
7714
+ return enumMap[p] ?? "unknown";
6837
7715
  }
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
7716
+ };
7717
+ const BlockHeader = codec.MessageCodec({
7718
+ blockHash: codec.OptionalCodec(FieldElement$1),
7719
+ parentBlockHash: codec.RequiredCodec(FieldElement$1),
7720
+ blockNumber: codec.RequiredCodec(codec.BigIntCodec),
7721
+ sequencerAddress: codec.RequiredCodec(FieldElement$1),
7722
+ newRoot: codec.OptionalCodec(FieldElement$1),
7723
+ timestamp: codec.RequiredCodec(codec.DateCodec),
7724
+ starknetVersion: codec.RequiredCodec(codec.StringCodec),
7725
+ l1GasPrice: codec.RequiredCodec(ResourcePrice),
7726
+ l1DataGasPrice: codec.RequiredCodec(ResourcePrice),
7727
+ l1DataAvailabilityMode: codec.RequiredCodec(L1DataAvailabilityMode)
6850
7728
  });
6851
- const TransactionMeta = schema.Schema.Struct({
6852
- transactionIndex: schema.Schema.Number,
6853
- transactionHash: FieldElement$1,
6854
- transactionStatus: TransactionStatus
7729
+ const TransactionMeta = codec.MessageCodec({
7730
+ transactionIndex: codec.RequiredCodec(codec.NumberCodec),
7731
+ transactionHash: codec.RequiredCodec(FieldElement$1),
7732
+ transactionStatus: codec.RequiredCodec(TransactionStatus)
6855
7733
  });
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
- })
7734
+ const InvokeTransactionV0 = codec.MessageCodec({
7735
+ maxFee: codec.RequiredCodec(FieldElement$1),
7736
+ signature: codec.ArrayCodec(FieldElement$1),
7737
+ contractAddress: codec.RequiredCodec(FieldElement$1),
7738
+ entryPointSelector: codec.RequiredCodec(FieldElement$1),
7739
+ calldata: codec.ArrayCodec(FieldElement$1)
6865
7740
  });
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
- })
7741
+ const InvokeTransactionV1 = codec.MessageCodec({
7742
+ senderAddress: codec.RequiredCodec(FieldElement$1),
7743
+ calldata: codec.ArrayCodec(FieldElement$1),
7744
+ maxFee: codec.RequiredCodec(FieldElement$1),
7745
+ signature: codec.ArrayCodec(FieldElement$1),
7746
+ nonce: codec.RequiredCodec(FieldElement$1)
6875
7747
  });
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
- })
7748
+ const InvokeTransactionV3 = codec.MessageCodec({
7749
+ senderAddress: codec.RequiredCodec(FieldElement$1),
7750
+ calldata: codec.ArrayCodec(FieldElement$1),
7751
+ signature: codec.ArrayCodec(FieldElement$1),
7752
+ nonce: codec.RequiredCodec(FieldElement$1),
7753
+ resourceBounds: codec.RequiredCodec(ResourceBoundsMapping),
7754
+ tip: codec.RequiredCodec(codec.BigIntCodec),
7755
+ paymasterData: codec.ArrayCodec(FieldElement$1),
7756
+ accountDeploymentData: codec.ArrayCodec(FieldElement$1),
7757
+ nonceDataAvailabilityMode: codec.RequiredCodec(DataAvailabilityMode),
7758
+ feeDataAvailabilityMode: codec.RequiredCodec(DataAvailabilityMode)
6890
7759
  });
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
- })
7760
+ const L1HandlerTransaction = codec.MessageCodec({
7761
+ nonce: codec.RequiredCodec(codec.BigIntCodec),
7762
+ contractAddress: codec.RequiredCodec(FieldElement$1),
7763
+ entryPointSelector: codec.RequiredCodec(FieldElement$1),
7764
+ calldata: codec.ArrayCodec(FieldElement$1)
6899
7765
  });
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
- })
7766
+ const DeployTransaction = codec.MessageCodec({
7767
+ contractAddressSalt: codec.RequiredCodec(FieldElement$1),
7768
+ constructorCalldata: codec.ArrayCodec(FieldElement$1),
7769
+ classHash: codec.RequiredCodec(FieldElement$1)
6907
7770
  });
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
- })
7771
+ const DeclareTransactionV0 = codec.MessageCodec({
7772
+ senderAddress: codec.RequiredCodec(FieldElement$1),
7773
+ maxFee: codec.RequiredCodec(FieldElement$1),
7774
+ signature: codec.ArrayCodec(FieldElement$1),
7775
+ classHash: codec.RequiredCodec(FieldElement$1)
6916
7776
  });
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
- })
7777
+ const DeclareTransactionV1 = codec.MessageCodec({
7778
+ senderAddress: codec.RequiredCodec(FieldElement$1),
7779
+ maxFee: codec.RequiredCodec(FieldElement$1),
7780
+ signature: codec.ArrayCodec(FieldElement$1),
7781
+ nonce: codec.RequiredCodec(FieldElement$1),
7782
+ classHash: codec.RequiredCodec(FieldElement$1)
6926
7783
  });
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
- })
7784
+ const DeclareTransactionV2 = codec.MessageCodec({
7785
+ senderAddress: codec.RequiredCodec(FieldElement$1),
7786
+ compiledClassHash: codec.RequiredCodec(FieldElement$1),
7787
+ maxFee: codec.RequiredCodec(FieldElement$1),
7788
+ signature: codec.ArrayCodec(FieldElement$1),
7789
+ nonce: codec.RequiredCodec(FieldElement$1),
7790
+ classHash: codec.RequiredCodec(FieldElement$1)
6937
7791
  });
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
- })
7792
+ const DeclareTransactionV3 = codec.MessageCodec({
7793
+ senderAddress: codec.RequiredCodec(FieldElement$1),
7794
+ compiledClassHash: codec.RequiredCodec(FieldElement$1),
7795
+ signature: codec.ArrayCodec(FieldElement$1),
7796
+ nonce: codec.RequiredCodec(FieldElement$1),
7797
+ classHash: codec.RequiredCodec(FieldElement$1),
7798
+ resourceBounds: codec.RequiredCodec(ResourceBoundsMapping),
7799
+ tip: codec.RequiredCodec(codec.BigIntCodec),
7800
+ paymasterData: codec.ArrayCodec(FieldElement$1),
7801
+ accountDeploymentData: codec.ArrayCodec(FieldElement$1),
7802
+ nonceDataAvailabilityMode: codec.RequiredCodec(DataAvailabilityMode),
7803
+ feeDataAvailabilityMode: codec.RequiredCodec(DataAvailabilityMode)
6953
7804
  });
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
- })
7805
+ const DeployAccountTransactionV1 = codec.MessageCodec({
7806
+ maxFee: codec.RequiredCodec(FieldElement$1),
7807
+ signature: codec.ArrayCodec(FieldElement$1),
7808
+ nonce: codec.RequiredCodec(FieldElement$1),
7809
+ contractAddressSalt: codec.RequiredCodec(FieldElement$1),
7810
+ constructorCalldata: codec.ArrayCodec(FieldElement$1),
7811
+ classHash: codec.RequiredCodec(FieldElement$1)
6964
7812
  });
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
- })
7813
+ const DeployAccountTransactionV3 = codec.MessageCodec({
7814
+ signature: codec.ArrayCodec(FieldElement$1),
7815
+ nonce: codec.RequiredCodec(FieldElement$1),
7816
+ contractAddressSalt: codec.RequiredCodec(FieldElement$1),
7817
+ constructorCalldata: codec.ArrayCodec(FieldElement$1),
7818
+ classHash: codec.RequiredCodec(FieldElement$1),
7819
+ resourceBounds: codec.RequiredCodec(ResourceBoundsMapping),
7820
+ tip: codec.RequiredCodec(codec.BigIntCodec),
7821
+ paymasterData: codec.ArrayCodec(FieldElement$1),
7822
+ nonceDataAvailabilityMode: codec.RequiredCodec(DataAvailabilityMode),
7823
+ feeDataAvailabilityMode: codec.RequiredCodec(DataAvailabilityMode)
6979
7824
  });
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
7825
+ const Transaction = codec.MessageCodec({
7826
+ filterIds: codec.ArrayCodec(codec.NumberCodec),
7827
+ meta: codec.RequiredCodec(TransactionMeta),
7828
+ transaction: codec.RequiredCodec(
7829
+ codec.OneOfCodec({
7830
+ invokeV0: InvokeTransactionV0,
7831
+ invokeV1: InvokeTransactionV1,
7832
+ invokeV3: InvokeTransactionV3,
7833
+ l1Handler: L1HandlerTransaction,
7834
+ deploy: DeployTransaction,
7835
+ declareV0: DeclareTransactionV0,
7836
+ declareV1: DeclareTransactionV1,
7837
+ declareV2: DeclareTransactionV2,
7838
+ declareV3: DeclareTransactionV3,
7839
+ deployAccountV1: DeployAccountTransactionV1,
7840
+ deployAccountV3: DeployAccountTransactionV3
7841
+ })
6995
7842
  )
6996
7843
  });
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
- }
7844
+ const PriceUnit = {
7845
+ encode(x) {
7846
+ switch (x) {
7847
+ case "wei":
7848
+ return PriceUnit$1.WEI;
7849
+ case "fri":
7850
+ return PriceUnit$1.FRI;
7851
+ case "unknown":
7852
+ return PriceUnit$1.UNSPECIFIED;
7853
+ default:
7854
+ return PriceUnit$1.UNRECOGNIZED;
7855
+ }
7856
+ },
7857
+ decode(p) {
7858
+ const enumMap = {
7859
+ [PriceUnit$1.WEI]: "wei",
7860
+ [PriceUnit$1.FRI]: "fri",
7861
+ [PriceUnit$1.UNSPECIFIED]: "unknown",
7862
+ [PriceUnit$1.UNRECOGNIZED]: "unknown"
7863
+ };
7864
+ return enumMap[p] ?? "unknown";
7013
7865
  }
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
7866
+ };
7867
+ const FeePayment = codec.MessageCodec({
7868
+ amount: codec.RequiredCodec(FieldElement$1),
7869
+ unit: codec.RequiredCodec(PriceUnit)
7038
7870
  });
7039
- const ExecutionSucceeded = schema.Schema.Struct({
7040
- _tag: tag("succeeded"),
7041
- succeeded: schema.Schema.Struct({})
7871
+ const ComputationResources = codec.MessageCodec({
7872
+ steps: codec.RequiredCodec(codec.BigIntCodec),
7873
+ memoryHoles: codec.OptionalCodec(codec.BigIntCodec),
7874
+ rangeCheckBuiltinApplications: codec.OptionalCodec(codec.BigIntCodec),
7875
+ pedersenBuiltinApplications: codec.OptionalCodec(codec.BigIntCodec),
7876
+ poseidonBuiltinApplications: codec.OptionalCodec(codec.BigIntCodec),
7877
+ ecOpBuiltinApplications: codec.OptionalCodec(codec.BigIntCodec),
7878
+ ecdsaBuiltinApplications: codec.OptionalCodec(codec.BigIntCodec),
7879
+ bitwiseBuiltinApplications: codec.OptionalCodec(codec.BigIntCodec),
7880
+ keccakBuiltinApplications: codec.OptionalCodec(codec.BigIntCodec),
7881
+ segmentArenaBuiltin: codec.OptionalCodec(codec.BigIntCodec)
7042
7882
  });
7043
- const ExecutionReverted = schema.Schema.Struct({
7044
- _tag: tag("reverted"),
7045
- reverted: schema.Schema.Struct({
7046
- reason: schema.Schema.optional(schema.Schema.String)
7047
- })
7883
+ const DataAvailabilityResources = codec.MessageCodec({
7884
+ l1Gas: codec.RequiredCodec(codec.BigIntCodec),
7885
+ l1DataGas: codec.RequiredCodec(codec.BigIntCodec)
7048
7886
  });
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)
7887
+ const ExecutionResources = codec.MessageCodec({
7888
+ computation: codec.RequiredCodec(ComputationResources),
7889
+ dataAvailability: codec.RequiredCodec(DataAvailabilityResources)
7055
7890
  });
7056
- const InvokeTransactionReceipt = schema.Schema.Struct({
7057
- _tag: tag("invoke"),
7058
- invoke: schema.Schema.Struct({})
7891
+ const ExecutionSucceeded = codec.MessageCodec({});
7892
+ const ExecutionReverted = codec.MessageCodec({
7893
+ reason: codec.OptionalCodec(codec.StringCodec)
7059
7894
  });
7060
- const L1HandlerTransactionReceipt = schema.Schema.Struct({
7061
- _tag: tag("l1Handler"),
7062
- l1Handler: schema.Schema.Struct({
7063
- messageHash: schema.Schema.Uint8ArrayFromSelf
7064
- })
7895
+ const TransactionReceiptMeta = codec.MessageCodec({
7896
+ transactionIndex: codec.RequiredCodec(codec.NumberCodec),
7897
+ transactionHash: codec.RequiredCodec(FieldElement$1),
7898
+ actualFee: codec.RequiredCodec(FeePayment),
7899
+ executionResources: codec.RequiredCodec(ExecutionResources),
7900
+ executionResult: codec.RequiredCodec(
7901
+ codec.OneOfCodec({
7902
+ succeeded: ExecutionSucceeded,
7903
+ reverted: ExecutionReverted
7904
+ })
7905
+ )
7065
7906
  });
7066
- const DeclareTransactionReceipt = schema.Schema.Struct({
7067
- _tag: tag("declare"),
7068
- declare: schema.Schema.Struct({})
7907
+ const InvokeTransactionReceipt = codec.MessageCodec({});
7908
+ const L1HandlerTransactionReceipt = codec.MessageCodec({
7909
+ messageHash: codec.RequiredCodec(codec.Uint8ArrayCodec)
7069
7910
  });
7070
- const DeployTransactionReceipt = schema.Schema.Struct({
7071
- _tag: tag("deploy"),
7072
- deploy: schema.Schema.Struct({
7073
- contractAddress: FieldElement$1
7074
- })
7911
+ const DeclareTransactionReceipt = codec.MessageCodec({});
7912
+ const DeployTransactionReceipt = codec.MessageCodec({
7913
+ contractAddress: codec.RequiredCodec(FieldElement$1)
7075
7914
  });
7076
- const DeployAccountTransactionReceipt = schema.Schema.Struct({
7077
- _tag: tag("deployAccount"),
7078
- deployAccount: schema.Schema.Struct({
7079
- contractAddress: FieldElement$1
7080
- })
7915
+ const DeployAccountTransactionReceipt = codec.MessageCodec({
7916
+ contractAddress: codec.RequiredCodec(FieldElement$1)
7081
7917
  });
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
7918
+ const TransactionReceipt = codec.MessageCodec({
7919
+ filterIds: codec.ArrayCodec(codec.NumberCodec),
7920
+ meta: codec.RequiredCodec(TransactionReceiptMeta),
7921
+ receipt: codec.RequiredCodec(
7922
+ codec.OneOfCodec({
7923
+ invoke: InvokeTransactionReceipt,
7924
+ l1Handler: L1HandlerTransactionReceipt,
7925
+ declare: DeclareTransactionReceipt,
7926
+ deploy: DeployTransactionReceipt,
7927
+ deployAccount: DeployAccountTransactionReceipt
7928
+ })
7091
7929
  )
7092
7930
  });
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
7931
+ const Event = codec.MessageCodec({
7932
+ filterIds: codec.ArrayCodec(codec.NumberCodec),
7933
+ address: codec.RequiredCodec(FieldElement$1),
7934
+ keys: codec.ArrayCodec(FieldElement$1),
7935
+ data: codec.ArrayCodec(FieldElement$1),
7936
+ eventIndex: codec.RequiredCodec(codec.NumberCodec),
7937
+ transactionIndex: codec.RequiredCodec(codec.NumberCodec),
7938
+ transactionHash: codec.RequiredCodec(FieldElement$1),
7939
+ transactionStatus: codec.RequiredCodec(TransactionStatus),
7940
+ eventIndexInTransaction: codec.RequiredCodec(codec.NumberCodec)
7103
7941
  });
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
7942
+ const MessageToL1 = codec.MessageCodec({
7943
+ filterIds: codec.ArrayCodec(codec.NumberCodec),
7944
+ fromAddress: codec.RequiredCodec(FieldElement$1),
7945
+ toAddress: codec.RequiredCodec(FieldElement$1),
7946
+ payload: codec.ArrayCodec(FieldElement$1),
7947
+ messageIndex: codec.RequiredCodec(codec.NumberCodec),
7948
+ transactionIndex: codec.RequiredCodec(codec.NumberCodec),
7949
+ transactionHash: codec.RequiredCodec(FieldElement$1),
7950
+ transactionStatus: codec.RequiredCodec(TransactionStatus),
7951
+ messageIndexInTransaction: codec.RequiredCodec(codec.NumberCodec)
7114
7952
  });
7115
- const StorageEntry = schema.Schema.Struct({
7116
- key: FieldElement$1,
7117
- value: FieldElement$1
7953
+ const StorageEntry = codec.MessageCodec({
7954
+ key: codec.RequiredCodec(FieldElement$1),
7955
+ value: codec.RequiredCodec(FieldElement$1)
7118
7956
  });
7119
- const StorageDiff = schema.Schema.Struct({
7120
- filterIds: schema.Schema.Array(schema.Schema.Number),
7121
- contractAddress: FieldElement$1,
7122
- storageEntries: schema.Schema.Array(StorageEntry)
7957
+ const StorageDiff = codec.MessageCodec({
7958
+ filterIds: codec.ArrayCodec(codec.NumberCodec),
7959
+ contractAddress: codec.RequiredCodec(FieldElement$1),
7960
+ storageEntries: codec.ArrayCodec(StorageEntry)
7123
7961
  });
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
- })
7962
+ const DeclaredClass = codec.MessageCodec({
7963
+ classHash: codec.OptionalCodec(FieldElement$1),
7964
+ compiledClassHash: codec.OptionalCodec(FieldElement$1)
7130
7965
  });
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
- })
7966
+ const ReplacedClass = codec.MessageCodec({
7967
+ contractAddress: codec.OptionalCodec(FieldElement$1),
7968
+ classHash: codec.OptionalCodec(FieldElement$1)
7137
7969
  });
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
- })
7970
+ const DeployedContract = codec.MessageCodec({
7971
+ contractAddress: codec.OptionalCodec(FieldElement$1),
7972
+ classHash: codec.OptionalCodec(FieldElement$1)
7144
7973
  });
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
7974
+ const ContractChange = codec.MessageCodec({
7975
+ filterIds: codec.ArrayCodec(codec.NumberCodec),
7976
+ change: codec.RequiredCodec(
7977
+ codec.OneOfCodec({
7978
+ declaredClass: DeclaredClass,
7979
+ replacedClass: ReplacedClass,
7980
+ deployedContract: DeployedContract
7981
+ })
7982
+ )
7153
7983
  });
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)
7984
+ const NonceUpdate = codec.MessageCodec({
7985
+ filterIds: codec.ArrayCodec(codec.NumberCodec),
7986
+ contractAddress: codec.RequiredCodec(FieldElement$1),
7987
+ nonce: codec.RequiredCodec(FieldElement$1)
7163
7988
  });
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
- }
7989
+ const CallType = {
7990
+ encode(x) {
7991
+ switch (x) {
7992
+ case "libraryCall":
7993
+ return CallType$1.LIBRARY_CALL;
7994
+ case "call":
7995
+ return CallType$1.CALL;
7996
+ case "delegate":
7997
+ return CallType$1.DELEGATE;
7998
+ case "unknown":
7999
+ return CallType$1.UNSPECIFIED;
8000
+ default:
8001
+ return CallType$1.UNRECOGNIZED;
8002
+ }
8003
+ },
8004
+ decode(p) {
8005
+ const enumMap = {
8006
+ [CallType$1.LIBRARY_CALL]: "libraryCall",
8007
+ [CallType$1.CALL]: "call",
8008
+ [CallType$1.DELEGATE]: "delegate",
8009
+ [CallType$1.UNSPECIFIED]: "unknown",
8010
+ [CallType$1.UNRECOGNIZED]: "unknown"
8011
+ };
8012
+ return enumMap[p] ?? "unknown";
7256
8013
  }
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({})
8014
+ };
8015
+ const _FunctionInvocationCodec = codec.MessageCodec({
8016
+ contractAddress: codec.RequiredCodec(FieldElement$1),
8017
+ entryPointSelector: codec.RequiredCodec(FieldElement$1),
8018
+ calldata: codec.ArrayCodec(FieldElement$1),
8019
+ callerAddress: codec.RequiredCodec(FieldElement$1),
8020
+ classHash: codec.RequiredCodec(FieldElement$1),
8021
+ callType: codec.RequiredCodec(CallType),
8022
+ result: codec.ArrayCodec(FieldElement$1),
8023
+ events: codec.ArrayCodec(codec.NumberCodec),
8024
+ messages: codec.ArrayCodec(codec.NumberCodec)
7285
8025
  });
7286
- const InvokeTransactionV3Filter = schema.Schema.Struct({
7287
- _tag: tag("invokeV3"),
7288
- invokeV3: schema.Schema.Struct({})
8026
+ const FunctionInvocationCodec = {
8027
+ encode(x) {
8028
+ const { calls, ...rest } = x;
8029
+ const encodedCalls = calls.map(FunctionInvocationCodec.encode);
8030
+ const encodedRest = _FunctionInvocationCodec.encode(rest);
8031
+ return { calls: encodedCalls, ...encodedRest };
8032
+ },
8033
+ decode(p) {
8034
+ const { calls = [], ...rest } = p;
8035
+ const decodedCalls = calls.map(FunctionInvocationCodec.decode);
8036
+ const decodedRest = _FunctionInvocationCodec.decode(rest);
8037
+ return { ...decodedRest, calls: decodedCalls };
8038
+ }
8039
+ };
8040
+ const ExecuteInvocationSuccess = FunctionInvocationCodec;
8041
+ const ExecuteInvocationReverted = codec.MessageCodec({
8042
+ reason: codec.OptionalCodec(codec.StringCodec)
7289
8043
  });
7290
- const DeployTransactionFilter = schema.Schema.Struct({
7291
- _tag: tag("deploy"),
7292
- deploy: schema.Schema.Struct({})
8044
+ const InvokeTransactionTrace = codec.MessageCodec({
8045
+ validateInvocation: codec.OptionalCodec(FunctionInvocationCodec),
8046
+ executeInvocation: codec.RequiredCodec(
8047
+ codec.OneOfCodec({
8048
+ success: ExecuteInvocationSuccess,
8049
+ reverted: ExecuteInvocationReverted
8050
+ })
8051
+ ),
8052
+ feeTransferInvocation: codec.OptionalCodec(FunctionInvocationCodec)
7293
8053
  });
7294
- const DeclareV0TransactionFilter = schema.Schema.Struct({
7295
- _tag: tag("declareV0"),
7296
- declareV0: schema.Schema.Struct({})
8054
+ const DeclareTransactionTrace = codec.MessageCodec({
8055
+ validateInvocation: codec.OptionalCodec(FunctionInvocationCodec),
8056
+ feeTransferInvocation: codec.OptionalCodec(FunctionInvocationCodec)
7297
8057
  });
7298
- const DeclareV1TransactionFilter = schema.Schema.Struct({
7299
- _tag: tag("declareV1"),
7300
- declareV1: schema.Schema.Struct({})
8058
+ const DeployAccountTransactionTrace = codec.MessageCodec({
8059
+ validateInvocation: codec.OptionalCodec(FunctionInvocationCodec),
8060
+ constructorInvocation: codec.OptionalCodec(FunctionInvocationCodec),
8061
+ feeTransferInvocation: codec.OptionalCodec(FunctionInvocationCodec)
7301
8062
  });
7302
- const DeclareV2TransactionFilter = schema.Schema.Struct({
7303
- _tag: tag("declareV2"),
7304
- declareV2: schema.Schema.Struct({})
8063
+ const L1HandlerTransactionTrace = codec.MessageCodec({
8064
+ functionInvocation: codec.OptionalCodec(FunctionInvocationCodec)
7305
8065
  });
7306
- const DeclareV3TransactionFilter = schema.Schema.Struct({
7307
- _tag: tag("declareV3"),
7308
- declareV3: schema.Schema.Struct({})
8066
+ const TransactionTrace = codec.MessageCodec({
8067
+ filterIds: codec.ArrayCodec(codec.NumberCodec),
8068
+ transactionIndex: codec.RequiredCodec(codec.NumberCodec),
8069
+ transactionHash: codec.RequiredCodec(FieldElement$1),
8070
+ traceRoot: codec.RequiredCodec(
8071
+ codec.OneOfCodec({
8072
+ invoke: InvokeTransactionTrace,
8073
+ declare: DeclareTransactionTrace,
8074
+ deployAccount: DeployAccountTransactionTrace,
8075
+ l1Handler: L1HandlerTransactionTrace
8076
+ })
8077
+ )
7309
8078
  });
7310
- const L1HandlerTransactionFilter = schema.Schema.Struct({
7311
- _tag: tag("l1Handler"),
7312
- l1Handler: schema.Schema.Struct({})
8079
+ const Block = codec.MessageCodec({
8080
+ header: codec.RequiredCodec(BlockHeader),
8081
+ transactions: codec.ArrayCodec(Transaction),
8082
+ receipts: codec.ArrayCodec(TransactionReceipt),
8083
+ events: codec.ArrayCodec(Event),
8084
+ messages: codec.ArrayCodec(MessageToL1),
8085
+ traces: codec.ArrayCodec(TransactionTrace),
8086
+ storageDiffs: codec.ArrayCodec(StorageDiff),
8087
+ contractChanges: codec.ArrayCodec(ContractChange),
8088
+ nonceUpdates: codec.ArrayCodec(NonceUpdate)
7313
8089
  });
7314
- const DeployAccountV1TransactionFilter = schema.Schema.Struct({
7315
- _tag: tag("deployAccountV1"),
7316
- deployAccountV1: schema.Schema.Struct({})
8090
+ const BlockFromBytes = {
8091
+ encode(x) {
8092
+ const block = Block.encode(x);
8093
+ return Block$1.encode(block).finish();
8094
+ },
8095
+ decode(p) {
8096
+ const block = Block$1.decode(p);
8097
+ return Block.decode(block);
8098
+ }
8099
+ };
8100
+
8101
+ const HeaderFilter = {
8102
+ encode(x) {
8103
+ switch (x) {
8104
+ case "always":
8105
+ return HeaderFilter$1.ALWAYS;
8106
+ case "on_data":
8107
+ return HeaderFilter$1.ON_DATA;
8108
+ case "on_data_or_on_new_block":
8109
+ return HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK;
8110
+ default:
8111
+ return HeaderFilter$1.UNSPECIFIED;
8112
+ }
8113
+ },
8114
+ decode(p) {
8115
+ const enumMap = {
8116
+ [HeaderFilter$1.ALWAYS]: "always",
8117
+ [HeaderFilter$1.ON_DATA]: "on_data",
8118
+ [HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK]: "on_data_or_on_new_block",
8119
+ [HeaderFilter$1.UNSPECIFIED]: "unknown",
8120
+ [HeaderFilter$1.UNRECOGNIZED]: "unknown"
8121
+ };
8122
+ return enumMap[p] ?? "unknown";
8123
+ }
8124
+ };
8125
+ const Key = {
8126
+ encode(x) {
8127
+ if (x === null) {
8128
+ return { value: void 0 };
8129
+ }
8130
+ return { value: FieldElement$1.encode(x) };
8131
+ },
8132
+ decode(p) {
8133
+ if (p.value === void 0) {
8134
+ return null;
8135
+ }
8136
+ return FieldElement$1.decode(p.value);
8137
+ }
8138
+ };
8139
+ const TransactionStatusFilter = {
8140
+ encode(x) {
8141
+ switch (x) {
8142
+ case "succeeded":
8143
+ return TransactionStatusFilter$1.SUCCEEDED;
8144
+ case "reverted":
8145
+ return TransactionStatusFilter$1.REVERTED;
8146
+ case "all":
8147
+ return TransactionStatusFilter$1.ALL;
8148
+ default:
8149
+ return TransactionStatusFilter$1.UNSPECIFIED;
8150
+ }
8151
+ },
8152
+ decode(p) {
8153
+ const enumMap = {
8154
+ [TransactionStatusFilter$1.SUCCEEDED]: "succeeded",
8155
+ [TransactionStatusFilter$1.REVERTED]: "reverted",
8156
+ [TransactionStatusFilter$1.ALL]: "all",
8157
+ [TransactionStatusFilter$1.UNSPECIFIED]: "unknown",
8158
+ [TransactionStatusFilter$1.UNRECOGNIZED]: "unknown"
8159
+ };
8160
+ return enumMap[p] ?? "unknown";
8161
+ }
8162
+ };
8163
+ const EventFilter = codec.MessageCodec({
8164
+ id: codec.OptionalCodec(codec.NumberCodec),
8165
+ address: codec.OptionalCodec(FieldElement$1),
8166
+ keys: codec.OptionalCodec(codec.ArrayCodec(Key)),
8167
+ strict: codec.OptionalCodec(codec.BooleanCodec),
8168
+ transactionStatus: codec.OptionalCodec(TransactionStatusFilter),
8169
+ includeTransaction: codec.OptionalCodec(codec.BooleanCodec),
8170
+ includeReceipt: codec.OptionalCodec(codec.BooleanCodec),
8171
+ includeMessages: codec.OptionalCodec(codec.BooleanCodec),
8172
+ includeSiblings: codec.OptionalCodec(codec.BooleanCodec),
8173
+ includeTransactionTrace: codec.OptionalCodec(codec.BooleanCodec)
7317
8174
  });
7318
- const DeployAccountV3TransactionFilter = schema.Schema.Struct({
7319
- _tag: tag("deployAccountV3"),
7320
- deployAccountV3: schema.Schema.Struct({})
8175
+ const MessageToL1Filter = codec.MessageCodec({
8176
+ id: codec.OptionalCodec(codec.NumberCodec),
8177
+ fromAddress: codec.OptionalCodec(FieldElement$1),
8178
+ toAddress: codec.OptionalCodec(FieldElement$1),
8179
+ transactionStatus: codec.OptionalCodec(TransactionStatusFilter),
8180
+ includeTransaction: codec.OptionalCodec(codec.BooleanCodec),
8181
+ includeReceipt: codec.OptionalCodec(codec.BooleanCodec),
8182
+ includeEvents: codec.OptionalCodec(codec.BooleanCodec),
8183
+ includeTransactionTrace: codec.OptionalCodec(codec.BooleanCodec)
7321
8184
  });
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
- )
8185
+ const InvokeTransactionV0Filter = codec.MessageCodec({});
8186
+ const InvokeTransactionV1Filter = codec.MessageCodec({});
8187
+ const InvokeTransactionV3Filter = codec.MessageCodec({});
8188
+ const DeployTransactionFilter = codec.MessageCodec({});
8189
+ const DeclareV0TransactionFilter = codec.MessageCodec({});
8190
+ const DeclareV1TransactionFilter = codec.MessageCodec({});
8191
+ const DeclareV2TransactionFilter = codec.MessageCodec({});
8192
+ const DeclareV3TransactionFilter = codec.MessageCodec({});
8193
+ const L1HandlerTransactionFilter = codec.MessageCodec({});
8194
+ const DeployAccountV1TransactionFilter = codec.MessageCodec({});
8195
+ const DeployAccountV3TransactionFilter = codec.MessageCodec({});
8196
+ const TransactionFilter = codec.MessageCodec({
8197
+ id: codec.OptionalCodec(codec.NumberCodec),
8198
+ transactionStatus: codec.OptionalCodec(TransactionStatusFilter),
8199
+ includeReceipt: codec.OptionalCodec(codec.BooleanCodec),
8200
+ includeMessages: codec.OptionalCodec(codec.BooleanCodec),
8201
+ includeEvents: codec.OptionalCodec(codec.BooleanCodec),
8202
+ includeTrace: codec.OptionalCodec(codec.BooleanCodec),
8203
+ transactionType: codec.OptionalCodec(
8204
+ codec.OneOfCodec({
8205
+ invokeV0: InvokeTransactionV0Filter,
8206
+ invokeV1: InvokeTransactionV1Filter,
8207
+ invokeV3: InvokeTransactionV3Filter,
8208
+ deploy: DeployTransactionFilter,
8209
+ declareV0: DeclareV0TransactionFilter,
8210
+ declareV1: DeclareV1TransactionFilter,
8211
+ declareV2: DeclareV2TransactionFilter,
8212
+ declareV3: DeclareV3TransactionFilter,
8213
+ l1Handler: L1HandlerTransactionFilter,
8214
+ deployAccountV1: DeployAccountV1TransactionFilter,
8215
+ deployAccountV3: DeployAccountV3TransactionFilter
8216
+ })
7343
8217
  )
7344
8218
  });
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({})
8219
+ const StorageDiffFilter = codec.MessageCodec({
8220
+ id: codec.OptionalCodec(codec.NumberCodec),
8221
+ contractAddress: codec.OptionalCodec(FieldElement$1)
7352
8222
  });
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
- )
8223
+ const DeclaredClassFilter = codec.MessageCodec({});
8224
+ const ReplacedClassFilter = codec.MessageCodec({});
8225
+ const DeployedContractFilter = codec.MessageCodec({});
8226
+ const ContractChangeFilter = codec.MessageCodec({
8227
+ id: codec.OptionalCodec(codec.NumberCodec),
8228
+ change: codec.OptionalCodec(
8229
+ codec.OneOfCodec({
8230
+ declaredClass: DeclaredClassFilter,
8231
+ replacedClass: ReplacedClassFilter,
8232
+ deployedContract: DeployedContractFilter
8233
+ })
7369
8234
  )
7370
8235
  });
7371
- const NonceUpdateFilter = schema.Schema.Struct({
7372
- id: schema.Schema.optional(schema.Schema.Number),
7373
- contractAddress: schema.Schema.optional(FieldElement$1)
8236
+ const NonceUpdateFilter = codec.MessageCodec({
8237
+ id: codec.OptionalCodec(codec.NumberCodec),
8238
+ contractAddress: codec.OptionalCodec(FieldElement$1)
7374
8239
  });
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))
8240
+ const Filter = codec.MessageCodec({
8241
+ header: codec.OptionalCodec(HeaderFilter),
8242
+ transactions: codec.OptionalCodec(codec.ArrayCodec(TransactionFilter)),
8243
+ events: codec.OptionalCodec(codec.ArrayCodec(EventFilter)),
8244
+ messages: codec.OptionalCodec(codec.ArrayCodec(MessageToL1Filter)),
8245
+ storageDiffs: codec.OptionalCodec(codec.ArrayCodec(StorageDiffFilter)),
8246
+ contractChanges: codec.OptionalCodec(codec.ArrayCodec(ContractChangeFilter)),
8247
+ nonceUpdates: codec.OptionalCodec(codec.ArrayCodec(NonceUpdateFilter))
7383
8248
  });
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
- }
8249
+ const FilterFromBytes = {
8250
+ encode(x) {
8251
+ const filter = Filter.encode(x);
8252
+ return Filter$1.encode(filter).finish();
8253
+ },
8254
+ decode(p) {
8255
+ const filter = Filter$1.decode(p);
8256
+ return Filter.decode(filter);
7397
8257
  }
7398
- );
7399
- const filterToBytes = schema.Schema.encodeSync(FilterFromBytes);
7400
- const filterFromBytes = schema.Schema.decodeSync(FilterFromBytes);
8258
+ };
7401
8259
  function mergeFilter(a, b) {
7402
8260
  const header = mergeHeaderFilter(a.header, b.header);
7403
8261
  return {
@@ -7484,6 +8342,7 @@ const PrimitiveTypeParsers = {
7484
8342
  "core::integer::u64": parser.parseU64,
7485
8343
  "core::integer::u128": parser.parseU128,
7486
8344
  "core::integer::u256": parser.parseU256,
8345
+ "core::bytes_31::bytes31": parser.parseBytes31,
7487
8346
  "core::starknet::contract_address::ContractAddress": parser.parseContractAddress
7488
8347
  };
7489
8348
  function isPrimitiveType(type) {
@@ -7510,6 +8369,19 @@ function getOptionType(type) {
7510
8369
  function isEmptyType(type) {
7511
8370
  return type === "()";
7512
8371
  }
8372
+ function isByteArray(type) {
8373
+ return type === "core::byte_array::ByteArray";
8374
+ }
8375
+
8376
+ function isEventAbi(item) {
8377
+ return item.type === "event";
8378
+ }
8379
+ function isStructEventAbi(item) {
8380
+ return isEventAbi(item) && item.kind === "struct";
8381
+ }
8382
+ function isEnumEventAbi(item) {
8383
+ return isEventAbi(item) && item.kind === "enum";
8384
+ }
7513
8385
 
7514
8386
  class DecodeEventError extends Error {
7515
8387
  constructor(message) {
@@ -7522,50 +8394,120 @@ function decodeEvent(args) {
7522
8394
  const eventAbi = abi.find(
7523
8395
  (item) => item.name === eventName && item.type === "event"
7524
8396
  );
7525
- if (!eventAbi || eventAbi.type !== "event") {
8397
+ if (!eventAbi || !isEventAbi(eventAbi)) {
7526
8398
  if (strict) {
7527
8399
  throw new DecodeEventError(`Event ${eventName} not found in ABI`);
7528
8400
  }
7529
8401
  return null;
7530
8402
  }
7531
- if (eventAbi.kind === "enum") {
7532
- throw new DecodeEventError("enum: not implemented");
8403
+ try {
8404
+ if (isStructEventAbi(eventAbi)) {
8405
+ return decodeStructEvent(abi, eventAbi, event, eventName);
8406
+ }
8407
+ if (isEnumEventAbi(eventAbi)) {
8408
+ return decodeEnumEvent(abi, eventAbi, event, eventName);
8409
+ }
8410
+ throw new DecodeEventError(
8411
+ `Unsupported event kind: ${eventAbi?.kind}`
8412
+ );
8413
+ } catch (error) {
8414
+ if ((error instanceof DecodeEventError || error instanceof parser.ParseError) && !strict) {
8415
+ return null;
8416
+ }
8417
+ throw error;
7533
8418
  }
8419
+ }
8420
+ function decodeStructEvent(abi, eventAbi, event, eventName) {
7534
8421
  const selector = BigInt(getEventSelector(eventName));
7535
8422
  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;
8423
+ throw new DecodeEventError(
8424
+ `Selector mismatch. Expected ${selector}, got ${event.keys?.[0]}`
8425
+ );
7542
8426
  }
7543
8427
  const keysAbi = eventAbi.members.filter((m) => m.kind === "key");
7544
8428
  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;
8429
+ const keysParser = compileEventMembers(abi, keysAbi);
8430
+ const dataParser = compileEventMembers(abi, dataAbi);
8431
+ const keysWithoutSelector = event.keys?.slice(1) ?? [];
8432
+ const { out: decodedKeys } = keysParser(keysWithoutSelector, 0);
8433
+ const { out: decodedData } = dataParser(event.data ?? [], 0);
8434
+ const decoded = {
8435
+ ...decodedKeys,
8436
+ ...decodedData
8437
+ };
8438
+ return {
8439
+ ...event,
8440
+ eventName,
8441
+ args: decoded
8442
+ };
8443
+ }
8444
+ function decodeEnumEvent(abi, eventAbi, event, eventName) {
8445
+ if (!event.keys || event.keys.length === 0) {
8446
+ throw new DecodeEventError(
8447
+ "Event has no keys; cannot determine variant selector"
8448
+ );
8449
+ }
8450
+ const variants = eventAbi.variants;
8451
+ const variantSelector = event.keys[0];
8452
+ const selectorToVariant = buildVariantSelectorMap(abi, variants);
8453
+ const matchingVariant = selectorToVariant[variantSelector];
8454
+ if (!matchingVariant) {
8455
+ throw new DecodeEventError(
8456
+ `No matching variant found for selector: ${variantSelector}`
8457
+ );
8458
+ }
8459
+ const structEventAbi = abi.find(
8460
+ (item) => item.name === matchingVariant.variant.type && item.type === "event"
8461
+ );
8462
+ if (!structEventAbi || !isStructEventAbi(structEventAbi)) {
8463
+ throw new DecodeEventError(
8464
+ `Nested event type not found or not a struct: ${matchingVariant.variant.type}`
8465
+ );
8466
+ }
8467
+ const decodedStruct = decodeStructEvent(
8468
+ abi,
8469
+ structEventAbi,
8470
+ event,
8471
+ matchingVariant.variant.name
8472
+ );
8473
+ return {
8474
+ ...event,
8475
+ eventName,
8476
+ args: {
8477
+ _tag: matchingVariant.variant.name,
8478
+ [matchingVariant.variant.name]: decodedStruct.args
7563
8479
  }
7564
- if (error instanceof parser.ParseError && !strict) {
7565
- return null;
8480
+ };
8481
+ }
8482
+ function buildVariantSelectorMap(abi, variants) {
8483
+ const selectorMap = {};
8484
+ for (const variant of variants) {
8485
+ if (variant.kind === "nested") {
8486
+ const selector = getEventSelector(variant.name);
8487
+ selectorMap[selector] = { variant, path: [variant.name] };
8488
+ } else if (variant.kind === "flat") {
8489
+ const flatEventName = variant.type;
8490
+ const flatEventAbi = abi.find(
8491
+ (item) => item.name === flatEventName && item.type === "event"
8492
+ );
8493
+ if (!flatEventAbi) {
8494
+ continue;
8495
+ }
8496
+ if (isEnumEventAbi(flatEventAbi)) {
8497
+ const nestedMap = buildVariantSelectorMap(abi, flatEventAbi.variants);
8498
+ for (const [
8499
+ nestedSelector,
8500
+ { variant: nestedVariant, path: nestedPath }
8501
+ ] of Object.entries(nestedMap)) {
8502
+ selectorMap[nestedSelector] = {
8503
+ variant: nestedVariant,
8504
+ path: [variant.name, ...nestedPath]
8505
+ };
8506
+ }
8507
+ }
7566
8508
  }
7567
- throw error;
7568
8509
  }
8510
+ return selectorMap;
7569
8511
  }
7570
8512
  function compileEventMembers(abi, members) {
7571
8513
  return compileStructParser(abi, members);
@@ -7589,6 +8531,9 @@ function compileTypeParser(abi, type) {
7589
8531
  if (isEmptyType(type)) {
7590
8532
  return parser.parseEmpty;
7591
8533
  }
8534
+ if (isByteArray(type)) {
8535
+ return parser.parseByteArray;
8536
+ }
7592
8537
  const typeAbi = abi.find((item) => item.name === type);
7593
8538
  if (!typeAbi) {
7594
8539
  throw new DecodeEventError(`Type ${type} not found in ABI`);
@@ -7597,8 +8542,9 @@ function compileTypeParser(abi, type) {
7597
8542
  case "struct": {
7598
8543
  return compileStructParser(abi, typeAbi.members);
7599
8544
  }
7600
- case "enum":
7601
- throw new DecodeEventError("enum: not implemented");
8545
+ case "enum": {
8546
+ return compileEnumParser(abi, typeAbi);
8547
+ }
7602
8548
  default:
7603
8549
  throw new DecodeEventError(`Invalid type ${typeAbi.type}`);
7604
8550
  }
@@ -7613,22 +8559,35 @@ function compileStructParser(abi, members) {
7613
8559
  }
7614
8560
  return parser.parseStruct(parsers);
7615
8561
  }
8562
+ function compileEnumParser(abi, enumAbi) {
8563
+ const parsers = {};
8564
+ for (const [index, variant] of enumAbi.variants.entries()) {
8565
+ parsers[variant.name] = {
8566
+ index,
8567
+ parser: compileTypeParser(abi, variant.type)
8568
+ };
8569
+ }
8570
+ return parser.parseEnum(parsers);
8571
+ }
7616
8572
 
7617
8573
  const StarknetStream = new protocol.StreamConfig(
7618
8574
  FilterFromBytes,
7619
8575
  BlockFromBytes,
7620
- mergeFilter
8576
+ mergeFilter,
8577
+ "starknet"
7621
8578
  );
7622
8579
 
7623
8580
  exports.Block = Block;
7624
8581
  exports.BlockFromBytes = BlockFromBytes;
7625
8582
  exports.BlockHeader = BlockHeader;
8583
+ exports.CallType = CallType;
7626
8584
  exports.ComputationResources = ComputationResources;
7627
8585
  exports.ContractChange = ContractChange;
7628
8586
  exports.ContractChangeFilter = ContractChangeFilter;
7629
8587
  exports.DataAvailabilityMode = DataAvailabilityMode;
7630
8588
  exports.DataAvailabilityResources = DataAvailabilityResources;
7631
8589
  exports.DeclareTransactionReceipt = DeclareTransactionReceipt;
8590
+ exports.DeclareTransactionTrace = DeclareTransactionTrace;
7632
8591
  exports.DeclareTransactionV0 = DeclareTransactionV0;
7633
8592
  exports.DeclareTransactionV1 = DeclareTransactionV1;
7634
8593
  exports.DeclareTransactionV2 = DeclareTransactionV2;
@@ -7641,6 +8600,7 @@ exports.DeclaredClass = DeclaredClass;
7641
8600
  exports.DeclaredClassFilter = DeclaredClassFilter;
7642
8601
  exports.DecodeEventError = DecodeEventError;
7643
8602
  exports.DeployAccountTransactionReceipt = DeployAccountTransactionReceipt;
8603
+ exports.DeployAccountTransactionTrace = DeployAccountTransactionTrace;
7644
8604
  exports.DeployAccountTransactionV1 = DeployAccountTransactionV1;
7645
8605
  exports.DeployAccountTransactionV3 = DeployAccountTransactionV3;
7646
8606
  exports.DeployAccountV1TransactionFilter = DeployAccountV1TransactionFilter;
@@ -7652,16 +8612,18 @@ exports.DeployedContract = DeployedContract;
7652
8612
  exports.DeployedContractFilter = DeployedContractFilter;
7653
8613
  exports.Event = Event;
7654
8614
  exports.EventFilter = EventFilter;
8615
+ exports.ExecuteInvocationReverted = ExecuteInvocationReverted;
8616
+ exports.ExecuteInvocationSuccess = ExecuteInvocationSuccess;
7655
8617
  exports.ExecutionResources = ExecutionResources;
7656
8618
  exports.ExecutionReverted = ExecutionReverted;
7657
8619
  exports.ExecutionSucceeded = ExecutionSucceeded;
7658
8620
  exports.FeePayment = FeePayment;
7659
8621
  exports.FieldElement = FieldElement$1;
7660
- exports.FieldElementProto = FieldElementProto;
7661
8622
  exports.Filter = Filter;
7662
8623
  exports.FilterFromBytes = FilterFromBytes;
7663
8624
  exports.HeaderFilter = HeaderFilter;
7664
8625
  exports.InvokeTransactionReceipt = InvokeTransactionReceipt;
8626
+ exports.InvokeTransactionTrace = InvokeTransactionTrace;
7665
8627
  exports.InvokeTransactionV0 = InvokeTransactionV0;
7666
8628
  exports.InvokeTransactionV0Filter = InvokeTransactionV0Filter;
7667
8629
  exports.InvokeTransactionV1 = InvokeTransactionV1;
@@ -7673,6 +8635,7 @@ exports.L1DataAvailabilityMode = L1DataAvailabilityMode;
7673
8635
  exports.L1HandlerTransaction = L1HandlerTransaction;
7674
8636
  exports.L1HandlerTransactionFilter = L1HandlerTransactionFilter;
7675
8637
  exports.L1HandlerTransactionReceipt = L1HandlerTransactionReceipt;
8638
+ exports.L1HandlerTransactionTrace = L1HandlerTransactionTrace;
7676
8639
  exports.MessageToL1 = MessageToL1;
7677
8640
  exports.MessageToL1Filter = MessageToL1Filter;
7678
8641
  exports.NonceUpdate = NonceUpdate;
@@ -7694,14 +8657,9 @@ exports.TransactionReceipt = TransactionReceipt;
7694
8657
  exports.TransactionReceiptMeta = TransactionReceiptMeta;
7695
8658
  exports.TransactionStatus = TransactionStatus;
7696
8659
  exports.TransactionStatusFilter = TransactionStatusFilter;
8660
+ exports.TransactionTrace = TransactionTrace;
7697
8661
  exports.U128 = U128;
7698
8662
  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
8663
  exports.getBigIntSelector = getBigIntSelector;
7706
8664
  exports.getEventSelector = getEventSelector;
7707
8665
  exports.getReceipt = getReceipt;
@@ -7709,3 +8667,4 @@ exports.getSelector = getSelector;
7709
8667
  exports.getTransaction = getTransaction;
7710
8668
  exports.mergeFilter = mergeFilter;
7711
8669
  exports.proto = index;
8670
+ //# sourceMappingURL=index.cjs.map