@apibara/evm 2.1.0-beta.22 → 2.1.0-beta.24

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,102 +1,73 @@
1
- import { BytesFromUint8Array, Bytes, StreamConfig } from '@apibara/protocol';
2
- import { Schema } from '@effect/schema';
3
- import { hexToBytes, pad } from 'viem';
1
+ import { BytesFromUint8Array, StreamConfig } from '@apibara/protocol';
2
+ import { MessageCodec, RequiredCodec, BigIntCodec, DateCodec, OptionalCodec, ArrayCodec, NumberCodec, BooleanCodec, OneOfCodec, StringCodec } from '@apibara/protocol/codec';
4
3
  import Long from 'long';
5
4
  import _m0 from 'protobufjs/minimal.js';
6
5
 
7
6
  const MAX_U64 = 0xffffffffffffffffn;
8
- const _Address = Schema.TemplateLiteral(Schema.Literal("0x"), Schema.String);
9
- const AddressProto = Schema.Struct({
10
- x0: Schema.BigIntFromSelf,
11
- x1: Schema.BigIntFromSelf,
12
- x2: Schema.Number
13
- });
14
- const Address$1 = Schema.transform(AddressProto, _Address, {
15
- decode(value) {
16
- const x0 = value.x0.toString(16).padStart(16, "0");
17
- const x1 = value.x1.toString(16).padStart(16, "0");
18
- const x2 = value.x2.toString(16).padStart(8, "0");
19
- return `0x${x0}${x1}${x2}`;
20
- },
21
- encode(value) {
22
- const bytes = hexToBytes(pad(value, { size: 20, dir: "left" }));
23
- const dv = new DataView(bytes.buffer);
24
- const x0 = dv.getBigUint64(0);
25
- const x1 = dv.getBigUint64(8);
26
- const x2 = dv.getUint32(16);
27
- return { x0, x1, x2 };
7
+ const MAX_U32 = 0xffffffffn;
8
+ const Address$1 = {
9
+ encode(x) {
10
+ const bn = BigInt(x);
11
+ const x2 = bn & MAX_U32;
12
+ const x1 = bn >> 32n & MAX_U64;
13
+ const x0 = bn >> 96n & MAX_U64;
14
+ return { x0, x1, x2: Number(x2) };
15
+ },
16
+ decode(p) {
17
+ const x0 = p.x0 ?? 0n;
18
+ const x1 = p.x1 ?? 0n;
19
+ const x2 = BigInt(p.x2 ?? 0);
20
+ const bn = x2 + (x1 << 32n) + (x0 << 96n);
21
+ return `0x${bn.toString(16).padStart(40, "0")}`;
28
22
  }
29
- });
30
- const _B256 = Schema.TemplateLiteral(Schema.Literal("0x"), Schema.String);
31
- const B256Proto = Schema.Struct({
32
- x0: Schema.BigIntFromSelf,
33
- x1: Schema.BigIntFromSelf,
34
- x2: Schema.BigIntFromSelf,
35
- x3: Schema.BigIntFromSelf
36
- });
37
- const B256$1 = Schema.transform(B256Proto, _B256, {
38
- decode(value) {
39
- const x0 = value.x0.toString(16).padStart(16, "0");
40
- const x1 = value.x1.toString(16).padStart(16, "0");
41
- const x2 = value.x2.toString(16).padStart(16, "0");
42
- const x3 = value.x3.toString(16).padStart(16, "0");
43
- return `0x${x0}${x1}${x2}${x3}`;
44
- },
45
- encode(value) {
46
- const bytes = hexToBytes(pad(value, { size: 32, dir: "left" }));
47
- const dv = new DataView(bytes.buffer);
48
- const x0 = dv.getBigUint64(0);
49
- const x1 = dv.getBigUint64(8);
50
- const x2 = dv.getBigUint64(16);
51
- const x3 = dv.getBigUint64(24);
23
+ };
24
+ const B256$1 = {
25
+ encode(x) {
26
+ const bn = BigInt(x);
27
+ const x3 = bn & MAX_U64;
28
+ const x2 = bn >> 64n & MAX_U64;
29
+ const x1 = bn >> 128n & MAX_U64;
30
+ const x0 = bn >> 192n & MAX_U64;
52
31
  return { x0, x1, x2, x3 };
53
- }
54
- });
55
- const b256ToProto = Schema.encodeSync(B256$1);
56
- const b256FromProto = Schema.decodeSync(B256$1);
57
- const U256Proto = Schema.Struct({
58
- x0: Schema.BigIntFromSelf,
59
- x1: Schema.BigIntFromSelf,
60
- x2: Schema.BigIntFromSelf,
61
- x3: Schema.BigIntFromSelf
62
- });
63
- const U256$1 = Schema.transform(U256Proto, Schema.BigIntFromSelf, {
64
- decode(value) {
65
- return (value.x0 << 8n * 24n) + (value.x1 << 8n * 16n) + (value.x2 << 8n * 8n) + value.x3;
66
32
  },
67
- encode(value) {
68
- const x0 = value >> 8n * 24n & MAX_U64;
69
- const x1 = value >> 8n * 16n & MAX_U64;
70
- const x2 = value >> 8n * 8n & MAX_U64;
71
- const x3 = value & MAX_U64;
72
- return { x0, x1, x2, x3 };
33
+ decode(p) {
34
+ const x0 = p.x0 ?? 0n;
35
+ const x1 = p.x1 ?? 0n;
36
+ const x2 = p.x2 ?? 0n;
37
+ const x3 = p.x3 ?? 0n;
38
+ const bn = x3 + (x2 << 64n) + (x1 << 128n) + (x0 << 192n);
39
+ return `0x${bn.toString(16).padStart(64, "0")}`;
73
40
  }
74
- });
75
- const u256ToProto = Schema.encodeSync(U256$1);
76
- const u256FromProto = Schema.decodeSync(U256$1);
77
- const U128Proto = Schema.Struct({
78
- x0: Schema.BigIntFromSelf,
79
- x1: Schema.BigIntFromSelf
80
- });
81
- const U128$1 = Schema.transform(U128Proto, Schema.BigIntFromSelf, {
82
- decode(value) {
83
- return (value.x0 << 8n * 8n) + value.x1;
41
+ };
42
+ const U256$1 = {
43
+ encode(x) {
44
+ const bn = BigInt(x);
45
+ const x3 = bn & MAX_U64;
46
+ const x2 = bn >> 64n & MAX_U64;
47
+ const x1 = bn >> 128n & MAX_U64;
48
+ const x0 = bn >> 192n & MAX_U64;
49
+ return { x0, x1, x2, x3 };
84
50
  },
85
- encode(value) {
86
- const x0 = value >> 8n * 8n & MAX_U64;
87
- const x1 = value & MAX_U64;
51
+ decode(p) {
52
+ const x0 = p.x0 ?? 0n;
53
+ const x1 = p.x1 ?? 0n;
54
+ const x2 = p.x2 ?? 0n;
55
+ const x3 = p.x3 ?? 0n;
56
+ return x3 + (x2 << 64n) + (x1 << 128n) + (x0 << 192n);
57
+ }
58
+ };
59
+ const U128$1 = {
60
+ encode(x) {
61
+ const x1 = x & MAX_U64;
62
+ const x0 = x >> 64n & MAX_U64;
88
63
  return { x0, x1 };
64
+ },
65
+ decode(p) {
66
+ const x0 = p.x0 ?? 0n;
67
+ const x1 = p.x1 ?? 0n;
68
+ return x1 + (x0 << 64n);
89
69
  }
90
- });
91
- const u128ToProto = Schema.encodeSync(U128$1);
92
- const u128FromProto = Schema.decodeSync(U128$1);
93
-
94
- function tag(tag2) {
95
- return Schema.Literal(tag2).pipe(
96
- Schema.propertySignature,
97
- Schema.fromKey("$case")
98
- );
99
- }
70
+ };
100
71
 
101
72
  const protobufPackage$2 = "evm.v2";
102
73
  function createBaseAddress() {
@@ -971,7 +942,8 @@ function createBaseBlockHeader() {
971
942
  totalDifficulty: void 0,
972
943
  blobGasUsed: void 0,
973
944
  excessBlobGas: void 0,
974
- parentBeaconBlockRoot: void 0
945
+ parentBeaconBlockRoot: void 0,
946
+ requestsHash: void 0
975
947
  };
976
948
  }
977
949
  const BlockHeader$1 = {
@@ -1048,6 +1020,9 @@ const BlockHeader$1 = {
1048
1020
  if (message.parentBeaconBlockRoot !== void 0) {
1049
1021
  B256.encode(message.parentBeaconBlockRoot, writer.uint32(178).fork()).ldelim();
1050
1022
  }
1023
+ if (message.requestsHash !== void 0) {
1024
+ B256.encode(message.requestsHash, writer.uint32(186).fork()).ldelim();
1025
+ }
1051
1026
  return writer;
1052
1027
  },
1053
1028
  decode(input, length) {
@@ -1189,6 +1164,12 @@ const BlockHeader$1 = {
1189
1164
  }
1190
1165
  message.parentBeaconBlockRoot = B256.decode(reader, reader.uint32());
1191
1166
  continue;
1167
+ case 23:
1168
+ if (tag !== 186) {
1169
+ break;
1170
+ }
1171
+ message.requestsHash = B256.decode(reader, reader.uint32());
1172
+ continue;
1192
1173
  }
1193
1174
  if ((tag & 7) === 4 || tag === 0) {
1194
1175
  break;
@@ -1220,7 +1201,8 @@ const BlockHeader$1 = {
1220
1201
  totalDifficulty: isSet$1(object.totalDifficulty) ? U256.fromJSON(object.totalDifficulty) : void 0,
1221
1202
  blobGasUsed: isSet$1(object.blobGasUsed) ? U128.fromJSON(object.blobGasUsed) : void 0,
1222
1203
  excessBlobGas: isSet$1(object.excessBlobGas) ? U128.fromJSON(object.excessBlobGas) : void 0,
1223
- parentBeaconBlockRoot: isSet$1(object.parentBeaconBlockRoot) ? B256.fromJSON(object.parentBeaconBlockRoot) : void 0
1204
+ parentBeaconBlockRoot: isSet$1(object.parentBeaconBlockRoot) ? B256.fromJSON(object.parentBeaconBlockRoot) : void 0,
1205
+ requestsHash: isSet$1(object.requestsHash) ? B256.fromJSON(object.requestsHash) : void 0
1224
1206
  };
1225
1207
  },
1226
1208
  toJSON(message) {
@@ -1291,6 +1273,9 @@ const BlockHeader$1 = {
1291
1273
  if (message.parentBeaconBlockRoot !== void 0) {
1292
1274
  obj.parentBeaconBlockRoot = B256.toJSON(message.parentBeaconBlockRoot);
1293
1275
  }
1276
+ if (message.requestsHash !== void 0) {
1277
+ obj.requestsHash = B256.toJSON(message.requestsHash);
1278
+ }
1294
1279
  return obj;
1295
1280
  },
1296
1281
  create(base) {
@@ -1320,6 +1305,7 @@ const BlockHeader$1 = {
1320
1305
  message.blobGasUsed = object.blobGasUsed !== void 0 && object.blobGasUsed !== null ? U128.fromPartial(object.blobGasUsed) : void 0;
1321
1306
  message.excessBlobGas = object.excessBlobGas !== void 0 && object.excessBlobGas !== null ? U128.fromPartial(object.excessBlobGas) : void 0;
1322
1307
  message.parentBeaconBlockRoot = object.parentBeaconBlockRoot !== void 0 && object.parentBeaconBlockRoot !== null ? B256.fromPartial(object.parentBeaconBlockRoot) : void 0;
1308
+ message.requestsHash = object.requestsHash !== void 0 && object.requestsHash !== null ? B256.fromPartial(object.requestsHash) : void 0;
1323
1309
  return message;
1324
1310
  }
1325
1311
  };
@@ -4046,416 +4032,368 @@ const index = {
4046
4032
  filter: filter
4047
4033
  };
4048
4034
 
4049
- const Bloom = Schema.transform(
4050
- Schema.Struct({
4051
- value: BytesFromUint8Array
4052
- }),
4053
- Bytes,
4054
- {
4055
- strict: false,
4056
- encode(value) {
4057
- throw new Error("Not implemented");
4058
- },
4059
- decode({ value }) {
4060
- return value;
4061
- }
4035
+ const Bloom = {
4036
+ encode(x) {
4037
+ return { value: BytesFromUint8Array.encode(x) };
4038
+ },
4039
+ decode({ value }) {
4040
+ return BytesFromUint8Array.decode(value);
4062
4041
  }
4063
- );
4064
- const TransactionStatus = Schema.transform(
4065
- Schema.Enums(TransactionStatus$1),
4066
- Schema.Literal("unknown", "succeeded", "reverted"),
4067
- {
4068
- decode(value) {
4069
- const enumMap = {
4070
- [TransactionStatus$1.SUCCEEDED]: "succeeded",
4071
- [TransactionStatus$1.REVERTED]: "reverted",
4072
- [TransactionStatus$1.UNSPECIFIED]: "unknown",
4073
- [TransactionStatus$1.UNRECOGNIZED]: "unknown"
4074
- };
4075
- return enumMap[value] ?? "unknown";
4076
- },
4077
- encode(value) {
4078
- throw new Error("encode: not implemented");
4079
- }
4042
+ };
4043
+ const TransactionStatus = {
4044
+ encode(x) {
4045
+ const enumMap = {
4046
+ unknown: TransactionStatus$1.UNSPECIFIED,
4047
+ succeeded: TransactionStatus$1.SUCCEEDED,
4048
+ reverted: TransactionStatus$1.REVERTED
4049
+ };
4050
+ return enumMap[x] ?? TransactionStatus$1.UNSPECIFIED;
4051
+ },
4052
+ decode(p) {
4053
+ const enumMap = {
4054
+ [TransactionStatus$1.SUCCEEDED]: "succeeded",
4055
+ [TransactionStatus$1.REVERTED]: "reverted",
4056
+ [TransactionStatus$1.UNSPECIFIED]: "unknown",
4057
+ [TransactionStatus$1.UNRECOGNIZED]: "unknown"
4058
+ };
4059
+ return enumMap[p] ?? "unknown";
4080
4060
  }
4081
- );
4082
- const BlockHeader = Schema.Struct({
4083
- blockNumber: Schema.BigIntFromSelf,
4084
- blockHash: B256$1,
4085
- parentBlockHash: B256$1,
4086
- unclesHash: B256$1,
4087
- miner: Address$1,
4088
- stateRoot: B256$1,
4089
- transactionsRoot: B256$1,
4090
- receiptsRoot: B256$1,
4091
- logsBloom: Bloom,
4092
- difficulty: U256$1,
4093
- gasLimit: U128$1,
4094
- gasUsed: U128$1,
4095
- timestamp: Schema.DateFromSelf,
4096
- extraData: BytesFromUint8Array,
4097
- mixHash: Schema.optional(B256$1),
4098
- nonce: Schema.optional(Schema.BigIntFromSelf),
4099
- baseFeePerGas: Schema.optional(U128$1),
4100
- withdrawalsRoot: Schema.optional(B256$1),
4101
- totalDifficulty: Schema.optional(U256$1),
4102
- blobGasUsed: Schema.optional(U128$1),
4103
- excessBlobGas: Schema.optional(U128$1),
4104
- parentBeaconBlockRoot: Schema.optional(B256$1)
4061
+ };
4062
+ const BlockHeader = MessageCodec({
4063
+ blockNumber: RequiredCodec(BigIntCodec),
4064
+ blockHash: RequiredCodec(B256$1),
4065
+ parentBlockHash: RequiredCodec(B256$1),
4066
+ unclesHash: RequiredCodec(B256$1),
4067
+ miner: RequiredCodec(Address$1),
4068
+ stateRoot: RequiredCodec(B256$1),
4069
+ transactionsRoot: RequiredCodec(B256$1),
4070
+ receiptsRoot: RequiredCodec(B256$1),
4071
+ logsBloom: RequiredCodec(Bloom),
4072
+ difficulty: RequiredCodec(U256$1),
4073
+ gasLimit: RequiredCodec(U128$1),
4074
+ gasUsed: RequiredCodec(U128$1),
4075
+ timestamp: RequiredCodec(DateCodec),
4076
+ extraData: RequiredCodec(BytesFromUint8Array),
4077
+ mixHash: OptionalCodec(B256$1),
4078
+ nonce: OptionalCodec(BigIntCodec),
4079
+ baseFeePerGas: OptionalCodec(U128$1),
4080
+ withdrawalsRoot: OptionalCodec(B256$1),
4081
+ totalDifficulty: OptionalCodec(U256$1),
4082
+ blobGasUsed: OptionalCodec(U128$1),
4083
+ excessBlobGas: OptionalCodec(U128$1),
4084
+ parentBeaconBlockRoot: OptionalCodec(B256$1),
4085
+ requestsHash: OptionalCodec(B256$1)
4105
4086
  });
4106
- const Withdrawal = Schema.Struct({
4107
- filterIds: Schema.Array(Schema.Number),
4108
- withdrawalIndex: Schema.Number,
4109
- index: Schema.BigIntFromSelf,
4110
- validatorIndex: Schema.Number,
4111
- address: Address$1,
4112
- amount: Schema.BigIntFromSelf
4087
+ const Withdrawal = MessageCodec({
4088
+ filterIds: ArrayCodec(NumberCodec),
4089
+ withdrawalIndex: RequiredCodec(NumberCodec),
4090
+ index: RequiredCodec(BigIntCodec),
4091
+ validatorIndex: RequiredCodec(NumberCodec),
4092
+ address: RequiredCodec(Address$1),
4093
+ amount: RequiredCodec(BigIntCodec)
4113
4094
  });
4114
- const AccessListItem = Schema.Struct({
4115
- address: Address$1,
4116
- storageKeys: Schema.Array(B256$1)
4095
+ const AccessListItem = MessageCodec({
4096
+ address: RequiredCodec(Address$1),
4097
+ storageKeys: ArrayCodec(B256$1)
4117
4098
  });
4118
- const Signature = Schema.Struct({
4119
- r: U256$1,
4120
- s: U256$1,
4121
- v: U256$1,
4122
- YParity: Schema.optional(Schema.Boolean)
4099
+ const Signature = MessageCodec({
4100
+ r: RequiredCodec(U256$1),
4101
+ s: RequiredCodec(U256$1),
4102
+ v: OptionalCodec(U256$1),
4103
+ YParity: OptionalCodec(BooleanCodec)
4123
4104
  });
4124
- const Transaction = Schema.Struct({
4125
- filterIds: Schema.Array(Schema.Number),
4126
- transactionIndex: Schema.Number,
4127
- transactionHash: B256$1,
4128
- nonce: Schema.BigIntFromSelf,
4129
- from: Address$1,
4130
- to: Schema.optional(Address$1),
4131
- value: U256$1,
4132
- gasPrice: Schema.optional(U128$1),
4133
- gas: U128$1,
4134
- maxFeePerGas: Schema.optional(U128$1),
4135
- maxPriorityFeePerGas: Schema.optional(U128$1),
4136
- input: BytesFromUint8Array,
4137
- signature: Schema.optional(Signature),
4138
- chainId: Schema.optional(Schema.BigIntFromSelf),
4139
- accessList: Schema.Array(AccessListItem),
4140
- transactionType: Schema.BigIntFromSelf,
4141
- maxFeePerBlobGas: Schema.optional(U128$1),
4142
- blobVersionedHashes: Schema.Array(B256$1),
4143
- transactionStatus: TransactionStatus
4105
+ const Transaction = MessageCodec({
4106
+ filterIds: ArrayCodec(NumberCodec),
4107
+ transactionIndex: RequiredCodec(NumberCodec),
4108
+ transactionHash: RequiredCodec(B256$1),
4109
+ nonce: RequiredCodec(BigIntCodec),
4110
+ from: RequiredCodec(Address$1),
4111
+ to: OptionalCodec(Address$1),
4112
+ value: RequiredCodec(U256$1),
4113
+ gasPrice: OptionalCodec(U128$1),
4114
+ gas: RequiredCodec(U128$1),
4115
+ maxFeePerGas: OptionalCodec(U128$1),
4116
+ maxPriorityFeePerGas: OptionalCodec(U128$1),
4117
+ input: RequiredCodec(BytesFromUint8Array),
4118
+ signature: OptionalCodec(Signature),
4119
+ chainId: OptionalCodec(BigIntCodec),
4120
+ accessList: ArrayCodec(AccessListItem),
4121
+ transactionType: RequiredCodec(BigIntCodec),
4122
+ maxFeePerBlobGas: OptionalCodec(U128$1),
4123
+ blobVersionedHashes: ArrayCodec(B256$1),
4124
+ transactionStatus: RequiredCodec(TransactionStatus)
4144
4125
  });
4145
- const TransactionReceipt = Schema.Struct({
4146
- filterIds: Schema.Array(Schema.Number),
4147
- transactionIndex: Schema.Number,
4148
- transactionHash: B256$1,
4149
- cumulativeGasUsed: U128$1,
4150
- gasUsed: U128$1,
4151
- effectiveGasPrice: U128$1,
4152
- from: Address$1,
4153
- to: Schema.optional(Address$1),
4154
- contractAddress: Schema.optional(Address$1),
4155
- logsBloom: Bloom,
4156
- transactionType: Schema.BigIntFromSelf,
4157
- blobGasUsed: Schema.optional(U128$1),
4158
- blobGasPrice: Schema.optional(U128$1),
4159
- transactionStatus: TransactionStatus
4126
+ const TransactionReceipt = MessageCodec({
4127
+ filterIds: ArrayCodec(NumberCodec),
4128
+ transactionIndex: RequiredCodec(NumberCodec),
4129
+ transactionHash: RequiredCodec(B256$1),
4130
+ cumulativeGasUsed: RequiredCodec(U128$1),
4131
+ gasUsed: RequiredCodec(U128$1),
4132
+ effectiveGasPrice: RequiredCodec(U128$1),
4133
+ from: RequiredCodec(Address$1),
4134
+ to: OptionalCodec(Address$1),
4135
+ contractAddress: OptionalCodec(Address$1),
4136
+ logsBloom: RequiredCodec(Bloom),
4137
+ transactionType: RequiredCodec(BigIntCodec),
4138
+ blobGasUsed: OptionalCodec(U128$1),
4139
+ blobGasPrice: OptionalCodec(U128$1),
4140
+ transactionStatus: RequiredCodec(TransactionStatus)
4160
4141
  });
4161
- const Log = Schema.Struct({
4162
- filterIds: Schema.Array(Schema.Number),
4163
- address: Address$1,
4164
- topics: Schema.Array(B256$1),
4165
- data: BytesFromUint8Array,
4166
- logIndex: Schema.Number,
4167
- logIndexInTransaction: Schema.Number,
4168
- transactionIndex: Schema.Number,
4169
- transactionHash: B256$1,
4170
- transactionStatus: TransactionStatus
4142
+ const Log = MessageCodec({
4143
+ filterIds: ArrayCodec(NumberCodec),
4144
+ address: RequiredCodec(Address$1),
4145
+ topics: ArrayCodec(B256$1),
4146
+ data: RequiredCodec(BytesFromUint8Array),
4147
+ logIndex: RequiredCodec(NumberCodec),
4148
+ logIndexInTransaction: RequiredCodec(NumberCodec),
4149
+ transactionIndex: RequiredCodec(NumberCodec),
4150
+ transactionHash: RequiredCodec(B256$1),
4151
+ transactionStatus: RequiredCodec(TransactionStatus)
4171
4152
  });
4172
- const CallType = Schema.transform(
4173
- Schema.Enums(CallType$1),
4174
- Schema.Literal(
4175
- "unknown",
4176
- "call",
4177
- "delegateCall",
4178
- "callCode",
4179
- "delegateCall",
4180
- "staticCall",
4181
- "authCall"
4182
- ),
4183
- {
4184
- decode(value) {
4185
- const enumMap = {
4186
- [CallType$1.CALL]: "call",
4187
- [CallType$1.CALL_CODE]: "callCode",
4188
- [CallType$1.DELEGATE_CALL]: "delegateCall",
4189
- [CallType$1.STATIC_CALL]: "staticCall",
4190
- [CallType$1.AUTH_CALL]: "authCall",
4191
- [CallType$1.UNSPECIFIED]: "unknown",
4192
- [CallType$1.UNRECOGNIZED]: "unknown"
4193
- };
4194
- return enumMap[value] ?? "unknown";
4195
- },
4196
- encode(value) {
4197
- throw new Error("encode: not implemented");
4198
- }
4153
+ const CallType = {
4154
+ encode(x) {
4155
+ const enumMap = {
4156
+ unknown: CallType$1.UNSPECIFIED,
4157
+ call: CallType$1.CALL,
4158
+ callCode: CallType$1.CALL_CODE,
4159
+ delegateCall: CallType$1.DELEGATE_CALL,
4160
+ staticCall: CallType$1.STATIC_CALL,
4161
+ authCall: CallType$1.AUTH_CALL
4162
+ };
4163
+ return enumMap[x] ?? CallType$1.UNSPECIFIED;
4164
+ },
4165
+ decode(p) {
4166
+ const enumMap = {
4167
+ [CallType$1.CALL]: "call",
4168
+ [CallType$1.CALL_CODE]: "callCode",
4169
+ [CallType$1.DELEGATE_CALL]: "delegateCall",
4170
+ [CallType$1.STATIC_CALL]: "staticCall",
4171
+ [CallType$1.AUTH_CALL]: "authCall",
4172
+ [CallType$1.UNSPECIFIED]: "unknown",
4173
+ [CallType$1.UNRECOGNIZED]: "unknown"
4174
+ };
4175
+ return enumMap[p] ?? "unknown";
4199
4176
  }
4200
- );
4201
- const CreationMethod = Schema.transform(
4202
- Schema.Enums(CreationMethod$1),
4203
- Schema.Literal("unknown", "create", "create2", "eofCreate"),
4204
- {
4205
- decode(value) {
4206
- const enumMap = {
4207
- [CreationMethod$1.CREATE]: "create",
4208
- [CreationMethod$1.CREATE2]: "create2",
4209
- [CreationMethod$1.EOF_CREATE]: "eofCreate",
4210
- [CallType$1.UNSPECIFIED]: "unknown",
4211
- [CallType$1.UNRECOGNIZED]: "unknown"
4212
- };
4213
- return enumMap[value] ?? "unknown";
4214
- },
4215
- encode(value) {
4216
- throw new Error("encode: not implemented");
4217
- }
4177
+ };
4178
+ const CreationMethod = {
4179
+ encode(x) {
4180
+ const enumMap = {
4181
+ unknown: CreationMethod$1.UNSPECIFIED,
4182
+ create: CreationMethod$1.CREATE,
4183
+ create2: CreationMethod$1.CREATE2,
4184
+ eofCreate: CreationMethod$1.EOF_CREATE
4185
+ };
4186
+ return enumMap[x] ?? CreationMethod$1.UNSPECIFIED;
4187
+ },
4188
+ decode(p) {
4189
+ const enumMap = {
4190
+ [CreationMethod$1.CREATE]: "create",
4191
+ [CreationMethod$1.CREATE2]: "create2",
4192
+ [CreationMethod$1.EOF_CREATE]: "eofCreate",
4193
+ [CreationMethod$1.UNSPECIFIED]: "unknown",
4194
+ [CreationMethod$1.UNRECOGNIZED]: "unknown"
4195
+ };
4196
+ return enumMap[p] ?? "unknown";
4218
4197
  }
4219
- );
4220
- const CallAction = Schema.Struct({
4221
- _tag: tag("call"),
4222
- call: Schema.Struct({
4223
- fromAddress: Address$1,
4224
- type: CallType,
4225
- gas: Schema.BigIntFromSelf,
4226
- input: BytesFromUint8Array,
4227
- toAddress: Address$1,
4228
- value: U256$1
4229
- })
4198
+ };
4199
+ const CallAction = MessageCodec({
4200
+ fromAddress: RequiredCodec(Address$1),
4201
+ type: RequiredCodec(CallType),
4202
+ gas: RequiredCodec(BigIntCodec),
4203
+ input: RequiredCodec(BytesFromUint8Array),
4204
+ toAddress: RequiredCodec(Address$1),
4205
+ value: RequiredCodec(U256$1)
4230
4206
  });
4231
- const CreateAction = Schema.Struct({
4232
- _tag: tag("create"),
4233
- create: Schema.Struct({
4234
- fromAddress: Address$1,
4235
- gas: Schema.BigIntFromSelf,
4236
- init: BytesFromUint8Array,
4237
- value: U256$1,
4238
- creationMethod: CreationMethod
4239
- })
4207
+ const CreateAction = MessageCodec({
4208
+ fromAddress: RequiredCodec(Address$1),
4209
+ gas: RequiredCodec(BigIntCodec),
4210
+ init: RequiredCodec(BytesFromUint8Array),
4211
+ value: RequiredCodec(U256$1),
4212
+ creationMethod: RequiredCodec(CreationMethod)
4240
4213
  });
4241
- const SelfDestructAction = Schema.Struct({
4242
- _tag: tag("selfDestruct"),
4243
- selfDestruct: Schema.Struct({
4244
- address: Address$1,
4245
- balance: U256$1,
4246
- refundAddress: Address$1
4247
- })
4214
+ const SelfDestructAction = MessageCodec({
4215
+ address: RequiredCodec(Address$1),
4216
+ balance: RequiredCodec(U256$1),
4217
+ refundAddress: RequiredCodec(Address$1)
4248
4218
  });
4249
- const RewardType = Schema.transform(
4250
- Schema.Enums(RewardType$1),
4251
- Schema.Literal("unknown", "block", "uncle"),
4252
- {
4253
- decode(value) {
4254
- const enumMap = {
4255
- [RewardType$1.BLOCK]: "block",
4256
- [RewardType$1.UNCLE]: "uncle",
4257
- [RewardType$1.UNSPECIFIED]: "unknown",
4258
- [RewardType$1.UNRECOGNIZED]: "unknown"
4259
- };
4260
- return enumMap[value] ?? "unknown";
4261
- },
4262
- encode(value) {
4263
- throw new Error("encode: not implemented");
4264
- }
4219
+ const RewardType = {
4220
+ encode(x) {
4221
+ const enumMap = {
4222
+ unknown: RewardType$1.UNSPECIFIED,
4223
+ block: RewardType$1.BLOCK,
4224
+ uncle: RewardType$1.UNCLE
4225
+ };
4226
+ return enumMap[x] ?? RewardType$1.UNSPECIFIED;
4227
+ },
4228
+ decode(p) {
4229
+ const enumMap = {
4230
+ [RewardType$1.BLOCK]: "block",
4231
+ [RewardType$1.UNCLE]: "uncle",
4232
+ [RewardType$1.UNSPECIFIED]: "unknown",
4233
+ [RewardType$1.UNRECOGNIZED]: "unknown"
4234
+ };
4235
+ return enumMap[p] ?? "unknown";
4265
4236
  }
4266
- );
4267
- const RewardAction = Schema.Struct({
4268
- _tag: tag("reward"),
4269
- reward: Schema.Struct({
4270
- author: Address$1,
4271
- type: RewardType,
4272
- value: U256$1
4273
- })
4237
+ };
4238
+ const RewardAction = MessageCodec({
4239
+ author: RequiredCodec(Address$1),
4240
+ type: RequiredCodec(RewardType),
4241
+ value: RequiredCodec(U256$1)
4274
4242
  });
4275
- const CallOutput = Schema.Struct({
4276
- _tag: tag("callOutput"),
4277
- callOutput: Schema.Struct({
4278
- gasUsed: Schema.BigIntFromSelf,
4279
- output: BytesFromUint8Array
4280
- })
4243
+ const CallOutput = MessageCodec({
4244
+ gasUsed: RequiredCodec(BigIntCodec),
4245
+ output: RequiredCodec(BytesFromUint8Array)
4281
4246
  });
4282
- const CreateOutput = Schema.Struct({
4283
- _tag: tag("createOutput"),
4284
- createOutput: Schema.Struct({
4285
- address: Address$1,
4286
- code: BytesFromUint8Array,
4287
- gasUsed: Schema.BigIntFromSelf
4288
- })
4247
+ const CreateOutput = MessageCodec({
4248
+ address: RequiredCodec(Address$1),
4249
+ code: RequiredCodec(BytesFromUint8Array),
4250
+ gasUsed: RequiredCodec(BigIntCodec)
4289
4251
  });
4290
- const Trace = Schema.Struct({
4291
- action: Schema.Union(
4292
- CallAction,
4293
- CreateAction,
4294
- SelfDestructAction,
4295
- RewardAction
4252
+ const Trace = MessageCodec({
4253
+ action: RequiredCodec(
4254
+ OneOfCodec({
4255
+ call: CallAction,
4256
+ create: CreateAction,
4257
+ selfDestruct: SelfDestructAction,
4258
+ reward: RewardAction
4259
+ })
4260
+ ),
4261
+ error: OptionalCodec(StringCodec),
4262
+ output: OptionalCodec(
4263
+ OneOfCodec({
4264
+ callOutput: CallOutput,
4265
+ createOutput: CreateOutput
4266
+ })
4296
4267
  ),
4297
- error: Schema.optional(Schema.String),
4298
- output: Schema.optional(Schema.Union(CallOutput, CreateOutput)),
4299
- subtraces: Schema.Number,
4300
- traceAddress: Schema.Array(Schema.Number)
4268
+ subtraces: RequiredCodec(NumberCodec),
4269
+ traceAddress: ArrayCodec(NumberCodec)
4301
4270
  });
4302
- const TransactionTrace = Schema.Struct({
4303
- filterIds: Schema.Array(Schema.Number),
4304
- transactionIndex: Schema.Number,
4305
- transactionHash: B256$1,
4306
- traces: Schema.Array(Trace)
4271
+ const TransactionTrace = MessageCodec({
4272
+ filterIds: ArrayCodec(NumberCodec),
4273
+ transactionIndex: RequiredCodec(NumberCodec),
4274
+ transactionHash: RequiredCodec(B256$1),
4275
+ traces: ArrayCodec(Trace)
4307
4276
  });
4308
- const Block = Schema.Struct({
4309
- header: BlockHeader,
4310
- withdrawals: Schema.Array(Withdrawal),
4311
- transactions: Schema.Array(Transaction),
4312
- receipts: Schema.Array(TransactionReceipt),
4313
- logs: Schema.Array(Log),
4314
- traces: Schema.Array(TransactionTrace)
4277
+ const Block = MessageCodec({
4278
+ header: RequiredCodec(BlockHeader),
4279
+ withdrawals: ArrayCodec(Withdrawal),
4280
+ transactions: ArrayCodec(Transaction),
4281
+ receipts: ArrayCodec(TransactionReceipt),
4282
+ logs: ArrayCodec(Log),
4283
+ traces: ArrayCodec(TransactionTrace)
4315
4284
  });
4316
- const BlockFromBytes = Schema.transform(
4317
- Schema.Uint8ArrayFromSelf,
4318
- Schema.NullOr(Block),
4319
- {
4320
- strict: false,
4321
- decode(value) {
4322
- if (value.length === 0) {
4323
- return null;
4324
- }
4325
- return Block$1.decode(value);
4326
- },
4327
- encode(value) {
4328
- if (value === null) {
4329
- return new Uint8Array();
4330
- }
4331
- return Block$1.encode(value).finish();
4332
- }
4285
+ const BlockFromBytes = {
4286
+ encode(x) {
4287
+ const block = Block.encode(x);
4288
+ return Block$1.encode(block).finish();
4289
+ },
4290
+ decode(p) {
4291
+ const block = Block$1.decode(p);
4292
+ return Block.decode(block);
4333
4293
  }
4334
- );
4294
+ };
4335
4295
 
4336
- const OptionalArray = (schema) => Schema.optional(Schema.Array(schema));
4337
- const HeaderFilter = Schema.transform(
4338
- Schema.Enums(HeaderFilter$1),
4339
- Schema.Literal("always", "on_data", "on_data_or_on_new_block", "unknown"),
4340
- {
4341
- decode(value) {
4342
- const enumMap = {
4343
- [HeaderFilter$1.ALWAYS]: "always",
4344
- [HeaderFilter$1.ON_DATA]: "on_data",
4345
- [HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK]: "on_data_or_on_new_block",
4346
- [HeaderFilter$1.UNSPECIFIED]: "unknown",
4347
- [HeaderFilter$1.UNRECOGNIZED]: "unknown"
4348
- };
4349
- return enumMap[value] ?? "unknown";
4350
- },
4351
- encode(value) {
4352
- switch (value) {
4353
- case "always":
4354
- return HeaderFilter$1.ALWAYS;
4355
- case "on_data":
4356
- return HeaderFilter$1.ON_DATA;
4357
- case "on_data_or_on_new_block":
4358
- return HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK;
4359
- default:
4360
- return HeaderFilter$1.UNSPECIFIED;
4361
- }
4362
- }
4296
+ const HeaderFilter = {
4297
+ encode(x) {
4298
+ switch (x) {
4299
+ case "always":
4300
+ return HeaderFilter$1.ALWAYS;
4301
+ case "on_data":
4302
+ return HeaderFilter$1.ON_DATA;
4303
+ case "on_data_or_on_new_block":
4304
+ return HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK;
4305
+ default:
4306
+ return HeaderFilter$1.UNSPECIFIED;
4307
+ }
4308
+ },
4309
+ decode(p) {
4310
+ const enumMap = {
4311
+ [HeaderFilter$1.ALWAYS]: "always",
4312
+ [HeaderFilter$1.ON_DATA]: "on_data",
4313
+ [HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK]: "on_data_or_on_new_block",
4314
+ [HeaderFilter$1.UNSPECIFIED]: "unknown",
4315
+ [HeaderFilter$1.UNRECOGNIZED]: "unknown"
4316
+ };
4317
+ return enumMap[p] ?? "unknown";
4363
4318
  }
4364
- );
4365
- const WithdrawalFilter = Schema.Struct({
4366
- id: Schema.optional(Schema.Number),
4367
- validatorIndex: Schema.optional(Schema.Number),
4368
- address: Schema.optional(Address$1)
4319
+ };
4320
+ const WithdrawalFilter = MessageCodec({
4321
+ id: OptionalCodec(NumberCodec),
4322
+ validatorIndex: OptionalCodec(NumberCodec),
4323
+ address: OptionalCodec(Address$1)
4369
4324
  });
4370
- const TransactionStatusFilter = Schema.transform(
4371
- Schema.Enums(TransactionStatusFilter$1),
4372
- Schema.Literal("succeeded", "reverted", "all", "unknown"),
4373
- {
4374
- decode(value) {
4375
- const enumMap = {
4376
- [TransactionStatusFilter$1.SUCCEEDED]: "succeeded",
4377
- [TransactionStatusFilter$1.REVERTED]: "reverted",
4378
- [TransactionStatusFilter$1.ALL]: "all",
4379
- [TransactionStatusFilter$1.UNSPECIFIED]: "unknown",
4380
- [TransactionStatusFilter$1.UNRECOGNIZED]: "unknown"
4381
- };
4382
- return enumMap[value] ?? "unknown";
4383
- },
4384
- encode(value) {
4385
- switch (value) {
4386
- case "succeeded":
4387
- return TransactionStatusFilter$1.SUCCEEDED;
4388
- case "reverted":
4389
- return TransactionStatusFilter$1.REVERTED;
4390
- case "all":
4391
- return TransactionStatusFilter$1.ALL;
4392
- default:
4393
- return TransactionStatusFilter$1.UNSPECIFIED;
4394
- }
4325
+ const TransactionStatusFilter = {
4326
+ decode(value) {
4327
+ const enumMap = {
4328
+ [TransactionStatusFilter$1.SUCCEEDED]: "succeeded",
4329
+ [TransactionStatusFilter$1.REVERTED]: "reverted",
4330
+ [TransactionStatusFilter$1.ALL]: "all",
4331
+ [TransactionStatusFilter$1.UNSPECIFIED]: "unknown",
4332
+ [TransactionStatusFilter$1.UNRECOGNIZED]: "unknown"
4333
+ };
4334
+ return enumMap[value] ?? "unknown";
4335
+ },
4336
+ encode(value) {
4337
+ switch (value) {
4338
+ case "succeeded":
4339
+ return TransactionStatusFilter$1.SUCCEEDED;
4340
+ case "reverted":
4341
+ return TransactionStatusFilter$1.REVERTED;
4342
+ case "all":
4343
+ return TransactionStatusFilter$1.ALL;
4344
+ default:
4345
+ return TransactionStatusFilter$1.UNSPECIFIED;
4395
4346
  }
4396
4347
  }
4397
- );
4398
- const Topic = Schema.transform(
4399
- Schema.Struct({ value: Schema.UndefinedOr(B256Proto) }),
4400
- Schema.NullOr(B256$1),
4401
- {
4402
- decode({ value }) {
4403
- if (value === void 0) {
4404
- return null;
4405
- }
4406
- return value;
4407
- },
4408
- encode(value) {
4409
- if (value === null) {
4410
- return { value: void 0 };
4411
- }
4412
- return { value };
4348
+ };
4349
+ const Topic = {
4350
+ encode(x) {
4351
+ if (x === null) {
4352
+ return { value: void 0 };
4413
4353
  }
4354
+ return { value: B256$1.encode(x) };
4355
+ },
4356
+ decode({ value }) {
4357
+ if (value === void 0) {
4358
+ return null;
4359
+ }
4360
+ return B256$1.decode(value);
4414
4361
  }
4415
- );
4416
- const LogFilter = Schema.Struct({
4417
- id: Schema.optional(Schema.Number),
4418
- address: Schema.optional(Address$1),
4419
- topics: OptionalArray(Topic),
4420
- strict: Schema.optional(Schema.Boolean),
4421
- transactionStatus: Schema.optional(TransactionStatusFilter),
4422
- includeTransaction: Schema.optional(Schema.Boolean),
4423
- includeReceipt: Schema.optional(Schema.Boolean),
4424
- includeTransactionTrace: Schema.optional(Schema.Boolean)
4362
+ };
4363
+ const LogFilter = MessageCodec({
4364
+ id: OptionalCodec(NumberCodec),
4365
+ address: OptionalCodec(Address$1),
4366
+ topics: OptionalCodec(ArrayCodec(Topic)),
4367
+ strict: OptionalCodec(BooleanCodec),
4368
+ transactionStatus: OptionalCodec(TransactionStatusFilter),
4369
+ includeTransaction: OptionalCodec(BooleanCodec),
4370
+ includeReceipt: OptionalCodec(BooleanCodec),
4371
+ includeTransactionTrace: OptionalCodec(BooleanCodec)
4425
4372
  });
4426
- const TransactionFilter = Schema.Struct({
4427
- id: Schema.optional(Schema.Number),
4428
- from: Schema.optional(Address$1),
4429
- to: Schema.optional(Address$1),
4430
- create: Schema.optional(Schema.Boolean),
4431
- transactionStatus: Schema.optional(TransactionStatusFilter),
4432
- includeReceipt: Schema.optional(Schema.Boolean),
4433
- includeLogs: Schema.optional(Schema.Boolean),
4434
- includeTransactionTrace: Schema.optional(Schema.Boolean)
4373
+ const TransactionFilter = MessageCodec({
4374
+ id: OptionalCodec(NumberCodec),
4375
+ from: OptionalCodec(Address$1),
4376
+ to: OptionalCodec(Address$1),
4377
+ create: OptionalCodec(BooleanCodec),
4378
+ transactionStatus: OptionalCodec(TransactionStatusFilter),
4379
+ includeReceipt: OptionalCodec(BooleanCodec),
4380
+ includeLogs: OptionalCodec(BooleanCodec),
4381
+ includeTransactionTrace: OptionalCodec(BooleanCodec)
4435
4382
  });
4436
- const Filter = Schema.Struct({
4437
- header: Schema.optional(HeaderFilter),
4438
- withdrawals: OptionalArray(WithdrawalFilter),
4439
- transactions: OptionalArray(TransactionFilter),
4440
- logs: OptionalArray(LogFilter)
4383
+ const Filter = MessageCodec({
4384
+ header: OptionalCodec(HeaderFilter),
4385
+ withdrawals: OptionalCodec(ArrayCodec(WithdrawalFilter)),
4386
+ transactions: OptionalCodec(ArrayCodec(TransactionFilter)),
4387
+ logs: OptionalCodec(ArrayCodec(LogFilter))
4441
4388
  });
4442
- const filterToProto = Schema.encodeSync(Filter);
4443
- const filterFromProto = Schema.decodeSync(Filter);
4444
- const FilterFromBytes = Schema.transform(
4445
- Schema.Uint8ArrayFromSelf,
4446
- Filter,
4447
- {
4448
- strict: false,
4449
- decode(value) {
4450
- return Filter$1.decode(value);
4451
- },
4452
- encode(value) {
4453
- return Filter$1.encode(value).finish();
4454
- }
4389
+ const FilterFromBytes = {
4390
+ encode(x) {
4391
+ return Filter$1.encode(Filter.encode(x)).finish();
4392
+ },
4393
+ decode(p) {
4394
+ return Filter.decode(Filter$1.decode(p));
4455
4395
  }
4456
- );
4457
- const filterToBytes = Schema.encodeSync(FilterFromBytes);
4458
- const filterFromBytes = Schema.decodeSync(FilterFromBytes);
4396
+ };
4459
4397
  function mergeFilter(a, b) {
4460
4398
  const header = mergeHeaderFilter(a.header, b.header);
4461
4399
  return {
@@ -4487,4 +4425,4 @@ const EvmStream = new StreamConfig(
4487
4425
  mergeFilter
4488
4426
  );
4489
4427
 
4490
- export { AccessListItem, Address$1 as Address, B256$1 as B256, B256Proto, Block, BlockFromBytes, BlockHeader, Bloom, CallAction, CallOutput, CallType, CreateAction, CreateOutput, CreationMethod, EvmStream, Filter, FilterFromBytes, HeaderFilter, Log, LogFilter, RewardAction, RewardType, SelfDestructAction, Signature, Topic, Trace, Transaction, TransactionFilter, TransactionReceipt, TransactionStatus, TransactionStatusFilter, TransactionTrace, U128$1 as U128, U256$1 as U256, Withdrawal, WithdrawalFilter, b256FromProto, b256ToProto, filterFromBytes, filterFromProto, filterToBytes, filterToProto, mergeFilter, index as proto, u128FromProto, u128ToProto, u256FromProto, u256ToProto };
4428
+ export { AccessListItem, Address$1 as Address, B256$1 as B256, Block, BlockFromBytes, BlockHeader, Bloom, CallAction, CallOutput, CallType, CreateAction, CreateOutput, CreationMethod, EvmStream, Filter, FilterFromBytes, HeaderFilter, Log, LogFilter, RewardAction, RewardType, SelfDestructAction, Signature, Topic, Trace, Transaction, TransactionFilter, TransactionReceipt, TransactionStatus, TransactionStatusFilter, TransactionTrace, U128$1 as U128, U256$1 as U256, Withdrawal, WithdrawalFilter, mergeFilter, index as proto };