@apibara/evm 2.1.0-beta.5 → 2.1.0-beta.51
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 +1554 -418
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1287 -1416
- package/dist/index.d.mts +1287 -1416
- package/dist/index.d.ts +1287 -1416
- package/dist/index.mjs +1545 -409
- package/dist/index.mjs.map +1 -0
- package/package.json +3 -5
- package/src/block.ts +358 -167
- package/src/common.ts +64 -95
- package/src/filter.ts +128 -134
- package/src/index.ts +1 -0
- package/src/proto/data.ts +1310 -3
- package/src/proto/filter.ts +46 -2
- package/src/common.test.ts +0 -79
- package/src/filter.test.ts +0 -187
package/src/proto/filter.ts
CHANGED
|
@@ -160,7 +160,11 @@ export interface TransactionFilter {
|
|
|
160
160
|
| boolean
|
|
161
161
|
| undefined;
|
|
162
162
|
/** Flag to request the transaction's logs. Defaults to `false`. */
|
|
163
|
-
readonly includeLogs?:
|
|
163
|
+
readonly includeLogs?:
|
|
164
|
+
| boolean
|
|
165
|
+
| undefined;
|
|
166
|
+
/** Flag to request the transaction's trace. Defaults to `false`. */
|
|
167
|
+
readonly includeTransactionTrace?: boolean | undefined;
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
export interface LogFilter {
|
|
@@ -204,7 +208,11 @@ export interface LogFilter {
|
|
|
204
208
|
*
|
|
205
209
|
* Defaults to false.
|
|
206
210
|
*/
|
|
207
|
-
readonly includeSiblings?:
|
|
211
|
+
readonly includeSiblings?:
|
|
212
|
+
| boolean
|
|
213
|
+
| undefined;
|
|
214
|
+
/** Flag to request the log's trace. Defaults to `false`. */
|
|
215
|
+
readonly includeTransactionTrace?: boolean | undefined;
|
|
208
216
|
}
|
|
209
217
|
|
|
210
218
|
/** Topic filter. */
|
|
@@ -427,6 +435,7 @@ function createBaseTransactionFilter(): TransactionFilter {
|
|
|
427
435
|
transactionStatus: undefined,
|
|
428
436
|
includeReceipt: undefined,
|
|
429
437
|
includeLogs: undefined,
|
|
438
|
+
includeTransactionTrace: undefined,
|
|
430
439
|
};
|
|
431
440
|
}
|
|
432
441
|
|
|
@@ -453,6 +462,9 @@ export const TransactionFilter = {
|
|
|
453
462
|
if (message.includeLogs !== undefined) {
|
|
454
463
|
writer.uint32(56).bool(message.includeLogs);
|
|
455
464
|
}
|
|
465
|
+
if (message.includeTransactionTrace !== undefined) {
|
|
466
|
+
writer.uint32(64).bool(message.includeTransactionTrace);
|
|
467
|
+
}
|
|
456
468
|
return writer;
|
|
457
469
|
},
|
|
458
470
|
|
|
@@ -512,6 +524,13 @@ export const TransactionFilter = {
|
|
|
512
524
|
|
|
513
525
|
message.includeLogs = reader.bool();
|
|
514
526
|
continue;
|
|
527
|
+
case 8:
|
|
528
|
+
if (tag !== 64) {
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
message.includeTransactionTrace = reader.bool();
|
|
533
|
+
continue;
|
|
515
534
|
}
|
|
516
535
|
if ((tag & 7) === 4 || tag === 0) {
|
|
517
536
|
break;
|
|
@@ -532,6 +551,9 @@ export const TransactionFilter = {
|
|
|
532
551
|
: undefined,
|
|
533
552
|
includeReceipt: isSet(object.includeReceipt) ? globalThis.Boolean(object.includeReceipt) : undefined,
|
|
534
553
|
includeLogs: isSet(object.includeLogs) ? globalThis.Boolean(object.includeLogs) : undefined,
|
|
554
|
+
includeTransactionTrace: isSet(object.includeTransactionTrace)
|
|
555
|
+
? globalThis.Boolean(object.includeTransactionTrace)
|
|
556
|
+
: undefined,
|
|
535
557
|
};
|
|
536
558
|
},
|
|
537
559
|
|
|
@@ -558,6 +580,9 @@ export const TransactionFilter = {
|
|
|
558
580
|
if (message.includeLogs !== undefined) {
|
|
559
581
|
obj.includeLogs = message.includeLogs;
|
|
560
582
|
}
|
|
583
|
+
if (message.includeTransactionTrace !== undefined) {
|
|
584
|
+
obj.includeTransactionTrace = message.includeTransactionTrace;
|
|
585
|
+
}
|
|
561
586
|
return obj;
|
|
562
587
|
},
|
|
563
588
|
|
|
@@ -573,6 +598,7 @@ export const TransactionFilter = {
|
|
|
573
598
|
message.transactionStatus = object.transactionStatus ?? undefined;
|
|
574
599
|
message.includeReceipt = object.includeReceipt ?? undefined;
|
|
575
600
|
message.includeLogs = object.includeLogs ?? undefined;
|
|
601
|
+
message.includeTransactionTrace = object.includeTransactionTrace ?? undefined;
|
|
576
602
|
return message;
|
|
577
603
|
},
|
|
578
604
|
};
|
|
@@ -587,6 +613,7 @@ function createBaseLogFilter(): LogFilter {
|
|
|
587
613
|
includeTransaction: undefined,
|
|
588
614
|
includeReceipt: undefined,
|
|
589
615
|
includeSiblings: undefined,
|
|
616
|
+
includeTransactionTrace: undefined,
|
|
590
617
|
};
|
|
591
618
|
}
|
|
592
619
|
|
|
@@ -618,6 +645,9 @@ export const LogFilter = {
|
|
|
618
645
|
if (message.includeSiblings !== undefined) {
|
|
619
646
|
writer.uint32(64).bool(message.includeSiblings);
|
|
620
647
|
}
|
|
648
|
+
if (message.includeTransactionTrace !== undefined) {
|
|
649
|
+
writer.uint32(72).bool(message.includeTransactionTrace);
|
|
650
|
+
}
|
|
621
651
|
return writer;
|
|
622
652
|
},
|
|
623
653
|
|
|
@@ -684,6 +714,13 @@ export const LogFilter = {
|
|
|
684
714
|
|
|
685
715
|
message.includeSiblings = reader.bool();
|
|
686
716
|
continue;
|
|
717
|
+
case 9:
|
|
718
|
+
if (tag !== 72) {
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
message.includeTransactionTrace = reader.bool();
|
|
723
|
+
continue;
|
|
687
724
|
}
|
|
688
725
|
if ((tag & 7) === 4 || tag === 0) {
|
|
689
726
|
break;
|
|
@@ -705,6 +742,9 @@ export const LogFilter = {
|
|
|
705
742
|
includeTransaction: isSet(object.includeTransaction) ? globalThis.Boolean(object.includeTransaction) : undefined,
|
|
706
743
|
includeReceipt: isSet(object.includeReceipt) ? globalThis.Boolean(object.includeReceipt) : undefined,
|
|
707
744
|
includeSiblings: isSet(object.includeSiblings) ? globalThis.Boolean(object.includeSiblings) : undefined,
|
|
745
|
+
includeTransactionTrace: isSet(object.includeTransactionTrace)
|
|
746
|
+
? globalThis.Boolean(object.includeTransactionTrace)
|
|
747
|
+
: undefined,
|
|
708
748
|
};
|
|
709
749
|
},
|
|
710
750
|
|
|
@@ -734,6 +774,9 @@ export const LogFilter = {
|
|
|
734
774
|
if (message.includeSiblings !== undefined) {
|
|
735
775
|
obj.includeSiblings = message.includeSiblings;
|
|
736
776
|
}
|
|
777
|
+
if (message.includeTransactionTrace !== undefined) {
|
|
778
|
+
obj.includeTransactionTrace = message.includeTransactionTrace;
|
|
779
|
+
}
|
|
737
780
|
return obj;
|
|
738
781
|
},
|
|
739
782
|
|
|
@@ -752,6 +795,7 @@ export const LogFilter = {
|
|
|
752
795
|
message.includeTransaction = object.includeTransaction ?? undefined;
|
|
753
796
|
message.includeReceipt = object.includeReceipt ?? undefined;
|
|
754
797
|
message.includeSiblings = object.includeSiblings ?? undefined;
|
|
798
|
+
message.includeTransactionTrace = object.includeTransactionTrace ?? undefined;
|
|
755
799
|
return message;
|
|
756
800
|
},
|
|
757
801
|
};
|
package/src/common.test.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { Schema } from "@effect/schema";
|
|
4
|
-
import { pad } from "viem";
|
|
5
|
-
|
|
6
|
-
import { Address, B256, U128, U256 } from "./common";
|
|
7
|
-
|
|
8
|
-
describe("Address", () => {
|
|
9
|
-
const encode = Schema.encodeSync(Address);
|
|
10
|
-
const decode = Schema.decodeSync(Address);
|
|
11
|
-
|
|
12
|
-
it("should convert to and from proto", () => {
|
|
13
|
-
const address = "0x27504265a9bc4330e3fe82061a60cd8b6369b4dc";
|
|
14
|
-
|
|
15
|
-
const message = encode(address);
|
|
16
|
-
|
|
17
|
-
expect(message.x0).toBeDefined();
|
|
18
|
-
expect(message.x1).toBeDefined();
|
|
19
|
-
expect(message.x2).toBeDefined();
|
|
20
|
-
|
|
21
|
-
const back = decode(message);
|
|
22
|
-
expect(back).toEqual(pad(address, { size: 20 }));
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe("B256", () => {
|
|
27
|
-
const encode = Schema.encodeSync(B256);
|
|
28
|
-
const decode = Schema.decodeSync(B256);
|
|
29
|
-
|
|
30
|
-
it("should convert to and from proto", () => {
|
|
31
|
-
const value =
|
|
32
|
-
"0x9df92d765b5aa041fd4bbe8d5878eb89290efa78e444c1a603eecfae2ea05fa4";
|
|
33
|
-
const message = encode(value);
|
|
34
|
-
|
|
35
|
-
expect(message.x0).toBeDefined();
|
|
36
|
-
expect(message.x1).toBeDefined();
|
|
37
|
-
expect(message.x2).toBeDefined();
|
|
38
|
-
expect(message.x3).toBeDefined();
|
|
39
|
-
|
|
40
|
-
const back = decode(message);
|
|
41
|
-
expect(back).toEqual(pad(value, { size: 32 }));
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe("U256", () => {
|
|
46
|
-
const encode = Schema.encodeSync(U256);
|
|
47
|
-
const decode = Schema.decodeSync(U256);
|
|
48
|
-
|
|
49
|
-
it("should convert to and from proto", () => {
|
|
50
|
-
const value = BigInt(
|
|
51
|
-
"0x9df92d765b5aa041fd4bbe8d5878eb89290efa78e444c1a603eecfae2ea05fa4",
|
|
52
|
-
);
|
|
53
|
-
const message = encode(value);
|
|
54
|
-
|
|
55
|
-
expect(message.x0).toBeDefined();
|
|
56
|
-
expect(message.x1).toBeDefined();
|
|
57
|
-
expect(message.x2).toBeDefined();
|
|
58
|
-
expect(message.x3).toBeDefined();
|
|
59
|
-
|
|
60
|
-
const back = decode(message);
|
|
61
|
-
expect(back).toEqual(value);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe("U128", () => {
|
|
66
|
-
const encode = Schema.encodeSync(U128);
|
|
67
|
-
const decode = Schema.decodeSync(U128);
|
|
68
|
-
|
|
69
|
-
it("should convert to and from proto", () => {
|
|
70
|
-
const value = BigInt("0x090efa78e444c1a603eecfae2ea05fa4");
|
|
71
|
-
const message = encode(value);
|
|
72
|
-
|
|
73
|
-
expect(message.x0).toBeDefined();
|
|
74
|
-
expect(message.x1).toBeDefined();
|
|
75
|
-
|
|
76
|
-
const back = decode(message);
|
|
77
|
-
expect(back).toEqual(value);
|
|
78
|
-
});
|
|
79
|
-
});
|
package/src/filter.test.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { encodeEventTopics, pad, parseAbi } from "viem";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { Schema } from "@effect/schema";
|
|
5
|
-
import {
|
|
6
|
-
Filter,
|
|
7
|
-
LogFilter,
|
|
8
|
-
filterFromProto,
|
|
9
|
-
filterToProto,
|
|
10
|
-
mergeFilter,
|
|
11
|
-
} from "./filter";
|
|
12
|
-
|
|
13
|
-
const abi = parseAbi([
|
|
14
|
-
"event Transfer(address indexed from, address indexed to, uint256 value)",
|
|
15
|
-
]);
|
|
16
|
-
|
|
17
|
-
describe("Filter", () => {
|
|
18
|
-
it("all filters are optional", () => {
|
|
19
|
-
const filter = Filter.make({});
|
|
20
|
-
|
|
21
|
-
const proto = filterToProto(filter);
|
|
22
|
-
const back = filterFromProto(proto);
|
|
23
|
-
expect(back).toEqual(filter);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("accepts logs filter", () => {
|
|
27
|
-
const filter = Filter.make({
|
|
28
|
-
logs: [
|
|
29
|
-
{
|
|
30
|
-
address: "0x123456789012",
|
|
31
|
-
strict: true,
|
|
32
|
-
topics: encodeEventTopics({
|
|
33
|
-
abi,
|
|
34
|
-
eventName: "Transfer",
|
|
35
|
-
args: { from: null, to: null },
|
|
36
|
-
}) as `0x${string}`[],
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
expect(filter.logs).toHaveLength(1);
|
|
42
|
-
|
|
43
|
-
const proto = filterToProto(filter);
|
|
44
|
-
const back = filterFromProto(proto);
|
|
45
|
-
|
|
46
|
-
expect(back).toBeDefined();
|
|
47
|
-
expect(back.logs).toHaveLength(1);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe("LogFilter", () => {
|
|
52
|
-
const encode = Schema.encodeSync(LogFilter);
|
|
53
|
-
const decode = Schema.decodeSync(LogFilter);
|
|
54
|
-
|
|
55
|
-
it("can be empty", () => {
|
|
56
|
-
const filter = LogFilter.make({});
|
|
57
|
-
|
|
58
|
-
const proto = encode(filter);
|
|
59
|
-
const back = decode(proto);
|
|
60
|
-
expect(back).toEqual(filter);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("can have null topics", () => {
|
|
64
|
-
const filter = LogFilter.make({
|
|
65
|
-
topics: [null, pad("0x1"), null, pad("0x3")],
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const proto = encode(filter);
|
|
69
|
-
const back = decode(proto);
|
|
70
|
-
expect(back).toEqual(filter);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("can have all optional fields", () => {
|
|
74
|
-
const filter = LogFilter.make({
|
|
75
|
-
address: pad("0xa", { size: 20 }),
|
|
76
|
-
topics: [null, pad("0x1"), null, pad("0x3")],
|
|
77
|
-
includeTransaction: true,
|
|
78
|
-
includeReceipt: true,
|
|
79
|
-
strict: true,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const proto = encode(filter);
|
|
83
|
-
const back = decode(proto);
|
|
84
|
-
expect(back).toEqual(filter);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe("mergeFilter", () => {
|
|
89
|
-
it("returns header.always if any has it", () => {
|
|
90
|
-
const fa = mergeFilter({}, { header: "always" });
|
|
91
|
-
expect(fa).toMatchInlineSnapshot(`
|
|
92
|
-
{
|
|
93
|
-
"header": "always",
|
|
94
|
-
"logs": [],
|
|
95
|
-
"transactions": [],
|
|
96
|
-
"withdrawals": [],
|
|
97
|
-
}
|
|
98
|
-
`);
|
|
99
|
-
const fb = mergeFilter({ header: "always" }, {});
|
|
100
|
-
expect(fb).toMatchInlineSnapshot(`
|
|
101
|
-
{
|
|
102
|
-
"header": "always",
|
|
103
|
-
"logs": [],
|
|
104
|
-
"transactions": [],
|
|
105
|
-
"withdrawals": [],
|
|
106
|
-
}
|
|
107
|
-
`);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("returns an empty header by default", () => {
|
|
111
|
-
const f = mergeFilter({}, {});
|
|
112
|
-
expect(f).toMatchInlineSnapshot(`
|
|
113
|
-
{
|
|
114
|
-
"header": undefined,
|
|
115
|
-
"logs": [],
|
|
116
|
-
"transactions": [],
|
|
117
|
-
"withdrawals": [],
|
|
118
|
-
}
|
|
119
|
-
`);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("concatenates logs", () => {
|
|
123
|
-
const f = mergeFilter(
|
|
124
|
-
{ logs: [{ address: "0xAAAAAAAAAAAAAAAAAAAAAA" }] },
|
|
125
|
-
{ logs: [{ address: "0xBBBBBBBBBBBBBBBBBBBBBB" }] },
|
|
126
|
-
);
|
|
127
|
-
expect(f).toMatchInlineSnapshot(`
|
|
128
|
-
{
|
|
129
|
-
"header": undefined,
|
|
130
|
-
"logs": [
|
|
131
|
-
{
|
|
132
|
-
"address": "0xAAAAAAAAAAAAAAAAAAAAAA",
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
"address": "0xBBBBBBBBBBBBBBBBBBBBBB",
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
"transactions": [],
|
|
139
|
-
"withdrawals": [],
|
|
140
|
-
}
|
|
141
|
-
`);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("concatenates transactions", () => {
|
|
145
|
-
const f = mergeFilter(
|
|
146
|
-
{ transactions: [{ from: "0xAAAAAAAAAAAAAAAAAAAAAA" }] },
|
|
147
|
-
{ transactions: [{ from: "0xBBBBBBBBBBBBBBBBBBBBBB" }] },
|
|
148
|
-
);
|
|
149
|
-
expect(f).toMatchInlineSnapshot(`
|
|
150
|
-
{
|
|
151
|
-
"header": undefined,
|
|
152
|
-
"logs": [],
|
|
153
|
-
"transactions": [
|
|
154
|
-
{
|
|
155
|
-
"from": "0xAAAAAAAAAAAAAAAAAAAAAA",
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"from": "0xBBBBBBBBBBBBBBBBBBBBBB",
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
"withdrawals": [],
|
|
162
|
-
}
|
|
163
|
-
`);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it("concatenates withdrawals", () => {
|
|
167
|
-
const f = mergeFilter(
|
|
168
|
-
{ withdrawals: [{ validatorIndex: 1 }] },
|
|
169
|
-
{ withdrawals: [{ validatorIndex: 100 }] },
|
|
170
|
-
);
|
|
171
|
-
expect(f).toMatchInlineSnapshot(`
|
|
172
|
-
{
|
|
173
|
-
"header": undefined,
|
|
174
|
-
"logs": [],
|
|
175
|
-
"transactions": [],
|
|
176
|
-
"withdrawals": [
|
|
177
|
-
{
|
|
178
|
-
"validatorIndex": 1,
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"validatorIndex": 100,
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
}
|
|
185
|
-
`);
|
|
186
|
-
});
|
|
187
|
-
});
|