@apibara/starknet 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 +1666 -691
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5193 -4382
- package/dist/index.d.mts +5193 -4382
- package/dist/index.d.ts +5193 -4382
- package/dist/index.mjs +1660 -686
- package/dist/index.mjs.map +1 -0
- package/dist/parser.cjs +59 -5
- package/dist/parser.cjs.map +1 -0
- package/dist/parser.d.cts +20 -13
- package/dist/parser.d.mts +20 -13
- package/dist/parser.d.ts +20 -13
- package/dist/parser.mjs +58 -6
- package/dist/parser.mjs.map +1 -0
- 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 +5 -7
- package/src/abi-wan-helpers.ts +181 -0
- package/src/abi.ts +6 -0
- package/src/block.ts +907 -423
- package/src/common.ts +20 -35
- package/src/event.ts +192 -44
- package/src/filter.ts +240 -239
- package/src/index.ts +3 -0
- package/src/parser.ts +102 -6
- package/src/proto/data.ts +1104 -2
- package/src/proto/filter.ts +76 -2
- 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/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
|
*
|
|
@@ -106,20 +110,22 @@ export type TransactionStatusFilter = typeof TransactionStatusFilter.Type;
|
|
|
106
110
|
* @prop includeReceipt Include the transaction receipt.
|
|
107
111
|
* @prop includeMessages Include the messages that were sent to L1 in the same transaction.
|
|
108
112
|
* @prop includeSiblings Include the sibling events of the matched events.
|
|
113
|
+
* @prop includeTransactionTrace Include the trace of the transaction that emitted the event.
|
|
109
114
|
*/
|
|
110
|
-
export const EventFilter =
|
|
111
|
-
id:
|
|
112
|
-
address:
|
|
113
|
-
keys:
|
|
114
|
-
strict:
|
|
115
|
-
transactionStatus:
|
|
116
|
-
includeTransaction:
|
|
117
|
-
includeReceipt:
|
|
118
|
-
includeMessages:
|
|
119
|
-
includeSiblings:
|
|
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),
|
|
120
126
|
});
|
|
121
127
|
|
|
122
|
-
export type EventFilter = typeof EventFilter
|
|
128
|
+
export type EventFilter = Readonly<CodecType<typeof EventFilter>>;
|
|
123
129
|
|
|
124
130
|
/** Filter messages to L1.
|
|
125
131
|
*
|
|
@@ -129,73 +135,76 @@ export type EventFilter = typeof EventFilter.Type;
|
|
|
129
135
|
* @prop includeTransaction Include the transaction that sent the message.
|
|
130
136
|
* @prop includeReceipt Include the transaction receipt.
|
|
131
137
|
* @prop includeEvents Include events from the same transaction.
|
|
138
|
+
* @prop includeTransactionTrace Include the trace of the transaction that sent the message.
|
|
132
139
|
*/
|
|
133
|
-
export const MessageToL1Filter =
|
|
134
|
-
id:
|
|
135
|
-
fromAddress:
|
|
136
|
-
toAddress:
|
|
137
|
-
transactionStatus:
|
|
138
|
-
includeTransaction:
|
|
139
|
-
includeReceipt:
|
|
140
|
-
includeEvents:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
export type MessageToL1Filter = typeof MessageToL1Filter.Type;
|
|
144
|
-
|
|
145
|
-
export const InvokeTransactionV0Filter = Schema.Struct({
|
|
146
|
-
_tag: tag("invokeV0"),
|
|
147
|
-
invokeV0: 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),
|
|
148
149
|
});
|
|
149
150
|
|
|
150
|
-
export
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
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
|
+
>;
|
|
199
208
|
|
|
200
209
|
/** Filter transactions.
|
|
201
210
|
*
|
|
@@ -203,118 +212,110 @@ export const DeployAccountV3TransactionFilter = Schema.Struct({
|
|
|
203
212
|
* @prop includeReceipt Include the transaction receipt.
|
|
204
213
|
* @prop includeEvents Include events from the same transaction.
|
|
205
214
|
* @prop includeMessages Include messages sent in the transaction.
|
|
215
|
+
* @prop includeTrace Include the transaction's trace.
|
|
206
216
|
*/
|
|
207
|
-
export const TransactionFilter =
|
|
208
|
-
id:
|
|
209
|
-
transactionStatus:
|
|
210
|
-
includeReceipt:
|
|
211
|
-
includeMessages:
|
|
212
|
-
includeEvents:
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
DeclareV3TransactionFilter,
|
|
224
|
-
L1HandlerTransactionFilter,
|
|
225
|
-
DeployAccountV1TransactionFilter,
|
|
226
|
-
DeployAccountV3TransactionFilter,
|
|
227
|
-
),
|
|
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
|
+
}),
|
|
228
238
|
),
|
|
229
239
|
});
|
|
230
240
|
|
|
231
|
-
export type TransactionFilter = typeof TransactionFilter
|
|
241
|
+
export type TransactionFilter = Readonly<CodecType<typeof TransactionFilter>>;
|
|
232
242
|
|
|
233
243
|
/** Filter storage diffs.
|
|
234
244
|
*
|
|
235
245
|
* @prop contractAddress Filter by contract address.
|
|
236
246
|
*/
|
|
237
|
-
export const StorageDiffFilter =
|
|
238
|
-
id:
|
|
239
|
-
contractAddress:
|
|
247
|
+
export const StorageDiffFilter = MessageCodec({
|
|
248
|
+
id: OptionalCodec(NumberCodec),
|
|
249
|
+
contractAddress: OptionalCodec(FieldElement),
|
|
240
250
|
});
|
|
241
251
|
|
|
242
|
-
export type StorageDiffFilter = typeof StorageDiffFilter
|
|
252
|
+
export type StorageDiffFilter = Readonly<CodecType<typeof StorageDiffFilter>>;
|
|
243
253
|
|
|
244
254
|
/** Filter declared classes. */
|
|
245
|
-
export const DeclaredClassFilter =
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
export type DeclaredClassFilter = typeof DeclaredClassFilter.Type;
|
|
255
|
+
export const DeclaredClassFilter = MessageCodec({});
|
|
256
|
+
export type DeclaredClassFilter = Readonly<
|
|
257
|
+
CodecType<typeof DeclaredClassFilter>
|
|
258
|
+
>;
|
|
251
259
|
|
|
252
|
-
export const ReplacedClassFilter =
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
export type ReplacedClassFilter = typeof ReplacedClassFilter.Type;
|
|
260
|
+
export const ReplacedClassFilter = MessageCodec({});
|
|
261
|
+
export type ReplacedClassFilter = Readonly<
|
|
262
|
+
CodecType<typeof ReplacedClassFilter>
|
|
263
|
+
>;
|
|
258
264
|
|
|
259
|
-
export const DeployedContractFilter =
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
export type DeployedContractFilter = typeof DeployedContractFilter.Type;
|
|
265
|
+
export const DeployedContractFilter = MessageCodec({});
|
|
266
|
+
export type DeployedContractFilter = Readonly<
|
|
267
|
+
CodecType<typeof DeployedContractFilter>
|
|
268
|
+
>;
|
|
265
269
|
|
|
266
270
|
/** Filter contract changes. */
|
|
267
|
-
export const ContractChangeFilter =
|
|
268
|
-
id:
|
|
269
|
-
change:
|
|
270
|
-
|
|
271
|
-
DeclaredClassFilter,
|
|
272
|
-
ReplacedClassFilter,
|
|
273
|
-
DeployedContractFilter,
|
|
274
|
-
),
|
|
271
|
+
export const ContractChangeFilter = MessageCodec({
|
|
272
|
+
id: OptionalCodec(NumberCodec),
|
|
273
|
+
change: OptionalCodec(
|
|
274
|
+
OneOfCodec({
|
|
275
|
+
declaredClass: DeclaredClassFilter,
|
|
276
|
+
replacedClass: ReplacedClassFilter,
|
|
277
|
+
deployedContract: DeployedContractFilter,
|
|
278
|
+
}),
|
|
275
279
|
),
|
|
276
280
|
});
|
|
277
281
|
|
|
282
|
+
export type ContractChangeFilter = Readonly<
|
|
283
|
+
CodecType<typeof ContractChangeFilter>
|
|
284
|
+
>;
|
|
285
|
+
|
|
278
286
|
/** Filter updates to nonces.
|
|
279
287
|
*
|
|
280
288
|
* @prop contractAddress Filter by contract address.
|
|
281
289
|
*/
|
|
282
|
-
export const NonceUpdateFilter =
|
|
283
|
-
id:
|
|
284
|
-
contractAddress:
|
|
290
|
+
export const NonceUpdateFilter = MessageCodec({
|
|
291
|
+
id: OptionalCodec(NumberCodec),
|
|
292
|
+
contractAddress: OptionalCodec(FieldElement),
|
|
285
293
|
});
|
|
286
294
|
|
|
287
|
-
export
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
+
export type NonceUpdateFilter = Readonly<CodecType<typeof NonceUpdateFilter>>;
|
|
296
|
+
|
|
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)),
|
|
295
305
|
});
|
|
296
306
|
|
|
297
|
-
export type Filter = typeof Filter
|
|
298
|
-
|
|
299
|
-
export const filterToProto = Schema.encodeSync(Filter);
|
|
300
|
-
export const filterFromProto = Schema.decodeSync(Filter);
|
|
301
|
-
|
|
302
|
-
export const FilterFromBytes = Schema.transform(
|
|
303
|
-
Schema.Uint8ArrayFromSelf,
|
|
304
|
-
Filter,
|
|
305
|
-
{
|
|
306
|
-
strict: false,
|
|
307
|
-
decode(value) {
|
|
308
|
-
return proto.filter.Filter.decode(value);
|
|
309
|
-
},
|
|
310
|
-
encode(value) {
|
|
311
|
-
return proto.filter.Filter.encode(value).finish();
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
);
|
|
307
|
+
export type Filter = Readonly<CodecType<typeof Filter>>;
|
|
315
308
|
|
|
316
|
-
export const
|
|
317
|
-
|
|
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
|
+
};
|
|
318
319
|
|
|
319
320
|
export function mergeFilter(a: Filter, b: Filter): Filter {
|
|
320
321
|
const header = mergeHeaderFilter(a.header, b.header);
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,8 @@ export { getBigIntSelector, getEventSelector, getSelector } from "./abi";
|
|
|
15
15
|
|
|
16
16
|
declare module "abi-wan-kanabi" {
|
|
17
17
|
interface Config {
|
|
18
|
+
AddressType: `0x${string}`;
|
|
19
|
+
ClassHashType: `0x${string}`;
|
|
18
20
|
FeltType: bigint;
|
|
19
21
|
BigIntType: bigint;
|
|
20
22
|
U256Type: bigint;
|
|
@@ -25,4 +27,5 @@ export const StarknetStream = new StreamConfig(
|
|
|
25
27
|
FilterFromBytes,
|
|
26
28
|
BlockFromBytes,
|
|
27
29
|
mergeFilter,
|
|
30
|
+
"starknet",
|
|
28
31
|
);
|