@apibara/starknet 0.1.1 → 0.2.0
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 +19 -0
- package/dist/cursor.js +30 -0
- package/dist/cursor.js.map +1 -0
- package/dist/felt.d.ts +19 -0
- package/dist/felt.js +60 -0
- package/dist/felt.js.map +1 -0
- package/dist/felt.test.d.ts +1 -0
- package/dist/felt.test.js +22 -0
- package/dist/felt.test.js.map +1 -0
- package/dist/filter.d.ts +285 -0
- package/dist/filter.js +490 -0
- package/dist/filter.js.map +1 -0
- package/dist/filter.test.d.ts +1 -0
- package/dist/filter.test.js +54 -0
- package/dist/filter.test.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/proto/filter.proto +154 -0
- package/dist/proto/generated.d.ts +4499 -0
- package/dist/proto/generated.js +10973 -0
- package/dist/proto/generated.js.map +1 -0
- package/dist/proto/index.d.ts +2 -0
- package/dist/proto/index.js +7 -0
- package/dist/proto/index.js.map +1 -0
- package/dist/proto/starknet.proto +220 -86
- package/dist/proto/types.proto +13 -0
- package/package.json +16 -7
- package/src/cursor.ts +26 -0
- package/src/felt.test.ts +24 -0
- package/src/felt.ts +61 -0
- package/src/filter.test.ts +63 -0
- package/src/filter.ts +620 -0
- package/src/index.ts +4 -18
- package/src/proto/filter.proto +154 -0
- package/src/proto/generated.d.ts +4499 -0
- package/src/proto/generated.js +11684 -0
- package/src/proto/index.ts +4 -0
- package/src/proto/starknet.proto +220 -86
- package/src/proto/types.proto +13 -0
- package/dist/proto/google/protobuf/timestamp.d.ts +0 -132
- package/dist/proto/google/protobuf/timestamp.js +0 -92
- package/dist/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/proto/starknet.d.ts +0 -1428
- package/dist/proto/starknet.js +0 -1506
- package/dist/proto/starknet.js.map +0 -1
- package/src/proto/google/protobuf/timestamp.ts +0 -216
- package/src/proto/starknet.ts +0 -1725
package/src/filter.ts
ADDED
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
import { v1alpha2 } from './proto'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Helper functions to create StarkNet data filters.
|
|
5
|
+
*/
|
|
6
|
+
export const Filter = {
|
|
7
|
+
/**
|
|
8
|
+
* Creates the root filter object.
|
|
9
|
+
*/
|
|
10
|
+
create: () => new FilterBuilder(),
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates a transaction filter.
|
|
14
|
+
*/
|
|
15
|
+
transaction: () => new TransactionFilter(),
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates an event filter.
|
|
19
|
+
*/
|
|
20
|
+
event: () => new EventFilter(),
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates an L2 to L1 message filter.
|
|
24
|
+
*/
|
|
25
|
+
message: () => new L2ToL1MessageFilter(),
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new state update filter.
|
|
29
|
+
*/
|
|
30
|
+
stateUpdate: () => new StateUpdateFilter(),
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class FilterBuilder {
|
|
34
|
+
private inner: v1alpha2.Filter
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
this.inner = new v1alpha2.Filter()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Include header in the returned data.
|
|
42
|
+
*/
|
|
43
|
+
withHeader() {
|
|
44
|
+
this.inner.header = {}
|
|
45
|
+
return this
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Include transaction data. Use an empty filter to return all transactions.
|
|
50
|
+
*/
|
|
51
|
+
addTransaction(
|
|
52
|
+
filterOrBuilder:
|
|
53
|
+
| IEncodableTransactionFilter
|
|
54
|
+
| ((builder: TransactionFilter) => IEncodableTransactionFilter)
|
|
55
|
+
) {
|
|
56
|
+
this.inner.transactions.push(createFilter(filterOrBuilder, () => new TransactionFilter()))
|
|
57
|
+
return this
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Include event data. Use an empty filter to include all events.
|
|
62
|
+
*/
|
|
63
|
+
addEvent(
|
|
64
|
+
filterOrBuilder:
|
|
65
|
+
| IEncodable<v1alpha2.IEventFilter>
|
|
66
|
+
| ((builder: EventFilter) => IEncodable<v1alpha2.IEventFilter>)
|
|
67
|
+
) {
|
|
68
|
+
this.inner.events.push(createFilter(filterOrBuilder, () => new EventFilter()))
|
|
69
|
+
return this
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Include messages from L2 to L1. Use an empty filter to include all messages.
|
|
74
|
+
*/
|
|
75
|
+
addMessage(
|
|
76
|
+
filterOrBuilder:
|
|
77
|
+
| IEncodable<v1alpha2.IL2ToL1MessageFilter>
|
|
78
|
+
| ((builder: L2ToL1MessageFilter) => IEncodable<v1alpha2.IL2ToL1MessageFilter>)
|
|
79
|
+
) {
|
|
80
|
+
this.inner.messages.push(createFilter(filterOrBuilder, () => new L2ToL1MessageFilter()))
|
|
81
|
+
return this
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Include state updates.
|
|
86
|
+
*/
|
|
87
|
+
withStateUpdate(
|
|
88
|
+
filterOrBuilder:
|
|
89
|
+
| IEncodable<v1alpha2.IStateUpdateFilter>
|
|
90
|
+
| ((filter: StateUpdateFilter) => IEncodable<v1alpha2.IStateUpdateFilter>)
|
|
91
|
+
) {
|
|
92
|
+
this.inner.stateUpdate = createFilter(filterOrBuilder, () => new StateUpdateFilter())
|
|
93
|
+
return this
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns the filter in encoded form, ready to be added to a request.
|
|
98
|
+
*/
|
|
99
|
+
encode(): Uint8Array {
|
|
100
|
+
return v1alpha2.Filter.encode(this.inner).finish()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns the filter as a plain object.
|
|
105
|
+
*/
|
|
106
|
+
toObject(): v1alpha2.IFilter {
|
|
107
|
+
return this.inner
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export class TransactionFilter {
|
|
112
|
+
/**
|
|
113
|
+
* Includes any transaction type.
|
|
114
|
+
*/
|
|
115
|
+
any() {
|
|
116
|
+
return new AnyTransactionFilter()
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Include invoke transactions, V0
|
|
120
|
+
*/
|
|
121
|
+
invokeV0() {
|
|
122
|
+
return new InvokeV0TransactionFilter()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Include invoke transactions, V1
|
|
127
|
+
*/
|
|
128
|
+
invokeV1() {
|
|
129
|
+
return new InvokeV1TransactionFilter()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Include deploy transactions
|
|
134
|
+
*/
|
|
135
|
+
deploy() {
|
|
136
|
+
return new DeployTransactionFilter()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Include declare transactions
|
|
141
|
+
*/
|
|
142
|
+
declare() {
|
|
143
|
+
return new DeclareTransactionFilter()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Include l1 handler transactions
|
|
148
|
+
*/
|
|
149
|
+
l1Handler() {
|
|
150
|
+
return new L1HandlerTransactionFilter()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Include deploy account transactions
|
|
155
|
+
*/
|
|
156
|
+
deployAccount() {
|
|
157
|
+
return new DeployAccountTransactionFilter()
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface IEncodable<T> {
|
|
162
|
+
encode(): T
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export class AnyTransactionFilter implements IEncodable<v1alpha2.ITransactionFilter> {
|
|
166
|
+
encode(): v1alpha2.ITransactionFilter {
|
|
167
|
+
return {}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
type IEncodableTransactionFilter = IEncodable<v1alpha2.ITransactionFilter>
|
|
172
|
+
|
|
173
|
+
export class InvokeV0TransactionFilter implements IEncodableTransactionFilter {
|
|
174
|
+
private inner: v1alpha2.IInvokeTransactionV0Filter
|
|
175
|
+
|
|
176
|
+
constructor() {
|
|
177
|
+
this.inner = {}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Filter by contract address.
|
|
182
|
+
*/
|
|
183
|
+
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
184
|
+
this.inner.contractAddress = address
|
|
185
|
+
return this
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Filter by entry point selector.
|
|
190
|
+
*/
|
|
191
|
+
withEntryPointSelector(selector: v1alpha2.IFieldElement) {
|
|
192
|
+
this.inner.entryPointSelector = selector
|
|
193
|
+
return this
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Filter by calldata prefix.
|
|
198
|
+
*/
|
|
199
|
+
withCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
200
|
+
this.inner.calldata = calldata
|
|
201
|
+
return this
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
encode(): v1alpha2.ITransactionFilter {
|
|
205
|
+
return {
|
|
206
|
+
invokeV0: this.inner,
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export class InvokeV1TransactionFilter implements IEncodableTransactionFilter {
|
|
212
|
+
private inner: v1alpha2.IInvokeTransactionV1Filter
|
|
213
|
+
|
|
214
|
+
constructor() {
|
|
215
|
+
this.inner = {}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Filter by sender address.
|
|
220
|
+
*/
|
|
221
|
+
withSenderAddress(address: v1alpha2.IFieldElement) {
|
|
222
|
+
this.inner.senderAddress = address
|
|
223
|
+
return this
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Filter by calldata prefix.
|
|
228
|
+
*/
|
|
229
|
+
withCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
230
|
+
this.inner.calldata = calldata
|
|
231
|
+
return this
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
encode(): v1alpha2.ITransactionFilter {
|
|
235
|
+
return {
|
|
236
|
+
invokeV1: this.inner,
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export class DeployTransactionFilter implements IEncodableTransactionFilter {
|
|
242
|
+
private inner: v1alpha2.IDeployTransactionFilter
|
|
243
|
+
|
|
244
|
+
constructor() {
|
|
245
|
+
this.inner = {}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Filter by contract address salt.
|
|
250
|
+
*/
|
|
251
|
+
withContractAddressSalt(salt: v1alpha2.IFieldElement) {
|
|
252
|
+
this.inner.contractAddressSalt = salt
|
|
253
|
+
return this
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Filter by class hash.
|
|
258
|
+
*/
|
|
259
|
+
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
260
|
+
this.inner.classHash = hash
|
|
261
|
+
return this
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Filter by constructor calldata prefix.
|
|
266
|
+
*/
|
|
267
|
+
withConstructorCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
268
|
+
this.inner.constructorCalldata = calldata
|
|
269
|
+
return this
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
encode(): v1alpha2.ITransactionFilter {
|
|
273
|
+
return {
|
|
274
|
+
deploy: this.inner,
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export class DeclareTransactionFilter implements IEncodableTransactionFilter {
|
|
280
|
+
private inner: v1alpha2.IDeclareTransactionFilter
|
|
281
|
+
|
|
282
|
+
constructor() {
|
|
283
|
+
this.inner = {}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Filter by sender address.
|
|
288
|
+
*/
|
|
289
|
+
withSenderAddress(address: v1alpha2.IFieldElement) {
|
|
290
|
+
this.inner.senderAddress = address
|
|
291
|
+
return this
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Filter by class hash.
|
|
296
|
+
*/
|
|
297
|
+
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
298
|
+
this.inner.classHash = hash
|
|
299
|
+
return this
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
encode(): v1alpha2.ITransactionFilter {
|
|
303
|
+
return {
|
|
304
|
+
declare: this.inner,
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export class L1HandlerTransactionFilter implements IEncodableTransactionFilter {
|
|
310
|
+
private inner: v1alpha2.IL1HandlerTransactionFilter
|
|
311
|
+
|
|
312
|
+
constructor() {
|
|
313
|
+
this.inner = {}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Filter by contract address.
|
|
318
|
+
*/
|
|
319
|
+
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
320
|
+
this.inner.contractAddress = address
|
|
321
|
+
return this
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Filter by entry point selector.
|
|
326
|
+
*/
|
|
327
|
+
withEntryPointSelector(selector: v1alpha2.IFieldElement) {
|
|
328
|
+
this.inner.entryPointSelector = selector
|
|
329
|
+
return this
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Filter by calldata prefix.
|
|
334
|
+
*/
|
|
335
|
+
withCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
336
|
+
this.inner.calldata = calldata
|
|
337
|
+
return this
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
encode(): v1alpha2.ITransactionFilter {
|
|
341
|
+
return {
|
|
342
|
+
l1Handler: this.inner,
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export class DeployAccountTransactionFilter implements IEncodableTransactionFilter {
|
|
348
|
+
private inner: v1alpha2.IDeployAccountTransactionFilter
|
|
349
|
+
|
|
350
|
+
constructor() {
|
|
351
|
+
this.inner = {}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Filter by contract address salt.
|
|
356
|
+
*/
|
|
357
|
+
withContractAddressSalt(salt: v1alpha2.IFieldElement) {
|
|
358
|
+
this.inner.contractAddressSalt = salt
|
|
359
|
+
return this
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Filter by class hash.
|
|
364
|
+
*/
|
|
365
|
+
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
366
|
+
this.inner.classHash = hash
|
|
367
|
+
return this
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Filter by constructor calldata prefix.
|
|
372
|
+
*/
|
|
373
|
+
withConstructorCalldata(calldata: v1alpha2.IFieldElement[]) {
|
|
374
|
+
this.inner.constructorCalldata = calldata
|
|
375
|
+
return this
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
encode(): v1alpha2.ITransactionFilter {
|
|
379
|
+
return {
|
|
380
|
+
deployAccount: this.inner,
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export class EventFilter implements IEncodable<v1alpha2.IEventFilter> {
|
|
386
|
+
private inner: v1alpha2.IEventFilter
|
|
387
|
+
|
|
388
|
+
constructor() {
|
|
389
|
+
this.inner = {}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Filter by address emitting the event.
|
|
394
|
+
*/
|
|
395
|
+
withFromAddress(address: v1alpha2.IFieldElement) {
|
|
396
|
+
this.inner.fromAddress = address
|
|
397
|
+
return this
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Filter by keys prefix.
|
|
402
|
+
*/
|
|
403
|
+
withKeys(keys: v1alpha2.IFieldElement[]) {
|
|
404
|
+
this.inner.keys = keys
|
|
405
|
+
return this
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Filter by data prefix.
|
|
410
|
+
*/
|
|
411
|
+
withData(data: v1alpha2.IFieldElement[]) {
|
|
412
|
+
this.inner.data = data
|
|
413
|
+
return this
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
encode(): v1alpha2.IEventFilter {
|
|
417
|
+
return this.inner
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export class L2ToL1MessageFilter implements IEncodable<v1alpha2.IL2ToL1MessageFilter> {
|
|
422
|
+
private inner: v1alpha2.IL2ToL1MessageFilter
|
|
423
|
+
|
|
424
|
+
constructor() {
|
|
425
|
+
this.inner = {}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Filter by destination address.
|
|
430
|
+
*/
|
|
431
|
+
withToAddress(address: v1alpha2.IFieldElement) {
|
|
432
|
+
this.inner.toAddress = address
|
|
433
|
+
return this
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Filter by payload prefix.
|
|
438
|
+
*/
|
|
439
|
+
withPayload(payload: v1alpha2.IFieldElement[]) {
|
|
440
|
+
this.inner.payload = payload
|
|
441
|
+
return this
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
encode(): v1alpha2.IL2ToL1MessageFilter {
|
|
445
|
+
return this.inner
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export class StateUpdateFilter implements IEncodable<v1alpha2.IStateUpdateFilter> {
|
|
450
|
+
private inner: v1alpha2.StateUpdateFilter
|
|
451
|
+
|
|
452
|
+
constructor() {
|
|
453
|
+
this.inner = new v1alpha2.StateUpdateFilter()
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Includes all storage changes that match the filter.
|
|
458
|
+
*/
|
|
459
|
+
addStorageDiff(
|
|
460
|
+
filterOrBuilder:
|
|
461
|
+
| IEncodable<v1alpha2.IStorageDiffFilter>
|
|
462
|
+
| ((builder: StorageDiffFilter) => IEncodable<v1alpha2.IStorageDiffFilter>)
|
|
463
|
+
) {
|
|
464
|
+
this.inner.storageDiffs.push(createFilter(filterOrBuilder, () => new StorageDiffFilter()))
|
|
465
|
+
return this
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Includes all declared contracts that match the filter.
|
|
470
|
+
*/
|
|
471
|
+
addDeclaredContract(
|
|
472
|
+
filterOrBuilder:
|
|
473
|
+
| IEncodable<v1alpha2.IDeclaredContractFilter>
|
|
474
|
+
| ((builder: DeclaredContractFilter) => IEncodable<v1alpha2.IDeclaredContractFilter>)
|
|
475
|
+
) {
|
|
476
|
+
this.inner.declaredContracts.push(
|
|
477
|
+
createFilter(filterOrBuilder, () => new DeclaredContractFilter())
|
|
478
|
+
)
|
|
479
|
+
return this
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Includes all deployed contracts that match the filter.
|
|
484
|
+
*/
|
|
485
|
+
addDeployedContract(
|
|
486
|
+
filterOrBuilder:
|
|
487
|
+
| IEncodable<v1alpha2.IDeployedContractFilter>
|
|
488
|
+
| ((builder: DeployedContractFilter) => IEncodable<v1alpha2.IDeployedContractFilter>)
|
|
489
|
+
) {
|
|
490
|
+
this.inner.deployedContracts.push(
|
|
491
|
+
createFilter(filterOrBuilder, () => new DeployedContractFilter())
|
|
492
|
+
)
|
|
493
|
+
return this
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Includes all nonce updates that match the filter.
|
|
498
|
+
*/
|
|
499
|
+
addNonceUpdate(
|
|
500
|
+
filterOrBuilder:
|
|
501
|
+
| IEncodable<v1alpha2.INonceUpdateFilter>
|
|
502
|
+
| ((builder: NonceUpdateFilter) => IEncodable<v1alpha2.INonceUpdateFilter>)
|
|
503
|
+
) {
|
|
504
|
+
this.inner.nonces.push(createFilter(filterOrBuilder, () => new NonceUpdateFilter()))
|
|
505
|
+
return this
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
encode(): v1alpha2.IStateUpdateFilter {
|
|
509
|
+
return this.inner
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export class StorageDiffFilter implements IEncodable<v1alpha2.IStorageDiffFilter> {
|
|
514
|
+
private inner: v1alpha2.StorageDiffFilter
|
|
515
|
+
|
|
516
|
+
constructor() {
|
|
517
|
+
this.inner = new v1alpha2.StorageDiffFilter()
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Filter by contract address.
|
|
522
|
+
*/
|
|
523
|
+
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
524
|
+
this.inner.contractAddress = address
|
|
525
|
+
return this
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
encode(): v1alpha2.IStorageDiffFilter {
|
|
529
|
+
return this.inner
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export class DeclaredContractFilter implements IEncodable<v1alpha2.IDeclaredContractFilter> {
|
|
534
|
+
private inner: v1alpha2.DeclaredContractFilter
|
|
535
|
+
|
|
536
|
+
constructor() {
|
|
537
|
+
this.inner = new v1alpha2.DeclaredContractFilter()
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Filter by class hash.
|
|
542
|
+
*/
|
|
543
|
+
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
544
|
+
this.inner.classHash = hash
|
|
545
|
+
return this
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
encode(): v1alpha2.IDeclaredContractFilter {
|
|
549
|
+
return this.inner
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export class DeployedContractFilter implements IEncodable<v1alpha2.IDeployedContractFilter> {
|
|
554
|
+
private inner: v1alpha2.DeployedContractFilter
|
|
555
|
+
|
|
556
|
+
constructor() {
|
|
557
|
+
this.inner = new v1alpha2.DeployedContractFilter()
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Filter by contract address.
|
|
562
|
+
*/
|
|
563
|
+
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
564
|
+
this.inner.contractAddress = address
|
|
565
|
+
return this
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Filter by class hash.
|
|
570
|
+
*/
|
|
571
|
+
withClassHash(hash: v1alpha2.IFieldElement) {
|
|
572
|
+
this.inner.classHash = hash
|
|
573
|
+
return this
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
encode(): v1alpha2.IDeployedContractFilter {
|
|
577
|
+
return this.inner
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export class NonceUpdateFilter implements IEncodable<v1alpha2.INonceUpdateFilter> {
|
|
582
|
+
private inner: v1alpha2.NonceUpdateFilter
|
|
583
|
+
|
|
584
|
+
constructor() {
|
|
585
|
+
this.inner = new v1alpha2.NonceUpdateFilter()
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Filter by contract address.
|
|
590
|
+
*/
|
|
591
|
+
withContractAddress(address: v1alpha2.IFieldElement) {
|
|
592
|
+
this.inner.contractAddress = address
|
|
593
|
+
return this
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Filter by nonce.
|
|
598
|
+
*/
|
|
599
|
+
withNonce(nonce: v1alpha2.IFieldElement) {
|
|
600
|
+
this.inner.nonce = nonce
|
|
601
|
+
return this
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
encode(): v1alpha2.INonceUpdateFilter {
|
|
605
|
+
return this.inner
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function createFilter<T, B>(
|
|
610
|
+
filterOrBuilder: IEncodable<T> | ((builder: B) => IEncodable<T>),
|
|
611
|
+
mk: () => B
|
|
612
|
+
) {
|
|
613
|
+
let filter
|
|
614
|
+
if (typeof filterOrBuilder === 'function') {
|
|
615
|
+
filter = filterOrBuilder(mk())
|
|
616
|
+
} else {
|
|
617
|
+
filter = filterOrBuilder
|
|
618
|
+
}
|
|
619
|
+
return filter.encode()
|
|
620
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Transaction,
|
|
6
|
-
TransactionCommon,
|
|
7
|
-
TransactionReceipt,
|
|
8
|
-
TransactionStatus,
|
|
9
|
-
InvokeTransaction,
|
|
10
|
-
DeclareTransaction,
|
|
11
|
-
DeployTransaction,
|
|
12
|
-
DeployAccountTransaction,
|
|
13
|
-
L1HandlerTransaction,
|
|
14
|
-
ExecutionResources,
|
|
15
|
-
BuiltinInstanceCounter,
|
|
16
|
-
L1ToL2Message,
|
|
17
|
-
L2ToL1Message,
|
|
18
|
-
} from './proto/starknet'
|
|
1
|
+
export * from './proto'
|
|
2
|
+
export * from './cursor'
|
|
3
|
+
export * from './filter'
|
|
4
|
+
export * from './felt'
|