@warptoad/skinny-fat-imt-js 0.0.2

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.
@@ -0,0 +1,702 @@
1
+ import { LeanIMT, type LeanIMTHashFunction } from "@zk-kit/lean-imt";
2
+ import { type Abi, type AbiEvent, type Address, type GetContractReturnType, type Hex, type PublicClient } from "viem";
3
+ import { type PostQueryEventFilter } from "./eventScanning.js";
4
+ import { skinnyStorageAbi, skinnyEventAbi, fatStorageAbi, fatEventAbi, iimtEventsAbi } from "./abis.js";
5
+ export { skinnyStorageAbi, skinnyEventAbi, fatStorageAbi, fatEventAbi, iimtEventsAbi };
6
+ export type AnyContract = {
7
+ address: Address;
8
+ abi: Abi;
9
+ read: Record<string, (...args: any[]) => Promise<any>>;
10
+ };
11
+ type ReadableStorageAbi = readonly [
12
+ ...typeof skinnyStorageAbi,
13
+ ...typeof fatStorageAbi
14
+ ];
15
+ type ReadableEventAbi = readonly [
16
+ ...typeof skinnyEventAbi,
17
+ ...typeof fatEventAbi,
18
+ ...typeof iimtEventsAbi
19
+ ];
20
+ type ReadableAbi = readonly [...ReadableStorageAbi, ...ReadableEventAbi];
21
+ /**
22
+ * A single event *entry* of the contract abi, by name. `EventLog`/`PostQueryEventFilter` want one
23
+ * AbiEvent, not a whole abi, and this is the exact same thing `queryEventInChunks` infers for
24
+ * `eventName`, so filters typed with it line up with the query they're passed to.
25
+ */
26
+ type ReadableEvent<TName extends string> = Extract<ReadableAbi[number], AbiEvent & {
27
+ name: TName;
28
+ }>;
29
+ export declare const readableStorageAbi: [{
30
+ readonly inputs: readonly [];
31
+ readonly name: "NotInitialized";
32
+ readonly type: "error";
33
+ }, {
34
+ readonly inputs: readonly [{
35
+ readonly internalType: "uint256";
36
+ readonly name: "treeId";
37
+ readonly type: "uint256";
38
+ }];
39
+ readonly name: "getSkinnyDepth";
40
+ readonly outputs: readonly [{
41
+ readonly internalType: "uint256";
42
+ readonly name: "";
43
+ readonly type: "uint256";
44
+ }];
45
+ readonly stateMutability: "view";
46
+ readonly type: "function";
47
+ }, {
48
+ readonly inputs: readonly [{
49
+ readonly internalType: "uint256";
50
+ readonly name: "treeId";
51
+ readonly type: "uint256";
52
+ }, {
53
+ readonly internalType: "uint256";
54
+ readonly name: "firstIndex";
55
+ readonly type: "uint256";
56
+ }, {
57
+ readonly internalType: "uint256";
58
+ readonly name: "endIndex";
59
+ readonly type: "uint256";
60
+ }];
61
+ readonly name: "getSkinnyLeaves";
62
+ readonly outputs: readonly [{
63
+ readonly internalType: "uint256[]";
64
+ readonly name: "";
65
+ readonly type: "uint256[]";
66
+ }];
67
+ readonly stateMutability: "view";
68
+ readonly type: "function";
69
+ }, {
70
+ readonly inputs: readonly [{
71
+ readonly internalType: "uint256";
72
+ readonly name: "treeId";
73
+ readonly type: "uint256";
74
+ }];
75
+ readonly name: "getSkinnyLeavesBaseSlot";
76
+ readonly outputs: readonly [{
77
+ readonly internalType: "uint256";
78
+ readonly name: "";
79
+ readonly type: "uint256";
80
+ }];
81
+ readonly stateMutability: "view";
82
+ readonly type: "function";
83
+ }, {
84
+ readonly inputs: readonly [{
85
+ readonly internalType: "uint256";
86
+ readonly name: "treeId";
87
+ readonly type: "uint256";
88
+ }];
89
+ readonly name: "getSkinnyRoot";
90
+ readonly outputs: readonly [{
91
+ readonly internalType: "uint256";
92
+ readonly name: "";
93
+ readonly type: "uint256";
94
+ }];
95
+ readonly stateMutability: "view";
96
+ readonly type: "function";
97
+ }, {
98
+ readonly inputs: readonly [{
99
+ readonly internalType: "uint256";
100
+ readonly name: "treeId";
101
+ readonly type: "uint256";
102
+ }, {
103
+ readonly internalType: "uint256";
104
+ readonly name: "firstIndex";
105
+ readonly type: "uint256";
106
+ }, {
107
+ readonly internalType: "uint256";
108
+ readonly name: "endIndex";
109
+ readonly type: "uint256";
110
+ }];
111
+ readonly name: "getSkinnySideNodes";
112
+ readonly outputs: readonly [{
113
+ readonly internalType: "uint256[]";
114
+ readonly name: "";
115
+ readonly type: "uint256[]";
116
+ }];
117
+ readonly stateMutability: "view";
118
+ readonly type: "function";
119
+ }, {
120
+ readonly inputs: readonly [{
121
+ readonly internalType: "uint256";
122
+ readonly name: "treeId";
123
+ readonly type: "uint256";
124
+ }];
125
+ readonly name: "getSkinnySize";
126
+ readonly outputs: readonly [{
127
+ readonly internalType: "uint256";
128
+ readonly name: "";
129
+ readonly type: "uint256";
130
+ }];
131
+ readonly stateMutability: "view";
132
+ readonly type: "function";
133
+ }, {
134
+ readonly inputs: readonly [{
135
+ readonly internalType: "bytes4";
136
+ readonly name: "interfaceId";
137
+ readonly type: "bytes4";
138
+ }];
139
+ readonly name: "supportsInterface";
140
+ readonly outputs: readonly [{
141
+ readonly internalType: "bool";
142
+ readonly name: "";
143
+ readonly type: "bool";
144
+ }];
145
+ readonly stateMutability: "view";
146
+ readonly type: "function";
147
+ }, {
148
+ readonly inputs: readonly [];
149
+ readonly name: "EndIndexOutOfRange";
150
+ readonly type: "error";
151
+ }, {
152
+ readonly inputs: readonly [];
153
+ readonly name: "LevelOutOfRange";
154
+ readonly type: "error";
155
+ }, {
156
+ readonly inputs: readonly [];
157
+ readonly name: "NotInitialized";
158
+ readonly type: "error";
159
+ }, {
160
+ readonly inputs: readonly [{
161
+ readonly internalType: "uint256";
162
+ readonly name: "treeId";
163
+ readonly type: "uint256";
164
+ }];
165
+ readonly name: "getFatDepth";
166
+ readonly outputs: readonly [{
167
+ readonly internalType: "uint256";
168
+ readonly name: "";
169
+ readonly type: "uint256";
170
+ }];
171
+ readonly stateMutability: "view";
172
+ readonly type: "function";
173
+ }, {
174
+ readonly inputs: readonly [{
175
+ readonly internalType: "uint256";
176
+ readonly name: "treeId";
177
+ readonly type: "uint256";
178
+ }, {
179
+ readonly internalType: "uint256";
180
+ readonly name: "firstIndex";
181
+ readonly type: "uint256";
182
+ }, {
183
+ readonly internalType: "uint256";
184
+ readonly name: "endIndex";
185
+ readonly type: "uint256";
186
+ }];
187
+ readonly name: "getFatLeaves";
188
+ readonly outputs: readonly [{
189
+ readonly internalType: "uint256[]";
190
+ readonly name: "";
191
+ readonly type: "uint256[]";
192
+ }];
193
+ readonly stateMutability: "view";
194
+ readonly type: "function";
195
+ }, {
196
+ readonly inputs: readonly [{
197
+ readonly internalType: "uint256";
198
+ readonly name: "treeId";
199
+ readonly type: "uint256";
200
+ }];
201
+ readonly name: "getFatLeavesBaseSlot";
202
+ readonly outputs: readonly [{
203
+ readonly internalType: "uint256";
204
+ readonly name: "";
205
+ readonly type: "uint256";
206
+ }];
207
+ readonly stateMutability: "view";
208
+ readonly type: "function";
209
+ }, {
210
+ readonly inputs: readonly [{
211
+ readonly internalType: "uint256";
212
+ readonly name: "treeId";
213
+ readonly type: "uint256";
214
+ }, {
215
+ readonly internalType: "uint256";
216
+ readonly name: "firstIndex";
217
+ readonly type: "uint256";
218
+ }, {
219
+ readonly internalType: "uint256";
220
+ readonly name: "endIndex";
221
+ readonly type: "uint256";
222
+ }, {
223
+ readonly internalType: "uint256";
224
+ readonly name: "level";
225
+ readonly type: "uint256";
226
+ }];
227
+ readonly name: "getFatNodes";
228
+ readonly outputs: readonly [{
229
+ readonly internalType: "uint256[]";
230
+ readonly name: "";
231
+ readonly type: "uint256[]";
232
+ }];
233
+ readonly stateMutability: "view";
234
+ readonly type: "function";
235
+ }, {
236
+ readonly inputs: readonly [{
237
+ readonly internalType: "uint256";
238
+ readonly name: "treeId";
239
+ readonly type: "uint256";
240
+ }];
241
+ readonly name: "getFatRoot";
242
+ readonly outputs: readonly [{
243
+ readonly internalType: "uint256";
244
+ readonly name: "";
245
+ readonly type: "uint256";
246
+ }];
247
+ readonly stateMutability: "view";
248
+ readonly type: "function";
249
+ }, {
250
+ readonly inputs: readonly [{
251
+ readonly internalType: "uint256";
252
+ readonly name: "treeId";
253
+ readonly type: "uint256";
254
+ }];
255
+ readonly name: "getFatSize";
256
+ readonly outputs: readonly [{
257
+ readonly internalType: "uint256";
258
+ readonly name: "";
259
+ readonly type: "uint256";
260
+ }];
261
+ readonly stateMutability: "view";
262
+ readonly type: "function";
263
+ }, {
264
+ readonly inputs: readonly [{
265
+ readonly internalType: "bytes4";
266
+ readonly name: "interfaceId";
267
+ readonly type: "bytes4";
268
+ }];
269
+ readonly name: "supportsInterface";
270
+ readonly outputs: readonly [{
271
+ readonly internalType: "bool";
272
+ readonly name: "";
273
+ readonly type: "bool";
274
+ }];
275
+ readonly stateMutability: "view";
276
+ readonly type: "function";
277
+ }];
278
+ export declare const readableEventAbi: [{
279
+ readonly inputs: readonly [];
280
+ readonly name: "NotInitialized";
281
+ readonly type: "error";
282
+ }, {
283
+ readonly inputs: readonly [{
284
+ readonly internalType: "uint256";
285
+ readonly name: "treeId";
286
+ readonly type: "uint256";
287
+ }];
288
+ readonly name: "getSkinnyDepth";
289
+ readonly outputs: readonly [{
290
+ readonly internalType: "uint256";
291
+ readonly name: "";
292
+ readonly type: "uint256";
293
+ }];
294
+ readonly stateMutability: "view";
295
+ readonly type: "function";
296
+ }, {
297
+ readonly inputs: readonly [{
298
+ readonly internalType: "uint256";
299
+ readonly name: "treeId";
300
+ readonly type: "uint256";
301
+ }];
302
+ readonly name: "getSkinnyRoot";
303
+ readonly outputs: readonly [{
304
+ readonly internalType: "uint256";
305
+ readonly name: "";
306
+ readonly type: "uint256";
307
+ }];
308
+ readonly stateMutability: "view";
309
+ readonly type: "function";
310
+ }, {
311
+ readonly inputs: readonly [{
312
+ readonly internalType: "uint256";
313
+ readonly name: "treeId";
314
+ readonly type: "uint256";
315
+ }, {
316
+ readonly internalType: "uint256";
317
+ readonly name: "firstIndex";
318
+ readonly type: "uint256";
319
+ }, {
320
+ readonly internalType: "uint256";
321
+ readonly name: "endIndex";
322
+ readonly type: "uint256";
323
+ }];
324
+ readonly name: "getSkinnySideNodes";
325
+ readonly outputs: readonly [{
326
+ readonly internalType: "uint256[]";
327
+ readonly name: "";
328
+ readonly type: "uint256[]";
329
+ }];
330
+ readonly stateMutability: "view";
331
+ readonly type: "function";
332
+ }, {
333
+ readonly inputs: readonly [{
334
+ readonly internalType: "uint256";
335
+ readonly name: "treeId";
336
+ readonly type: "uint256";
337
+ }];
338
+ readonly name: "getSkinnySize";
339
+ readonly outputs: readonly [{
340
+ readonly internalType: "uint256";
341
+ readonly name: "";
342
+ readonly type: "uint256";
343
+ }];
344
+ readonly stateMutability: "view";
345
+ readonly type: "function";
346
+ }, {
347
+ readonly inputs: readonly [{
348
+ readonly internalType: "bytes4";
349
+ readonly name: "interfaceId";
350
+ readonly type: "bytes4";
351
+ }];
352
+ readonly name: "supportsInterface";
353
+ readonly outputs: readonly [{
354
+ readonly internalType: "bool";
355
+ readonly name: "";
356
+ readonly type: "bool";
357
+ }];
358
+ readonly stateMutability: "view";
359
+ readonly type: "function";
360
+ }, {
361
+ readonly inputs: readonly [];
362
+ readonly name: "EndIndexOutOfRange";
363
+ readonly type: "error";
364
+ }, {
365
+ readonly inputs: readonly [];
366
+ readonly name: "LevelOutOfRange";
367
+ readonly type: "error";
368
+ }, {
369
+ readonly inputs: readonly [];
370
+ readonly name: "NotInitialized";
371
+ readonly type: "error";
372
+ }, {
373
+ readonly inputs: readonly [{
374
+ readonly internalType: "uint256";
375
+ readonly name: "treeId";
376
+ readonly type: "uint256";
377
+ }];
378
+ readonly name: "getFatDepth";
379
+ readonly outputs: readonly [{
380
+ readonly internalType: "uint256";
381
+ readonly name: "";
382
+ readonly type: "uint256";
383
+ }];
384
+ readonly stateMutability: "view";
385
+ readonly type: "function";
386
+ }, {
387
+ readonly inputs: readonly [{
388
+ readonly internalType: "uint256";
389
+ readonly name: "treeId";
390
+ readonly type: "uint256";
391
+ }, {
392
+ readonly internalType: "uint256";
393
+ readonly name: "firstIndex";
394
+ readonly type: "uint256";
395
+ }, {
396
+ readonly internalType: "uint256";
397
+ readonly name: "endIndex";
398
+ readonly type: "uint256";
399
+ }];
400
+ readonly name: "getFatLeaves";
401
+ readonly outputs: readonly [{
402
+ readonly internalType: "uint256[]";
403
+ readonly name: "";
404
+ readonly type: "uint256[]";
405
+ }];
406
+ readonly stateMutability: "view";
407
+ readonly type: "function";
408
+ }, {
409
+ readonly inputs: readonly [{
410
+ readonly internalType: "uint256";
411
+ readonly name: "treeId";
412
+ readonly type: "uint256";
413
+ }, {
414
+ readonly internalType: "uint256";
415
+ readonly name: "firstIndex";
416
+ readonly type: "uint256";
417
+ }, {
418
+ readonly internalType: "uint256";
419
+ readonly name: "endIndex";
420
+ readonly type: "uint256";
421
+ }, {
422
+ readonly internalType: "uint256";
423
+ readonly name: "level";
424
+ readonly type: "uint256";
425
+ }];
426
+ readonly name: "getFatNodes";
427
+ readonly outputs: readonly [{
428
+ readonly internalType: "uint256[]";
429
+ readonly name: "";
430
+ readonly type: "uint256[]";
431
+ }];
432
+ readonly stateMutability: "view";
433
+ readonly type: "function";
434
+ }, {
435
+ readonly inputs: readonly [{
436
+ readonly internalType: "uint256";
437
+ readonly name: "treeId";
438
+ readonly type: "uint256";
439
+ }];
440
+ readonly name: "getFatRoot";
441
+ readonly outputs: readonly [{
442
+ readonly internalType: "uint256";
443
+ readonly name: "";
444
+ readonly type: "uint256";
445
+ }];
446
+ readonly stateMutability: "view";
447
+ readonly type: "function";
448
+ }, {
449
+ readonly inputs: readonly [{
450
+ readonly internalType: "uint256";
451
+ readonly name: "treeId";
452
+ readonly type: "uint256";
453
+ }];
454
+ readonly name: "getFatSize";
455
+ readonly outputs: readonly [{
456
+ readonly internalType: "uint256";
457
+ readonly name: "";
458
+ readonly type: "uint256";
459
+ }];
460
+ readonly stateMutability: "view";
461
+ readonly type: "function";
462
+ }, {
463
+ readonly inputs: readonly [{
464
+ readonly internalType: "bytes4";
465
+ readonly name: "interfaceId";
466
+ readonly type: "bytes4";
467
+ }];
468
+ readonly name: "supportsInterface";
469
+ readonly outputs: readonly [{
470
+ readonly internalType: "bool";
471
+ readonly name: "";
472
+ readonly type: "bool";
473
+ }];
474
+ readonly stateMutability: "view";
475
+ readonly type: "function";
476
+ }, {
477
+ readonly anonymous: false;
478
+ readonly inputs: readonly [{
479
+ readonly indexed: true;
480
+ readonly internalType: "uint256";
481
+ readonly name: "treeId";
482
+ readonly type: "uint256";
483
+ }, {
484
+ readonly indexed: true;
485
+ readonly internalType: "uint256";
486
+ readonly name: "index";
487
+ readonly type: "uint256";
488
+ }, {
489
+ readonly indexed: true;
490
+ readonly internalType: "uint256";
491
+ readonly name: "leaf";
492
+ readonly type: "uint256";
493
+ }];
494
+ readonly name: "NewLeaf";
495
+ readonly type: "event";
496
+ }, {
497
+ readonly anonymous: false;
498
+ readonly inputs: readonly [{
499
+ readonly indexed: true;
500
+ readonly internalType: "uint256";
501
+ readonly name: "treeId";
502
+ readonly type: "uint256";
503
+ }, {
504
+ readonly indexed: true;
505
+ readonly internalType: "uint256";
506
+ readonly name: "root";
507
+ readonly type: "uint256";
508
+ }, {
509
+ readonly indexed: false;
510
+ readonly internalType: "uint256";
511
+ readonly name: "size";
512
+ readonly type: "uint256";
513
+ }];
514
+ readonly name: "NewRoot";
515
+ readonly type: "event";
516
+ }, {
517
+ readonly anonymous: false;
518
+ readonly inputs: readonly [{
519
+ readonly indexed: true;
520
+ readonly internalType: "uint256";
521
+ readonly name: "treeId";
522
+ readonly type: "uint256";
523
+ }];
524
+ readonly name: "NewTree";
525
+ readonly type: "event";
526
+ }, {
527
+ readonly anonymous: false;
528
+ readonly inputs: readonly [{
529
+ readonly indexed: true;
530
+ readonly internalType: "uint256";
531
+ readonly name: "treeId";
532
+ readonly type: "uint256";
533
+ }, {
534
+ readonly indexed: true;
535
+ readonly internalType: "uint256";
536
+ readonly name: "startIndex";
537
+ readonly type: "uint256";
538
+ }, {
539
+ readonly indexed: false;
540
+ readonly internalType: "uint256";
541
+ readonly name: "nextIndex";
542
+ readonly type: "uint256";
543
+ }, {
544
+ readonly indexed: true;
545
+ readonly internalType: "uint256";
546
+ readonly name: "leaf";
547
+ readonly type: "uint256";
548
+ }];
549
+ readonly name: "RepeatedLeafs";
550
+ readonly type: "event";
551
+ }, {
552
+ readonly anonymous: false;
553
+ readonly inputs: readonly [{
554
+ readonly indexed: true;
555
+ readonly internalType: "uint256";
556
+ readonly name: "treeId";
557
+ readonly type: "uint256";
558
+ }, {
559
+ readonly indexed: true;
560
+ readonly internalType: "uint256";
561
+ readonly name: "index";
562
+ readonly type: "uint256";
563
+ }, {
564
+ readonly indexed: true;
565
+ readonly internalType: "uint256";
566
+ readonly name: "newLeaf";
567
+ readonly type: "uint256";
568
+ }, {
569
+ readonly indexed: false;
570
+ readonly internalType: "uint256";
571
+ readonly name: "oldLeaf";
572
+ readonly type: "uint256";
573
+ }];
574
+ readonly name: "UpdatedLeaf";
575
+ readonly type: "event";
576
+ }];
577
+ export type ReadableContract = GetContractReturnType<ReadableAbi, PublicClient>;
578
+ export type ReadableContractStorage = GetContractReturnType<ReadableStorageAbi, PublicClient>;
579
+ export type ReadableContractEvent = GetContractReturnType<ReadableEventAbi, PublicClient>;
580
+ export type ReadableContractSkinnyEvent = GetContractReturnType<typeof skinnyEventAbi, PublicClient>;
581
+ export type ReadableContractSkinnyStorage = GetContractReturnType<typeof skinnyStorageAbi, PublicClient>;
582
+ export type ReadableContractFatEvent = GetContractReturnType<typeof fatEventAbi, PublicClient>;
583
+ export type ReadableContractFatStorage = GetContractReturnType<typeof fatStorageAbi, PublicClient>;
584
+ export declare const ERC165_IDS: {
585
+ readonly skinnyEvent: `0x${string}`;
586
+ readonly skinnyStorage: `0x${string}`;
587
+ readonly fatEvent: `0x${string}`;
588
+ readonly fatStorage: `0x${string}`;
589
+ };
590
+ declare enum TREE_TYPE {
591
+ UNKNOWN = 0,
592
+ FAT_STORAGE = 1,
593
+ FAT_EVENT = 2,
594
+ SKINNY_STORAGE = 3,
595
+ SKINNY_EVENT = 4,
596
+ NO_INTERFACE = 5
597
+ }
598
+ export declare const LeanIMTHashFuncPoseidon2: LeanIMTHashFunction;
599
+ export type CachedTree = {
600
+ tree: LeanIMT<bigint>;
601
+ type: TREE_TYPE;
602
+ lastSynced: bigint;
603
+ insertOnlyTree?: boolean;
604
+ };
605
+ /**
606
+ * A detached LeanIMT holding the same leaves *and* internal nodes as `tree`, so it can be grown
607
+ * without touching the original. Copies the nodes rather than replaying the leaves on purpose:
608
+ * `new LeanIMT(hash, tree.leaves)` would rehash the whole tree, which is the exact cost a caller
609
+ * growing a cached tree is trying to avoid. This is array copies only, no hashing.
610
+ */
611
+ export declare function copyTree(tree: LeanIMT<bigint>, hashFunc: LeanIMTHashFunction): LeanIMT<bigint>;
612
+ export declare class Trees {
613
+ private trees;
614
+ /** last known size per tree, with the block it was read at. See {@link getTreeSizeStorage}. */
615
+ private sizes;
616
+ contractAddress: Address;
617
+ contract: ReadableContract;
618
+ hashFunc: LeanIMTHashFunction;
619
+ private publicClient;
620
+ constructor(contractAddress: Address, client: PublicClient, hashFunc?: LeanIMTHashFunction);
621
+ sync(treeIds?: bigint[] | undefined, { fullNodeMode, attemptFastSizeMatch, syncToRoot, eventChunkSize, storageChunkSize, insertOnlyTree, autoDiscovery, hasRepeatedLeafs, blockNumber }?: {
622
+ fullNodeMode?: boolean;
623
+ blockNumber?: bigint;
624
+ attemptFastSizeMatch?: boolean;
625
+ syncToRoot?: bigint;
626
+ eventChunkSize?: bigint;
627
+ storageChunkSize?: bigint;
628
+ hasRepeatedLeafs?: boolean;
629
+ insertOnlyTree?: boolean;
630
+ autoDiscovery?: boolean | undefined;
631
+ }): Promise<{
632
+ [treeId: `0x${string}`]: CachedTree;
633
+ }>;
634
+ /**
635
+ * Reads trees straight from contract storage, at `blockNumber` (defaults to the safe block).
636
+ *
637
+ * `attemptFastSizeMatch` (default true) bets that the cached tree is still the right *prefix* of the
638
+ * onchain one, so only the difference in size has to be dealt with: read the leaves past the
639
+ * cache's end, or drop the ones past the onchain size. It is a hope, not a promise, so it always
640
+ * ends in a root check — a tree that had an update(), or was reset and regrown with different
641
+ * leaves, fails that check and is re-read in full. Turning it off re-reads every leaf up front.
642
+ */
643
+ syncTreesStorage(treeIds?: bigint[] | undefined, { chunkSize, attemptFastSizeMatch, blockNumber }?: {
644
+ attemptFastSizeMatch?: boolean;
645
+ chunkSize?: bigint;
646
+ blockNumber?: bigint;
647
+ }): Promise<{
648
+ [treeId: Hex]: CachedTree;
649
+ }>;
650
+ /**
651
+ * The leaves of `[startIndex, endIndex)`, read in chunks of `chunkSize`. Same range as
652
+ * {@link Trees#getLeavesStorage}, which does it in a single call, but split up so a big range
653
+ * doesn't have to fit in one eth_call. What the caller does with them (build a tree, grow one)
654
+ * is up to it.
655
+ */
656
+ private readLeavesStorage;
657
+ syncTreesEvent(treeIds?: bigint[] | undefined, { blockNumber, attemptFastSizeMatch, syncToRoot, chunkSize, insertOnlyTree, autoDiscovery, hasRepeatedLeafs }?: {
658
+ blockNumber?: bigint;
659
+ attemptFastSizeMatch?: boolean;
660
+ syncToRoot?: bigint;
661
+ chunkSize?: bigint;
662
+ hasRepeatedLeafs?: boolean;
663
+ insertOnlyTree?: boolean;
664
+ autoDiscovery?: boolean | undefined;
665
+ }): Promise<{
666
+ [treeId: `0x${string}`]: CachedTree;
667
+ }>;
668
+ getContract(): Promise<ReadableContract>;
669
+ getOldestSyncTreeId(treeIds: Hex[]): Hex;
670
+ getOldestSyncBlock(treeIds: bigint[]): bigint;
671
+ getTreeType(treeId: Hex, chainId: number): Promise<TREE_TYPE>;
672
+ getLeavesStorage(treeId: Hex, chainId: number, startIndex: bigint, endIndex: bigint, blockNumber: bigint): Promise<readonly bigint[]>;
673
+ getTreeSizeStorage(treeId: Hex, chainId: number, blockNumber: bigint): Promise<bigint>;
674
+ getRootStorage(treeId: Hex, chainId: number, blockNumber: bigint): Promise<bigint>;
675
+ initTree(treeId: Hex, chainId: number): Promise<CachedTree>;
676
+ }
677
+ export declare function identifyTree(treeId: bigint, contract: AnyContract): Promise<TREE_TYPE>;
678
+ type SyncState = {
679
+ lastBlockSynced: bigint;
680
+ unsyncedIds: Set<Hex>;
681
+ treeCache: {
682
+ [treeId: Hex]: CachedTree;
683
+ };
684
+ treeState: {
685
+ [treeId: Hex]: {
686
+ expectedRoot: bigint;
687
+ tree?: LeanIMT<bigint>;
688
+ leaves: bigint[];
689
+ count: bigint;
690
+ targetSize: bigint;
691
+ lastSynced: bigint;
692
+ };
693
+ };
694
+ };
695
+ type IMTEventFilter = PostQueryEventFilter<ReadableEvent<"NewRoot" | "NewLeaf" | "UpdatedLeaf" | "RepeatedLeafs">>;
696
+ export declare function getEventFilter(firstBlock: bigint, syncState: SyncState, { autoDiscover, syncToRoot, attemptFastSizeMatch, hashFunc }?: {
697
+ hashFunc?: LeanIMTHashFunction;
698
+ attemptFastSizeMatch?: boolean;
699
+ autoDiscover?: boolean;
700
+ syncToRoot?: bigint;
701
+ }): IMTEventFilter;
702
+ //# sourceMappingURL=Trees.d.ts.map