@apibara/evm 2.0.0-beta.7 → 2.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2333,6 +2333,49 @@ const data = {
2333
2333
  };
2334
2334
 
2335
2335
  const protobufPackage = "evm.v2";
2336
+ var HeaderFilter$1 = /* @__PURE__ */ ((HeaderFilter2) => {
2337
+ HeaderFilter2[HeaderFilter2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
2338
+ HeaderFilter2[HeaderFilter2["ALWAYS"] = 1] = "ALWAYS";
2339
+ HeaderFilter2[HeaderFilter2["ON_DATA"] = 2] = "ON_DATA";
2340
+ HeaderFilter2[HeaderFilter2["ON_DATA_OR_ON_NEW_BLOCK"] = 3] = "ON_DATA_OR_ON_NEW_BLOCK";
2341
+ HeaderFilter2[HeaderFilter2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
2342
+ return HeaderFilter2;
2343
+ })(HeaderFilter$1 || {});
2344
+ function headerFilterFromJSON(object) {
2345
+ switch (object) {
2346
+ case 0:
2347
+ case "HEADER_FILTER_UNSPECIFIED":
2348
+ return 0 /* UNSPECIFIED */;
2349
+ case 1:
2350
+ case "HEADER_FILTER_ALWAYS":
2351
+ return 1 /* ALWAYS */;
2352
+ case 2:
2353
+ case "HEADER_FILTER_ON_DATA":
2354
+ return 2 /* ON_DATA */;
2355
+ case 3:
2356
+ case "HEADER_FILTER_ON_DATA_OR_ON_NEW_BLOCK":
2357
+ return 3 /* ON_DATA_OR_ON_NEW_BLOCK */;
2358
+ case -1:
2359
+ case "UNRECOGNIZED":
2360
+ default:
2361
+ return -1 /* UNRECOGNIZED */;
2362
+ }
2363
+ }
2364
+ function headerFilterToJSON(object) {
2365
+ switch (object) {
2366
+ case 0 /* UNSPECIFIED */:
2367
+ return "HEADER_FILTER_UNSPECIFIED";
2368
+ case 1 /* ALWAYS */:
2369
+ return "HEADER_FILTER_ALWAYS";
2370
+ case 2 /* ON_DATA */:
2371
+ return "HEADER_FILTER_ON_DATA";
2372
+ case 3 /* ON_DATA_OR_ON_NEW_BLOCK */:
2373
+ return "HEADER_FILTER_ON_DATA_OR_ON_NEW_BLOCK";
2374
+ case -1 /* UNRECOGNIZED */:
2375
+ default:
2376
+ return "UNRECOGNIZED";
2377
+ }
2378
+ }
2336
2379
  var TransactionStatusFilter$1 = /* @__PURE__ */ ((TransactionStatusFilter2) => {
2337
2380
  TransactionStatusFilter2[TransactionStatusFilter2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
2338
2381
  TransactionStatusFilter2[TransactionStatusFilter2["SUCCEEDED"] = 1] = "SUCCEEDED";
@@ -2377,12 +2420,12 @@ function transactionStatusFilterToJSON(object) {
2377
2420
  }
2378
2421
  }
2379
2422
  function createBaseFilter() {
2380
- return { header: void 0, withdrawals: [], transactions: [], logs: [] };
2423
+ return { header: 0, withdrawals: [], transactions: [], logs: [] };
2381
2424
  }
2382
2425
  const Filter$1 = {
2383
2426
  encode(message, writer = _m0__default.Writer.create()) {
2384
- if (message.header !== void 0) {
2385
- HeaderFilter$1.encode(message.header, writer.uint32(10).fork()).ldelim();
2427
+ if (message.header !== void 0 && message.header !== 0) {
2428
+ writer.uint32(8).int32(message.header);
2386
2429
  }
2387
2430
  if (message.withdrawals !== void 0 && message.withdrawals.length !== 0) {
2388
2431
  for (const v of message.withdrawals) {
@@ -2409,10 +2452,10 @@ const Filter$1 = {
2409
2452
  const tag = reader.uint32();
2410
2453
  switch (tag >>> 3) {
2411
2454
  case 1:
2412
- if (tag !== 10) {
2455
+ if (tag !== 8) {
2413
2456
  break;
2414
2457
  }
2415
- message.header = HeaderFilter$1.decode(reader, reader.uint32());
2458
+ message.header = reader.int32();
2416
2459
  continue;
2417
2460
  case 2:
2418
2461
  if (tag !== 18) {
@@ -2442,7 +2485,7 @@ const Filter$1 = {
2442
2485
  },
2443
2486
  fromJSON(object) {
2444
2487
  return {
2445
- header: isSet(object.header) ? HeaderFilter$1.fromJSON(object.header) : void 0,
2488
+ header: isSet(object.header) ? headerFilterFromJSON(object.header) : 0,
2446
2489
  withdrawals: globalThis.Array.isArray(object?.withdrawals) ? object.withdrawals.map((e) => WithdrawalFilter$1.fromJSON(e)) : [],
2447
2490
  transactions: globalThis.Array.isArray(object?.transactions) ? object.transactions.map((e) => TransactionFilter$1.fromJSON(e)) : [],
2448
2491
  logs: globalThis.Array.isArray(object?.logs) ? object.logs.map((e) => LogFilter$1.fromJSON(e)) : []
@@ -2450,8 +2493,8 @@ const Filter$1 = {
2450
2493
  },
2451
2494
  toJSON(message) {
2452
2495
  const obj = {};
2453
- if (message.header !== void 0) {
2454
- obj.header = HeaderFilter$1.toJSON(message.header);
2496
+ if (message.header !== void 0 && message.header !== 0) {
2497
+ obj.header = headerFilterToJSON(message.header);
2455
2498
  }
2456
2499
  if (message.withdrawals?.length) {
2457
2500
  obj.withdrawals = message.withdrawals.map((e) => WithdrawalFilter$1.toJSON(e));
@@ -2469,63 +2512,13 @@ const Filter$1 = {
2469
2512
  },
2470
2513
  fromPartial(object) {
2471
2514
  const message = createBaseFilter();
2472
- message.header = object.header !== void 0 && object.header !== null ? HeaderFilter$1.fromPartial(object.header) : void 0;
2515
+ message.header = object.header ?? 0;
2473
2516
  message.withdrawals = object.withdrawals?.map((e) => WithdrawalFilter$1.fromPartial(e)) || [];
2474
2517
  message.transactions = object.transactions?.map((e) => TransactionFilter$1.fromPartial(e)) || [];
2475
2518
  message.logs = object.logs?.map((e) => LogFilter$1.fromPartial(e)) || [];
2476
2519
  return message;
2477
2520
  }
2478
2521
  };
2479
- function createBaseHeaderFilter() {
2480
- return { always: void 0 };
2481
- }
2482
- const HeaderFilter$1 = {
2483
- encode(message, writer = _m0__default.Writer.create()) {
2484
- if (message.always !== void 0) {
2485
- writer.uint32(8).bool(message.always);
2486
- }
2487
- return writer;
2488
- },
2489
- decode(input, length) {
2490
- const reader = input instanceof _m0__default.Reader ? input : _m0__default.Reader.create(input);
2491
- let end = length === void 0 ? reader.len : reader.pos + length;
2492
- const message = createBaseHeaderFilter();
2493
- while (reader.pos < end) {
2494
- const tag = reader.uint32();
2495
- switch (tag >>> 3) {
2496
- case 1:
2497
- if (tag !== 8) {
2498
- break;
2499
- }
2500
- message.always = reader.bool();
2501
- continue;
2502
- }
2503
- if ((tag & 7) === 4 || tag === 0) {
2504
- break;
2505
- }
2506
- reader.skipType(tag & 7);
2507
- }
2508
- return message;
2509
- },
2510
- fromJSON(object) {
2511
- return { always: isSet(object.always) ? globalThis.Boolean(object.always) : void 0 };
2512
- },
2513
- toJSON(message) {
2514
- const obj = {};
2515
- if (message.always !== void 0) {
2516
- obj.always = message.always;
2517
- }
2518
- return obj;
2519
- },
2520
- create(base) {
2521
- return HeaderFilter$1.fromPartial(base ?? {});
2522
- },
2523
- fromPartial(object) {
2524
- const message = createBaseHeaderFilter();
2525
- message.always = object.always ?? void 0;
2526
- return message;
2527
- }
2528
- };
2529
2522
  function createBaseWithdrawalFilter() {
2530
2523
  return { id: 0, validatorIndex: void 0, address: void 0 };
2531
2524
  }
@@ -2974,6 +2967,8 @@ const filter = {
2974
2967
  TransactionFilter: TransactionFilter$1,
2975
2968
  TransactionStatusFilter: TransactionStatusFilter$1,
2976
2969
  WithdrawalFilter: WithdrawalFilter$1,
2970
+ headerFilterFromJSON: headerFilterFromJSON,
2971
+ headerFilterToJSON: headerFilterToJSON,
2977
2972
  protobufPackage: protobufPackage,
2978
2973
  transactionStatusFilterFromJSON: transactionStatusFilterFromJSON,
2979
2974
  transactionStatusFilterToJSON: transactionStatusFilterToJSON
@@ -3136,9 +3131,34 @@ const BlockFromBytes = schema.Schema.transform(
3136
3131
  );
3137
3132
 
3138
3133
  const OptionalArray = (schema$1) => schema.Schema.optional(schema.Schema.Array(schema$1));
3139
- const HeaderFilter = schema.Schema.Struct({
3140
- always: schema.Schema.optional(schema.Schema.Boolean)
3141
- });
3134
+ const HeaderFilter = schema.Schema.transform(
3135
+ schema.Schema.Enums(HeaderFilter$1),
3136
+ schema.Schema.Literal("always", "on_data", "on_data_or_on_new_block", "unknown"),
3137
+ {
3138
+ decode(value) {
3139
+ const enumMap = {
3140
+ [HeaderFilter$1.ALWAYS]: "always",
3141
+ [HeaderFilter$1.ON_DATA]: "on_data",
3142
+ [HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK]: "on_data_or_on_new_block",
3143
+ [HeaderFilter$1.UNSPECIFIED]: "unknown",
3144
+ [HeaderFilter$1.UNRECOGNIZED]: "unknown"
3145
+ };
3146
+ return enumMap[value] ?? "unknown";
3147
+ },
3148
+ encode(value) {
3149
+ switch (value) {
3150
+ case "always":
3151
+ return HeaderFilter$1.ALWAYS;
3152
+ case "on_data":
3153
+ return HeaderFilter$1.ON_DATA;
3154
+ case "on_data_or_on_new_block":
3155
+ return HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK;
3156
+ default:
3157
+ return HeaderFilter$1.UNSPECIFIED;
3158
+ }
3159
+ }
3160
+ }
3161
+ );
3142
3162
  const WithdrawalFilter = schema.Schema.Struct({
3143
3163
  id: schema.Schema.optional(schema.Schema.Number),
3144
3164
  validatorIndex: schema.Schema.optional(schema.Schema.Number),
@@ -3247,9 +3267,13 @@ function mergeHeaderFilter(a, b) {
3247
3267
  if (b === void 0) {
3248
3268
  return a;
3249
3269
  }
3250
- return {
3251
- always: a.always || b.always
3252
- };
3270
+ if (a === "always" || b === "always") {
3271
+ return "always";
3272
+ }
3273
+ if (a === "on_data_or_on_new_block" || b === "on_data_or_on_new_block") {
3274
+ return "on_data_or_on_new_block";
3275
+ }
3276
+ return "on_data";
3253
3277
  }
3254
3278
 
3255
3279
  const EvmStream = new protocol.StreamConfig(
package/dist/index.d.cts CHANGED
@@ -360,6 +360,15 @@ declare namespace data {
360
360
 
361
361
  declare const protobufPackage = "evm.v2";
362
362
  /** EVM DNA definitions (filter). */
363
+ declare enum HeaderFilter$1 {
364
+ UNSPECIFIED = 0,
365
+ ALWAYS = 1,
366
+ ON_DATA = 2,
367
+ ON_DATA_OR_ON_NEW_BLOCK = 3,
368
+ UNRECOGNIZED = -1
369
+ }
370
+ declare function headerFilterFromJSON(object: any): HeaderFilter$1;
371
+ declare function headerFilterToJSON(object: HeaderFilter$1): string;
363
372
  declare enum TransactionStatusFilter$1 {
364
373
  UNSPECIFIED = 0,
365
374
  SUCCEEDED = 1,
@@ -387,18 +396,6 @@ declare const Filter$1: {
387
396
  create(base?: DeepPartial<Filter$1>): Filter$1;
388
397
  fromPartial(object: DeepPartial<Filter$1>): Filter$1;
389
398
  };
390
- interface HeaderFilter$1 {
391
- /** Always include header data. Defaults to `false`. */
392
- readonly always?: boolean | undefined;
393
- }
394
- declare const HeaderFilter$1: {
395
- encode(message: HeaderFilter$1, writer?: _m0.Writer): _m0.Writer;
396
- decode(input: _m0.Reader | Uint8Array, length?: number): HeaderFilter$1;
397
- fromJSON(object: any): HeaderFilter$1;
398
- toJSON(message: HeaderFilter$1): unknown;
399
- create(base?: DeepPartial<HeaderFilter$1>): HeaderFilter$1;
400
- fromPartial(object: DeepPartial<HeaderFilter$1>): HeaderFilter$1;
401
- };
402
399
  interface WithdrawalFilter$1 {
403
400
  readonly id?: number | undefined;
404
401
  /** Filter based on the validator index. */
@@ -503,11 +500,13 @@ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U
503
500
  } : Partial<T>;
504
501
 
505
502
  type filter_DeepPartial<T> = DeepPartial<T>;
503
+ declare const filter_headerFilterFromJSON: typeof headerFilterFromJSON;
504
+ declare const filter_headerFilterToJSON: typeof headerFilterToJSON;
506
505
  declare const filter_protobufPackage: typeof protobufPackage;
507
506
  declare const filter_transactionStatusFilterFromJSON: typeof transactionStatusFilterFromJSON;
508
507
  declare const filter_transactionStatusFilterToJSON: typeof transactionStatusFilterToJSON;
509
508
  declare namespace filter {
510
- export { type filter_DeepPartial as DeepPartial, Filter$1 as Filter, HeaderFilter$1 as HeaderFilter, LogFilter$1 as LogFilter, Topic$1 as Topic, TransactionFilter$1 as TransactionFilter, TransactionStatusFilter$1 as TransactionStatusFilter, WithdrawalFilter$1 as WithdrawalFilter, filter_protobufPackage as protobufPackage, filter_transactionStatusFilterFromJSON as transactionStatusFilterFromJSON, filter_transactionStatusFilterToJSON as transactionStatusFilterToJSON };
509
+ export { type filter_DeepPartial as DeepPartial, Filter$1 as Filter, HeaderFilter$1 as HeaderFilter, LogFilter$1 as LogFilter, Topic$1 as Topic, TransactionFilter$1 as TransactionFilter, TransactionStatusFilter$1 as TransactionStatusFilter, WithdrawalFilter$1 as WithdrawalFilter, filter_headerFilterFromJSON as headerFilterFromJSON, filter_headerFilterToJSON as headerFilterToJSON, filter_protobufPackage as protobufPackage, filter_transactionStatusFilterFromJSON as transactionStatusFilterFromJSON, filter_transactionStatusFilterToJSON as transactionStatusFilterToJSON };
511
510
  }
512
511
 
513
512
  declare const index_common: typeof common;
@@ -583,9 +582,13 @@ declare const u128FromProto: (i: {
583
582
  readonly x1: bigint;
584
583
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => bigint;
585
584
 
586
- declare const HeaderFilter: Schema.Struct<{
587
- always: Schema.optional<typeof Schema.Boolean>;
588
- }>;
585
+ /** Header options.
586
+ *
587
+ * - `always`: receive all block headers.
588
+ * - `on_data`: receive headers only if any other filter matches.
589
+ * - `on_data_or_on_new_block`: receive headers only if any other filter matches and for "live" blocks.
590
+ */
591
+ declare const HeaderFilter: Schema.transform<Schema.Enums<typeof HeaderFilter$1>, Schema.Literal<["always", "on_data", "on_data_or_on_new_block", "unknown"]>>;
589
592
  type HeaderFilter = typeof HeaderFilter.Type;
590
593
  declare const WithdrawalFilter: Schema.Struct<{
591
594
  id: Schema.optional<typeof Schema.Number>;
@@ -657,9 +660,7 @@ declare const TransactionFilter: Schema.Struct<{
657
660
  }>;
658
661
  type TransactionFilter = typeof TransactionFilter.Type;
659
662
  declare const Filter: Schema.Struct<{
660
- header: Schema.optional<Schema.Struct<{
661
- always: Schema.optional<typeof Schema.Boolean>;
662
- }>>;
663
+ header: Schema.optional<Schema.transform<Schema.Enums<typeof HeaderFilter$1>, Schema.Literal<["always", "on_data", "on_data_or_on_new_block", "unknown"]>>>;
663
664
  withdrawals: Schema.optional<Schema.Array$<Schema.Struct<{
664
665
  id: Schema.optional<typeof Schema.Number>;
665
666
  validatorIndex: Schema.optional<typeof Schema.Number>;
@@ -714,9 +715,7 @@ declare const Filter: Schema.Struct<{
714
715
  }>;
715
716
  type Filter = typeof Filter.Type;
716
717
  declare const filterToProto: (a: {
717
- readonly header?: {
718
- readonly always?: boolean | undefined;
719
- } | undefined;
718
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
720
719
  readonly withdrawals?: readonly {
721
720
  readonly id?: number | undefined;
722
721
  readonly validatorIndex?: number | undefined;
@@ -741,9 +740,7 @@ declare const filterToProto: (a: {
741
740
  readonly includeTransaction?: boolean | undefined;
742
741
  }[] | undefined;
743
742
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => {
744
- readonly header?: {
745
- readonly always?: boolean | undefined;
746
- } | undefined;
743
+ readonly header?: HeaderFilter$1 | undefined;
747
744
  readonly withdrawals?: readonly {
748
745
  readonly id?: number | undefined;
749
746
  readonly validatorIndex?: number | undefined;
@@ -792,9 +789,7 @@ declare const filterToProto: (a: {
792
789
  }[] | undefined;
793
790
  };
794
791
  declare const filterFromProto: (i: {
795
- readonly header?: {
796
- readonly always?: boolean | undefined;
797
- } | undefined;
792
+ readonly header?: HeaderFilter$1 | undefined;
798
793
  readonly withdrawals?: readonly {
799
794
  readonly id?: number | undefined;
800
795
  readonly validatorIndex?: number | undefined;
@@ -842,9 +837,7 @@ declare const filterFromProto: (i: {
842
837
  readonly includeTransaction?: boolean | undefined;
843
838
  }[] | undefined;
844
839
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => {
845
- readonly header?: {
846
- readonly always?: boolean | undefined;
847
- } | undefined;
840
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
848
841
  readonly withdrawals?: readonly {
849
842
  readonly id?: number | undefined;
850
843
  readonly validatorIndex?: number | undefined;
@@ -870,9 +863,7 @@ declare const filterFromProto: (i: {
870
863
  }[] | undefined;
871
864
  };
872
865
  declare const FilterFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.Struct<{
873
- header: Schema.optional<Schema.Struct<{
874
- always: Schema.optional<typeof Schema.Boolean>;
875
- }>>;
866
+ header: Schema.optional<Schema.transform<Schema.Enums<typeof HeaderFilter$1>, Schema.Literal<["always", "on_data", "on_data_or_on_new_block", "unknown"]>>>;
876
867
  withdrawals: Schema.optional<Schema.Array$<Schema.Struct<{
877
868
  id: Schema.optional<typeof Schema.Number>;
878
869
  validatorIndex: Schema.optional<typeof Schema.Number>;
@@ -926,9 +917,7 @@ declare const FilterFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8A
926
917
  }>>>;
927
918
  }>>;
928
919
  declare const filterToBytes: (a: {
929
- readonly header?: {
930
- readonly always?: boolean | undefined;
931
- } | undefined;
920
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
932
921
  readonly withdrawals?: readonly {
933
922
  readonly id?: number | undefined;
934
923
  readonly validatorIndex?: number | undefined;
@@ -954,9 +943,7 @@ declare const filterToBytes: (a: {
954
943
  }[] | undefined;
955
944
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => Uint8Array;
956
945
  declare const filterFromBytes: (i: Uint8Array, overrideOptions?: _effect_schema_AST.ParseOptions) => {
957
- readonly header?: {
958
- readonly always?: boolean | undefined;
959
- } | undefined;
946
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
960
947
  readonly withdrawals?: readonly {
961
948
  readonly id?: number | undefined;
962
949
  readonly validatorIndex?: number | undefined;
@@ -1862,9 +1849,7 @@ declare const BlockFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Ar
1862
1849
  }>>>;
1863
1850
 
1864
1851
  declare const EvmStream: StreamConfig<{
1865
- readonly header?: {
1866
- readonly always?: boolean | undefined;
1867
- } | undefined;
1852
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
1868
1853
  readonly withdrawals?: readonly {
1869
1854
  readonly id?: number | undefined;
1870
1855
  readonly validatorIndex?: number | undefined;
package/dist/index.d.mts CHANGED
@@ -360,6 +360,15 @@ declare namespace data {
360
360
 
361
361
  declare const protobufPackage = "evm.v2";
362
362
  /** EVM DNA definitions (filter). */
363
+ declare enum HeaderFilter$1 {
364
+ UNSPECIFIED = 0,
365
+ ALWAYS = 1,
366
+ ON_DATA = 2,
367
+ ON_DATA_OR_ON_NEW_BLOCK = 3,
368
+ UNRECOGNIZED = -1
369
+ }
370
+ declare function headerFilterFromJSON(object: any): HeaderFilter$1;
371
+ declare function headerFilterToJSON(object: HeaderFilter$1): string;
363
372
  declare enum TransactionStatusFilter$1 {
364
373
  UNSPECIFIED = 0,
365
374
  SUCCEEDED = 1,
@@ -387,18 +396,6 @@ declare const Filter$1: {
387
396
  create(base?: DeepPartial<Filter$1>): Filter$1;
388
397
  fromPartial(object: DeepPartial<Filter$1>): Filter$1;
389
398
  };
390
- interface HeaderFilter$1 {
391
- /** Always include header data. Defaults to `false`. */
392
- readonly always?: boolean | undefined;
393
- }
394
- declare const HeaderFilter$1: {
395
- encode(message: HeaderFilter$1, writer?: _m0.Writer): _m0.Writer;
396
- decode(input: _m0.Reader | Uint8Array, length?: number): HeaderFilter$1;
397
- fromJSON(object: any): HeaderFilter$1;
398
- toJSON(message: HeaderFilter$1): unknown;
399
- create(base?: DeepPartial<HeaderFilter$1>): HeaderFilter$1;
400
- fromPartial(object: DeepPartial<HeaderFilter$1>): HeaderFilter$1;
401
- };
402
399
  interface WithdrawalFilter$1 {
403
400
  readonly id?: number | undefined;
404
401
  /** Filter based on the validator index. */
@@ -503,11 +500,13 @@ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U
503
500
  } : Partial<T>;
504
501
 
505
502
  type filter_DeepPartial<T> = DeepPartial<T>;
503
+ declare const filter_headerFilterFromJSON: typeof headerFilterFromJSON;
504
+ declare const filter_headerFilterToJSON: typeof headerFilterToJSON;
506
505
  declare const filter_protobufPackage: typeof protobufPackage;
507
506
  declare const filter_transactionStatusFilterFromJSON: typeof transactionStatusFilterFromJSON;
508
507
  declare const filter_transactionStatusFilterToJSON: typeof transactionStatusFilterToJSON;
509
508
  declare namespace filter {
510
- export { type filter_DeepPartial as DeepPartial, Filter$1 as Filter, HeaderFilter$1 as HeaderFilter, LogFilter$1 as LogFilter, Topic$1 as Topic, TransactionFilter$1 as TransactionFilter, TransactionStatusFilter$1 as TransactionStatusFilter, WithdrawalFilter$1 as WithdrawalFilter, filter_protobufPackage as protobufPackage, filter_transactionStatusFilterFromJSON as transactionStatusFilterFromJSON, filter_transactionStatusFilterToJSON as transactionStatusFilterToJSON };
509
+ export { type filter_DeepPartial as DeepPartial, Filter$1 as Filter, HeaderFilter$1 as HeaderFilter, LogFilter$1 as LogFilter, Topic$1 as Topic, TransactionFilter$1 as TransactionFilter, TransactionStatusFilter$1 as TransactionStatusFilter, WithdrawalFilter$1 as WithdrawalFilter, filter_headerFilterFromJSON as headerFilterFromJSON, filter_headerFilterToJSON as headerFilterToJSON, filter_protobufPackage as protobufPackage, filter_transactionStatusFilterFromJSON as transactionStatusFilterFromJSON, filter_transactionStatusFilterToJSON as transactionStatusFilterToJSON };
511
510
  }
512
511
 
513
512
  declare const index_common: typeof common;
@@ -583,9 +582,13 @@ declare const u128FromProto: (i: {
583
582
  readonly x1: bigint;
584
583
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => bigint;
585
584
 
586
- declare const HeaderFilter: Schema.Struct<{
587
- always: Schema.optional<typeof Schema.Boolean>;
588
- }>;
585
+ /** Header options.
586
+ *
587
+ * - `always`: receive all block headers.
588
+ * - `on_data`: receive headers only if any other filter matches.
589
+ * - `on_data_or_on_new_block`: receive headers only if any other filter matches and for "live" blocks.
590
+ */
591
+ declare const HeaderFilter: Schema.transform<Schema.Enums<typeof HeaderFilter$1>, Schema.Literal<["always", "on_data", "on_data_or_on_new_block", "unknown"]>>;
589
592
  type HeaderFilter = typeof HeaderFilter.Type;
590
593
  declare const WithdrawalFilter: Schema.Struct<{
591
594
  id: Schema.optional<typeof Schema.Number>;
@@ -657,9 +660,7 @@ declare const TransactionFilter: Schema.Struct<{
657
660
  }>;
658
661
  type TransactionFilter = typeof TransactionFilter.Type;
659
662
  declare const Filter: Schema.Struct<{
660
- header: Schema.optional<Schema.Struct<{
661
- always: Schema.optional<typeof Schema.Boolean>;
662
- }>>;
663
+ header: Schema.optional<Schema.transform<Schema.Enums<typeof HeaderFilter$1>, Schema.Literal<["always", "on_data", "on_data_or_on_new_block", "unknown"]>>>;
663
664
  withdrawals: Schema.optional<Schema.Array$<Schema.Struct<{
664
665
  id: Schema.optional<typeof Schema.Number>;
665
666
  validatorIndex: Schema.optional<typeof Schema.Number>;
@@ -714,9 +715,7 @@ declare const Filter: Schema.Struct<{
714
715
  }>;
715
716
  type Filter = typeof Filter.Type;
716
717
  declare const filterToProto: (a: {
717
- readonly header?: {
718
- readonly always?: boolean | undefined;
719
- } | undefined;
718
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
720
719
  readonly withdrawals?: readonly {
721
720
  readonly id?: number | undefined;
722
721
  readonly validatorIndex?: number | undefined;
@@ -741,9 +740,7 @@ declare const filterToProto: (a: {
741
740
  readonly includeTransaction?: boolean | undefined;
742
741
  }[] | undefined;
743
742
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => {
744
- readonly header?: {
745
- readonly always?: boolean | undefined;
746
- } | undefined;
743
+ readonly header?: HeaderFilter$1 | undefined;
747
744
  readonly withdrawals?: readonly {
748
745
  readonly id?: number | undefined;
749
746
  readonly validatorIndex?: number | undefined;
@@ -792,9 +789,7 @@ declare const filterToProto: (a: {
792
789
  }[] | undefined;
793
790
  };
794
791
  declare const filterFromProto: (i: {
795
- readonly header?: {
796
- readonly always?: boolean | undefined;
797
- } | undefined;
792
+ readonly header?: HeaderFilter$1 | undefined;
798
793
  readonly withdrawals?: readonly {
799
794
  readonly id?: number | undefined;
800
795
  readonly validatorIndex?: number | undefined;
@@ -842,9 +837,7 @@ declare const filterFromProto: (i: {
842
837
  readonly includeTransaction?: boolean | undefined;
843
838
  }[] | undefined;
844
839
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => {
845
- readonly header?: {
846
- readonly always?: boolean | undefined;
847
- } | undefined;
840
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
848
841
  readonly withdrawals?: readonly {
849
842
  readonly id?: number | undefined;
850
843
  readonly validatorIndex?: number | undefined;
@@ -870,9 +863,7 @@ declare const filterFromProto: (i: {
870
863
  }[] | undefined;
871
864
  };
872
865
  declare const FilterFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.Struct<{
873
- header: Schema.optional<Schema.Struct<{
874
- always: Schema.optional<typeof Schema.Boolean>;
875
- }>>;
866
+ header: Schema.optional<Schema.transform<Schema.Enums<typeof HeaderFilter$1>, Schema.Literal<["always", "on_data", "on_data_or_on_new_block", "unknown"]>>>;
876
867
  withdrawals: Schema.optional<Schema.Array$<Schema.Struct<{
877
868
  id: Schema.optional<typeof Schema.Number>;
878
869
  validatorIndex: Schema.optional<typeof Schema.Number>;
@@ -926,9 +917,7 @@ declare const FilterFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8A
926
917
  }>>>;
927
918
  }>>;
928
919
  declare const filterToBytes: (a: {
929
- readonly header?: {
930
- readonly always?: boolean | undefined;
931
- } | undefined;
920
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
932
921
  readonly withdrawals?: readonly {
933
922
  readonly id?: number | undefined;
934
923
  readonly validatorIndex?: number | undefined;
@@ -954,9 +943,7 @@ declare const filterToBytes: (a: {
954
943
  }[] | undefined;
955
944
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => Uint8Array;
956
945
  declare const filterFromBytes: (i: Uint8Array, overrideOptions?: _effect_schema_AST.ParseOptions) => {
957
- readonly header?: {
958
- readonly always?: boolean | undefined;
959
- } | undefined;
946
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
960
947
  readonly withdrawals?: readonly {
961
948
  readonly id?: number | undefined;
962
949
  readonly validatorIndex?: number | undefined;
@@ -1862,9 +1849,7 @@ declare const BlockFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Ar
1862
1849
  }>>>;
1863
1850
 
1864
1851
  declare const EvmStream: StreamConfig<{
1865
- readonly header?: {
1866
- readonly always?: boolean | undefined;
1867
- } | undefined;
1852
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
1868
1853
  readonly withdrawals?: readonly {
1869
1854
  readonly id?: number | undefined;
1870
1855
  readonly validatorIndex?: number | undefined;
package/dist/index.d.ts CHANGED
@@ -360,6 +360,15 @@ declare namespace data {
360
360
 
361
361
  declare const protobufPackage = "evm.v2";
362
362
  /** EVM DNA definitions (filter). */
363
+ declare enum HeaderFilter$1 {
364
+ UNSPECIFIED = 0,
365
+ ALWAYS = 1,
366
+ ON_DATA = 2,
367
+ ON_DATA_OR_ON_NEW_BLOCK = 3,
368
+ UNRECOGNIZED = -1
369
+ }
370
+ declare function headerFilterFromJSON(object: any): HeaderFilter$1;
371
+ declare function headerFilterToJSON(object: HeaderFilter$1): string;
363
372
  declare enum TransactionStatusFilter$1 {
364
373
  UNSPECIFIED = 0,
365
374
  SUCCEEDED = 1,
@@ -387,18 +396,6 @@ declare const Filter$1: {
387
396
  create(base?: DeepPartial<Filter$1>): Filter$1;
388
397
  fromPartial(object: DeepPartial<Filter$1>): Filter$1;
389
398
  };
390
- interface HeaderFilter$1 {
391
- /** Always include header data. Defaults to `false`. */
392
- readonly always?: boolean | undefined;
393
- }
394
- declare const HeaderFilter$1: {
395
- encode(message: HeaderFilter$1, writer?: _m0.Writer): _m0.Writer;
396
- decode(input: _m0.Reader | Uint8Array, length?: number): HeaderFilter$1;
397
- fromJSON(object: any): HeaderFilter$1;
398
- toJSON(message: HeaderFilter$1): unknown;
399
- create(base?: DeepPartial<HeaderFilter$1>): HeaderFilter$1;
400
- fromPartial(object: DeepPartial<HeaderFilter$1>): HeaderFilter$1;
401
- };
402
399
  interface WithdrawalFilter$1 {
403
400
  readonly id?: number | undefined;
404
401
  /** Filter based on the validator index. */
@@ -503,11 +500,13 @@ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U
503
500
  } : Partial<T>;
504
501
 
505
502
  type filter_DeepPartial<T> = DeepPartial<T>;
503
+ declare const filter_headerFilterFromJSON: typeof headerFilterFromJSON;
504
+ declare const filter_headerFilterToJSON: typeof headerFilterToJSON;
506
505
  declare const filter_protobufPackage: typeof protobufPackage;
507
506
  declare const filter_transactionStatusFilterFromJSON: typeof transactionStatusFilterFromJSON;
508
507
  declare const filter_transactionStatusFilterToJSON: typeof transactionStatusFilterToJSON;
509
508
  declare namespace filter {
510
- export { type filter_DeepPartial as DeepPartial, Filter$1 as Filter, HeaderFilter$1 as HeaderFilter, LogFilter$1 as LogFilter, Topic$1 as Topic, TransactionFilter$1 as TransactionFilter, TransactionStatusFilter$1 as TransactionStatusFilter, WithdrawalFilter$1 as WithdrawalFilter, filter_protobufPackage as protobufPackage, filter_transactionStatusFilterFromJSON as transactionStatusFilterFromJSON, filter_transactionStatusFilterToJSON as transactionStatusFilterToJSON };
509
+ export { type filter_DeepPartial as DeepPartial, Filter$1 as Filter, HeaderFilter$1 as HeaderFilter, LogFilter$1 as LogFilter, Topic$1 as Topic, TransactionFilter$1 as TransactionFilter, TransactionStatusFilter$1 as TransactionStatusFilter, WithdrawalFilter$1 as WithdrawalFilter, filter_headerFilterFromJSON as headerFilterFromJSON, filter_headerFilterToJSON as headerFilterToJSON, filter_protobufPackage as protobufPackage, filter_transactionStatusFilterFromJSON as transactionStatusFilterFromJSON, filter_transactionStatusFilterToJSON as transactionStatusFilterToJSON };
511
510
  }
512
511
 
513
512
  declare const index_common: typeof common;
@@ -583,9 +582,13 @@ declare const u128FromProto: (i: {
583
582
  readonly x1: bigint;
584
583
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => bigint;
585
584
 
586
- declare const HeaderFilter: Schema.Struct<{
587
- always: Schema.optional<typeof Schema.Boolean>;
588
- }>;
585
+ /** Header options.
586
+ *
587
+ * - `always`: receive all block headers.
588
+ * - `on_data`: receive headers only if any other filter matches.
589
+ * - `on_data_or_on_new_block`: receive headers only if any other filter matches and for "live" blocks.
590
+ */
591
+ declare const HeaderFilter: Schema.transform<Schema.Enums<typeof HeaderFilter$1>, Schema.Literal<["always", "on_data", "on_data_or_on_new_block", "unknown"]>>;
589
592
  type HeaderFilter = typeof HeaderFilter.Type;
590
593
  declare const WithdrawalFilter: Schema.Struct<{
591
594
  id: Schema.optional<typeof Schema.Number>;
@@ -657,9 +660,7 @@ declare const TransactionFilter: Schema.Struct<{
657
660
  }>;
658
661
  type TransactionFilter = typeof TransactionFilter.Type;
659
662
  declare const Filter: Schema.Struct<{
660
- header: Schema.optional<Schema.Struct<{
661
- always: Schema.optional<typeof Schema.Boolean>;
662
- }>>;
663
+ header: Schema.optional<Schema.transform<Schema.Enums<typeof HeaderFilter$1>, Schema.Literal<["always", "on_data", "on_data_or_on_new_block", "unknown"]>>>;
663
664
  withdrawals: Schema.optional<Schema.Array$<Schema.Struct<{
664
665
  id: Schema.optional<typeof Schema.Number>;
665
666
  validatorIndex: Schema.optional<typeof Schema.Number>;
@@ -714,9 +715,7 @@ declare const Filter: Schema.Struct<{
714
715
  }>;
715
716
  type Filter = typeof Filter.Type;
716
717
  declare const filterToProto: (a: {
717
- readonly header?: {
718
- readonly always?: boolean | undefined;
719
- } | undefined;
718
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
720
719
  readonly withdrawals?: readonly {
721
720
  readonly id?: number | undefined;
722
721
  readonly validatorIndex?: number | undefined;
@@ -741,9 +740,7 @@ declare const filterToProto: (a: {
741
740
  readonly includeTransaction?: boolean | undefined;
742
741
  }[] | undefined;
743
742
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => {
744
- readonly header?: {
745
- readonly always?: boolean | undefined;
746
- } | undefined;
743
+ readonly header?: HeaderFilter$1 | undefined;
747
744
  readonly withdrawals?: readonly {
748
745
  readonly id?: number | undefined;
749
746
  readonly validatorIndex?: number | undefined;
@@ -792,9 +789,7 @@ declare const filterToProto: (a: {
792
789
  }[] | undefined;
793
790
  };
794
791
  declare const filterFromProto: (i: {
795
- readonly header?: {
796
- readonly always?: boolean | undefined;
797
- } | undefined;
792
+ readonly header?: HeaderFilter$1 | undefined;
798
793
  readonly withdrawals?: readonly {
799
794
  readonly id?: number | undefined;
800
795
  readonly validatorIndex?: number | undefined;
@@ -842,9 +837,7 @@ declare const filterFromProto: (i: {
842
837
  readonly includeTransaction?: boolean | undefined;
843
838
  }[] | undefined;
844
839
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => {
845
- readonly header?: {
846
- readonly always?: boolean | undefined;
847
- } | undefined;
840
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
848
841
  readonly withdrawals?: readonly {
849
842
  readonly id?: number | undefined;
850
843
  readonly validatorIndex?: number | undefined;
@@ -870,9 +863,7 @@ declare const filterFromProto: (i: {
870
863
  }[] | undefined;
871
864
  };
872
865
  declare const FilterFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.Struct<{
873
- header: Schema.optional<Schema.Struct<{
874
- always: Schema.optional<typeof Schema.Boolean>;
875
- }>>;
866
+ header: Schema.optional<Schema.transform<Schema.Enums<typeof HeaderFilter$1>, Schema.Literal<["always", "on_data", "on_data_or_on_new_block", "unknown"]>>>;
876
867
  withdrawals: Schema.optional<Schema.Array$<Schema.Struct<{
877
868
  id: Schema.optional<typeof Schema.Number>;
878
869
  validatorIndex: Schema.optional<typeof Schema.Number>;
@@ -926,9 +917,7 @@ declare const FilterFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8A
926
917
  }>>>;
927
918
  }>>;
928
919
  declare const filterToBytes: (a: {
929
- readonly header?: {
930
- readonly always?: boolean | undefined;
931
- } | undefined;
920
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
932
921
  readonly withdrawals?: readonly {
933
922
  readonly id?: number | undefined;
934
923
  readonly validatorIndex?: number | undefined;
@@ -954,9 +943,7 @@ declare const filterToBytes: (a: {
954
943
  }[] | undefined;
955
944
  }, overrideOptions?: _effect_schema_AST.ParseOptions) => Uint8Array;
956
945
  declare const filterFromBytes: (i: Uint8Array, overrideOptions?: _effect_schema_AST.ParseOptions) => {
957
- readonly header?: {
958
- readonly always?: boolean | undefined;
959
- } | undefined;
946
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
960
947
  readonly withdrawals?: readonly {
961
948
  readonly id?: number | undefined;
962
949
  readonly validatorIndex?: number | undefined;
@@ -1862,9 +1849,7 @@ declare const BlockFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Ar
1862
1849
  }>>>;
1863
1850
 
1864
1851
  declare const EvmStream: StreamConfig<{
1865
- readonly header?: {
1866
- readonly always?: boolean | undefined;
1867
- } | undefined;
1852
+ readonly header?: "unknown" | "always" | "on_data" | "on_data_or_on_new_block" | undefined;
1868
1853
  readonly withdrawals?: readonly {
1869
1854
  readonly id?: number | undefined;
1870
1855
  readonly validatorIndex?: number | undefined;
package/dist/index.mjs CHANGED
@@ -2326,6 +2326,49 @@ const data = {
2326
2326
  };
2327
2327
 
2328
2328
  const protobufPackage = "evm.v2";
2329
+ var HeaderFilter$1 = /* @__PURE__ */ ((HeaderFilter2) => {
2330
+ HeaderFilter2[HeaderFilter2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
2331
+ HeaderFilter2[HeaderFilter2["ALWAYS"] = 1] = "ALWAYS";
2332
+ HeaderFilter2[HeaderFilter2["ON_DATA"] = 2] = "ON_DATA";
2333
+ HeaderFilter2[HeaderFilter2["ON_DATA_OR_ON_NEW_BLOCK"] = 3] = "ON_DATA_OR_ON_NEW_BLOCK";
2334
+ HeaderFilter2[HeaderFilter2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
2335
+ return HeaderFilter2;
2336
+ })(HeaderFilter$1 || {});
2337
+ function headerFilterFromJSON(object) {
2338
+ switch (object) {
2339
+ case 0:
2340
+ case "HEADER_FILTER_UNSPECIFIED":
2341
+ return 0 /* UNSPECIFIED */;
2342
+ case 1:
2343
+ case "HEADER_FILTER_ALWAYS":
2344
+ return 1 /* ALWAYS */;
2345
+ case 2:
2346
+ case "HEADER_FILTER_ON_DATA":
2347
+ return 2 /* ON_DATA */;
2348
+ case 3:
2349
+ case "HEADER_FILTER_ON_DATA_OR_ON_NEW_BLOCK":
2350
+ return 3 /* ON_DATA_OR_ON_NEW_BLOCK */;
2351
+ case -1:
2352
+ case "UNRECOGNIZED":
2353
+ default:
2354
+ return -1 /* UNRECOGNIZED */;
2355
+ }
2356
+ }
2357
+ function headerFilterToJSON(object) {
2358
+ switch (object) {
2359
+ case 0 /* UNSPECIFIED */:
2360
+ return "HEADER_FILTER_UNSPECIFIED";
2361
+ case 1 /* ALWAYS */:
2362
+ return "HEADER_FILTER_ALWAYS";
2363
+ case 2 /* ON_DATA */:
2364
+ return "HEADER_FILTER_ON_DATA";
2365
+ case 3 /* ON_DATA_OR_ON_NEW_BLOCK */:
2366
+ return "HEADER_FILTER_ON_DATA_OR_ON_NEW_BLOCK";
2367
+ case -1 /* UNRECOGNIZED */:
2368
+ default:
2369
+ return "UNRECOGNIZED";
2370
+ }
2371
+ }
2329
2372
  var TransactionStatusFilter$1 = /* @__PURE__ */ ((TransactionStatusFilter2) => {
2330
2373
  TransactionStatusFilter2[TransactionStatusFilter2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
2331
2374
  TransactionStatusFilter2[TransactionStatusFilter2["SUCCEEDED"] = 1] = "SUCCEEDED";
@@ -2370,12 +2413,12 @@ function transactionStatusFilterToJSON(object) {
2370
2413
  }
2371
2414
  }
2372
2415
  function createBaseFilter() {
2373
- return { header: void 0, withdrawals: [], transactions: [], logs: [] };
2416
+ return { header: 0, withdrawals: [], transactions: [], logs: [] };
2374
2417
  }
2375
2418
  const Filter$1 = {
2376
2419
  encode(message, writer = _m0.Writer.create()) {
2377
- if (message.header !== void 0) {
2378
- HeaderFilter$1.encode(message.header, writer.uint32(10).fork()).ldelim();
2420
+ if (message.header !== void 0 && message.header !== 0) {
2421
+ writer.uint32(8).int32(message.header);
2379
2422
  }
2380
2423
  if (message.withdrawals !== void 0 && message.withdrawals.length !== 0) {
2381
2424
  for (const v of message.withdrawals) {
@@ -2402,10 +2445,10 @@ const Filter$1 = {
2402
2445
  const tag = reader.uint32();
2403
2446
  switch (tag >>> 3) {
2404
2447
  case 1:
2405
- if (tag !== 10) {
2448
+ if (tag !== 8) {
2406
2449
  break;
2407
2450
  }
2408
- message.header = HeaderFilter$1.decode(reader, reader.uint32());
2451
+ message.header = reader.int32();
2409
2452
  continue;
2410
2453
  case 2:
2411
2454
  if (tag !== 18) {
@@ -2435,7 +2478,7 @@ const Filter$1 = {
2435
2478
  },
2436
2479
  fromJSON(object) {
2437
2480
  return {
2438
- header: isSet(object.header) ? HeaderFilter$1.fromJSON(object.header) : void 0,
2481
+ header: isSet(object.header) ? headerFilterFromJSON(object.header) : 0,
2439
2482
  withdrawals: globalThis.Array.isArray(object?.withdrawals) ? object.withdrawals.map((e) => WithdrawalFilter$1.fromJSON(e)) : [],
2440
2483
  transactions: globalThis.Array.isArray(object?.transactions) ? object.transactions.map((e) => TransactionFilter$1.fromJSON(e)) : [],
2441
2484
  logs: globalThis.Array.isArray(object?.logs) ? object.logs.map((e) => LogFilter$1.fromJSON(e)) : []
@@ -2443,8 +2486,8 @@ const Filter$1 = {
2443
2486
  },
2444
2487
  toJSON(message) {
2445
2488
  const obj = {};
2446
- if (message.header !== void 0) {
2447
- obj.header = HeaderFilter$1.toJSON(message.header);
2489
+ if (message.header !== void 0 && message.header !== 0) {
2490
+ obj.header = headerFilterToJSON(message.header);
2448
2491
  }
2449
2492
  if (message.withdrawals?.length) {
2450
2493
  obj.withdrawals = message.withdrawals.map((e) => WithdrawalFilter$1.toJSON(e));
@@ -2462,63 +2505,13 @@ const Filter$1 = {
2462
2505
  },
2463
2506
  fromPartial(object) {
2464
2507
  const message = createBaseFilter();
2465
- message.header = object.header !== void 0 && object.header !== null ? HeaderFilter$1.fromPartial(object.header) : void 0;
2508
+ message.header = object.header ?? 0;
2466
2509
  message.withdrawals = object.withdrawals?.map((e) => WithdrawalFilter$1.fromPartial(e)) || [];
2467
2510
  message.transactions = object.transactions?.map((e) => TransactionFilter$1.fromPartial(e)) || [];
2468
2511
  message.logs = object.logs?.map((e) => LogFilter$1.fromPartial(e)) || [];
2469
2512
  return message;
2470
2513
  }
2471
2514
  };
2472
- function createBaseHeaderFilter() {
2473
- return { always: void 0 };
2474
- }
2475
- const HeaderFilter$1 = {
2476
- encode(message, writer = _m0.Writer.create()) {
2477
- if (message.always !== void 0) {
2478
- writer.uint32(8).bool(message.always);
2479
- }
2480
- return writer;
2481
- },
2482
- decode(input, length) {
2483
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
2484
- let end = length === void 0 ? reader.len : reader.pos + length;
2485
- const message = createBaseHeaderFilter();
2486
- while (reader.pos < end) {
2487
- const tag = reader.uint32();
2488
- switch (tag >>> 3) {
2489
- case 1:
2490
- if (tag !== 8) {
2491
- break;
2492
- }
2493
- message.always = reader.bool();
2494
- continue;
2495
- }
2496
- if ((tag & 7) === 4 || tag === 0) {
2497
- break;
2498
- }
2499
- reader.skipType(tag & 7);
2500
- }
2501
- return message;
2502
- },
2503
- fromJSON(object) {
2504
- return { always: isSet(object.always) ? globalThis.Boolean(object.always) : void 0 };
2505
- },
2506
- toJSON(message) {
2507
- const obj = {};
2508
- if (message.always !== void 0) {
2509
- obj.always = message.always;
2510
- }
2511
- return obj;
2512
- },
2513
- create(base) {
2514
- return HeaderFilter$1.fromPartial(base ?? {});
2515
- },
2516
- fromPartial(object) {
2517
- const message = createBaseHeaderFilter();
2518
- message.always = object.always ?? void 0;
2519
- return message;
2520
- }
2521
- };
2522
2515
  function createBaseWithdrawalFilter() {
2523
2516
  return { id: 0, validatorIndex: void 0, address: void 0 };
2524
2517
  }
@@ -2967,6 +2960,8 @@ const filter = {
2967
2960
  TransactionFilter: TransactionFilter$1,
2968
2961
  TransactionStatusFilter: TransactionStatusFilter$1,
2969
2962
  WithdrawalFilter: WithdrawalFilter$1,
2963
+ headerFilterFromJSON: headerFilterFromJSON,
2964
+ headerFilterToJSON: headerFilterToJSON,
2970
2965
  protobufPackage: protobufPackage,
2971
2966
  transactionStatusFilterFromJSON: transactionStatusFilterFromJSON,
2972
2967
  transactionStatusFilterToJSON: transactionStatusFilterToJSON
@@ -3129,9 +3124,34 @@ const BlockFromBytes = Schema.transform(
3129
3124
  );
3130
3125
 
3131
3126
  const OptionalArray = (schema) => Schema.optional(Schema.Array(schema));
3132
- const HeaderFilter = Schema.Struct({
3133
- always: Schema.optional(Schema.Boolean)
3134
- });
3127
+ const HeaderFilter = Schema.transform(
3128
+ Schema.Enums(HeaderFilter$1),
3129
+ Schema.Literal("always", "on_data", "on_data_or_on_new_block", "unknown"),
3130
+ {
3131
+ decode(value) {
3132
+ const enumMap = {
3133
+ [HeaderFilter$1.ALWAYS]: "always",
3134
+ [HeaderFilter$1.ON_DATA]: "on_data",
3135
+ [HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK]: "on_data_or_on_new_block",
3136
+ [HeaderFilter$1.UNSPECIFIED]: "unknown",
3137
+ [HeaderFilter$1.UNRECOGNIZED]: "unknown"
3138
+ };
3139
+ return enumMap[value] ?? "unknown";
3140
+ },
3141
+ encode(value) {
3142
+ switch (value) {
3143
+ case "always":
3144
+ return HeaderFilter$1.ALWAYS;
3145
+ case "on_data":
3146
+ return HeaderFilter$1.ON_DATA;
3147
+ case "on_data_or_on_new_block":
3148
+ return HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK;
3149
+ default:
3150
+ return HeaderFilter$1.UNSPECIFIED;
3151
+ }
3152
+ }
3153
+ }
3154
+ );
3135
3155
  const WithdrawalFilter = Schema.Struct({
3136
3156
  id: Schema.optional(Schema.Number),
3137
3157
  validatorIndex: Schema.optional(Schema.Number),
@@ -3240,9 +3260,13 @@ function mergeHeaderFilter(a, b) {
3240
3260
  if (b === void 0) {
3241
3261
  return a;
3242
3262
  }
3243
- return {
3244
- always: a.always || b.always
3245
- };
3263
+ if (a === "always" || b === "always") {
3264
+ return "always";
3265
+ }
3266
+ if (a === "on_data_or_on_new_block" || b === "on_data_or_on_new_block") {
3267
+ return "on_data_or_on_new_block";
3268
+ }
3269
+ return "on_data";
3246
3270
  }
3247
3271
 
3248
3272
  const EvmStream = new StreamConfig(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apibara/evm",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.1-beta.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -35,7 +35,7 @@
35
35
  "vitest": "^1.6.0"
36
36
  },
37
37
  "dependencies": {
38
- "@apibara/protocol": "2.0.0-beta.7",
38
+ "@apibara/protocol": "2.0.0-beta.8",
39
39
  "@effect/schema": "^0.67.15",
40
40
  "effect": "^3.2.6",
41
41
  "long": "^5.2.1",
@@ -87,23 +87,19 @@ describe("LogFilter", () => {
87
87
 
88
88
  describe("mergeFilter", () => {
89
89
  it("returns header.always if any has it", () => {
90
- const fa = mergeFilter({}, { header: { always: true } });
90
+ const fa = mergeFilter({}, { header: "always" });
91
91
  expect(fa).toMatchInlineSnapshot(`
92
92
  {
93
- "header": {
94
- "always": true,
95
- },
93
+ "header": "always",
96
94
  "logs": [],
97
95
  "transactions": [],
98
96
  "withdrawals": [],
99
97
  }
100
98
  `);
101
- const fb = mergeFilter({ header: { always: true } }, {});
99
+ const fb = mergeFilter({ header: "always" }, {});
102
100
  expect(fb).toMatchInlineSnapshot(`
103
101
  {
104
- "header": {
105
- "always": true,
106
- },
102
+ "header": "always",
107
103
  "logs": [],
108
104
  "transactions": [],
109
105
  "withdrawals": [],
package/src/filter.ts CHANGED
@@ -7,9 +7,41 @@ import * as proto from "./proto";
7
7
  const OptionalArray = <TSchema extends Schema.Schema.Any>(schema: TSchema) =>
8
8
  Schema.optional(Schema.Array(schema));
9
9
 
10
- export const HeaderFilter = Schema.Struct({
11
- always: Schema.optional(Schema.Boolean),
12
- });
10
+ /** Header options.
11
+ *
12
+ * - `always`: receive all block headers.
13
+ * - `on_data`: receive headers only if any other filter matches.
14
+ * - `on_data_or_on_new_block`: receive headers only if any other filter matches and for "live" blocks.
15
+ */
16
+ export const HeaderFilter = Schema.transform(
17
+ Schema.Enums(proto.filter.HeaderFilter),
18
+ Schema.Literal("always", "on_data", "on_data_or_on_new_block", "unknown"),
19
+ {
20
+ decode(value) {
21
+ const enumMap = {
22
+ [proto.filter.HeaderFilter.ALWAYS]: "always",
23
+ [proto.filter.HeaderFilter.ON_DATA]: "on_data",
24
+ [proto.filter.HeaderFilter.ON_DATA_OR_ON_NEW_BLOCK]:
25
+ "on_data_or_on_new_block",
26
+ [proto.filter.HeaderFilter.UNSPECIFIED]: "unknown",
27
+ [proto.filter.HeaderFilter.UNRECOGNIZED]: "unknown",
28
+ } as const;
29
+ return enumMap[value] ?? "unknown";
30
+ },
31
+ encode(value) {
32
+ switch (value) {
33
+ case "always":
34
+ return proto.filter.HeaderFilter.ALWAYS;
35
+ case "on_data":
36
+ return proto.filter.HeaderFilter.ON_DATA;
37
+ case "on_data_or_on_new_block":
38
+ return proto.filter.HeaderFilter.ON_DATA_OR_ON_NEW_BLOCK;
39
+ default:
40
+ return proto.filter.HeaderFilter.UNSPECIFIED;
41
+ }
42
+ },
43
+ },
44
+ );
13
45
 
14
46
  export type HeaderFilter = typeof HeaderFilter.Type;
15
47
 
@@ -144,7 +176,14 @@ function mergeHeaderFilter(
144
176
  if (b === undefined) {
145
177
  return a;
146
178
  }
147
- return {
148
- always: a.always || b.always,
149
- };
179
+
180
+ if (a === "always" || b === "always") {
181
+ return "always";
182
+ }
183
+
184
+ if (a === "on_data_or_on_new_block" || b === "on_data_or_on_new_block") {
185
+ return "on_data_or_on_new_block";
186
+ }
187
+
188
+ return "on_data";
150
189
  }
@@ -12,6 +12,51 @@ export const protobufPackage = "evm.v2";
12
12
 
13
13
  /** EVM DNA definitions (filter). */
14
14
 
15
+ export enum HeaderFilter {
16
+ UNSPECIFIED = 0,
17
+ ALWAYS = 1,
18
+ ON_DATA = 2,
19
+ ON_DATA_OR_ON_NEW_BLOCK = 3,
20
+ UNRECOGNIZED = -1,
21
+ }
22
+
23
+ export function headerFilterFromJSON(object: any): HeaderFilter {
24
+ switch (object) {
25
+ case 0:
26
+ case "HEADER_FILTER_UNSPECIFIED":
27
+ return HeaderFilter.UNSPECIFIED;
28
+ case 1:
29
+ case "HEADER_FILTER_ALWAYS":
30
+ return HeaderFilter.ALWAYS;
31
+ case 2:
32
+ case "HEADER_FILTER_ON_DATA":
33
+ return HeaderFilter.ON_DATA;
34
+ case 3:
35
+ case "HEADER_FILTER_ON_DATA_OR_ON_NEW_BLOCK":
36
+ return HeaderFilter.ON_DATA_OR_ON_NEW_BLOCK;
37
+ case -1:
38
+ case "UNRECOGNIZED":
39
+ default:
40
+ return HeaderFilter.UNRECOGNIZED;
41
+ }
42
+ }
43
+
44
+ export function headerFilterToJSON(object: HeaderFilter): string {
45
+ switch (object) {
46
+ case HeaderFilter.UNSPECIFIED:
47
+ return "HEADER_FILTER_UNSPECIFIED";
48
+ case HeaderFilter.ALWAYS:
49
+ return "HEADER_FILTER_ALWAYS";
50
+ case HeaderFilter.ON_DATA:
51
+ return "HEADER_FILTER_ON_DATA";
52
+ case HeaderFilter.ON_DATA_OR_ON_NEW_BLOCK:
53
+ return "HEADER_FILTER_ON_DATA_OR_ON_NEW_BLOCK";
54
+ case HeaderFilter.UNRECOGNIZED:
55
+ default:
56
+ return "UNRECOGNIZED";
57
+ }
58
+ }
59
+
15
60
  export enum TransactionStatusFilter {
16
61
  UNSPECIFIED = 0,
17
62
  SUCCEEDED = 1,
@@ -74,11 +119,6 @@ export interface Filter {
74
119
  readonly logs?: readonly LogFilter[] | undefined;
75
120
  }
76
121
 
77
- export interface HeaderFilter {
78
- /** Always include header data. Defaults to `false`. */
79
- readonly always?: boolean | undefined;
80
- }
81
-
82
122
  export interface WithdrawalFilter {
83
123
  readonly id?:
84
124
  | number
@@ -174,13 +214,13 @@ export interface Topic {
174
214
  }
175
215
 
176
216
  function createBaseFilter(): Filter {
177
- return { header: undefined, withdrawals: [], transactions: [], logs: [] };
217
+ return { header: 0, withdrawals: [], transactions: [], logs: [] };
178
218
  }
179
219
 
180
220
  export const Filter = {
181
221
  encode(message: Filter, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
182
- if (message.header !== undefined) {
183
- HeaderFilter.encode(message.header, writer.uint32(10).fork()).ldelim();
222
+ if (message.header !== undefined && message.header !== 0) {
223
+ writer.uint32(8).int32(message.header);
184
224
  }
185
225
  if (message.withdrawals !== undefined && message.withdrawals.length !== 0) {
186
226
  for (const v of message.withdrawals) {
@@ -208,11 +248,11 @@ export const Filter = {
208
248
  const tag = reader.uint32();
209
249
  switch (tag >>> 3) {
210
250
  case 1:
211
- if (tag !== 10) {
251
+ if (tag !== 8) {
212
252
  break;
213
253
  }
214
254
 
215
- message.header = HeaderFilter.decode(reader, reader.uint32());
255
+ message.header = reader.int32() as any;
216
256
  continue;
217
257
  case 2:
218
258
  if (tag !== 18) {
@@ -246,7 +286,7 @@ export const Filter = {
246
286
 
247
287
  fromJSON(object: any): Filter {
248
288
  return {
249
- header: isSet(object.header) ? HeaderFilter.fromJSON(object.header) : undefined,
289
+ header: isSet(object.header) ? headerFilterFromJSON(object.header) : 0,
250
290
  withdrawals: globalThis.Array.isArray(object?.withdrawals)
251
291
  ? object.withdrawals.map((e: any) => WithdrawalFilter.fromJSON(e))
252
292
  : [],
@@ -259,8 +299,8 @@ export const Filter = {
259
299
 
260
300
  toJSON(message: Filter): unknown {
261
301
  const obj: any = {};
262
- if (message.header !== undefined) {
263
- obj.header = HeaderFilter.toJSON(message.header);
302
+ if (message.header !== undefined && message.header !== 0) {
303
+ obj.header = headerFilterToJSON(message.header);
264
304
  }
265
305
  if (message.withdrawals?.length) {
266
306
  obj.withdrawals = message.withdrawals.map((e) => WithdrawalFilter.toJSON(e));
@@ -279,9 +319,7 @@ export const Filter = {
279
319
  },
280
320
  fromPartial(object: DeepPartial<Filter>): Filter {
281
321
  const message = createBaseFilter() as any;
282
- message.header = (object.header !== undefined && object.header !== null)
283
- ? HeaderFilter.fromPartial(object.header)
284
- : undefined;
322
+ message.header = object.header ?? 0;
285
323
  message.withdrawals = object.withdrawals?.map((e) => WithdrawalFilter.fromPartial(e)) || [];
286
324
  message.transactions = object.transactions?.map((e) => TransactionFilter.fromPartial(e)) || [];
287
325
  message.logs = object.logs?.map((e) => LogFilter.fromPartial(e)) || [];
@@ -289,63 +327,6 @@ export const Filter = {
289
327
  },
290
328
  };
291
329
 
292
- function createBaseHeaderFilter(): HeaderFilter {
293
- return { always: undefined };
294
- }
295
-
296
- export const HeaderFilter = {
297
- encode(message: HeaderFilter, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
298
- if (message.always !== undefined) {
299
- writer.uint32(8).bool(message.always);
300
- }
301
- return writer;
302
- },
303
-
304
- decode(input: _m0.Reader | Uint8Array, length?: number): HeaderFilter {
305
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
306
- let end = length === undefined ? reader.len : reader.pos + length;
307
- const message = createBaseHeaderFilter() as any;
308
- while (reader.pos < end) {
309
- const tag = reader.uint32();
310
- switch (tag >>> 3) {
311
- case 1:
312
- if (tag !== 8) {
313
- break;
314
- }
315
-
316
- message.always = reader.bool();
317
- continue;
318
- }
319
- if ((tag & 7) === 4 || tag === 0) {
320
- break;
321
- }
322
- reader.skipType(tag & 7);
323
- }
324
- return message;
325
- },
326
-
327
- fromJSON(object: any): HeaderFilter {
328
- return { always: isSet(object.always) ? globalThis.Boolean(object.always) : undefined };
329
- },
330
-
331
- toJSON(message: HeaderFilter): unknown {
332
- const obj: any = {};
333
- if (message.always !== undefined) {
334
- obj.always = message.always;
335
- }
336
- return obj;
337
- },
338
-
339
- create(base?: DeepPartial<HeaderFilter>): HeaderFilter {
340
- return HeaderFilter.fromPartial(base ?? {});
341
- },
342
- fromPartial(object: DeepPartial<HeaderFilter>): HeaderFilter {
343
- const message = createBaseHeaderFilter() as any;
344
- message.always = object.always ?? undefined;
345
- return message;
346
- },
347
- };
348
-
349
330
  function createBaseWithdrawalFilter(): WithdrawalFilter {
350
331
  return { id: 0, validatorIndex: undefined, address: undefined };
351
332
  }