@gitmyabi/fundcollector 0.0.0-stage → 1.0.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.
@@ -0,0 +1,742 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * FundCollector ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const FundCollectorAbi = [
10
+ {
11
+ "inputs": [
12
+ {
13
+ "internalType": "address",
14
+ "name": "initialOwner",
15
+ "type": "address"
16
+ }
17
+ ],
18
+ "stateMutability": "nonpayable",
19
+ "type": "constructor"
20
+ },
21
+ {
22
+ "inputs": [
23
+ {
24
+ "internalType": "address",
25
+ "name": "owner",
26
+ "type": "address"
27
+ }
28
+ ],
29
+ "name": "OwnableInvalidOwner",
30
+ "type": "error"
31
+ },
32
+ {
33
+ "inputs": [
34
+ {
35
+ "internalType": "address",
36
+ "name": "account",
37
+ "type": "address"
38
+ }
39
+ ],
40
+ "name": "OwnableUnauthorizedAccount",
41
+ "type": "error"
42
+ },
43
+ {
44
+ "inputs": [],
45
+ "name": "ReentrancyGuardReentrantCall",
46
+ "type": "error"
47
+ },
48
+ {
49
+ "inputs": [
50
+ {
51
+ "internalType": "address",
52
+ "name": "token",
53
+ "type": "address"
54
+ }
55
+ ],
56
+ "name": "SafeERC20FailedOperation",
57
+ "type": "error"
58
+ },
59
+ {
60
+ "anonymous": false,
61
+ "inputs": [
62
+ {
63
+ "indexed": true,
64
+ "internalType": "address",
65
+ "name": "to",
66
+ "type": "address"
67
+ },
68
+ {
69
+ "indexed": false,
70
+ "internalType": "uint256",
71
+ "name": "amount",
72
+ "type": "uint256"
73
+ }
74
+ ],
75
+ "name": "EthRescued",
76
+ "type": "event"
77
+ },
78
+ {
79
+ "anonymous": false,
80
+ "inputs": [
81
+ {
82
+ "indexed": true,
83
+ "internalType": "address",
84
+ "name": "previousOwner",
85
+ "type": "address"
86
+ },
87
+ {
88
+ "indexed": true,
89
+ "internalType": "address",
90
+ "name": "newOwner",
91
+ "type": "address"
92
+ }
93
+ ],
94
+ "name": "OwnershipTransferred",
95
+ "type": "event"
96
+ },
97
+ {
98
+ "anonymous": false,
99
+ "inputs": [
100
+ {
101
+ "indexed": true,
102
+ "internalType": "address",
103
+ "name": "token",
104
+ "type": "address"
105
+ },
106
+ {
107
+ "indexed": true,
108
+ "internalType": "address",
109
+ "name": "from",
110
+ "type": "address"
111
+ },
112
+ {
113
+ "indexed": true,
114
+ "internalType": "address",
115
+ "name": "to",
116
+ "type": "address"
117
+ },
118
+ {
119
+ "indexed": false,
120
+ "internalType": "uint256",
121
+ "name": "amount",
122
+ "type": "uint256"
123
+ }
124
+ ],
125
+ "name": "Swept",
126
+ "type": "event"
127
+ },
128
+ {
129
+ "anonymous": false,
130
+ "inputs": [
131
+ {
132
+ "indexed": true,
133
+ "internalType": "address",
134
+ "name": "token",
135
+ "type": "address"
136
+ },
137
+ {
138
+ "indexed": true,
139
+ "internalType": "address",
140
+ "name": "to",
141
+ "type": "address"
142
+ },
143
+ {
144
+ "indexed": false,
145
+ "internalType": "uint256",
146
+ "name": "amount",
147
+ "type": "uint256"
148
+ }
149
+ ],
150
+ "name": "TokenRescued",
151
+ "type": "event"
152
+ },
153
+ {
154
+ "inputs": [],
155
+ "name": "owner",
156
+ "outputs": [
157
+ {
158
+ "internalType": "address",
159
+ "name": "",
160
+ "type": "address"
161
+ }
162
+ ],
163
+ "stateMutability": "view",
164
+ "type": "function"
165
+ },
166
+ {
167
+ "inputs": [],
168
+ "name": "renounceOwnership",
169
+ "outputs": [],
170
+ "stateMutability": "nonpayable",
171
+ "type": "function"
172
+ },
173
+ {
174
+ "inputs": [
175
+ {
176
+ "internalType": "address payable",
177
+ "name": "to",
178
+ "type": "address"
179
+ },
180
+ {
181
+ "internalType": "uint256",
182
+ "name": "amount",
183
+ "type": "uint256"
184
+ }
185
+ ],
186
+ "name": "rescueETH",
187
+ "outputs": [],
188
+ "stateMutability": "nonpayable",
189
+ "type": "function"
190
+ },
191
+ {
192
+ "inputs": [
193
+ {
194
+ "internalType": "address",
195
+ "name": "token",
196
+ "type": "address"
197
+ },
198
+ {
199
+ "internalType": "address",
200
+ "name": "to",
201
+ "type": "address"
202
+ },
203
+ {
204
+ "internalType": "uint256",
205
+ "name": "amount",
206
+ "type": "uint256"
207
+ }
208
+ ],
209
+ "name": "rescueToken",
210
+ "outputs": [],
211
+ "stateMutability": "nonpayable",
212
+ "type": "function"
213
+ },
214
+ {
215
+ "inputs": [
216
+ {
217
+ "internalType": "address",
218
+ "name": "token",
219
+ "type": "address"
220
+ },
221
+ {
222
+ "internalType": "address",
223
+ "name": "from",
224
+ "type": "address"
225
+ },
226
+ {
227
+ "internalType": "uint256",
228
+ "name": "amount",
229
+ "type": "uint256"
230
+ },
231
+ {
232
+ "internalType": "address",
233
+ "name": "recipient",
234
+ "type": "address"
235
+ }
236
+ ],
237
+ "name": "sweep",
238
+ "outputs": [],
239
+ "stateMutability": "nonpayable",
240
+ "type": "function"
241
+ },
242
+ {
243
+ "inputs": [
244
+ {
245
+ "internalType": "address",
246
+ "name": "token",
247
+ "type": "address"
248
+ },
249
+ {
250
+ "internalType": "address[]",
251
+ "name": "froms",
252
+ "type": "address[]"
253
+ },
254
+ {
255
+ "internalType": "uint256[]",
256
+ "name": "amounts",
257
+ "type": "uint256[]"
258
+ },
259
+ {
260
+ "internalType": "address",
261
+ "name": "recipient",
262
+ "type": "address"
263
+ }
264
+ ],
265
+ "name": "sweepBatch",
266
+ "outputs": [],
267
+ "stateMutability": "nonpayable",
268
+ "type": "function"
269
+ },
270
+ {
271
+ "inputs": [
272
+ {
273
+ "internalType": "address",
274
+ "name": "newOwner",
275
+ "type": "address"
276
+ }
277
+ ],
278
+ "name": "transferOwnership",
279
+ "outputs": [],
280
+ "stateMutability": "nonpayable",
281
+ "type": "function"
282
+ },
283
+ {
284
+ "stateMutability": "payable",
285
+ "type": "receive"
286
+ }
287
+ ] as const satisfies Abi;
288
+
289
+ /**
290
+ * Type-safe ABI for FundCollector
291
+ */
292
+ export type FundCollectorAbi = typeof FundCollectorAbi;
293
+
294
+ /**
295
+ * Contract instance type for FundCollector
296
+ */
297
+ // Use any for contract type to avoid complex viem type issues
298
+ // The runtime behavior is type-safe through viem's ABI typing
299
+ export type FundCollectorContract = any;
300
+
301
+ /**
302
+ * FundCollector Contract Class
303
+ *
304
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * import { createPublicClient, createWalletClient, http } from 'viem';
309
+ * import { mainnet } from 'viem/chains';
310
+ * import { FundCollector } from 'FundCollector';
311
+ *
312
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
313
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
314
+ *
315
+ * const contract = new FundCollector('0x...', { publicClient, walletClient });
316
+ *
317
+ * // Read functions
318
+ * const result = await contract.balanceOf('0x...');
319
+ *
320
+ * // Write functions
321
+ * const hash = await contract.transfer('0x...', 1000n);
322
+ *
323
+ * // Simulate transactions (dry-run)
324
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
325
+ * console.log('Gas estimate:', simulation.request.gas);
326
+ *
327
+ * // Watch events
328
+ * const unwatch = contract.watch.Transfer((event) => {
329
+ * console.log('Transfer event:', event);
330
+ * });
331
+ * ```
332
+ */
333
+ export class FundCollector {
334
+ private contract: FundCollectorContract;
335
+ private contractAddress: Address;
336
+ private publicClient: PublicClient;
337
+
338
+ constructor(
339
+ address: Address,
340
+ clients: {
341
+ publicClient: PublicClient;
342
+ walletClient?: WalletClient;
343
+ }
344
+ ) {
345
+ this.contractAddress = address;
346
+ this.publicClient = clients.publicClient;
347
+ this.contract = getContract({
348
+ address,
349
+ abi: FundCollectorAbi,
350
+ client: {
351
+ public: clients.publicClient,
352
+ wallet: clients.walletClient,
353
+ },
354
+ });
355
+ }
356
+
357
+ /**
358
+ * Get the contract address
359
+ */
360
+ get address(): Address {
361
+ return this.contractAddress;
362
+ }
363
+
364
+ /**
365
+ * Get the underlying viem contract instance.
366
+ */
367
+ getContract(): FundCollectorContract {
368
+ return this.contract;
369
+ }
370
+
371
+ /**
372
+ * owner
373
+ * view
374
+ */
375
+ async owner(): Promise<`0x${string}`> {
376
+ return this.contract.read.owner() as Promise<`0x${string}`>;
377
+ }
378
+
379
+ /**
380
+ * renounceOwnership
381
+ * nonpayable
382
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
383
+ */
384
+ async renounceOwnership(options?: {
385
+ accessList?: import('viem').AccessList;
386
+ authorizationList?: import('viem').AuthorizationList;
387
+ chain?: import('viem').Chain | null;
388
+ dataSuffix?: `0x${string}`;
389
+ gas?: bigint;
390
+ gasPrice?: bigint;
391
+ maxFeePerGas?: bigint;
392
+ maxPriorityFeePerGas?: bigint;
393
+ nonce?: number;
394
+ value?: bigint;
395
+ }): Promise<`0x${string}`> {
396
+ if (!this.contract.write) {
397
+ throw new Error('Wallet client is required for write operations');
398
+ }
399
+ return this.contract.write.renounceOwnership(options) as Promise<`0x${string}`>;
400
+ }
401
+
402
+ /**
403
+ * rescueETH
404
+ * nonpayable
405
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
406
+ */
407
+ async rescueETH(to: `0x${string}`, amount: bigint, options?: {
408
+ accessList?: import('viem').AccessList;
409
+ authorizationList?: import('viem').AuthorizationList;
410
+ chain?: import('viem').Chain | null;
411
+ dataSuffix?: `0x${string}`;
412
+ gas?: bigint;
413
+ gasPrice?: bigint;
414
+ maxFeePerGas?: bigint;
415
+ maxPriorityFeePerGas?: bigint;
416
+ nonce?: number;
417
+ value?: bigint;
418
+ }): Promise<`0x${string}`> {
419
+ if (!this.contract.write) {
420
+ throw new Error('Wallet client is required for write operations');
421
+ }
422
+ return this.contract.write.rescueETH([to, amount] as const, options) as Promise<`0x${string}`>;
423
+ }
424
+
425
+ /**
426
+ * rescueToken
427
+ * nonpayable
428
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
429
+ */
430
+ async rescueToken(token: `0x${string}`, to: `0x${string}`, amount: bigint, options?: {
431
+ accessList?: import('viem').AccessList;
432
+ authorizationList?: import('viem').AuthorizationList;
433
+ chain?: import('viem').Chain | null;
434
+ dataSuffix?: `0x${string}`;
435
+ gas?: bigint;
436
+ gasPrice?: bigint;
437
+ maxFeePerGas?: bigint;
438
+ maxPriorityFeePerGas?: bigint;
439
+ nonce?: number;
440
+ value?: bigint;
441
+ }): Promise<`0x${string}`> {
442
+ if (!this.contract.write) {
443
+ throw new Error('Wallet client is required for write operations');
444
+ }
445
+ return this.contract.write.rescueToken([token, to, amount] as const, options) as Promise<`0x${string}`>;
446
+ }
447
+
448
+ /**
449
+ * sweep
450
+ * nonpayable
451
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
452
+ */
453
+ async sweep(token: `0x${string}`, from: `0x${string}`, amount: bigint, recipient: `0x${string}`, options?: {
454
+ accessList?: import('viem').AccessList;
455
+ authorizationList?: import('viem').AuthorizationList;
456
+ chain?: import('viem').Chain | null;
457
+ dataSuffix?: `0x${string}`;
458
+ gas?: bigint;
459
+ gasPrice?: bigint;
460
+ maxFeePerGas?: bigint;
461
+ maxPriorityFeePerGas?: bigint;
462
+ nonce?: number;
463
+ value?: bigint;
464
+ }): Promise<`0x${string}`> {
465
+ if (!this.contract.write) {
466
+ throw new Error('Wallet client is required for write operations');
467
+ }
468
+ return this.contract.write.sweep([token, from, amount, recipient] as const, options) as Promise<`0x${string}`>;
469
+ }
470
+
471
+ /**
472
+ * sweepBatch
473
+ * nonpayable
474
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
475
+ */
476
+ async sweepBatch(token: `0x${string}`, froms: `0x${string}`[], amounts: bigint[], recipient: `0x${string}`, options?: {
477
+ accessList?: import('viem').AccessList;
478
+ authorizationList?: import('viem').AuthorizationList;
479
+ chain?: import('viem').Chain | null;
480
+ dataSuffix?: `0x${string}`;
481
+ gas?: bigint;
482
+ gasPrice?: bigint;
483
+ maxFeePerGas?: bigint;
484
+ maxPriorityFeePerGas?: bigint;
485
+ nonce?: number;
486
+ value?: bigint;
487
+ }): Promise<`0x${string}`> {
488
+ if (!this.contract.write) {
489
+ throw new Error('Wallet client is required for write operations');
490
+ }
491
+ return this.contract.write.sweepBatch([token, froms, amounts, recipient] as const, options) as Promise<`0x${string}`>;
492
+ }
493
+
494
+ /**
495
+ * transferOwnership
496
+ * nonpayable
497
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
498
+ */
499
+ async transferOwnership(newOwner: `0x${string}`, options?: {
500
+ accessList?: import('viem').AccessList;
501
+ authorizationList?: import('viem').AuthorizationList;
502
+ chain?: import('viem').Chain | null;
503
+ dataSuffix?: `0x${string}`;
504
+ gas?: bigint;
505
+ gasPrice?: bigint;
506
+ maxFeePerGas?: bigint;
507
+ maxPriorityFeePerGas?: bigint;
508
+ nonce?: number;
509
+ value?: bigint;
510
+ }): Promise<`0x${string}`> {
511
+ if (!this.contract.write) {
512
+ throw new Error('Wallet client is required for write operations');
513
+ }
514
+ return this.contract.write.transferOwnership([newOwner] as const, options) as Promise<`0x${string}`>;
515
+ }
516
+
517
+
518
+
519
+ /**
520
+ * Simulate contract write operations (dry-run without sending transaction)
521
+ *
522
+ * @example
523
+ * const result = await contract.simulate.transfer('0x...', 1000n);
524
+ * console.log('Gas estimate:', result.request.gas);
525
+ * console.log('Would succeed:', result.result);
526
+ */
527
+ get simulate() {
528
+ const contract = this.contract;
529
+ if (!contract.simulate) {
530
+ throw new Error('Public client is required for simulation');
531
+ }
532
+ return {
533
+ /**
534
+ * Simulate renounceOwnership
535
+ * Returns gas estimate and result without sending transaction
536
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
537
+ */
538
+ async renounceOwnership(options?: {
539
+ accessList?: import('viem').AccessList;
540
+ authorizationList?: import('viem').AuthorizationList;
541
+ chain?: import('viem').Chain | null;
542
+ dataSuffix?: `0x${string}`;
543
+ gas?: bigint;
544
+ gasPrice?: bigint;
545
+ maxFeePerGas?: bigint;
546
+ maxPriorityFeePerGas?: bigint;
547
+ nonce?: number;
548
+ value?: bigint;
549
+ }): Promise<void> {
550
+ return contract.simulate.renounceOwnership(options) as Promise<void>;
551
+ },
552
+ /**
553
+ * Simulate rescueETH
554
+ * Returns gas estimate and result without sending transaction
555
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
556
+ */
557
+ async rescueETH(to: `0x${string}`, amount: bigint, options?: {
558
+ accessList?: import('viem').AccessList;
559
+ authorizationList?: import('viem').AuthorizationList;
560
+ chain?: import('viem').Chain | null;
561
+ dataSuffix?: `0x${string}`;
562
+ gas?: bigint;
563
+ gasPrice?: bigint;
564
+ maxFeePerGas?: bigint;
565
+ maxPriorityFeePerGas?: bigint;
566
+ nonce?: number;
567
+ value?: bigint;
568
+ }): Promise<void> {
569
+ return contract.simulate.rescueETH([to, amount] as const, options) as Promise<void>;
570
+ },
571
+ /**
572
+ * Simulate rescueToken
573
+ * Returns gas estimate and result without sending transaction
574
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
575
+ */
576
+ async rescueToken(token: `0x${string}`, to: `0x${string}`, amount: bigint, options?: {
577
+ accessList?: import('viem').AccessList;
578
+ authorizationList?: import('viem').AuthorizationList;
579
+ chain?: import('viem').Chain | null;
580
+ dataSuffix?: `0x${string}`;
581
+ gas?: bigint;
582
+ gasPrice?: bigint;
583
+ maxFeePerGas?: bigint;
584
+ maxPriorityFeePerGas?: bigint;
585
+ nonce?: number;
586
+ value?: bigint;
587
+ }): Promise<void> {
588
+ return contract.simulate.rescueToken([token, to, amount] as const, options) as Promise<void>;
589
+ },
590
+ /**
591
+ * Simulate sweep
592
+ * Returns gas estimate and result without sending transaction
593
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
594
+ */
595
+ async sweep(token: `0x${string}`, from: `0x${string}`, amount: bigint, recipient: `0x${string}`, options?: {
596
+ accessList?: import('viem').AccessList;
597
+ authorizationList?: import('viem').AuthorizationList;
598
+ chain?: import('viem').Chain | null;
599
+ dataSuffix?: `0x${string}`;
600
+ gas?: bigint;
601
+ gasPrice?: bigint;
602
+ maxFeePerGas?: bigint;
603
+ maxPriorityFeePerGas?: bigint;
604
+ nonce?: number;
605
+ value?: bigint;
606
+ }): Promise<void> {
607
+ return contract.simulate.sweep([token, from, amount, recipient] as const, options) as Promise<void>;
608
+ },
609
+ /**
610
+ * Simulate sweepBatch
611
+ * Returns gas estimate and result without sending transaction
612
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
613
+ */
614
+ async sweepBatch(token: `0x${string}`, froms: `0x${string}`[], amounts: bigint[], recipient: `0x${string}`, options?: {
615
+ accessList?: import('viem').AccessList;
616
+ authorizationList?: import('viem').AuthorizationList;
617
+ chain?: import('viem').Chain | null;
618
+ dataSuffix?: `0x${string}`;
619
+ gas?: bigint;
620
+ gasPrice?: bigint;
621
+ maxFeePerGas?: bigint;
622
+ maxPriorityFeePerGas?: bigint;
623
+ nonce?: number;
624
+ value?: bigint;
625
+ }): Promise<void> {
626
+ return contract.simulate.sweepBatch([token, froms, amounts, recipient] as const, options) as Promise<void>;
627
+ },
628
+ /**
629
+ * Simulate transferOwnership
630
+ * Returns gas estimate and result without sending transaction
631
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
632
+ */
633
+ async transferOwnership(newOwner: `0x${string}`, options?: {
634
+ accessList?: import('viem').AccessList;
635
+ authorizationList?: import('viem').AuthorizationList;
636
+ chain?: import('viem').Chain | null;
637
+ dataSuffix?: `0x${string}`;
638
+ gas?: bigint;
639
+ gasPrice?: bigint;
640
+ maxFeePerGas?: bigint;
641
+ maxPriorityFeePerGas?: bigint;
642
+ nonce?: number;
643
+ value?: bigint;
644
+ }): Promise<void> {
645
+ return contract.simulate.transferOwnership([newOwner] as const, options) as Promise<void>;
646
+ }
647
+ };
648
+ }
649
+
650
+ /**
651
+ * Watch contract events
652
+ *
653
+ * @example
654
+ * // Watch all Transfer events
655
+ * const unwatch = contract.watch.Transfer((event) => {
656
+ * console.log('Transfer:', event);
657
+ * });
658
+ *
659
+ * // Stop watching
660
+ * unwatch();
661
+ */
662
+ get watch() {
663
+ return {
664
+ /**
665
+ * Watch EthRescued events
666
+ * @param callback Function to call when event is emitted
667
+ * @param filter Optional filter for indexed parameters
668
+ * @returns Unwatch function to stop listening
669
+ */
670
+ EthRescued: (callback: (event: { to: `0x${string}`; amount: bigint }) => void, filter?: { to?: `0x${string}` | `0x${string}`[] | null }) => {
671
+ return this.publicClient.watchContractEvent({
672
+ address: this.contractAddress,
673
+ abi: FundCollectorAbi,
674
+ eventName: 'EthRescued',
675
+ args: filter as any,
676
+ onLogs: (logs: any[]) => {
677
+ logs.forEach((log: any) => {
678
+ callback(log.args as any);
679
+ });
680
+ },
681
+ }) as () => void;
682
+ },
683
+ /**
684
+ * Watch OwnershipTransferred events
685
+ * @param callback Function to call when event is emitted
686
+ * @param filter Optional filter for indexed parameters
687
+ * @returns Unwatch function to stop listening
688
+ */
689
+ OwnershipTransferred: (callback: (event: { previousOwner: `0x${string}`; newOwner: `0x${string}` }) => void, filter?: { previousOwner?: `0x${string}` | `0x${string}`[] | null; newOwner?: `0x${string}` | `0x${string}`[] | null }) => {
690
+ return this.publicClient.watchContractEvent({
691
+ address: this.contractAddress,
692
+ abi: FundCollectorAbi,
693
+ eventName: 'OwnershipTransferred',
694
+ args: filter as any,
695
+ onLogs: (logs: any[]) => {
696
+ logs.forEach((log: any) => {
697
+ callback(log.args as any);
698
+ });
699
+ },
700
+ }) as () => void;
701
+ },
702
+ /**
703
+ * Watch Swept events
704
+ * @param callback Function to call when event is emitted
705
+ * @param filter Optional filter for indexed parameters
706
+ * @returns Unwatch function to stop listening
707
+ */
708
+ Swept: (callback: (event: { token: `0x${string}`; from: `0x${string}`; to: `0x${string}`; amount: bigint }) => void, filter?: { token?: `0x${string}` | `0x${string}`[] | null; from?: `0x${string}` | `0x${string}`[] | null; to?: `0x${string}` | `0x${string}`[] | null }) => {
709
+ return this.publicClient.watchContractEvent({
710
+ address: this.contractAddress,
711
+ abi: FundCollectorAbi,
712
+ eventName: 'Swept',
713
+ args: filter as any,
714
+ onLogs: (logs: any[]) => {
715
+ logs.forEach((log: any) => {
716
+ callback(log.args as any);
717
+ });
718
+ },
719
+ }) as () => void;
720
+ },
721
+ /**
722
+ * Watch TokenRescued events
723
+ * @param callback Function to call when event is emitted
724
+ * @param filter Optional filter for indexed parameters
725
+ * @returns Unwatch function to stop listening
726
+ */
727
+ TokenRescued: (callback: (event: { token: `0x${string}`; to: `0x${string}`; amount: bigint }) => void, filter?: { token?: `0x${string}` | `0x${string}`[] | null; to?: `0x${string}` | `0x${string}`[] | null }) => {
728
+ return this.publicClient.watchContractEvent({
729
+ address: this.contractAddress,
730
+ abi: FundCollectorAbi,
731
+ eventName: 'TokenRescued',
732
+ args: filter as any,
733
+ onLogs: (logs: any[]) => {
734
+ logs.forEach((log: any) => {
735
+ callback(log.args as any);
736
+ });
737
+ },
738
+ }) as () => void;
739
+ }
740
+ };
741
+ }
742
+ }