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