@apibara/evm 2.1.0-beta.2 → 2.1.0-beta.20
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 +1393 -186
- package/dist/index.d.cts +835 -2
- package/dist/index.d.mts +835 -2
- package/dist/index.d.ts +835 -2
- package/dist/index.mjs +1383 -187
- package/package.json +2 -2
- package/src/block.ts +186 -0
- package/src/common.ts +6 -0
- package/src/filter.ts +4 -0
- package/src/helpers.ts +8 -0
- package/src/proto/data.ts +1284 -2
- package/src/proto/filter.ts +46 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/evm",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"vitest": "^1.6.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@apibara/protocol": "2.1.0-beta.
|
|
38
|
+
"@apibara/protocol": "2.1.0-beta.20",
|
|
39
39
|
"@effect/schema": "^0.67.15",
|
|
40
40
|
"effect": "^3.2.6",
|
|
41
41
|
"long": "^5.2.1",
|
package/src/block.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Bytes, BytesFromUint8Array } from "@apibara/protocol";
|
|
|
2
2
|
import { Schema } from "@effect/schema";
|
|
3
3
|
|
|
4
4
|
import { Address, B256, U128, U256 } from "./common";
|
|
5
|
+
import { tag } from "./helpers";
|
|
5
6
|
import * as proto from "./proto";
|
|
6
7
|
|
|
7
8
|
export const Bloom = Schema.transform(
|
|
@@ -20,6 +21,8 @@ export const Bloom = Schema.transform(
|
|
|
20
21
|
},
|
|
21
22
|
);
|
|
22
23
|
|
|
24
|
+
export type Bloom = typeof Bloom.Type;
|
|
25
|
+
|
|
23
26
|
export const TransactionStatus = Schema.transform(
|
|
24
27
|
Schema.Enums(proto.data.TransactionStatus),
|
|
25
28
|
Schema.Literal("unknown", "succeeded", "reverted"),
|
|
@@ -78,11 +81,15 @@ export const Withdrawal = Schema.Struct({
|
|
|
78
81
|
amount: Schema.BigIntFromSelf,
|
|
79
82
|
});
|
|
80
83
|
|
|
84
|
+
export type Withdrawal = typeof Withdrawal.Type;
|
|
85
|
+
|
|
81
86
|
export const AccessListItem = Schema.Struct({
|
|
82
87
|
address: Address,
|
|
83
88
|
storageKeys: Schema.Array(B256),
|
|
84
89
|
});
|
|
85
90
|
|
|
91
|
+
export type AccessListItem = typeof AccessListItem.Type;
|
|
92
|
+
|
|
86
93
|
export const Signature = Schema.Struct({
|
|
87
94
|
r: U256,
|
|
88
95
|
s: U256,
|
|
@@ -90,6 +97,8 @@ export const Signature = Schema.Struct({
|
|
|
90
97
|
YParity: Schema.optional(Schema.Boolean),
|
|
91
98
|
});
|
|
92
99
|
|
|
100
|
+
export type Signature = typeof Signature.Type;
|
|
101
|
+
|
|
93
102
|
export const Transaction = Schema.Struct({
|
|
94
103
|
filterIds: Schema.Array(Schema.Number),
|
|
95
104
|
transactionIndex: Schema.Number,
|
|
@@ -112,6 +121,8 @@ export const Transaction = Schema.Struct({
|
|
|
112
121
|
transactionStatus: TransactionStatus,
|
|
113
122
|
});
|
|
114
123
|
|
|
124
|
+
export type Transaction = typeof Transaction.Type;
|
|
125
|
+
|
|
115
126
|
export const TransactionReceipt = Schema.Struct({
|
|
116
127
|
filterIds: Schema.Array(Schema.Number),
|
|
117
128
|
transactionIndex: Schema.Number,
|
|
@@ -129,6 +140,8 @@ export const TransactionReceipt = Schema.Struct({
|
|
|
129
140
|
transactionStatus: TransactionStatus,
|
|
130
141
|
});
|
|
131
142
|
|
|
143
|
+
export type TransactionReceipt = typeof TransactionReceipt.Type;
|
|
144
|
+
|
|
132
145
|
export const Log = Schema.Struct({
|
|
133
146
|
filterIds: Schema.Array(Schema.Number),
|
|
134
147
|
address: Address,
|
|
@@ -143,12 +156,185 @@ export const Log = Schema.Struct({
|
|
|
143
156
|
|
|
144
157
|
export type Log = typeof Log.Type;
|
|
145
158
|
|
|
159
|
+
export const CallType = Schema.transform(
|
|
160
|
+
Schema.Enums(proto.data.CallType),
|
|
161
|
+
Schema.Literal(
|
|
162
|
+
"unknown",
|
|
163
|
+
"call",
|
|
164
|
+
"delegateCall",
|
|
165
|
+
"callCode",
|
|
166
|
+
"delegateCall",
|
|
167
|
+
"staticCall",
|
|
168
|
+
"authCall",
|
|
169
|
+
),
|
|
170
|
+
{
|
|
171
|
+
decode(value) {
|
|
172
|
+
const enumMap = {
|
|
173
|
+
[proto.data.CallType.CALL]: "call",
|
|
174
|
+
[proto.data.CallType.CALL_CODE]: "callCode",
|
|
175
|
+
[proto.data.CallType.DELEGATE_CALL]: "delegateCall",
|
|
176
|
+
[proto.data.CallType.STATIC_CALL]: "staticCall",
|
|
177
|
+
[proto.data.CallType.AUTH_CALL]: "authCall",
|
|
178
|
+
[proto.data.CallType.UNSPECIFIED]: "unknown",
|
|
179
|
+
[proto.data.CallType.UNRECOGNIZED]: "unknown",
|
|
180
|
+
} as const;
|
|
181
|
+
|
|
182
|
+
return enumMap[value] ?? "unknown";
|
|
183
|
+
},
|
|
184
|
+
encode(value) {
|
|
185
|
+
throw new Error("encode: not implemented");
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
export type CallType = typeof CallType.Type;
|
|
191
|
+
|
|
192
|
+
export const CreationMethod = Schema.transform(
|
|
193
|
+
Schema.Enums(proto.data.CreationMethod),
|
|
194
|
+
Schema.Literal("unknown", "create", "create2", "eofCreate"),
|
|
195
|
+
{
|
|
196
|
+
decode(value) {
|
|
197
|
+
const enumMap = {
|
|
198
|
+
[proto.data.CreationMethod.CREATE]: "create",
|
|
199
|
+
[proto.data.CreationMethod.CREATE2]: "create2",
|
|
200
|
+
[proto.data.CreationMethod.EOF_CREATE]: "eofCreate",
|
|
201
|
+
[proto.data.CallType.UNSPECIFIED]: "unknown",
|
|
202
|
+
[proto.data.CallType.UNRECOGNIZED]: "unknown",
|
|
203
|
+
} as const;
|
|
204
|
+
|
|
205
|
+
return enumMap[value] ?? "unknown";
|
|
206
|
+
},
|
|
207
|
+
encode(value) {
|
|
208
|
+
throw new Error("encode: not implemented");
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
export type CreationMethod = typeof CreationMethod.Type;
|
|
214
|
+
|
|
215
|
+
export const CallAction = Schema.Struct({
|
|
216
|
+
_tag: tag("call"),
|
|
217
|
+
call: Schema.Struct({
|
|
218
|
+
fromAddress: Address,
|
|
219
|
+
type: CallType,
|
|
220
|
+
gas: Schema.BigIntFromSelf,
|
|
221
|
+
input: BytesFromUint8Array,
|
|
222
|
+
toAddress: Address,
|
|
223
|
+
value: U256,
|
|
224
|
+
}),
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
export type CallAction = typeof CallAction.Type;
|
|
228
|
+
|
|
229
|
+
export const CreateAction = Schema.Struct({
|
|
230
|
+
_tag: tag("create"),
|
|
231
|
+
create: Schema.Struct({
|
|
232
|
+
fromAddress: Address,
|
|
233
|
+
gas: Schema.BigIntFromSelf,
|
|
234
|
+
init: BytesFromUint8Array,
|
|
235
|
+
value: U256,
|
|
236
|
+
creationMethod: CreationMethod,
|
|
237
|
+
}),
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
export type CreateAction = typeof CreateAction.Type;
|
|
241
|
+
|
|
242
|
+
export const SelfDestructAction = Schema.Struct({
|
|
243
|
+
_tag: tag("selfDestruct"),
|
|
244
|
+
selfDestruct: Schema.Struct({
|
|
245
|
+
address: Address,
|
|
246
|
+
balance: U256,
|
|
247
|
+
refundAddress: Address,
|
|
248
|
+
}),
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
export type SelfDestructAction = typeof SelfDestructAction.Type;
|
|
252
|
+
|
|
253
|
+
export const RewardType = Schema.transform(
|
|
254
|
+
Schema.Enums(proto.data.RewardType),
|
|
255
|
+
Schema.Literal("unknown", "block", "uncle"),
|
|
256
|
+
{
|
|
257
|
+
decode(value) {
|
|
258
|
+
const enumMap = {
|
|
259
|
+
[proto.data.RewardType.BLOCK]: "block",
|
|
260
|
+
[proto.data.RewardType.UNCLE]: "uncle",
|
|
261
|
+
[proto.data.RewardType.UNSPECIFIED]: "unknown",
|
|
262
|
+
[proto.data.RewardType.UNRECOGNIZED]: "unknown",
|
|
263
|
+
} as const;
|
|
264
|
+
|
|
265
|
+
return enumMap[value] ?? "unknown";
|
|
266
|
+
},
|
|
267
|
+
encode(value) {
|
|
268
|
+
throw new Error("encode: not implemented");
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
export type RewardType = typeof RewardType.Type;
|
|
274
|
+
|
|
275
|
+
export const RewardAction = Schema.Struct({
|
|
276
|
+
_tag: tag("reward"),
|
|
277
|
+
reward: Schema.Struct({
|
|
278
|
+
author: Address,
|
|
279
|
+
type: RewardType,
|
|
280
|
+
value: U256,
|
|
281
|
+
}),
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
export type RewardAction = typeof RewardAction.Type;
|
|
285
|
+
|
|
286
|
+
export const CallOutput = Schema.Struct({
|
|
287
|
+
_tag: tag("callOutput"),
|
|
288
|
+
callOutput: Schema.Struct({
|
|
289
|
+
gasUsed: Schema.BigIntFromSelf,
|
|
290
|
+
output: BytesFromUint8Array,
|
|
291
|
+
}),
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
export type CallOutput = typeof CallOutput.Type;
|
|
295
|
+
|
|
296
|
+
export const CreateOutput = Schema.Struct({
|
|
297
|
+
_tag: tag("createOutput"),
|
|
298
|
+
createOutput: Schema.Struct({
|
|
299
|
+
address: Address,
|
|
300
|
+
code: BytesFromUint8Array,
|
|
301
|
+
gasUsed: Schema.BigIntFromSelf,
|
|
302
|
+
}),
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
export type CreateOutput = typeof CreateOutput.Type;
|
|
306
|
+
|
|
307
|
+
export const Trace = Schema.Struct({
|
|
308
|
+
action: Schema.Union(
|
|
309
|
+
CallAction,
|
|
310
|
+
CreateAction,
|
|
311
|
+
SelfDestructAction,
|
|
312
|
+
RewardAction,
|
|
313
|
+
),
|
|
314
|
+
error: Schema.optional(Schema.String),
|
|
315
|
+
output: Schema.optional(Schema.Union(CallOutput, CreateOutput)),
|
|
316
|
+
subtraces: Schema.Number,
|
|
317
|
+
traceAddress: Schema.Array(Schema.Number),
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
export type Trace = typeof Trace.Type;
|
|
321
|
+
|
|
322
|
+
export const TransactionTrace = Schema.Struct({
|
|
323
|
+
filterIds: Schema.Array(Schema.Number),
|
|
324
|
+
transactionIndex: Schema.Number,
|
|
325
|
+
transactionHash: B256,
|
|
326
|
+
traces: Schema.Array(Trace),
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
export type TransactionTrace = typeof TransactionTrace.Type;
|
|
330
|
+
|
|
146
331
|
export const Block = Schema.Struct({
|
|
147
332
|
header: BlockHeader,
|
|
148
333
|
withdrawals: Schema.Array(Withdrawal),
|
|
149
334
|
transactions: Schema.Array(Transaction),
|
|
150
335
|
receipts: Schema.Array(TransactionReceipt),
|
|
151
336
|
logs: Schema.Array(Log),
|
|
337
|
+
traces: Schema.Array(TransactionTrace),
|
|
152
338
|
});
|
|
153
339
|
|
|
154
340
|
export type Block = typeof Block.Type;
|
package/src/common.ts
CHANGED
|
@@ -62,6 +62,8 @@ export const B256 = Schema.transform(B256Proto, _B256, {
|
|
|
62
62
|
},
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
export type B256 = typeof B256.Type;
|
|
66
|
+
|
|
65
67
|
export const b256ToProto = Schema.encodeSync(B256);
|
|
66
68
|
export const b256FromProto = Schema.decodeSync(B256);
|
|
67
69
|
|
|
@@ -92,6 +94,8 @@ export const U256 = Schema.transform(U256Proto, Schema.BigIntFromSelf, {
|
|
|
92
94
|
},
|
|
93
95
|
});
|
|
94
96
|
|
|
97
|
+
export type U256 = typeof U256.Type;
|
|
98
|
+
|
|
95
99
|
export const u256ToProto = Schema.encodeSync(U256);
|
|
96
100
|
export const u256FromProto = Schema.decodeSync(U256);
|
|
97
101
|
|
|
@@ -113,5 +117,7 @@ export const U128 = Schema.transform(U128Proto, Schema.BigIntFromSelf, {
|
|
|
113
117
|
},
|
|
114
118
|
});
|
|
115
119
|
|
|
120
|
+
export type U128 = typeof U128.Type;
|
|
121
|
+
|
|
116
122
|
export const u128ToProto = Schema.encodeSync(U128);
|
|
117
123
|
export const u128FromProto = Schema.decodeSync(U128);
|
package/src/filter.ts
CHANGED
|
@@ -103,6 +103,8 @@ export const Topic = Schema.transform(
|
|
|
103
103
|
},
|
|
104
104
|
);
|
|
105
105
|
|
|
106
|
+
export type Topic = typeof Topic.Type;
|
|
107
|
+
|
|
106
108
|
export const LogFilter = Schema.Struct({
|
|
107
109
|
id: Schema.optional(Schema.Number),
|
|
108
110
|
address: Schema.optional(Address),
|
|
@@ -111,6 +113,7 @@ export const LogFilter = Schema.Struct({
|
|
|
111
113
|
transactionStatus: Schema.optional(TransactionStatusFilter),
|
|
112
114
|
includeTransaction: Schema.optional(Schema.Boolean),
|
|
113
115
|
includeReceipt: Schema.optional(Schema.Boolean),
|
|
116
|
+
includeTransactionTrace: Schema.optional(Schema.Boolean),
|
|
114
117
|
});
|
|
115
118
|
|
|
116
119
|
export type LogFilter = typeof LogFilter.Type;
|
|
@@ -123,6 +126,7 @@ export const TransactionFilter = Schema.Struct({
|
|
|
123
126
|
transactionStatus: Schema.optional(TransactionStatusFilter),
|
|
124
127
|
includeReceipt: Schema.optional(Schema.Boolean),
|
|
125
128
|
includeLogs: Schema.optional(Schema.Boolean),
|
|
129
|
+
includeTransactionTrace: Schema.optional(Schema.Boolean),
|
|
126
130
|
});
|
|
127
131
|
|
|
128
132
|
export type TransactionFilter = typeof TransactionFilter.Type;
|