@apibara/starknet 2.1.0-beta.3 → 2.1.0-beta.30

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