@apibara/starknet 0.2.1 → 0.3.1
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/cursor.d.ts +2 -2
- package/dist/cursor.js +1 -1
- package/dist/cursor.js.map +1 -1
- package/dist/felt.d.ts +1 -1
- package/dist/felt.js +5 -5
- package/dist/felt.js.map +1 -1
- package/dist/felt.test.js +9 -9
- package/dist/felt.test.js.map +1 -1
- package/dist/filter.d.ts +47 -1
- package/dist/filter.js +83 -2
- package/dist/filter.js.map +1 -1
- package/dist/filter.test.js +76 -22
- package/dist/filter.test.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js.map +1 -1
- package/dist/proto/filter.proto +26 -0
- package/dist/proto/generated.d.ts +493 -0
- package/dist/proto/generated.js +4613 -3289
- package/dist/proto/generated.js.map +1 -1
- package/dist/proto/index.d.ts +1 -1
- package/dist/proto/index.js.map +1 -1
- package/dist/proto/starknet.proto +33 -3
- package/package.json +4 -8
- package/src/cursor.ts +14 -8
- package/src/felt.test.ts +21 -19
- package/src/felt.ts +22 -22
- package/src/filter.test.ts +129 -53
- package/src/filter.ts +309 -152
- package/src/index.ts +4 -4
- package/src/proto/filter.proto +26 -0
- package/src/proto/generated.d.ts +493 -0
- package/src/proto/generated.js +4690 -3288
- package/src/proto/index.ts +2 -2
- package/src/proto/starknet.proto +33 -3
package/src/filter.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v1alpha2 } from
|
|
1
|
+
import { v1alpha2 } from "./proto";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Helper functions to create StarkNet data filters.
|
|
@@ -28,13 +28,13 @@ export const Filter = {
|
|
|
28
28
|
* Creates a new state update filter.
|
|
29
29
|
*/
|
|
30
30
|
stateUpdate: () => new StateUpdateFilter(),
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
|
|
33
33
|
export class FilterBuilder {
|
|
34
|
-
private inner: v1alpha2.Filter
|
|
34
|
+
private inner: v1alpha2.Filter;
|
|
35
35
|
|
|
36
36
|
constructor() {
|
|
37
|
-
this.inner = new v1alpha2.Filter()
|
|
37
|
+
this.inner = new v1alpha2.Filter();
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -44,9 +44,9 @@ export class FilterBuilder {
|
|
|
44
44
|
* other filter matches.
|
|
45
45
|
*/
|
|
46
46
|
withHeader(args?: { weak?: boolean }) {
|
|
47
|
-
const { weak } = args ?? {}
|
|
48
|
-
this.inner.header = { weak }
|
|
49
|
-
return this
|
|
47
|
+
const { weak } = args ?? {};
|
|
48
|
+
this.inner.header = { weak };
|
|
49
|
+
return this;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -55,10 +55,12 @@ export class FilterBuilder {
|
|
|
55
55
|
addTransaction(
|
|
56
56
|
filterOrBuilder:
|
|
57
57
|
| IEncodableTransactionFilter
|
|
58
|
-
| ((builder: TransactionFilter) => IEncodableTransactionFilter)
|
|
58
|
+
| ((builder: TransactionFilter) => IEncodableTransactionFilter),
|
|
59
59
|
) {
|
|
60
|
-
this.inner.transactions.push(
|
|
61
|
-
|
|
60
|
+
this.inner.transactions.push(
|
|
61
|
+
createFilter(filterOrBuilder, () => new TransactionFilter()),
|
|
62
|
+
);
|
|
63
|
+
return this;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
/**
|
|
@@ -67,10 +69,12 @@ export class FilterBuilder {
|
|
|
67
69
|
addEvent(
|
|
68
70
|
filterOrBuilder:
|
|
69
71
|
| IEncodable<v1alpha2.IEventFilter>
|
|
70
|
-
| ((builder: EventFilter) => IEncodable<v1alpha2.IEventFilter>)
|
|
72
|
+
| ((builder: EventFilter) => IEncodable<v1alpha2.IEventFilter>),
|
|
71
73
|
) {
|
|
72
|
-
this.inner.events.push(
|
|
73
|
-
|
|
74
|
+
this.inner.events.push(
|
|
75
|
+
createFilter(filterOrBuilder, () => new EventFilter()),
|
|
76
|
+
);
|
|
77
|
+
return this;
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
/**
|
|
@@ -79,10 +83,14 @@ export class FilterBuilder {
|
|
|
79
83
|
addMessage(
|
|
80
84
|
filterOrBuilder:
|
|
81
85
|
| IEncodable<v1alpha2.IL2ToL1MessageFilter>
|
|
82
|
-
| ((
|
|
86
|
+
| ((
|
|
87
|
+
builder: L2ToL1MessageFilter,
|
|
88
|
+
) => IEncodable<v1alpha2.IL2ToL1MessageFilter>),
|
|
83
89
|
) {
|
|
84
|
-
this.inner.messages.push(
|
|
85
|
-
|
|
90
|
+
this.inner.messages.push(
|
|
91
|
+
createFilter(filterOrBuilder, () => new L2ToL1MessageFilter()),
|
|
92
|
+
);
|
|
93
|
+
return this;
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
/**
|
|
@@ -91,24 +99,29 @@ export class FilterBuilder {
|
|
|
91
99
|
withStateUpdate(
|
|
92
100
|
filterOrBuilder:
|
|
93
101
|
| IEncodable<v1alpha2.IStateUpdateFilter>
|
|
94
|
-
| ((
|
|
102
|
+
| ((
|
|
103
|
+
filter: StateUpdateFilter,
|
|
104
|
+
) => IEncodable<v1alpha2.IStateUpdateFilter>),
|
|
95
105
|
) {
|
|
96
|
-
this.inner.stateUpdate = createFilter(
|
|
97
|
-
|
|
106
|
+
this.inner.stateUpdate = createFilter(
|
|
107
|
+
filterOrBuilder,
|
|
108
|
+
() => new StateUpdateFilter(),
|
|
109
|
+
);
|
|
110
|
+
return this;
|
|
98
111
|
}
|
|
99
112
|
|
|
100
113
|
/**
|
|
101
114
|
* Returns the filter in encoded form, ready to be added to a request.
|
|
102
115
|
*/
|
|
103
116
|
encode(): Uint8Array {
|
|
104
|
-
return v1alpha2.Filter.encode(this.inner).finish()
|
|
117
|
+
return v1alpha2.Filter.encode(this.inner).finish();
|
|
105
118
|
}
|
|
106
119
|
|
|
107
120
|
/**
|
|
108
121
|
* Returns the filter as a plain object.
|
|
109
122
|
*/
|
|
110
123
|
toObject(): v1alpha2.IFilter {
|
|
111
|
-
return this.inner
|
|
124
|
+
return this.inner;
|
|
112
125
|
}
|
|
113
126
|
}
|
|
114
127
|
|
|
@@ -117,344 +130,376 @@ export class TransactionFilter {
|
|
|
117
130
|
* Includes any transaction type.
|
|
118
131
|
*/
|
|
119
132
|
any() {
|
|
120
|
-
return new AnyTransactionFilter()
|
|
133
|
+
return new AnyTransactionFilter();
|
|
121
134
|
}
|
|
122
135
|
/**
|
|
123
136
|
* Include invoke transactions, V0
|
|
124
137
|
*/
|
|
125
138
|
invokeV0() {
|
|
126
|
-
return new InvokeV0TransactionFilter()
|
|
139
|
+
return new InvokeV0TransactionFilter();
|
|
127
140
|
}
|
|
128
141
|
|
|
129
142
|
/**
|
|
130
143
|
* Include invoke transactions, V1
|
|
131
144
|
*/
|
|
132
145
|
invokeV1() {
|
|
133
|
-
return new InvokeV1TransactionFilter()
|
|
146
|
+
return new InvokeV1TransactionFilter();
|
|
134
147
|
}
|
|
135
148
|
|
|
136
149
|
/**
|
|
137
150
|
* Include deploy transactions
|
|
138
151
|
*/
|
|
139
152
|
deploy() {
|
|
140
|
-
return new DeployTransactionFilter()
|
|
153
|
+
return new DeployTransactionFilter();
|
|
141
154
|
}
|
|
142
155
|
|
|
143
156
|
/**
|
|
144
157
|
* Include declare transactions
|
|
145
158
|
*/
|
|
146
159
|
declare() {
|
|
147
|
-
return new DeclareTransactionFilter()
|
|
160
|
+
return new DeclareTransactionFilter();
|
|
148
161
|
}
|
|
149
162
|
|
|
150
163
|
/**
|
|
151
164
|
* Include l1 handler transactions
|
|
152
165
|
*/
|
|
153
166
|
l1Handler() {
|
|
154
|
-
return new L1HandlerTransactionFilter()
|
|
167
|
+
return new L1HandlerTransactionFilter();
|
|
155
168
|
}
|
|
156
169
|
|
|
157
170
|
/**
|
|
158
171
|
* Include deploy account transactions
|
|
159
172
|
*/
|
|
160
173
|
deployAccount() {
|
|
161
|
-
return new DeployAccountTransactionFilter()
|
|
174
|
+
return new DeployAccountTransactionFilter();
|
|
162
175
|
}
|
|
163
176
|
}
|
|
164
177
|
|
|
165
178
|
export interface IEncodable<T> {
|
|
166
|
-
encode(): T
|
|
179
|
+
encode(): T;
|
|
167
180
|
}
|
|
168
181
|
|
|
169
|
-
export class AnyTransactionFilter
|
|
182
|
+
export class AnyTransactionFilter
|
|
183
|
+
implements IEncodable<v1alpha2.ITransactionFilter>
|
|
184
|
+
{
|
|
170
185
|
encode(): v1alpha2.ITransactionFilter {
|
|
171
|
-
return {}
|
|
186
|
+
return {};
|
|
172
187
|
}
|
|
173
188
|
}
|
|
174
189
|
|
|
175
|
-
type IEncodableTransactionFilter = IEncodable<v1alpha2.ITransactionFilter
|
|
190
|
+
type IEncodableTransactionFilter = IEncodable<v1alpha2.ITransactionFilter>;
|
|
176
191
|
|
|
177
192
|
export class InvokeV0TransactionFilter implements IEncodableTransactionFilter {
|
|
178
|
-
private inner: v1alpha2.IInvokeTransactionV0Filter
|
|
193
|
+
private inner: v1alpha2.IInvokeTransactionV0Filter;
|
|
179
194
|
|
|
180
195
|
constructor() {
|
|
181
|
-
this.inner = {}
|
|
196
|
+
this.inner = {};
|
|
182
197
|
}
|
|
183
198
|
|
|
184
199
|
/**
|
|
185
200
|
* Filter by contract address.
|
|
186
201
|
*/
|
|
187
202
|
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
188
|
-
this.inner.contractAddress = address
|
|
189
|
-
return this
|
|
203
|
+
this.inner.contractAddress = address;
|
|
204
|
+
return this;
|
|
190
205
|
}
|
|
191
206
|
|
|
192
207
|
/**
|
|
193
208
|
* Filter by entry point selector.
|
|
194
209
|
*/
|
|
195
210
|
withEntryPointSelector(selector: v1alpha2.IFieldElement) {
|
|
196
|
-
this.inner.entryPointSelector = selector
|
|
197
|
-
return this
|
|
211
|
+
this.inner.entryPointSelector = selector;
|
|
212
|
+
return this;
|
|
198
213
|
}
|
|
199
214
|
|
|
200
215
|
/**
|
|
201
216
|
* Filter by calldata prefix.
|
|
202
217
|
*/
|
|
203
218
|
withCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
204
|
-
this.inner.calldata = calldata
|
|
205
|
-
return this
|
|
219
|
+
this.inner.calldata = calldata;
|
|
220
|
+
return this;
|
|
206
221
|
}
|
|
207
222
|
|
|
208
223
|
encode(): v1alpha2.ITransactionFilter {
|
|
209
224
|
return {
|
|
210
225
|
invokeV0: this.inner,
|
|
211
|
-
}
|
|
226
|
+
};
|
|
212
227
|
}
|
|
213
228
|
}
|
|
214
229
|
|
|
215
230
|
export class InvokeV1TransactionFilter implements IEncodableTransactionFilter {
|
|
216
|
-
private inner: v1alpha2.IInvokeTransactionV1Filter
|
|
231
|
+
private inner: v1alpha2.IInvokeTransactionV1Filter;
|
|
217
232
|
|
|
218
233
|
constructor() {
|
|
219
|
-
this.inner = {}
|
|
234
|
+
this.inner = {};
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
/**
|
|
223
238
|
* Filter by sender address.
|
|
224
239
|
*/
|
|
225
240
|
withSenderAddress(address: v1alpha2.IFieldElement) {
|
|
226
|
-
this.inner.senderAddress = address
|
|
227
|
-
return this
|
|
241
|
+
this.inner.senderAddress = address;
|
|
242
|
+
return this;
|
|
228
243
|
}
|
|
229
244
|
|
|
230
245
|
/**
|
|
231
246
|
* Filter by calldata prefix.
|
|
232
247
|
*/
|
|
233
248
|
withCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
234
|
-
this.inner.calldata = calldata
|
|
235
|
-
return this
|
|
249
|
+
this.inner.calldata = calldata;
|
|
250
|
+
return this;
|
|
236
251
|
}
|
|
237
252
|
|
|
238
253
|
encode(): v1alpha2.ITransactionFilter {
|
|
239
254
|
return {
|
|
240
255
|
invokeV1: this.inner,
|
|
241
|
-
}
|
|
256
|
+
};
|
|
242
257
|
}
|
|
243
258
|
}
|
|
244
259
|
|
|
245
260
|
export class DeployTransactionFilter implements IEncodableTransactionFilter {
|
|
246
|
-
private inner: v1alpha2.IDeployTransactionFilter
|
|
261
|
+
private inner: v1alpha2.IDeployTransactionFilter;
|
|
247
262
|
|
|
248
263
|
constructor() {
|
|
249
|
-
this.inner = {}
|
|
264
|
+
this.inner = {};
|
|
250
265
|
}
|
|
251
266
|
|
|
252
267
|
/**
|
|
253
268
|
* Filter by contract address salt.
|
|
254
269
|
*/
|
|
255
270
|
withContractAddressSalt(salt: v1alpha2.IFieldElement) {
|
|
256
|
-
this.inner.contractAddressSalt = salt
|
|
257
|
-
return this
|
|
271
|
+
this.inner.contractAddressSalt = salt;
|
|
272
|
+
return this;
|
|
258
273
|
}
|
|
259
274
|
|
|
260
275
|
/**
|
|
261
276
|
* Filter by class hash.
|
|
262
277
|
*/
|
|
263
278
|
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
264
|
-
this.inner.classHash = hash
|
|
265
|
-
return this
|
|
279
|
+
this.inner.classHash = hash;
|
|
280
|
+
return this;
|
|
266
281
|
}
|
|
267
282
|
|
|
268
283
|
/**
|
|
269
284
|
* Filter by constructor calldata prefix.
|
|
270
285
|
*/
|
|
271
286
|
withConstructorCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
272
|
-
this.inner.constructorCalldata = calldata
|
|
273
|
-
return this
|
|
287
|
+
this.inner.constructorCalldata = calldata;
|
|
288
|
+
return this;
|
|
274
289
|
}
|
|
275
290
|
|
|
276
291
|
encode(): v1alpha2.ITransactionFilter {
|
|
277
292
|
return {
|
|
278
293
|
deploy: this.inner,
|
|
279
|
-
}
|
|
294
|
+
};
|
|
280
295
|
}
|
|
281
296
|
}
|
|
282
297
|
|
|
283
298
|
export class DeclareTransactionFilter implements IEncodableTransactionFilter {
|
|
284
|
-
private inner: v1alpha2.IDeclareTransactionFilter
|
|
299
|
+
private inner: v1alpha2.IDeclareTransactionFilter;
|
|
285
300
|
|
|
286
301
|
constructor() {
|
|
287
|
-
this.inner = {}
|
|
302
|
+
this.inner = {};
|
|
288
303
|
}
|
|
289
304
|
|
|
290
305
|
/**
|
|
291
306
|
* Filter by sender address.
|
|
292
307
|
*/
|
|
293
308
|
withSenderAddress(address: v1alpha2.IFieldElement) {
|
|
294
|
-
this.inner.senderAddress = address
|
|
295
|
-
return this
|
|
309
|
+
this.inner.senderAddress = address;
|
|
310
|
+
return this;
|
|
296
311
|
}
|
|
297
312
|
|
|
298
313
|
/**
|
|
299
314
|
* Filter by class hash.
|
|
300
315
|
*/
|
|
301
316
|
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
302
|
-
this.inner.classHash = hash
|
|
303
|
-
return this
|
|
317
|
+
this.inner.classHash = hash;
|
|
318
|
+
return this;
|
|
304
319
|
}
|
|
305
320
|
|
|
306
321
|
encode(): v1alpha2.ITransactionFilter {
|
|
307
322
|
return {
|
|
308
323
|
declare: this.inner,
|
|
309
|
-
}
|
|
324
|
+
};
|
|
310
325
|
}
|
|
311
326
|
}
|
|
312
327
|
|
|
313
328
|
export class L1HandlerTransactionFilter implements IEncodableTransactionFilter {
|
|
314
|
-
private inner: v1alpha2.IL1HandlerTransactionFilter
|
|
329
|
+
private inner: v1alpha2.IL1HandlerTransactionFilter;
|
|
315
330
|
|
|
316
331
|
constructor() {
|
|
317
|
-
this.inner = {}
|
|
332
|
+
this.inner = {};
|
|
318
333
|
}
|
|
319
334
|
|
|
320
335
|
/**
|
|
321
336
|
* Filter by contract address.
|
|
322
337
|
*/
|
|
323
338
|
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
324
|
-
this.inner.contractAddress = address
|
|
325
|
-
return this
|
|
339
|
+
this.inner.contractAddress = address;
|
|
340
|
+
return this;
|
|
326
341
|
}
|
|
327
342
|
|
|
328
343
|
/**
|
|
329
344
|
* Filter by entry point selector.
|
|
330
345
|
*/
|
|
331
346
|
withEntryPointSelector(selector: v1alpha2.IFieldElement) {
|
|
332
|
-
this.inner.entryPointSelector = selector
|
|
333
|
-
return this
|
|
347
|
+
this.inner.entryPointSelector = selector;
|
|
348
|
+
return this;
|
|
334
349
|
}
|
|
335
350
|
|
|
336
351
|
/**
|
|
337
352
|
* Filter by calldata prefix.
|
|
338
353
|
*/
|
|
339
354
|
withCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
340
|
-
this.inner.calldata = calldata
|
|
341
|
-
return this
|
|
355
|
+
this.inner.calldata = calldata;
|
|
356
|
+
return this;
|
|
342
357
|
}
|
|
343
358
|
|
|
344
359
|
encode(): v1alpha2.ITransactionFilter {
|
|
345
360
|
return {
|
|
346
361
|
l1Handler: this.inner,
|
|
347
|
-
}
|
|
362
|
+
};
|
|
348
363
|
}
|
|
349
364
|
}
|
|
350
365
|
|
|
351
|
-
export class DeployAccountTransactionFilter
|
|
352
|
-
|
|
366
|
+
export class DeployAccountTransactionFilter
|
|
367
|
+
implements IEncodableTransactionFilter
|
|
368
|
+
{
|
|
369
|
+
private inner: v1alpha2.IDeployAccountTransactionFilter;
|
|
353
370
|
|
|
354
371
|
constructor() {
|
|
355
|
-
this.inner = {}
|
|
372
|
+
this.inner = {};
|
|
356
373
|
}
|
|
357
374
|
|
|
358
375
|
/**
|
|
359
376
|
* Filter by contract address salt.
|
|
360
377
|
*/
|
|
361
378
|
withContractAddressSalt(salt: v1alpha2.IFieldElement) {
|
|
362
|
-
this.inner.contractAddressSalt = salt
|
|
363
|
-
return this
|
|
379
|
+
this.inner.contractAddressSalt = salt;
|
|
380
|
+
return this;
|
|
364
381
|
}
|
|
365
382
|
|
|
366
383
|
/**
|
|
367
384
|
* Filter by class hash.
|
|
368
385
|
*/
|
|
369
386
|
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
370
|
-
this.inner.classHash = hash
|
|
371
|
-
return this
|
|
387
|
+
this.inner.classHash = hash;
|
|
388
|
+
return this;
|
|
372
389
|
}
|
|
373
390
|
|
|
374
391
|
/**
|
|
375
392
|
* Filter by constructor calldata prefix.
|
|
376
393
|
*/
|
|
377
394
|
withConstructorCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
378
|
-
this.inner.constructorCalldata = calldata
|
|
379
|
-
return this
|
|
395
|
+
this.inner.constructorCalldata = calldata;
|
|
396
|
+
return this;
|
|
380
397
|
}
|
|
381
398
|
|
|
382
399
|
encode(): v1alpha2.ITransactionFilter {
|
|
383
400
|
return {
|
|
384
401
|
deployAccount: this.inner,
|
|
385
|
-
}
|
|
402
|
+
};
|
|
386
403
|
}
|
|
387
404
|
}
|
|
388
405
|
|
|
389
406
|
export class EventFilter implements IEncodable<v1alpha2.IEventFilter> {
|
|
390
|
-
private inner: v1alpha2.IEventFilter
|
|
407
|
+
private inner: v1alpha2.IEventFilter;
|
|
391
408
|
|
|
392
409
|
constructor() {
|
|
393
|
-
this.inner = {}
|
|
410
|
+
this.inner = {};
|
|
394
411
|
}
|
|
395
412
|
|
|
396
413
|
/**
|
|
397
414
|
* Filter by address emitting the event.
|
|
398
415
|
*/
|
|
399
416
|
withFromAddress(address: v1alpha2.IFieldElement) {
|
|
400
|
-
this.inner.fromAddress = address
|
|
401
|
-
return this
|
|
417
|
+
this.inner.fromAddress = address;
|
|
418
|
+
return this;
|
|
402
419
|
}
|
|
403
420
|
|
|
404
421
|
/**
|
|
405
422
|
* Filter by keys prefix.
|
|
406
423
|
*/
|
|
407
424
|
withKeys(keys: v1alpha2.IFieldElement[]) {
|
|
408
|
-
this.inner.keys = keys
|
|
409
|
-
return this
|
|
425
|
+
this.inner.keys = keys;
|
|
426
|
+
return this;
|
|
410
427
|
}
|
|
411
428
|
|
|
412
429
|
/**
|
|
413
430
|
* Filter by data prefix.
|
|
414
431
|
*/
|
|
415
432
|
withData(data: v1alpha2.IFieldElement[]) {
|
|
416
|
-
this.inner.data = data
|
|
417
|
-
return this
|
|
433
|
+
this.inner.data = data;
|
|
434
|
+
return this;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Include events emitted by reverted transactions.
|
|
439
|
+
*/
|
|
440
|
+
withIncludeReverted(includeReverted: boolean) {
|
|
441
|
+
this.inner.includeReverted = includeReverted;
|
|
442
|
+
return this;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Include the transaction that emitted the event. Defaults to true.
|
|
447
|
+
*/
|
|
448
|
+
withIncludeTransaction(includeTransaction: boolean) {
|
|
449
|
+
this.inner.includeTransaction = includeTransaction;
|
|
450
|
+
return this;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Include the receipt of the transaction that emitted the event. Defaults to true.
|
|
455
|
+
*/
|
|
456
|
+
withIncludeReceipt(includeReceipt: boolean) {
|
|
457
|
+
this.inner.includeReceipt = includeReceipt;
|
|
458
|
+
return this;
|
|
418
459
|
}
|
|
419
460
|
|
|
420
461
|
encode(): v1alpha2.IEventFilter {
|
|
421
|
-
return this.inner
|
|
462
|
+
return this.inner;
|
|
422
463
|
}
|
|
423
464
|
}
|
|
424
465
|
|
|
425
|
-
export class L2ToL1MessageFilter
|
|
426
|
-
|
|
466
|
+
export class L2ToL1MessageFilter
|
|
467
|
+
implements IEncodable<v1alpha2.IL2ToL1MessageFilter>
|
|
468
|
+
{
|
|
469
|
+
private inner: v1alpha2.IL2ToL1MessageFilter;
|
|
427
470
|
|
|
428
471
|
constructor() {
|
|
429
|
-
this.inner = {}
|
|
472
|
+
this.inner = {};
|
|
430
473
|
}
|
|
431
474
|
|
|
432
475
|
/**
|
|
433
476
|
* Filter by destination address.
|
|
434
477
|
*/
|
|
435
478
|
withToAddress(address: v1alpha2.IFieldElement) {
|
|
436
|
-
this.inner.toAddress = address
|
|
437
|
-
return this
|
|
479
|
+
this.inner.toAddress = address;
|
|
480
|
+
return this;
|
|
438
481
|
}
|
|
439
482
|
|
|
440
483
|
/**
|
|
441
484
|
* Filter by payload prefix.
|
|
442
485
|
*/
|
|
443
486
|
withPayload(payload: v1alpha2.IFieldElement[]) {
|
|
444
|
-
this.inner.payload = payload
|
|
445
|
-
return this
|
|
487
|
+
this.inner.payload = payload;
|
|
488
|
+
return this;
|
|
446
489
|
}
|
|
447
490
|
|
|
448
491
|
encode(): v1alpha2.IL2ToL1MessageFilter {
|
|
449
|
-
return this.inner
|
|
492
|
+
return this.inner;
|
|
450
493
|
}
|
|
451
494
|
}
|
|
452
495
|
|
|
453
|
-
export class StateUpdateFilter
|
|
454
|
-
|
|
496
|
+
export class StateUpdateFilter
|
|
497
|
+
implements IEncodable<v1alpha2.IStateUpdateFilter>
|
|
498
|
+
{
|
|
499
|
+
private inner: v1alpha2.StateUpdateFilter;
|
|
455
500
|
|
|
456
501
|
constructor() {
|
|
457
|
-
this.inner = new v1alpha2.StateUpdateFilter()
|
|
502
|
+
this.inner = new v1alpha2.StateUpdateFilter();
|
|
458
503
|
}
|
|
459
504
|
|
|
460
505
|
/**
|
|
@@ -463,10 +508,14 @@ export class StateUpdateFilter implements IEncodable<v1alpha2.IStateUpdateFilter
|
|
|
463
508
|
addStorageDiff(
|
|
464
509
|
filterOrBuilder:
|
|
465
510
|
| IEncodable<v1alpha2.IStorageDiffFilter>
|
|
466
|
-
| ((
|
|
511
|
+
| ((
|
|
512
|
+
builder: StorageDiffFilter,
|
|
513
|
+
) => IEncodable<v1alpha2.IStorageDiffFilter>),
|
|
467
514
|
) {
|
|
468
|
-
this.inner.storageDiffs.push(
|
|
469
|
-
|
|
515
|
+
this.inner.storageDiffs.push(
|
|
516
|
+
createFilter(filterOrBuilder, () => new StorageDiffFilter()),
|
|
517
|
+
);
|
|
518
|
+
return this;
|
|
470
519
|
}
|
|
471
520
|
|
|
472
521
|
/**
|
|
@@ -475,12 +524,14 @@ export class StateUpdateFilter implements IEncodable<v1alpha2.IStateUpdateFilter
|
|
|
475
524
|
addDeclaredContract(
|
|
476
525
|
filterOrBuilder:
|
|
477
526
|
| IEncodable<v1alpha2.IDeclaredContractFilter>
|
|
478
|
-
| ((
|
|
527
|
+
| ((
|
|
528
|
+
builder: DeclaredContractFilter,
|
|
529
|
+
) => IEncodable<v1alpha2.IDeclaredContractFilter>),
|
|
479
530
|
) {
|
|
480
531
|
this.inner.declaredContracts.push(
|
|
481
|
-
createFilter(filterOrBuilder, () => new DeclaredContractFilter())
|
|
482
|
-
)
|
|
483
|
-
return this
|
|
532
|
+
createFilter(filterOrBuilder, () => new DeclaredContractFilter()),
|
|
533
|
+
);
|
|
534
|
+
return this;
|
|
484
535
|
}
|
|
485
536
|
|
|
486
537
|
/**
|
|
@@ -489,12 +540,46 @@ export class StateUpdateFilter implements IEncodable<v1alpha2.IStateUpdateFilter
|
|
|
489
540
|
addDeployedContract(
|
|
490
541
|
filterOrBuilder:
|
|
491
542
|
| IEncodable<v1alpha2.IDeployedContractFilter>
|
|
492
|
-
| ((
|
|
543
|
+
| ((
|
|
544
|
+
builder: DeployedContractFilter,
|
|
545
|
+
) => IEncodable<v1alpha2.IDeployedContractFilter>),
|
|
493
546
|
) {
|
|
494
547
|
this.inner.deployedContracts.push(
|
|
495
|
-
createFilter(filterOrBuilder, () => new DeployedContractFilter())
|
|
496
|
-
)
|
|
497
|
-
return this
|
|
548
|
+
createFilter(filterOrBuilder, () => new DeployedContractFilter()),
|
|
549
|
+
);
|
|
550
|
+
return this;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Includes all declared classes that match the filter.
|
|
555
|
+
*/
|
|
556
|
+
addDeclaredClass(
|
|
557
|
+
filterOrBuilder:
|
|
558
|
+
| IEncodable<v1alpha2.IDeclaredClassFilter>
|
|
559
|
+
| ((
|
|
560
|
+
builder: DeclaredClassFilter,
|
|
561
|
+
) => IEncodable<v1alpha2.IDeclaredClassFilter>),
|
|
562
|
+
) {
|
|
563
|
+
this.inner.declaredClasses.push(
|
|
564
|
+
createFilter(filterOrBuilder, () => new DeclaredClassFilter()),
|
|
565
|
+
);
|
|
566
|
+
return this;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Includes all replaced classes that match the filter.
|
|
571
|
+
*/
|
|
572
|
+
addReplacedClass(
|
|
573
|
+
filterOrBuilder:
|
|
574
|
+
| IEncodable<v1alpha2.IReplacedClassFilter>
|
|
575
|
+
| ((
|
|
576
|
+
builder: ReplacedClassFilter,
|
|
577
|
+
) => IEncodable<v1alpha2.IReplacedClassFilter>),
|
|
578
|
+
) {
|
|
579
|
+
this.inner.replacedClasses.push(
|
|
580
|
+
createFilter(filterOrBuilder, () => new ReplacedClassFilter()),
|
|
581
|
+
);
|
|
582
|
+
return this;
|
|
498
583
|
}
|
|
499
584
|
|
|
500
585
|
/**
|
|
@@ -503,122 +588,194 @@ export class StateUpdateFilter implements IEncodable<v1alpha2.IStateUpdateFilter
|
|
|
503
588
|
addNonceUpdate(
|
|
504
589
|
filterOrBuilder:
|
|
505
590
|
| IEncodable<v1alpha2.INonceUpdateFilter>
|
|
506
|
-
| ((
|
|
591
|
+
| ((
|
|
592
|
+
builder: NonceUpdateFilter,
|
|
593
|
+
) => IEncodable<v1alpha2.INonceUpdateFilter>),
|
|
507
594
|
) {
|
|
508
|
-
this.inner.nonces.push(
|
|
509
|
-
|
|
595
|
+
this.inner.nonces.push(
|
|
596
|
+
createFilter(filterOrBuilder, () => new NonceUpdateFilter()),
|
|
597
|
+
);
|
|
598
|
+
return this;
|
|
510
599
|
}
|
|
511
600
|
|
|
512
601
|
encode(): v1alpha2.IStateUpdateFilter {
|
|
513
|
-
return this.inner
|
|
602
|
+
return this.inner;
|
|
514
603
|
}
|
|
515
604
|
}
|
|
516
605
|
|
|
517
|
-
export class StorageDiffFilter
|
|
518
|
-
|
|
606
|
+
export class StorageDiffFilter
|
|
607
|
+
implements IEncodable<v1alpha2.IStorageDiffFilter>
|
|
608
|
+
{
|
|
609
|
+
private inner: v1alpha2.StorageDiffFilter;
|
|
519
610
|
|
|
520
611
|
constructor() {
|
|
521
|
-
this.inner = new v1alpha2.StorageDiffFilter()
|
|
612
|
+
this.inner = new v1alpha2.StorageDiffFilter();
|
|
522
613
|
}
|
|
523
614
|
|
|
524
615
|
/**
|
|
525
616
|
* Filter by contract address.
|
|
526
617
|
*/
|
|
527
618
|
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
528
|
-
this.inner.contractAddress = address
|
|
529
|
-
return this
|
|
619
|
+
this.inner.contractAddress = address;
|
|
620
|
+
return this;
|
|
530
621
|
}
|
|
531
622
|
|
|
532
623
|
encode(): v1alpha2.IStorageDiffFilter {
|
|
533
|
-
return this.inner
|
|
624
|
+
return this.inner;
|
|
534
625
|
}
|
|
535
626
|
}
|
|
536
627
|
|
|
537
|
-
export class DeclaredContractFilter
|
|
538
|
-
|
|
628
|
+
export class DeclaredContractFilter
|
|
629
|
+
implements IEncodable<v1alpha2.IDeclaredContractFilter>
|
|
630
|
+
{
|
|
631
|
+
private inner: v1alpha2.DeclaredContractFilter;
|
|
539
632
|
|
|
540
633
|
constructor() {
|
|
541
|
-
this.inner = new v1alpha2.DeclaredContractFilter()
|
|
634
|
+
this.inner = new v1alpha2.DeclaredContractFilter();
|
|
542
635
|
}
|
|
543
636
|
|
|
544
637
|
/**
|
|
545
638
|
* Filter by class hash.
|
|
546
639
|
*/
|
|
547
640
|
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
548
|
-
this.inner.classHash = hash
|
|
549
|
-
return this
|
|
641
|
+
this.inner.classHash = hash;
|
|
642
|
+
return this;
|
|
550
643
|
}
|
|
551
644
|
|
|
552
645
|
encode(): v1alpha2.IDeclaredContractFilter {
|
|
553
|
-
return this.inner
|
|
646
|
+
return this.inner;
|
|
554
647
|
}
|
|
555
648
|
}
|
|
556
649
|
|
|
557
|
-
export class DeployedContractFilter
|
|
558
|
-
|
|
650
|
+
export class DeployedContractFilter
|
|
651
|
+
implements IEncodable<v1alpha2.IDeployedContractFilter>
|
|
652
|
+
{
|
|
653
|
+
private inner: v1alpha2.DeployedContractFilter;
|
|
559
654
|
|
|
560
655
|
constructor() {
|
|
561
|
-
this.inner = new v1alpha2.DeployedContractFilter()
|
|
656
|
+
this.inner = new v1alpha2.DeployedContractFilter();
|
|
562
657
|
}
|
|
563
658
|
|
|
564
659
|
/**
|
|
565
660
|
* Filter by contract address.
|
|
566
661
|
*/
|
|
567
662
|
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
568
|
-
this.inner.contractAddress = address
|
|
569
|
-
return this
|
|
663
|
+
this.inner.contractAddress = address;
|
|
664
|
+
return this;
|
|
570
665
|
}
|
|
571
666
|
|
|
572
667
|
/**
|
|
573
668
|
* Filter by class hash.
|
|
574
669
|
*/
|
|
575
670
|
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
576
|
-
this.inner.classHash = hash
|
|
577
|
-
return this
|
|
671
|
+
this.inner.classHash = hash;
|
|
672
|
+
return this;
|
|
578
673
|
}
|
|
579
674
|
|
|
580
675
|
encode(): v1alpha2.IDeployedContractFilter {
|
|
581
|
-
return this.inner
|
|
676
|
+
return this.inner;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export class DeclaredClassFilter
|
|
681
|
+
implements IEncodable<v1alpha2.IDeclaredClassFilter>
|
|
682
|
+
{
|
|
683
|
+
private inner: v1alpha2.DeclaredClassFilter;
|
|
684
|
+
|
|
685
|
+
constructor() {
|
|
686
|
+
this.inner = new v1alpha2.DeclaredClassFilter();
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Filter by class hash.
|
|
691
|
+
*/
|
|
692
|
+
withCompiledClassHash(classHash: v1alpha2.IFieldElement) {
|
|
693
|
+
this.inner.compiledClassHash = classHash;
|
|
694
|
+
return this;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Filter by class hash.
|
|
699
|
+
*/
|
|
700
|
+
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
701
|
+
this.inner.classHash = hash;
|
|
702
|
+
return this;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
encode(): v1alpha2.IDeclaredClassFilter {
|
|
706
|
+
return this.inner;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
export class ReplacedClassFilter
|
|
711
|
+
implements IEncodable<v1alpha2.IReplacedClassFilter>
|
|
712
|
+
{
|
|
713
|
+
private inner: v1alpha2.ReplacedClassFilter;
|
|
714
|
+
|
|
715
|
+
constructor() {
|
|
716
|
+
this.inner = new v1alpha2.ReplacedClassFilter();
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Filter by contract address.
|
|
721
|
+
*/
|
|
722
|
+
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
723
|
+
this.inner.contractAddress = address;
|
|
724
|
+
return this;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Filter by class hash.
|
|
729
|
+
*/
|
|
730
|
+
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
731
|
+
this.inner.classHash = hash;
|
|
732
|
+
return this;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
encode(): v1alpha2.IReplacedClassFilter {
|
|
736
|
+
return this.inner;
|
|
582
737
|
}
|
|
583
738
|
}
|
|
584
739
|
|
|
585
|
-
export class NonceUpdateFilter
|
|
586
|
-
|
|
740
|
+
export class NonceUpdateFilter
|
|
741
|
+
implements IEncodable<v1alpha2.INonceUpdateFilter>
|
|
742
|
+
{
|
|
743
|
+
private inner: v1alpha2.NonceUpdateFilter;
|
|
587
744
|
|
|
588
745
|
constructor() {
|
|
589
|
-
this.inner = new v1alpha2.NonceUpdateFilter()
|
|
746
|
+
this.inner = new v1alpha2.NonceUpdateFilter();
|
|
590
747
|
}
|
|
591
748
|
|
|
592
749
|
/**
|
|
593
750
|
* Filter by contract address.
|
|
594
751
|
*/
|
|
595
752
|
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
596
|
-
this.inner.contractAddress = address
|
|
597
|
-
return this
|
|
753
|
+
this.inner.contractAddress = address;
|
|
754
|
+
return this;
|
|
598
755
|
}
|
|
599
756
|
|
|
600
757
|
/**
|
|
601
758
|
* Filter by nonce.
|
|
602
759
|
*/
|
|
603
760
|
withNonce(nonce: v1alpha2.IFieldElement) {
|
|
604
|
-
this.inner.nonce = nonce
|
|
605
|
-
return this
|
|
761
|
+
this.inner.nonce = nonce;
|
|
762
|
+
return this;
|
|
606
763
|
}
|
|
607
764
|
|
|
608
765
|
encode(): v1alpha2.INonceUpdateFilter {
|
|
609
|
-
return this.inner
|
|
766
|
+
return this.inner;
|
|
610
767
|
}
|
|
611
768
|
}
|
|
612
769
|
|
|
613
770
|
function createFilter<T, B>(
|
|
614
771
|
filterOrBuilder: IEncodable<T> | ((builder: B) => IEncodable<T>),
|
|
615
|
-
mk: () => B
|
|
772
|
+
mk: () => B,
|
|
616
773
|
) {
|
|
617
|
-
let filter
|
|
618
|
-
if (typeof filterOrBuilder ===
|
|
619
|
-
filter = filterOrBuilder(mk())
|
|
774
|
+
let filter;
|
|
775
|
+
if (typeof filterOrBuilder === "function") {
|
|
776
|
+
filter = filterOrBuilder(mk());
|
|
620
777
|
} else {
|
|
621
|
-
filter = filterOrBuilder
|
|
778
|
+
filter = filterOrBuilder;
|
|
622
779
|
}
|
|
623
|
-
return filter.encode()
|
|
780
|
+
return filter.encode();
|
|
624
781
|
}
|