@apibara/starknet 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 +638 -768
- package/dist/index.d.cts +4994 -4857
- package/dist/index.d.mts +4994 -4857
- package/dist/index.d.ts +4994 -4857
- package/dist/index.mjs +639 -761
- package/dist/parser.d.cts +3 -3
- package/dist/parser.d.mts +3 -3
- package/dist/parser.d.ts +3 -3
- package/dist/shared/starknet.e649ecb1.d.cts +40 -0
- package/dist/shared/starknet.e649ecb1.d.mts +40 -0
- package/dist/shared/starknet.e649ecb1.d.ts +40 -0
- package/package.json +2 -3
- package/src/block.ts +827 -565
- package/src/common.ts +20 -35
- package/src/filter.ts +235 -268
- package/dist/shared/starknet.2b19268a.d.cts +0 -32
- package/dist/shared/starknet.2b19268a.d.mts +0 -32
- package/dist/shared/starknet.2b19268a.d.ts +0 -32
- package/src/common.test.ts +0 -21
- package/src/filter.test.ts +0 -832
- package/src/helpers.ts +0 -8
- package/src/parser.test.ts +0 -169
package/src/common.ts
CHANGED
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Codec, CodecType } from "@apibara/protocol/codec";
|
|
2
|
+
import type * as proto from "./proto";
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
Schema.Literal("0x"),
|
|
5
|
-
Schema.String,
|
|
6
|
-
);
|
|
4
|
+
const MAX_U64 = 0xffffffffffffffffn;
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/** Field element. */
|
|
17
|
-
export const FieldElement = Schema.transform(FieldElementProto, _FieldElement, {
|
|
18
|
-
decode(value) {
|
|
19
|
-
const x0 = value.x0.toString(16).padStart(16, "0");
|
|
20
|
-
const x1 = value.x1.toString(16).padStart(16, "0");
|
|
21
|
-
const x2 = value.x2.toString(16).padStart(16, "0");
|
|
22
|
-
const x3 = value.x3.toString(16).padStart(16, "0");
|
|
23
|
-
return `0x${x0}${x1}${x2}${x3}` as `0x${string}`;
|
|
24
|
-
},
|
|
25
|
-
encode(value) {
|
|
26
|
-
const bn = BigInt(value);
|
|
27
|
-
const hex = bn.toString(16).padStart(64, "0");
|
|
28
|
-
const s = hex.length;
|
|
29
|
-
const x3 = BigInt(`0x${hex.slice(s - 16, s)}`);
|
|
30
|
-
const x2 = BigInt(`0x${hex.slice(s - 32, s - 16)}`);
|
|
31
|
-
const x1 = BigInt(`0x${hex.slice(s - 48, s - 32)}`);
|
|
32
|
-
const x0 = BigInt(`0x${hex.slice(s - 64, s - 48)}`);
|
|
6
|
+
export const FieldElement: Codec<`0x${string}`, proto.common.FieldElement> = {
|
|
7
|
+
encode(x) {
|
|
8
|
+
const bn = BigInt(x);
|
|
9
|
+
const x3 = bn & MAX_U64;
|
|
10
|
+
const x2 = (bn >> 64n) & MAX_U64;
|
|
11
|
+
const x1 = (bn >> 128n) & MAX_U64;
|
|
12
|
+
const x0 = (bn >> 192n) & MAX_U64;
|
|
33
13
|
return { x0, x1, x2, x3 };
|
|
34
14
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
15
|
+
decode(p) {
|
|
16
|
+
const x0 = p.x0 ?? 0n;
|
|
17
|
+
const x1 = p.x1 ?? 0n;
|
|
18
|
+
const x2 = p.x2 ?? 0n;
|
|
19
|
+
const x3 = p.x3 ?? 0n;
|
|
20
|
+
const bn = x3 + (x2 << 64n) + (x1 << 128n) + (x0 << 192n);
|
|
21
|
+
return `0x${bn.toString(16).padStart(64, "0")}` as `0x${string}`;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
38
24
|
|
|
39
|
-
export
|
|
40
|
-
export const feltFromProto = Schema.decodeSync(FieldElement);
|
|
25
|
+
export type FieldElement = CodecType<typeof FieldElement>;
|
package/src/filter.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
ArrayCodec,
|
|
3
|
+
BooleanCodec,
|
|
4
|
+
type Codec,
|
|
5
|
+
type CodecType,
|
|
6
|
+
MessageCodec,
|
|
7
|
+
NumberCodec,
|
|
8
|
+
OneOfCodec,
|
|
9
|
+
OptionalCodec,
|
|
10
|
+
} from "@apibara/protocol/codec";
|
|
11
|
+
import { FieldElement } from "./common";
|
|
5
12
|
import * as proto from "./proto";
|
|
6
13
|
|
|
7
14
|
/** Header options.
|
|
@@ -10,90 +17,87 @@ import * as proto from "./proto";
|
|
|
10
17
|
* - `on_data`: receive headers only if any other filter matches.
|
|
11
18
|
* - `on_data_or_on_new_block`: receive headers only if any other filter matches and for "live" blocks.
|
|
12
19
|
*/
|
|
13
|
-
export const HeaderFilter
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
20
|
+
export const HeaderFilter: Codec<
|
|
21
|
+
"always" | "on_data" | "on_data_or_on_new_block" | "unknown",
|
|
22
|
+
proto.filter.HeaderFilter
|
|
23
|
+
> = {
|
|
24
|
+
encode(x) {
|
|
25
|
+
switch (x) {
|
|
26
|
+
case "always":
|
|
27
|
+
return proto.filter.HeaderFilter.ALWAYS;
|
|
28
|
+
case "on_data":
|
|
29
|
+
return proto.filter.HeaderFilter.ON_DATA;
|
|
30
|
+
case "on_data_or_on_new_block":
|
|
31
|
+
return proto.filter.HeaderFilter.ON_DATA_OR_ON_NEW_BLOCK;
|
|
32
|
+
default:
|
|
33
|
+
return proto.filter.HeaderFilter.UNSPECIFIED;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
decode(p) {
|
|
37
|
+
const enumMap = {
|
|
38
|
+
[proto.filter.HeaderFilter.ALWAYS]: "always",
|
|
39
|
+
[proto.filter.HeaderFilter.ON_DATA]: "on_data",
|
|
40
|
+
[proto.filter.HeaderFilter.ON_DATA_OR_ON_NEW_BLOCK]:
|
|
41
|
+
"on_data_or_on_new_block",
|
|
42
|
+
[proto.filter.HeaderFilter.UNSPECIFIED]: "unknown",
|
|
43
|
+
[proto.filter.HeaderFilter.UNRECOGNIZED]: "unknown",
|
|
44
|
+
} as const;
|
|
45
|
+
return enumMap[p] ?? "unknown";
|
|
40
46
|
},
|
|
41
|
-
|
|
47
|
+
};
|
|
42
48
|
|
|
43
|
-
export type HeaderFilter = typeof HeaderFilter
|
|
49
|
+
export type HeaderFilter = CodecType<typeof HeaderFilter>;
|
|
44
50
|
|
|
45
51
|
/** An event key filter. Use `null` to match any event key. */
|
|
46
|
-
export const Key
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
52
|
+
export const Key: Codec<
|
|
53
|
+
FieldElement | null,
|
|
54
|
+
{ value?: proto.common.FieldElement | undefined }
|
|
55
|
+
> = {
|
|
56
|
+
encode(x) {
|
|
57
|
+
if (x === null) {
|
|
58
|
+
return { value: undefined };
|
|
59
|
+
}
|
|
60
|
+
return { value: FieldElement.encode(x) };
|
|
61
|
+
},
|
|
62
|
+
decode(p) {
|
|
63
|
+
if (p.value === undefined) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return FieldElement.decode(p.value);
|
|
62
67
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export type Key = typeof Key
|
|
66
|
-
|
|
67
|
-
export const TransactionStatusFilter
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
switch (value) {
|
|
83
|
-
case "succeeded":
|
|
84
|
-
return proto.filter.TransactionStatusFilter.SUCCEEDED;
|
|
85
|
-
case "reverted":
|
|
86
|
-
return proto.filter.TransactionStatusFilter.REVERTED;
|
|
87
|
-
case "all":
|
|
88
|
-
return proto.filter.TransactionStatusFilter.ALL;
|
|
89
|
-
default:
|
|
90
|
-
return proto.filter.TransactionStatusFilter.UNSPECIFIED;
|
|
91
|
-
}
|
|
92
|
-
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type Key = CodecType<typeof Key>;
|
|
71
|
+
|
|
72
|
+
export const TransactionStatusFilter: Codec<
|
|
73
|
+
"succeeded" | "reverted" | "all" | "unknown",
|
|
74
|
+
proto.filter.TransactionStatusFilter
|
|
75
|
+
> = {
|
|
76
|
+
encode(x) {
|
|
77
|
+
switch (x) {
|
|
78
|
+
case "succeeded":
|
|
79
|
+
return proto.filter.TransactionStatusFilter.SUCCEEDED;
|
|
80
|
+
case "reverted":
|
|
81
|
+
return proto.filter.TransactionStatusFilter.REVERTED;
|
|
82
|
+
case "all":
|
|
83
|
+
return proto.filter.TransactionStatusFilter.ALL;
|
|
84
|
+
default:
|
|
85
|
+
return proto.filter.TransactionStatusFilter.UNSPECIFIED;
|
|
86
|
+
}
|
|
93
87
|
},
|
|
94
|
-
)
|
|
88
|
+
decode(p) {
|
|
89
|
+
const enumMap = {
|
|
90
|
+
[proto.filter.TransactionStatusFilter.SUCCEEDED]: "succeeded",
|
|
91
|
+
[proto.filter.TransactionStatusFilter.REVERTED]: "reverted",
|
|
92
|
+
[proto.filter.TransactionStatusFilter.ALL]: "all",
|
|
93
|
+
[proto.filter.TransactionStatusFilter.UNSPECIFIED]: "unknown",
|
|
94
|
+
[proto.filter.TransactionStatusFilter.UNRECOGNIZED]: "unknown",
|
|
95
|
+
} as const;
|
|
96
|
+
return enumMap[p] ?? "unknown";
|
|
97
|
+
},
|
|
98
|
+
};
|
|
95
99
|
|
|
96
|
-
export type TransactionStatusFilter = typeof TransactionStatusFilter
|
|
100
|
+
export type TransactionStatusFilter = CodecType<typeof TransactionStatusFilter>;
|
|
97
101
|
|
|
98
102
|
/** Filter events.
|
|
99
103
|
*
|
|
@@ -108,20 +112,20 @@ export type TransactionStatusFilter = typeof TransactionStatusFilter.Type;
|
|
|
108
112
|
* @prop includeSiblings Include the sibling events of the matched events.
|
|
109
113
|
* @prop includeTransactionTrace Include the trace of the transaction that emitted the event.
|
|
110
114
|
*/
|
|
111
|
-
export const EventFilter =
|
|
112
|
-
id:
|
|
113
|
-
address:
|
|
114
|
-
keys:
|
|
115
|
-
strict:
|
|
116
|
-
transactionStatus:
|
|
117
|
-
includeTransaction:
|
|
118
|
-
includeReceipt:
|
|
119
|
-
includeMessages:
|
|
120
|
-
includeSiblings:
|
|
121
|
-
includeTransactionTrace:
|
|
115
|
+
export const EventFilter = MessageCodec({
|
|
116
|
+
id: OptionalCodec(NumberCodec),
|
|
117
|
+
address: OptionalCodec(FieldElement),
|
|
118
|
+
keys: OptionalCodec(ArrayCodec(Key)),
|
|
119
|
+
strict: OptionalCodec(BooleanCodec),
|
|
120
|
+
transactionStatus: OptionalCodec(TransactionStatusFilter),
|
|
121
|
+
includeTransaction: OptionalCodec(BooleanCodec),
|
|
122
|
+
includeReceipt: OptionalCodec(BooleanCodec),
|
|
123
|
+
includeMessages: OptionalCodec(BooleanCodec),
|
|
124
|
+
includeSiblings: OptionalCodec(BooleanCodec),
|
|
125
|
+
includeTransactionTrace: OptionalCodec(BooleanCodec),
|
|
122
126
|
});
|
|
123
127
|
|
|
124
|
-
export type EventFilter = typeof EventFilter
|
|
128
|
+
export type EventFilter = Readonly<CodecType<typeof EventFilter>>;
|
|
125
129
|
|
|
126
130
|
/** Filter messages to L1.
|
|
127
131
|
*
|
|
@@ -133,97 +137,74 @@ export type EventFilter = typeof EventFilter.Type;
|
|
|
133
137
|
* @prop includeEvents Include events from the same transaction.
|
|
134
138
|
* @prop includeTransactionTrace Include the trace of the transaction that sent the message.
|
|
135
139
|
*/
|
|
136
|
-
export const MessageToL1Filter =
|
|
137
|
-
id:
|
|
138
|
-
fromAddress:
|
|
139
|
-
toAddress:
|
|
140
|
-
transactionStatus:
|
|
141
|
-
includeTransaction:
|
|
142
|
-
includeReceipt:
|
|
143
|
-
includeEvents:
|
|
144
|
-
includeTransactionTrace:
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
export type MessageToL1Filter = typeof MessageToL1Filter.Type;
|
|
148
|
-
|
|
149
|
-
export const InvokeTransactionV0Filter = Schema.Struct({
|
|
150
|
-
_tag: tag("invokeV0"),
|
|
151
|
-
invokeV0: Schema.Struct({}),
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
export type InvokeTransactionV0Filter = typeof InvokeTransactionV0Filter.Type;
|
|
155
|
-
|
|
156
|
-
export const InvokeTransactionV1Filter = Schema.Struct({
|
|
157
|
-
_tag: tag("invokeV1"),
|
|
158
|
-
invokeV1: Schema.Struct({}),
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
export type InvokeTransactionV1Filter = typeof InvokeTransactionV1Filter.Type;
|
|
162
|
-
|
|
163
|
-
export const InvokeTransactionV3Filter = Schema.Struct({
|
|
164
|
-
_tag: tag("invokeV3"),
|
|
165
|
-
invokeV3: Schema.Struct({}),
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
export type InvokeTransactionV3Filter = typeof InvokeTransactionV3Filter.Type;
|
|
169
|
-
|
|
170
|
-
export const DeployTransactionFilter = Schema.Struct({
|
|
171
|
-
_tag: tag("deploy"),
|
|
172
|
-
deploy: Schema.Struct({}),
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
export type DeployTransactionFilter = typeof DeployTransactionFilter.Type;
|
|
176
|
-
|
|
177
|
-
export const DeclareV0TransactionFilter = Schema.Struct({
|
|
178
|
-
_tag: tag("declareV0"),
|
|
179
|
-
declareV0: Schema.Struct({}),
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
export type DeclareV0TransactionFilter = typeof DeclareV0TransactionFilter.Type;
|
|
183
|
-
|
|
184
|
-
export const DeclareV1TransactionFilter = Schema.Struct({
|
|
185
|
-
_tag: tag("declareV1"),
|
|
186
|
-
declareV1: Schema.Struct({}),
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
export type DeclareV1TransactionFilter = typeof DeclareV1TransactionFilter.Type;
|
|
190
|
-
|
|
191
|
-
export const DeclareV2TransactionFilter = Schema.Struct({
|
|
192
|
-
_tag: tag("declareV2"),
|
|
193
|
-
declareV2: Schema.Struct({}),
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
export type DeclareV2TransactionFilter = typeof DeclareV2TransactionFilter.Type;
|
|
197
|
-
|
|
198
|
-
export const DeclareV3TransactionFilter = Schema.Struct({
|
|
199
|
-
_tag: tag("declareV3"),
|
|
200
|
-
declareV3: Schema.Struct({}),
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
export type DeclareV3TransactionFilter = typeof DeclareV3TransactionFilter.Type;
|
|
204
|
-
|
|
205
|
-
export const L1HandlerTransactionFilter = Schema.Struct({
|
|
206
|
-
_tag: tag("l1Handler"),
|
|
207
|
-
l1Handler: Schema.Struct({}),
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
export type L1HandlerTransactionFilter = typeof L1HandlerTransactionFilter.Type;
|
|
211
|
-
|
|
212
|
-
export const DeployAccountV1TransactionFilter = Schema.Struct({
|
|
213
|
-
_tag: tag("deployAccountV1"),
|
|
214
|
-
deployAccountV1: Schema.Struct({}),
|
|
140
|
+
export const MessageToL1Filter = MessageCodec({
|
|
141
|
+
id: OptionalCodec(NumberCodec),
|
|
142
|
+
fromAddress: OptionalCodec(FieldElement),
|
|
143
|
+
toAddress: OptionalCodec(FieldElement),
|
|
144
|
+
transactionStatus: OptionalCodec(TransactionStatusFilter),
|
|
145
|
+
includeTransaction: OptionalCodec(BooleanCodec),
|
|
146
|
+
includeReceipt: OptionalCodec(BooleanCodec),
|
|
147
|
+
includeEvents: OptionalCodec(BooleanCodec),
|
|
148
|
+
includeTransactionTrace: OptionalCodec(BooleanCodec),
|
|
215
149
|
});
|
|
216
150
|
|
|
217
|
-
export type
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
export const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
export
|
|
226
|
-
|
|
151
|
+
export type MessageToL1Filter = Readonly<CodecType<typeof MessageToL1Filter>>;
|
|
152
|
+
|
|
153
|
+
// Transaction type filters
|
|
154
|
+
export const InvokeTransactionV0Filter = MessageCodec({});
|
|
155
|
+
export type InvokeTransactionV0Filter = Readonly<
|
|
156
|
+
CodecType<typeof InvokeTransactionV0Filter>
|
|
157
|
+
>;
|
|
158
|
+
|
|
159
|
+
export const InvokeTransactionV1Filter = MessageCodec({});
|
|
160
|
+
export type InvokeTransactionV1Filter = Readonly<
|
|
161
|
+
CodecType<typeof InvokeTransactionV1Filter>
|
|
162
|
+
>;
|
|
163
|
+
|
|
164
|
+
export const InvokeTransactionV3Filter = MessageCodec({});
|
|
165
|
+
export type InvokeTransactionV3Filter = Readonly<
|
|
166
|
+
CodecType<typeof InvokeTransactionV3Filter>
|
|
167
|
+
>;
|
|
168
|
+
|
|
169
|
+
export const DeployTransactionFilter = MessageCodec({});
|
|
170
|
+
export type DeployTransactionFilter = Readonly<
|
|
171
|
+
CodecType<typeof DeployTransactionFilter>
|
|
172
|
+
>;
|
|
173
|
+
|
|
174
|
+
export const DeclareV0TransactionFilter = MessageCodec({});
|
|
175
|
+
export type DeclareV0TransactionFilter = Readonly<
|
|
176
|
+
CodecType<typeof DeclareV0TransactionFilter>
|
|
177
|
+
>;
|
|
178
|
+
|
|
179
|
+
export const DeclareV1TransactionFilter = MessageCodec({});
|
|
180
|
+
export type DeclareV1TransactionFilter = Readonly<
|
|
181
|
+
CodecType<typeof DeclareV1TransactionFilter>
|
|
182
|
+
>;
|
|
183
|
+
|
|
184
|
+
export const DeclareV2TransactionFilter = MessageCodec({});
|
|
185
|
+
export type DeclareV2TransactionFilter = Readonly<
|
|
186
|
+
CodecType<typeof DeclareV2TransactionFilter>
|
|
187
|
+
>;
|
|
188
|
+
|
|
189
|
+
export const DeclareV3TransactionFilter = MessageCodec({});
|
|
190
|
+
export type DeclareV3TransactionFilter = Readonly<
|
|
191
|
+
CodecType<typeof DeclareV3TransactionFilter>
|
|
192
|
+
>;
|
|
193
|
+
|
|
194
|
+
export const L1HandlerTransactionFilter = MessageCodec({});
|
|
195
|
+
export type L1HandlerTransactionFilter = Readonly<
|
|
196
|
+
CodecType<typeof L1HandlerTransactionFilter>
|
|
197
|
+
>;
|
|
198
|
+
|
|
199
|
+
export const DeployAccountV1TransactionFilter = MessageCodec({});
|
|
200
|
+
export type DeployAccountV1TransactionFilter = Readonly<
|
|
201
|
+
CodecType<typeof DeployAccountV1TransactionFilter>
|
|
202
|
+
>;
|
|
203
|
+
|
|
204
|
+
export const DeployAccountV3TransactionFilter = MessageCodec({});
|
|
205
|
+
export type DeployAccountV3TransactionFilter = Readonly<
|
|
206
|
+
CodecType<typeof DeployAccountV3TransactionFilter>
|
|
207
|
+
>;
|
|
227
208
|
|
|
228
209
|
/** Filter transactions.
|
|
229
210
|
*
|
|
@@ -233,122 +214,108 @@ export type DeployAccountV3TransactionFilter =
|
|
|
233
214
|
* @prop includeMessages Include messages sent in the transaction.
|
|
234
215
|
* @prop includeTrace Include the transaction's trace.
|
|
235
216
|
*/
|
|
236
|
-
export const TransactionFilter =
|
|
237
|
-
id:
|
|
238
|
-
transactionStatus:
|
|
239
|
-
includeReceipt:
|
|
240
|
-
includeMessages:
|
|
241
|
-
includeEvents:
|
|
242
|
-
includeTrace:
|
|
243
|
-
transactionType:
|
|
244
|
-
|
|
245
|
-
InvokeTransactionV0Filter,
|
|
246
|
-
InvokeTransactionV1Filter,
|
|
247
|
-
InvokeTransactionV3Filter,
|
|
248
|
-
DeployTransactionFilter,
|
|
249
|
-
DeclareV0TransactionFilter,
|
|
250
|
-
DeclareV1TransactionFilter,
|
|
251
|
-
DeclareV2TransactionFilter,
|
|
252
|
-
DeclareV3TransactionFilter,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
),
|
|
217
|
+
export const TransactionFilter = MessageCodec({
|
|
218
|
+
id: OptionalCodec(NumberCodec),
|
|
219
|
+
transactionStatus: OptionalCodec(TransactionStatusFilter),
|
|
220
|
+
includeReceipt: OptionalCodec(BooleanCodec),
|
|
221
|
+
includeMessages: OptionalCodec(BooleanCodec),
|
|
222
|
+
includeEvents: OptionalCodec(BooleanCodec),
|
|
223
|
+
includeTrace: OptionalCodec(BooleanCodec),
|
|
224
|
+
transactionType: OptionalCodec(
|
|
225
|
+
OneOfCodec({
|
|
226
|
+
invokeV0: InvokeTransactionV0Filter,
|
|
227
|
+
invokeV1: InvokeTransactionV1Filter,
|
|
228
|
+
invokeV3: InvokeTransactionV3Filter,
|
|
229
|
+
deploy: DeployTransactionFilter,
|
|
230
|
+
declareV0: DeclareV0TransactionFilter,
|
|
231
|
+
declareV1: DeclareV1TransactionFilter,
|
|
232
|
+
declareV2: DeclareV2TransactionFilter,
|
|
233
|
+
declareV3: DeclareV3TransactionFilter,
|
|
234
|
+
l1Handler: L1HandlerTransactionFilter,
|
|
235
|
+
deployAccountV1: DeployAccountV1TransactionFilter,
|
|
236
|
+
deployAccountV3: DeployAccountV3TransactionFilter,
|
|
237
|
+
}),
|
|
258
238
|
),
|
|
259
239
|
});
|
|
260
240
|
|
|
261
|
-
export type TransactionFilter = typeof TransactionFilter
|
|
241
|
+
export type TransactionFilter = Readonly<CodecType<typeof TransactionFilter>>;
|
|
262
242
|
|
|
263
243
|
/** Filter storage diffs.
|
|
264
244
|
*
|
|
265
245
|
* @prop contractAddress Filter by contract address.
|
|
266
246
|
*/
|
|
267
|
-
export const StorageDiffFilter =
|
|
268
|
-
id:
|
|
269
|
-
contractAddress:
|
|
247
|
+
export const StorageDiffFilter = MessageCodec({
|
|
248
|
+
id: OptionalCodec(NumberCodec),
|
|
249
|
+
contractAddress: OptionalCodec(FieldElement),
|
|
270
250
|
});
|
|
271
251
|
|
|
272
|
-
export type StorageDiffFilter = typeof StorageDiffFilter
|
|
252
|
+
export type StorageDiffFilter = Readonly<CodecType<typeof StorageDiffFilter>>;
|
|
273
253
|
|
|
274
254
|
/** Filter declared classes. */
|
|
275
|
-
export const DeclaredClassFilter =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
255
|
+
export const DeclaredClassFilter = MessageCodec({});
|
|
256
|
+
export type DeclaredClassFilter = Readonly<
|
|
257
|
+
CodecType<typeof DeclaredClassFilter>
|
|
258
|
+
>;
|
|
279
259
|
|
|
280
|
-
export
|
|
260
|
+
export const ReplacedClassFilter = MessageCodec({});
|
|
261
|
+
export type ReplacedClassFilter = Readonly<
|
|
262
|
+
CodecType<typeof ReplacedClassFilter>
|
|
263
|
+
>;
|
|
281
264
|
|
|
282
|
-
export const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
export type ReplacedClassFilter = typeof ReplacedClassFilter.Type;
|
|
288
|
-
|
|
289
|
-
export const DeployedContractFilter = Schema.Struct({
|
|
290
|
-
_tag: tag("deployedContract"),
|
|
291
|
-
deployedContract: Schema.Struct({}),
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
export type DeployedContractFilter = typeof DeployedContractFilter.Type;
|
|
265
|
+
export const DeployedContractFilter = MessageCodec({});
|
|
266
|
+
export type DeployedContractFilter = Readonly<
|
|
267
|
+
CodecType<typeof DeployedContractFilter>
|
|
268
|
+
>;
|
|
295
269
|
|
|
296
270
|
/** Filter contract changes. */
|
|
297
|
-
export const ContractChangeFilter =
|
|
298
|
-
id:
|
|
299
|
-
change:
|
|
300
|
-
|
|
301
|
-
DeclaredClassFilter,
|
|
302
|
-
ReplacedClassFilter,
|
|
303
|
-
DeployedContractFilter,
|
|
304
|
-
),
|
|
271
|
+
export const ContractChangeFilter = MessageCodec({
|
|
272
|
+
id: OptionalCodec(NumberCodec),
|
|
273
|
+
change: OptionalCodec(
|
|
274
|
+
OneOfCodec({
|
|
275
|
+
declaredClass: DeclaredClassFilter,
|
|
276
|
+
replacedClass: ReplacedClassFilter,
|
|
277
|
+
deployedContract: DeployedContractFilter,
|
|
278
|
+
}),
|
|
305
279
|
),
|
|
306
280
|
});
|
|
307
281
|
|
|
308
|
-
export type ContractChangeFilter =
|
|
282
|
+
export type ContractChangeFilter = Readonly<
|
|
283
|
+
CodecType<typeof ContractChangeFilter>
|
|
284
|
+
>;
|
|
309
285
|
|
|
310
286
|
/** Filter updates to nonces.
|
|
311
287
|
*
|
|
312
288
|
* @prop contractAddress Filter by contract address.
|
|
313
289
|
*/
|
|
314
|
-
export const NonceUpdateFilter =
|
|
315
|
-
id:
|
|
316
|
-
contractAddress:
|
|
290
|
+
export const NonceUpdateFilter = MessageCodec({
|
|
291
|
+
id: OptionalCodec(NumberCodec),
|
|
292
|
+
contractAddress: OptionalCodec(FieldElement),
|
|
317
293
|
});
|
|
318
294
|
|
|
319
|
-
export type NonceUpdateFilter = typeof NonceUpdateFilter
|
|
295
|
+
export type NonceUpdateFilter = Readonly<CodecType<typeof NonceUpdateFilter>>;
|
|
320
296
|
|
|
321
|
-
export const Filter =
|
|
322
|
-
header:
|
|
323
|
-
transactions:
|
|
324
|
-
events:
|
|
325
|
-
messages:
|
|
326
|
-
storageDiffs:
|
|
327
|
-
contractChanges:
|
|
328
|
-
nonceUpdates:
|
|
297
|
+
export const Filter = MessageCodec({
|
|
298
|
+
header: OptionalCodec(HeaderFilter),
|
|
299
|
+
transactions: OptionalCodec(ArrayCodec(TransactionFilter)),
|
|
300
|
+
events: OptionalCodec(ArrayCodec(EventFilter)),
|
|
301
|
+
messages: OptionalCodec(ArrayCodec(MessageToL1Filter)),
|
|
302
|
+
storageDiffs: OptionalCodec(ArrayCodec(StorageDiffFilter)),
|
|
303
|
+
contractChanges: OptionalCodec(ArrayCodec(ContractChangeFilter)),
|
|
304
|
+
nonceUpdates: OptionalCodec(ArrayCodec(NonceUpdateFilter)),
|
|
329
305
|
});
|
|
330
306
|
|
|
331
|
-
export type Filter = typeof Filter
|
|
332
|
-
|
|
333
|
-
export const filterToProto = Schema.encodeSync(Filter);
|
|
334
|
-
export const filterFromProto = Schema.decodeSync(Filter);
|
|
335
|
-
|
|
336
|
-
export const FilterFromBytes = Schema.transform(
|
|
337
|
-
Schema.Uint8ArrayFromSelf,
|
|
338
|
-
Filter,
|
|
339
|
-
{
|
|
340
|
-
strict: false,
|
|
341
|
-
decode(value) {
|
|
342
|
-
return proto.filter.Filter.decode(value);
|
|
343
|
-
},
|
|
344
|
-
encode(value) {
|
|
345
|
-
return proto.filter.Filter.encode(value).finish();
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
);
|
|
307
|
+
export type Filter = Readonly<CodecType<typeof Filter>>;
|
|
349
308
|
|
|
350
|
-
export const
|
|
351
|
-
|
|
309
|
+
export const FilterFromBytes: Codec<Filter, Uint8Array> = {
|
|
310
|
+
encode(x) {
|
|
311
|
+
const filter = Filter.encode(x);
|
|
312
|
+
return proto.filter.Filter.encode(filter).finish();
|
|
313
|
+
},
|
|
314
|
+
decode(p) {
|
|
315
|
+
const filter = proto.filter.Filter.decode(p);
|
|
316
|
+
return Filter.decode(filter);
|
|
317
|
+
},
|
|
318
|
+
};
|
|
352
319
|
|
|
353
320
|
export function mergeFilter(a: Filter, b: Filter): Filter {
|
|
354
321
|
const header = mergeHeaderFilter(a.header, b.header);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as _effect_schema_AST from '@effect/schema/AST';
|
|
2
|
-
import { Schema } from '@effect/schema';
|
|
3
|
-
|
|
4
|
-
/** Wire representation of `FieldElement`. */
|
|
5
|
-
declare const FieldElementProto: Schema.Struct<{
|
|
6
|
-
x0: typeof Schema.BigIntFromSelf;
|
|
7
|
-
x1: typeof Schema.BigIntFromSelf;
|
|
8
|
-
x2: typeof Schema.BigIntFromSelf;
|
|
9
|
-
x3: typeof Schema.BigIntFromSelf;
|
|
10
|
-
}>;
|
|
11
|
-
/** Field element. */
|
|
12
|
-
declare const FieldElement: Schema.transform<Schema.Struct<{
|
|
13
|
-
x0: typeof Schema.BigIntFromSelf;
|
|
14
|
-
x1: typeof Schema.BigIntFromSelf;
|
|
15
|
-
x2: typeof Schema.BigIntFromSelf;
|
|
16
|
-
x3: typeof Schema.BigIntFromSelf;
|
|
17
|
-
}>, Schema.SchemaClass<`0x${string}`, `0x${string}`, never>>;
|
|
18
|
-
type FieldElement = Schema.Schema.Type<typeof FieldElement>;
|
|
19
|
-
declare const feltToProto: (a: `0x${string}`, overrideOptions?: _effect_schema_AST.ParseOptions) => {
|
|
20
|
-
readonly x0: bigint;
|
|
21
|
-
readonly x1: bigint;
|
|
22
|
-
readonly x2: bigint;
|
|
23
|
-
readonly x3: bigint;
|
|
24
|
-
};
|
|
25
|
-
declare const feltFromProto: (i: {
|
|
26
|
-
readonly x0: bigint;
|
|
27
|
-
readonly x1: bigint;
|
|
28
|
-
readonly x2: bigint;
|
|
29
|
-
readonly x3: bigint;
|
|
30
|
-
}, overrideOptions?: _effect_schema_AST.ParseOptions) => `0x${string}`;
|
|
31
|
-
|
|
32
|
-
export { FieldElement as F, FieldElementProto as a, feltFromProto as b, feltToProto as f };
|