@apibara/evm 2.1.0-beta.23 → 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() {
@@ -4061,417 +4032,368 @@ const index = {
4061
4032
  filter: filter
4062
4033
  };
4063
4034
 
4064
- const Bloom = Schema.transform(
4065
- Schema.Struct({
4066
- value: BytesFromUint8Array
4067
- }),
4068
- Bytes,
4069
- {
4070
- strict: false,
4071
- encode(value) {
4072
- throw new Error("Not implemented");
4073
- },
4074
- decode({ value }) {
4075
- return value;
4076
- }
4035
+ const Bloom = {
4036
+ encode(x) {
4037
+ return { value: BytesFromUint8Array.encode(x) };
4038
+ },
4039
+ decode({ value }) {
4040
+ return BytesFromUint8Array.decode(value);
4077
4041
  }
4078
- );
4079
- const TransactionStatus = Schema.transform(
4080
- Schema.Enums(TransactionStatus$1),
4081
- Schema.Literal("unknown", "succeeded", "reverted"),
4082
- {
4083
- decode(value) {
4084
- const enumMap = {
4085
- [TransactionStatus$1.SUCCEEDED]: "succeeded",
4086
- [TransactionStatus$1.REVERTED]: "reverted",
4087
- [TransactionStatus$1.UNSPECIFIED]: "unknown",
4088
- [TransactionStatus$1.UNRECOGNIZED]: "unknown"
4089
- };
4090
- return enumMap[value] ?? "unknown";
4091
- },
4092
- encode(value) {
4093
- throw new Error("encode: not implemented");
4094
- }
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";
4095
4060
  }
4096
- );
4097
- const BlockHeader = Schema.Struct({
4098
- blockNumber: Schema.BigIntFromSelf,
4099
- blockHash: B256$1,
4100
- parentBlockHash: B256$1,
4101
- unclesHash: B256$1,
4102
- miner: Address$1,
4103
- stateRoot: B256$1,
4104
- transactionsRoot: B256$1,
4105
- receiptsRoot: B256$1,
4106
- logsBloom: Bloom,
4107
- difficulty: U256$1,
4108
- gasLimit: U128$1,
4109
- gasUsed: U128$1,
4110
- timestamp: Schema.DateFromSelf,
4111
- extraData: BytesFromUint8Array,
4112
- mixHash: Schema.optional(B256$1),
4113
- nonce: Schema.optional(Schema.BigIntFromSelf),
4114
- baseFeePerGas: Schema.optional(U128$1),
4115
- withdrawalsRoot: Schema.optional(B256$1),
4116
- totalDifficulty: Schema.optional(U256$1),
4117
- blobGasUsed: Schema.optional(U128$1),
4118
- excessBlobGas: Schema.optional(U128$1),
4119
- parentBeaconBlockRoot: Schema.optional(B256$1),
4120
- requestsHash: 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)
4121
4086
  });
4122
- const Withdrawal = Schema.Struct({
4123
- filterIds: Schema.Array(Schema.Number),
4124
- withdrawalIndex: Schema.Number,
4125
- index: Schema.BigIntFromSelf,
4126
- validatorIndex: Schema.Number,
4127
- address: Address$1,
4128
- 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)
4129
4094
  });
4130
- const AccessListItem = Schema.Struct({
4131
- address: Address$1,
4132
- storageKeys: Schema.Array(B256$1)
4095
+ const AccessListItem = MessageCodec({
4096
+ address: RequiredCodec(Address$1),
4097
+ storageKeys: ArrayCodec(B256$1)
4133
4098
  });
4134
- const Signature = Schema.Struct({
4135
- r: U256$1,
4136
- s: U256$1,
4137
- v: Schema.optional(U256$1),
4138
- 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)
4139
4104
  });
4140
- const Transaction = Schema.Struct({
4141
- filterIds: Schema.Array(Schema.Number),
4142
- transactionIndex: Schema.Number,
4143
- transactionHash: B256$1,
4144
- nonce: Schema.BigIntFromSelf,
4145
- from: Address$1,
4146
- to: Schema.optional(Address$1),
4147
- value: U256$1,
4148
- gasPrice: Schema.optional(U128$1),
4149
- gas: U128$1,
4150
- maxFeePerGas: Schema.optional(U128$1),
4151
- maxPriorityFeePerGas: Schema.optional(U128$1),
4152
- input: BytesFromUint8Array,
4153
- signature: Schema.optional(Signature),
4154
- chainId: Schema.optional(Schema.BigIntFromSelf),
4155
- accessList: Schema.Array(AccessListItem),
4156
- transactionType: Schema.BigIntFromSelf,
4157
- maxFeePerBlobGas: Schema.optional(U128$1),
4158
- blobVersionedHashes: Schema.Array(B256$1),
4159
- 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)
4160
4125
  });
4161
- const TransactionReceipt = Schema.Struct({
4162
- filterIds: Schema.Array(Schema.Number),
4163
- transactionIndex: Schema.Number,
4164
- transactionHash: B256$1,
4165
- cumulativeGasUsed: U128$1,
4166
- gasUsed: U128$1,
4167
- effectiveGasPrice: U128$1,
4168
- from: Address$1,
4169
- to: Schema.optional(Address$1),
4170
- contractAddress: Schema.optional(Address$1),
4171
- logsBloom: Bloom,
4172
- transactionType: Schema.BigIntFromSelf,
4173
- blobGasUsed: Schema.optional(U128$1),
4174
- blobGasPrice: Schema.optional(U128$1),
4175
- 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)
4176
4141
  });
4177
- const Log = Schema.Struct({
4178
- filterIds: Schema.Array(Schema.Number),
4179
- address: Address$1,
4180
- topics: Schema.Array(B256$1),
4181
- data: BytesFromUint8Array,
4182
- logIndex: Schema.Number,
4183
- logIndexInTransaction: Schema.Number,
4184
- transactionIndex: Schema.Number,
4185
- transactionHash: B256$1,
4186
- 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)
4187
4152
  });
4188
- const CallType = Schema.transform(
4189
- Schema.Enums(CallType$1),
4190
- Schema.Literal(
4191
- "unknown",
4192
- "call",
4193
- "delegateCall",
4194
- "callCode",
4195
- "delegateCall",
4196
- "staticCall",
4197
- "authCall"
4198
- ),
4199
- {
4200
- decode(value) {
4201
- const enumMap = {
4202
- [CallType$1.CALL]: "call",
4203
- [CallType$1.CALL_CODE]: "callCode",
4204
- [CallType$1.DELEGATE_CALL]: "delegateCall",
4205
- [CallType$1.STATIC_CALL]: "staticCall",
4206
- [CallType$1.AUTH_CALL]: "authCall",
4207
- [CallType$1.UNSPECIFIED]: "unknown",
4208
- [CallType$1.UNRECOGNIZED]: "unknown"
4209
- };
4210
- return enumMap[value] ?? "unknown";
4211
- },
4212
- encode(value) {
4213
- throw new Error("encode: not implemented");
4214
- }
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";
4215
4176
  }
4216
- );
4217
- const CreationMethod = Schema.transform(
4218
- Schema.Enums(CreationMethod$1),
4219
- Schema.Literal("unknown", "create", "create2", "eofCreate"),
4220
- {
4221
- decode(value) {
4222
- const enumMap = {
4223
- [CreationMethod$1.CREATE]: "create",
4224
- [CreationMethod$1.CREATE2]: "create2",
4225
- [CreationMethod$1.EOF_CREATE]: "eofCreate",
4226
- [CallType$1.UNSPECIFIED]: "unknown",
4227
- [CallType$1.UNRECOGNIZED]: "unknown"
4228
- };
4229
- return enumMap[value] ?? "unknown";
4230
- },
4231
- encode(value) {
4232
- throw new Error("encode: not implemented");
4233
- }
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";
4234
4197
  }
4235
- );
4236
- const CallAction = Schema.Struct({
4237
- _tag: tag("call"),
4238
- call: Schema.Struct({
4239
- fromAddress: Address$1,
4240
- type: CallType,
4241
- gas: Schema.BigIntFromSelf,
4242
- input: BytesFromUint8Array,
4243
- toAddress: Address$1,
4244
- value: U256$1
4245
- })
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)
4246
4206
  });
4247
- const CreateAction = Schema.Struct({
4248
- _tag: tag("create"),
4249
- create: Schema.Struct({
4250
- fromAddress: Address$1,
4251
- gas: Schema.BigIntFromSelf,
4252
- init: BytesFromUint8Array,
4253
- value: U256$1,
4254
- creationMethod: CreationMethod
4255
- })
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)
4256
4213
  });
4257
- const SelfDestructAction = Schema.Struct({
4258
- _tag: tag("selfDestruct"),
4259
- selfDestruct: Schema.Struct({
4260
- address: Address$1,
4261
- balance: U256$1,
4262
- refundAddress: Address$1
4263
- })
4214
+ const SelfDestructAction = MessageCodec({
4215
+ address: RequiredCodec(Address$1),
4216
+ balance: RequiredCodec(U256$1),
4217
+ refundAddress: RequiredCodec(Address$1)
4264
4218
  });
4265
- const RewardType = Schema.transform(
4266
- Schema.Enums(RewardType$1),
4267
- Schema.Literal("unknown", "block", "uncle"),
4268
- {
4269
- decode(value) {
4270
- const enumMap = {
4271
- [RewardType$1.BLOCK]: "block",
4272
- [RewardType$1.UNCLE]: "uncle",
4273
- [RewardType$1.UNSPECIFIED]: "unknown",
4274
- [RewardType$1.UNRECOGNIZED]: "unknown"
4275
- };
4276
- return enumMap[value] ?? "unknown";
4277
- },
4278
- encode(value) {
4279
- throw new Error("encode: not implemented");
4280
- }
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";
4281
4236
  }
4282
- );
4283
- const RewardAction = Schema.Struct({
4284
- _tag: tag("reward"),
4285
- reward: Schema.Struct({
4286
- author: Address$1,
4287
- type: RewardType,
4288
- value: U256$1
4289
- })
4237
+ };
4238
+ const RewardAction = MessageCodec({
4239
+ author: RequiredCodec(Address$1),
4240
+ type: RequiredCodec(RewardType),
4241
+ value: RequiredCodec(U256$1)
4290
4242
  });
4291
- const CallOutput = Schema.Struct({
4292
- _tag: tag("callOutput"),
4293
- callOutput: Schema.Struct({
4294
- gasUsed: Schema.BigIntFromSelf,
4295
- output: BytesFromUint8Array
4296
- })
4243
+ const CallOutput = MessageCodec({
4244
+ gasUsed: RequiredCodec(BigIntCodec),
4245
+ output: RequiredCodec(BytesFromUint8Array)
4297
4246
  });
4298
- const CreateOutput = Schema.Struct({
4299
- _tag: tag("createOutput"),
4300
- createOutput: Schema.Struct({
4301
- address: Address$1,
4302
- code: BytesFromUint8Array,
4303
- gasUsed: Schema.BigIntFromSelf
4304
- })
4247
+ const CreateOutput = MessageCodec({
4248
+ address: RequiredCodec(Address$1),
4249
+ code: RequiredCodec(BytesFromUint8Array),
4250
+ gasUsed: RequiredCodec(BigIntCodec)
4305
4251
  });
4306
- const Trace = Schema.Struct({
4307
- action: Schema.Union(
4308
- CallAction,
4309
- CreateAction,
4310
- SelfDestructAction,
4311
- RewardAction
4252
+ const Trace = MessageCodec({
4253
+ action: RequiredCodec(
4254
+ OneOfCodec({
4255
+ call: CallAction,
4256
+ create: CreateAction,
4257
+ selfDestruct: SelfDestructAction,
4258
+ reward: RewardAction
4259
+ })
4312
4260
  ),
4313
- error: Schema.optional(Schema.String),
4314
- output: Schema.optional(Schema.Union(CallOutput, CreateOutput)),
4315
- subtraces: Schema.Number,
4316
- traceAddress: Schema.Array(Schema.Number)
4261
+ error: OptionalCodec(StringCodec),
4262
+ output: OptionalCodec(
4263
+ OneOfCodec({
4264
+ callOutput: CallOutput,
4265
+ createOutput: CreateOutput
4266
+ })
4267
+ ),
4268
+ subtraces: RequiredCodec(NumberCodec),
4269
+ traceAddress: ArrayCodec(NumberCodec)
4317
4270
  });
4318
- const TransactionTrace = Schema.Struct({
4319
- filterIds: Schema.Array(Schema.Number),
4320
- transactionIndex: Schema.Number,
4321
- transactionHash: B256$1,
4322
- 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)
4323
4276
  });
4324
- const Block = Schema.Struct({
4325
- header: BlockHeader,
4326
- withdrawals: Schema.Array(Withdrawal),
4327
- transactions: Schema.Array(Transaction),
4328
- receipts: Schema.Array(TransactionReceipt),
4329
- logs: Schema.Array(Log),
4330
- 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)
4331
4284
  });
4332
- const BlockFromBytes = Schema.transform(
4333
- Schema.Uint8ArrayFromSelf,
4334
- Schema.NullOr(Block),
4335
- {
4336
- strict: false,
4337
- decode(value) {
4338
- if (value.length === 0) {
4339
- return null;
4340
- }
4341
- return Block$1.decode(value);
4342
- },
4343
- encode(value) {
4344
- if (value === null) {
4345
- return new Uint8Array();
4346
- }
4347
- return Block$1.encode(value).finish();
4348
- }
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);
4349
4293
  }
4350
- );
4294
+ };
4351
4295
 
4352
- const OptionalArray = (schema) => Schema.optional(Schema.Array(schema));
4353
- const HeaderFilter = Schema.transform(
4354
- Schema.Enums(HeaderFilter$1),
4355
- Schema.Literal("always", "on_data", "on_data_or_on_new_block", "unknown"),
4356
- {
4357
- decode(value) {
4358
- const enumMap = {
4359
- [HeaderFilter$1.ALWAYS]: "always",
4360
- [HeaderFilter$1.ON_DATA]: "on_data",
4361
- [HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK]: "on_data_or_on_new_block",
4362
- [HeaderFilter$1.UNSPECIFIED]: "unknown",
4363
- [HeaderFilter$1.UNRECOGNIZED]: "unknown"
4364
- };
4365
- return enumMap[value] ?? "unknown";
4366
- },
4367
- encode(value) {
4368
- switch (value) {
4369
- case "always":
4370
- return HeaderFilter$1.ALWAYS;
4371
- case "on_data":
4372
- return HeaderFilter$1.ON_DATA;
4373
- case "on_data_or_on_new_block":
4374
- return HeaderFilter$1.ON_DATA_OR_ON_NEW_BLOCK;
4375
- default:
4376
- return HeaderFilter$1.UNSPECIFIED;
4377
- }
4378
- }
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";
4379
4318
  }
4380
- );
4381
- const WithdrawalFilter = Schema.Struct({
4382
- id: Schema.optional(Schema.Number),
4383
- validatorIndex: Schema.optional(Schema.Number),
4384
- address: Schema.optional(Address$1)
4319
+ };
4320
+ const WithdrawalFilter = MessageCodec({
4321
+ id: OptionalCodec(NumberCodec),
4322
+ validatorIndex: OptionalCodec(NumberCodec),
4323
+ address: OptionalCodec(Address$1)
4385
4324
  });
4386
- const TransactionStatusFilter = Schema.transform(
4387
- Schema.Enums(TransactionStatusFilter$1),
4388
- Schema.Literal("succeeded", "reverted", "all", "unknown"),
4389
- {
4390
- decode(value) {
4391
- const enumMap = {
4392
- [TransactionStatusFilter$1.SUCCEEDED]: "succeeded",
4393
- [TransactionStatusFilter$1.REVERTED]: "reverted",
4394
- [TransactionStatusFilter$1.ALL]: "all",
4395
- [TransactionStatusFilter$1.UNSPECIFIED]: "unknown",
4396
- [TransactionStatusFilter$1.UNRECOGNIZED]: "unknown"
4397
- };
4398
- return enumMap[value] ?? "unknown";
4399
- },
4400
- encode(value) {
4401
- switch (value) {
4402
- case "succeeded":
4403
- return TransactionStatusFilter$1.SUCCEEDED;
4404
- case "reverted":
4405
- return TransactionStatusFilter$1.REVERTED;
4406
- case "all":
4407
- return TransactionStatusFilter$1.ALL;
4408
- default:
4409
- return TransactionStatusFilter$1.UNSPECIFIED;
4410
- }
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;
4411
4346
  }
4412
4347
  }
4413
- );
4414
- const Topic = Schema.transform(
4415
- Schema.Struct({ value: Schema.UndefinedOr(B256Proto) }),
4416
- Schema.NullOr(B256$1),
4417
- {
4418
- decode({ value }) {
4419
- if (value === void 0) {
4420
- return null;
4421
- }
4422
- return value;
4423
- },
4424
- encode(value) {
4425
- if (value === null) {
4426
- return { value: void 0 };
4427
- }
4428
- return { value };
4348
+ };
4349
+ const Topic = {
4350
+ encode(x) {
4351
+ if (x === null) {
4352
+ return { value: void 0 };
4429
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);
4430
4361
  }
4431
- );
4432
- const LogFilter = Schema.Struct({
4433
- id: Schema.optional(Schema.Number),
4434
- address: Schema.optional(Address$1),
4435
- topics: OptionalArray(Topic),
4436
- strict: Schema.optional(Schema.Boolean),
4437
- transactionStatus: Schema.optional(TransactionStatusFilter),
4438
- includeTransaction: Schema.optional(Schema.Boolean),
4439
- includeReceipt: Schema.optional(Schema.Boolean),
4440
- 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)
4441
4372
  });
4442
- const TransactionFilter = Schema.Struct({
4443
- id: Schema.optional(Schema.Number),
4444
- from: Schema.optional(Address$1),
4445
- to: Schema.optional(Address$1),
4446
- create: Schema.optional(Schema.Boolean),
4447
- transactionStatus: Schema.optional(TransactionStatusFilter),
4448
- includeReceipt: Schema.optional(Schema.Boolean),
4449
- includeLogs: Schema.optional(Schema.Boolean),
4450
- 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)
4451
4382
  });
4452
- const Filter = Schema.Struct({
4453
- header: Schema.optional(HeaderFilter),
4454
- withdrawals: OptionalArray(WithdrawalFilter),
4455
- transactions: OptionalArray(TransactionFilter),
4456
- 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))
4457
4388
  });
4458
- const filterToProto = Schema.encodeSync(Filter);
4459
- const filterFromProto = Schema.decodeSync(Filter);
4460
- const FilterFromBytes = Schema.transform(
4461
- Schema.Uint8ArrayFromSelf,
4462
- Filter,
4463
- {
4464
- strict: false,
4465
- decode(value) {
4466
- return Filter$1.decode(value);
4467
- },
4468
- encode(value) {
4469
- return Filter$1.encode(value).finish();
4470
- }
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));
4471
4395
  }
4472
- );
4473
- const filterToBytes = Schema.encodeSync(FilterFromBytes);
4474
- const filterFromBytes = Schema.decodeSync(FilterFromBytes);
4396
+ };
4475
4397
  function mergeFilter(a, b) {
4476
4398
  const header = mergeHeaderFilter(a.header, b.header);
4477
4399
  return {
@@ -4503,4 +4425,4 @@ const EvmStream = new StreamConfig(
4503
4425
  mergeFilter
4504
4426
  );
4505
4427
 
4506
- 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 };