@gitmyabi-stg/safe 0.0.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.
@@ -0,0 +1,1063 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * SafeToken ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const SafeTokenAbi = [
10
+ {
11
+ "inputs": [
12
+ {
13
+ "internalType": "address",
14
+ "name": "owner",
15
+ "type": "address"
16
+ }
17
+ ],
18
+ "stateMutability": "nonpayable",
19
+ "type": "constructor"
20
+ },
21
+ {
22
+ "anonymous": false,
23
+ "inputs": [
24
+ {
25
+ "indexed": true,
26
+ "internalType": "address",
27
+ "name": "owner",
28
+ "type": "address"
29
+ },
30
+ {
31
+ "indexed": true,
32
+ "internalType": "address",
33
+ "name": "spender",
34
+ "type": "address"
35
+ },
36
+ {
37
+ "indexed": false,
38
+ "internalType": "uint256",
39
+ "name": "value",
40
+ "type": "uint256"
41
+ }
42
+ ],
43
+ "name": "Approval",
44
+ "type": "event"
45
+ },
46
+ {
47
+ "anonymous": false,
48
+ "inputs": [
49
+ {
50
+ "indexed": true,
51
+ "internalType": "address",
52
+ "name": "previousOwner",
53
+ "type": "address"
54
+ },
55
+ {
56
+ "indexed": true,
57
+ "internalType": "address",
58
+ "name": "newOwner",
59
+ "type": "address"
60
+ }
61
+ ],
62
+ "name": "OwnershipTransferred",
63
+ "type": "event"
64
+ },
65
+ {
66
+ "anonymous": false,
67
+ "inputs": [
68
+ {
69
+ "indexed": false,
70
+ "internalType": "address",
71
+ "name": "account",
72
+ "type": "address"
73
+ }
74
+ ],
75
+ "name": "Paused",
76
+ "type": "event"
77
+ },
78
+ {
79
+ "anonymous": false,
80
+ "inputs": [
81
+ {
82
+ "indexed": true,
83
+ "internalType": "address",
84
+ "name": "from",
85
+ "type": "address"
86
+ },
87
+ {
88
+ "indexed": true,
89
+ "internalType": "address",
90
+ "name": "to",
91
+ "type": "address"
92
+ },
93
+ {
94
+ "indexed": false,
95
+ "internalType": "uint256",
96
+ "name": "value",
97
+ "type": "uint256"
98
+ }
99
+ ],
100
+ "name": "Transfer",
101
+ "type": "event"
102
+ },
103
+ {
104
+ "anonymous": false,
105
+ "inputs": [
106
+ {
107
+ "indexed": false,
108
+ "internalType": "address",
109
+ "name": "account",
110
+ "type": "address"
111
+ }
112
+ ],
113
+ "name": "Unpaused",
114
+ "type": "event"
115
+ },
116
+ {
117
+ "inputs": [
118
+ {
119
+ "internalType": "address",
120
+ "name": "owner",
121
+ "type": "address"
122
+ },
123
+ {
124
+ "internalType": "address",
125
+ "name": "spender",
126
+ "type": "address"
127
+ }
128
+ ],
129
+ "name": "allowance",
130
+ "outputs": [
131
+ {
132
+ "internalType": "uint256",
133
+ "name": "",
134
+ "type": "uint256"
135
+ }
136
+ ],
137
+ "stateMutability": "view",
138
+ "type": "function"
139
+ },
140
+ {
141
+ "inputs": [
142
+ {
143
+ "internalType": "address",
144
+ "name": "spender",
145
+ "type": "address"
146
+ },
147
+ {
148
+ "internalType": "uint256",
149
+ "name": "amount",
150
+ "type": "uint256"
151
+ }
152
+ ],
153
+ "name": "approve",
154
+ "outputs": [
155
+ {
156
+ "internalType": "bool",
157
+ "name": "",
158
+ "type": "bool"
159
+ }
160
+ ],
161
+ "stateMutability": "nonpayable",
162
+ "type": "function"
163
+ },
164
+ {
165
+ "inputs": [
166
+ {
167
+ "internalType": "address",
168
+ "name": "account",
169
+ "type": "address"
170
+ }
171
+ ],
172
+ "name": "balanceOf",
173
+ "outputs": [
174
+ {
175
+ "internalType": "uint256",
176
+ "name": "",
177
+ "type": "uint256"
178
+ }
179
+ ],
180
+ "stateMutability": "view",
181
+ "type": "function"
182
+ },
183
+ {
184
+ "inputs": [],
185
+ "name": "decimals",
186
+ "outputs": [
187
+ {
188
+ "internalType": "uint8",
189
+ "name": "",
190
+ "type": "uint8"
191
+ }
192
+ ],
193
+ "stateMutability": "view",
194
+ "type": "function"
195
+ },
196
+ {
197
+ "inputs": [
198
+ {
199
+ "internalType": "address",
200
+ "name": "spender",
201
+ "type": "address"
202
+ },
203
+ {
204
+ "internalType": "uint256",
205
+ "name": "subtractedValue",
206
+ "type": "uint256"
207
+ }
208
+ ],
209
+ "name": "decreaseAllowance",
210
+ "outputs": [
211
+ {
212
+ "internalType": "bool",
213
+ "name": "",
214
+ "type": "bool"
215
+ }
216
+ ],
217
+ "stateMutability": "nonpayable",
218
+ "type": "function"
219
+ },
220
+ {
221
+ "inputs": [
222
+ {
223
+ "internalType": "address",
224
+ "name": "spender",
225
+ "type": "address"
226
+ },
227
+ {
228
+ "internalType": "uint256",
229
+ "name": "addedValue",
230
+ "type": "uint256"
231
+ }
232
+ ],
233
+ "name": "increaseAllowance",
234
+ "outputs": [
235
+ {
236
+ "internalType": "bool",
237
+ "name": "",
238
+ "type": "bool"
239
+ }
240
+ ],
241
+ "stateMutability": "nonpayable",
242
+ "type": "function"
243
+ },
244
+ {
245
+ "inputs": [],
246
+ "name": "name",
247
+ "outputs": [
248
+ {
249
+ "internalType": "string",
250
+ "name": "",
251
+ "type": "string"
252
+ }
253
+ ],
254
+ "stateMutability": "view",
255
+ "type": "function"
256
+ },
257
+ {
258
+ "inputs": [],
259
+ "name": "owner",
260
+ "outputs": [
261
+ {
262
+ "internalType": "address",
263
+ "name": "",
264
+ "type": "address"
265
+ }
266
+ ],
267
+ "stateMutability": "view",
268
+ "type": "function"
269
+ },
270
+ {
271
+ "inputs": [],
272
+ "name": "paused",
273
+ "outputs": [
274
+ {
275
+ "internalType": "bool",
276
+ "name": "",
277
+ "type": "bool"
278
+ }
279
+ ],
280
+ "stateMutability": "view",
281
+ "type": "function"
282
+ },
283
+ {
284
+ "inputs": [],
285
+ "name": "renounceOwnership",
286
+ "outputs": [],
287
+ "stateMutability": "nonpayable",
288
+ "type": "function"
289
+ },
290
+ {
291
+ "inputs": [
292
+ {
293
+ "internalType": "contract IERC20",
294
+ "name": "token",
295
+ "type": "address"
296
+ },
297
+ {
298
+ "internalType": "address",
299
+ "name": "beneficiary",
300
+ "type": "address"
301
+ }
302
+ ],
303
+ "name": "rescueToken",
304
+ "outputs": [],
305
+ "stateMutability": "nonpayable",
306
+ "type": "function"
307
+ },
308
+ {
309
+ "inputs": [],
310
+ "name": "symbol",
311
+ "outputs": [
312
+ {
313
+ "internalType": "string",
314
+ "name": "",
315
+ "type": "string"
316
+ }
317
+ ],
318
+ "stateMutability": "view",
319
+ "type": "function"
320
+ },
321
+ {
322
+ "inputs": [],
323
+ "name": "totalSupply",
324
+ "outputs": [
325
+ {
326
+ "internalType": "uint256",
327
+ "name": "",
328
+ "type": "uint256"
329
+ }
330
+ ],
331
+ "stateMutability": "view",
332
+ "type": "function"
333
+ },
334
+ {
335
+ "inputs": [
336
+ {
337
+ "internalType": "address",
338
+ "name": "to",
339
+ "type": "address"
340
+ },
341
+ {
342
+ "internalType": "uint256",
343
+ "name": "amount",
344
+ "type": "uint256"
345
+ }
346
+ ],
347
+ "name": "transfer",
348
+ "outputs": [
349
+ {
350
+ "internalType": "bool",
351
+ "name": "",
352
+ "type": "bool"
353
+ }
354
+ ],
355
+ "stateMutability": "nonpayable",
356
+ "type": "function"
357
+ },
358
+ {
359
+ "inputs": [
360
+ {
361
+ "internalType": "address",
362
+ "name": "from",
363
+ "type": "address"
364
+ },
365
+ {
366
+ "internalType": "address",
367
+ "name": "to",
368
+ "type": "address"
369
+ },
370
+ {
371
+ "internalType": "uint256",
372
+ "name": "amount",
373
+ "type": "uint256"
374
+ }
375
+ ],
376
+ "name": "transferFrom",
377
+ "outputs": [
378
+ {
379
+ "internalType": "bool",
380
+ "name": "",
381
+ "type": "bool"
382
+ }
383
+ ],
384
+ "stateMutability": "nonpayable",
385
+ "type": "function"
386
+ },
387
+ {
388
+ "inputs": [
389
+ {
390
+ "internalType": "address",
391
+ "name": "newOwner",
392
+ "type": "address"
393
+ }
394
+ ],
395
+ "name": "transferOwnership",
396
+ "outputs": [],
397
+ "stateMutability": "nonpayable",
398
+ "type": "function"
399
+ },
400
+ {
401
+ "inputs": [],
402
+ "name": "unpause",
403
+ "outputs": [],
404
+ "stateMutability": "nonpayable",
405
+ "type": "function"
406
+ }
407
+ ] as const satisfies Abi;
408
+
409
+ /**
410
+ * Type-safe ABI for SafeToken
411
+ */
412
+ export type SafeTokenAbi = typeof SafeTokenAbi;
413
+
414
+ /**
415
+ * Contract instance type for SafeToken
416
+ */
417
+ // Use any for contract type to avoid complex viem type issues
418
+ // The runtime behavior is type-safe through viem's ABI typing
419
+ export type SafeTokenContract = any;
420
+
421
+ /**
422
+ * SafeToken Contract Class
423
+ *
424
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
425
+ *
426
+ * @example
427
+ * ```typescript
428
+ * import { createPublicClient, createWalletClient, http } from 'viem';
429
+ * import { mainnet } from 'viem/chains';
430
+ * import { SafeToken } from 'SafeToken';
431
+ *
432
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
433
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
434
+ *
435
+ * const contract = new SafeToken('0x...', { publicClient, walletClient });
436
+ *
437
+ * // Read functions
438
+ * const result = await contract.balanceOf('0x...');
439
+ *
440
+ * // Write functions
441
+ * const hash = await contract.transfer('0x...', 1000n);
442
+ *
443
+ * // Simulate transactions (dry-run)
444
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
445
+ * console.log('Gas estimate:', simulation.request.gas);
446
+ *
447
+ * // Watch events
448
+ * const unwatch = contract.watch.Transfer((event) => {
449
+ * console.log('Transfer event:', event);
450
+ * });
451
+ * ```
452
+ */
453
+ export class SafeToken {
454
+ private contract: SafeTokenContract;
455
+ private contractAddress: Address;
456
+ private publicClient: PublicClient;
457
+
458
+ constructor(
459
+ address: Address,
460
+ clients: {
461
+ publicClient: PublicClient;
462
+ walletClient?: WalletClient;
463
+ }
464
+ ) {
465
+ this.contractAddress = address;
466
+ this.publicClient = clients.publicClient;
467
+ this.contract = getContract({
468
+ address,
469
+ abi: SafeTokenAbi,
470
+ client: {
471
+ public: clients.publicClient,
472
+ wallet: clients.walletClient,
473
+ },
474
+ });
475
+ }
476
+
477
+ /**
478
+ * Get the contract address
479
+ */
480
+ get address(): Address {
481
+ return this.contractAddress;
482
+ }
483
+
484
+ /**
485
+ * Get the underlying viem contract instance.
486
+ */
487
+ getContract(): SafeTokenContract {
488
+ return this.contract;
489
+ }
490
+
491
+ /**
492
+ * allowance
493
+ * view
494
+ */
495
+ async allowance(owner: `0x${string}`, spender: `0x${string}`): Promise<bigint> {
496
+ return this.contract.read.allowance([owner, spender] as const) as Promise<bigint>;
497
+ }
498
+
499
+ /**
500
+ * balanceOf
501
+ * view
502
+ */
503
+ async balanceOf(account: `0x${string}`): Promise<bigint> {
504
+ return this.contract.read.balanceOf([account] as const) as Promise<bigint>;
505
+ }
506
+
507
+ /**
508
+ * decimals
509
+ * view
510
+ */
511
+ async decimals(): Promise<bigint> {
512
+ return this.contract.read.decimals() as Promise<bigint>;
513
+ }
514
+
515
+ /**
516
+ * name
517
+ * view
518
+ */
519
+ async name(): Promise<string> {
520
+ return this.contract.read.name() as Promise<string>;
521
+ }
522
+
523
+ /**
524
+ * owner
525
+ * view
526
+ */
527
+ async owner(): Promise<`0x${string}`> {
528
+ return this.contract.read.owner() as Promise<`0x${string}`>;
529
+ }
530
+
531
+ /**
532
+ * paused
533
+ * view
534
+ */
535
+ async paused(): Promise<boolean> {
536
+ return this.contract.read.paused() as Promise<boolean>;
537
+ }
538
+
539
+ /**
540
+ * symbol
541
+ * view
542
+ */
543
+ async symbol(): Promise<string> {
544
+ return this.contract.read.symbol() as Promise<string>;
545
+ }
546
+
547
+ /**
548
+ * totalSupply
549
+ * view
550
+ */
551
+ async totalSupply(): Promise<bigint> {
552
+ return this.contract.read.totalSupply() as Promise<bigint>;
553
+ }
554
+
555
+ /**
556
+ * approve
557
+ * nonpayable
558
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
559
+ */
560
+ async approve(spender: `0x${string}`, amount: bigint, options?: {
561
+ accessList?: import('viem').AccessList;
562
+ authorizationList?: import('viem').AuthorizationList;
563
+ chain?: import('viem').Chain | null;
564
+ dataSuffix?: `0x${string}`;
565
+ gas?: bigint;
566
+ gasPrice?: bigint;
567
+ maxFeePerGas?: bigint;
568
+ maxPriorityFeePerGas?: bigint;
569
+ nonce?: number;
570
+ value?: bigint;
571
+ }): Promise<`0x${string}`> {
572
+ if (!this.contract.write) {
573
+ throw new Error('Wallet client is required for write operations');
574
+ }
575
+ return this.contract.write.approve([spender, amount] as const, options) as Promise<`0x${string}`>;
576
+ }
577
+
578
+ /**
579
+ * decreaseAllowance
580
+ * nonpayable
581
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
582
+ */
583
+ async decreaseAllowance(spender: `0x${string}`, subtractedValue: bigint, options?: {
584
+ accessList?: import('viem').AccessList;
585
+ authorizationList?: import('viem').AuthorizationList;
586
+ chain?: import('viem').Chain | null;
587
+ dataSuffix?: `0x${string}`;
588
+ gas?: bigint;
589
+ gasPrice?: bigint;
590
+ maxFeePerGas?: bigint;
591
+ maxPriorityFeePerGas?: bigint;
592
+ nonce?: number;
593
+ value?: bigint;
594
+ }): Promise<`0x${string}`> {
595
+ if (!this.contract.write) {
596
+ throw new Error('Wallet client is required for write operations');
597
+ }
598
+ return this.contract.write.decreaseAllowance([spender, subtractedValue] as const, options) as Promise<`0x${string}`>;
599
+ }
600
+
601
+ /**
602
+ * increaseAllowance
603
+ * nonpayable
604
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
605
+ */
606
+ async increaseAllowance(spender: `0x${string}`, addedValue: bigint, options?: {
607
+ accessList?: import('viem').AccessList;
608
+ authorizationList?: import('viem').AuthorizationList;
609
+ chain?: import('viem').Chain | null;
610
+ dataSuffix?: `0x${string}`;
611
+ gas?: bigint;
612
+ gasPrice?: bigint;
613
+ maxFeePerGas?: bigint;
614
+ maxPriorityFeePerGas?: bigint;
615
+ nonce?: number;
616
+ value?: bigint;
617
+ }): Promise<`0x${string}`> {
618
+ if (!this.contract.write) {
619
+ throw new Error('Wallet client is required for write operations');
620
+ }
621
+ return this.contract.write.increaseAllowance([spender, addedValue] as const, options) as Promise<`0x${string}`>;
622
+ }
623
+
624
+ /**
625
+ * renounceOwnership
626
+ * nonpayable
627
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
628
+ */
629
+ async renounceOwnership(options?: {
630
+ accessList?: import('viem').AccessList;
631
+ authorizationList?: import('viem').AuthorizationList;
632
+ chain?: import('viem').Chain | null;
633
+ dataSuffix?: `0x${string}`;
634
+ gas?: bigint;
635
+ gasPrice?: bigint;
636
+ maxFeePerGas?: bigint;
637
+ maxPriorityFeePerGas?: bigint;
638
+ nonce?: number;
639
+ value?: bigint;
640
+ }): Promise<`0x${string}`> {
641
+ if (!this.contract.write) {
642
+ throw new Error('Wallet client is required for write operations');
643
+ }
644
+ return this.contract.write.renounceOwnership(options) as Promise<`0x${string}`>;
645
+ }
646
+
647
+ /**
648
+ * rescueToken
649
+ * nonpayable
650
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
651
+ */
652
+ async rescueToken(token: `0x${string}`, beneficiary: `0x${string}`, options?: {
653
+ accessList?: import('viem').AccessList;
654
+ authorizationList?: import('viem').AuthorizationList;
655
+ chain?: import('viem').Chain | null;
656
+ dataSuffix?: `0x${string}`;
657
+ gas?: bigint;
658
+ gasPrice?: bigint;
659
+ maxFeePerGas?: bigint;
660
+ maxPriorityFeePerGas?: bigint;
661
+ nonce?: number;
662
+ value?: bigint;
663
+ }): Promise<`0x${string}`> {
664
+ if (!this.contract.write) {
665
+ throw new Error('Wallet client is required for write operations');
666
+ }
667
+ return this.contract.write.rescueToken([token, beneficiary] as const, options) as Promise<`0x${string}`>;
668
+ }
669
+
670
+ /**
671
+ * transfer
672
+ * nonpayable
673
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
674
+ */
675
+ async transfer(to: `0x${string}`, amount: bigint, options?: {
676
+ accessList?: import('viem').AccessList;
677
+ authorizationList?: import('viem').AuthorizationList;
678
+ chain?: import('viem').Chain | null;
679
+ dataSuffix?: `0x${string}`;
680
+ gas?: bigint;
681
+ gasPrice?: bigint;
682
+ maxFeePerGas?: bigint;
683
+ maxPriorityFeePerGas?: bigint;
684
+ nonce?: number;
685
+ value?: bigint;
686
+ }): Promise<`0x${string}`> {
687
+ if (!this.contract.write) {
688
+ throw new Error('Wallet client is required for write operations');
689
+ }
690
+ return this.contract.write.transfer([to, amount] as const, options) as Promise<`0x${string}`>;
691
+ }
692
+
693
+ /**
694
+ * transferFrom
695
+ * nonpayable
696
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
697
+ */
698
+ async transferFrom(from: `0x${string}`, to: `0x${string}`, amount: bigint, options?: {
699
+ accessList?: import('viem').AccessList;
700
+ authorizationList?: import('viem').AuthorizationList;
701
+ chain?: import('viem').Chain | null;
702
+ dataSuffix?: `0x${string}`;
703
+ gas?: bigint;
704
+ gasPrice?: bigint;
705
+ maxFeePerGas?: bigint;
706
+ maxPriorityFeePerGas?: bigint;
707
+ nonce?: number;
708
+ value?: bigint;
709
+ }): Promise<`0x${string}`> {
710
+ if (!this.contract.write) {
711
+ throw new Error('Wallet client is required for write operations');
712
+ }
713
+ return this.contract.write.transferFrom([from, to, amount] as const, options) as Promise<`0x${string}`>;
714
+ }
715
+
716
+ /**
717
+ * transferOwnership
718
+ * nonpayable
719
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
720
+ */
721
+ async transferOwnership(newOwner: `0x${string}`, options?: {
722
+ accessList?: import('viem').AccessList;
723
+ authorizationList?: import('viem').AuthorizationList;
724
+ chain?: import('viem').Chain | null;
725
+ dataSuffix?: `0x${string}`;
726
+ gas?: bigint;
727
+ gasPrice?: bigint;
728
+ maxFeePerGas?: bigint;
729
+ maxPriorityFeePerGas?: bigint;
730
+ nonce?: number;
731
+ value?: bigint;
732
+ }): Promise<`0x${string}`> {
733
+ if (!this.contract.write) {
734
+ throw new Error('Wallet client is required for write operations');
735
+ }
736
+ return this.contract.write.transferOwnership([newOwner] as const, options) as Promise<`0x${string}`>;
737
+ }
738
+
739
+ /**
740
+ * unpause
741
+ * nonpayable
742
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
743
+ */
744
+ async unpause(options?: {
745
+ accessList?: import('viem').AccessList;
746
+ authorizationList?: import('viem').AuthorizationList;
747
+ chain?: import('viem').Chain | null;
748
+ dataSuffix?: `0x${string}`;
749
+ gas?: bigint;
750
+ gasPrice?: bigint;
751
+ maxFeePerGas?: bigint;
752
+ maxPriorityFeePerGas?: bigint;
753
+ nonce?: number;
754
+ value?: bigint;
755
+ }): Promise<`0x${string}`> {
756
+ if (!this.contract.write) {
757
+ throw new Error('Wallet client is required for write operations');
758
+ }
759
+ return this.contract.write.unpause(options) as Promise<`0x${string}`>;
760
+ }
761
+
762
+
763
+
764
+ /**
765
+ * Simulate contract write operations (dry-run without sending transaction)
766
+ *
767
+ * @example
768
+ * const result = await contract.simulate.transfer('0x...', 1000n);
769
+ * console.log('Gas estimate:', result.request.gas);
770
+ * console.log('Would succeed:', result.result);
771
+ */
772
+ get simulate() {
773
+ const contract = this.contract;
774
+ if (!contract.simulate) {
775
+ throw new Error('Public client is required for simulation');
776
+ }
777
+ return {
778
+ /**
779
+ * Simulate approve
780
+ * Returns gas estimate and result without sending transaction
781
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
782
+ */
783
+ async approve(spender: `0x${string}`, amount: bigint, options?: {
784
+ accessList?: import('viem').AccessList;
785
+ authorizationList?: import('viem').AuthorizationList;
786
+ chain?: import('viem').Chain | null;
787
+ dataSuffix?: `0x${string}`;
788
+ gas?: bigint;
789
+ gasPrice?: bigint;
790
+ maxFeePerGas?: bigint;
791
+ maxPriorityFeePerGas?: bigint;
792
+ nonce?: number;
793
+ value?: bigint;
794
+ }): Promise<boolean> {
795
+ return contract.simulate.approve([spender, amount] as const, options) as Promise<boolean>;
796
+ },
797
+ /**
798
+ * Simulate decreaseAllowance
799
+ * Returns gas estimate and result without sending transaction
800
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
801
+ */
802
+ async decreaseAllowance(spender: `0x${string}`, subtractedValue: bigint, options?: {
803
+ accessList?: import('viem').AccessList;
804
+ authorizationList?: import('viem').AuthorizationList;
805
+ chain?: import('viem').Chain | null;
806
+ dataSuffix?: `0x${string}`;
807
+ gas?: bigint;
808
+ gasPrice?: bigint;
809
+ maxFeePerGas?: bigint;
810
+ maxPriorityFeePerGas?: bigint;
811
+ nonce?: number;
812
+ value?: bigint;
813
+ }): Promise<boolean> {
814
+ return contract.simulate.decreaseAllowance([spender, subtractedValue] as const, options) as Promise<boolean>;
815
+ },
816
+ /**
817
+ * Simulate increaseAllowance
818
+ * Returns gas estimate and result without sending transaction
819
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
820
+ */
821
+ async increaseAllowance(spender: `0x${string}`, addedValue: bigint, options?: {
822
+ accessList?: import('viem').AccessList;
823
+ authorizationList?: import('viem').AuthorizationList;
824
+ chain?: import('viem').Chain | null;
825
+ dataSuffix?: `0x${string}`;
826
+ gas?: bigint;
827
+ gasPrice?: bigint;
828
+ maxFeePerGas?: bigint;
829
+ maxPriorityFeePerGas?: bigint;
830
+ nonce?: number;
831
+ value?: bigint;
832
+ }): Promise<boolean> {
833
+ return contract.simulate.increaseAllowance([spender, addedValue] as const, options) as Promise<boolean>;
834
+ },
835
+ /**
836
+ * Simulate renounceOwnership
837
+ * Returns gas estimate and result without sending transaction
838
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
839
+ */
840
+ async renounceOwnership(options?: {
841
+ accessList?: import('viem').AccessList;
842
+ authorizationList?: import('viem').AuthorizationList;
843
+ chain?: import('viem').Chain | null;
844
+ dataSuffix?: `0x${string}`;
845
+ gas?: bigint;
846
+ gasPrice?: bigint;
847
+ maxFeePerGas?: bigint;
848
+ maxPriorityFeePerGas?: bigint;
849
+ nonce?: number;
850
+ value?: bigint;
851
+ }): Promise<void> {
852
+ return contract.simulate.renounceOwnership(options) as Promise<void>;
853
+ },
854
+ /**
855
+ * Simulate rescueToken
856
+ * Returns gas estimate and result without sending transaction
857
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
858
+ */
859
+ async rescueToken(token: `0x${string}`, beneficiary: `0x${string}`, options?: {
860
+ accessList?: import('viem').AccessList;
861
+ authorizationList?: import('viem').AuthorizationList;
862
+ chain?: import('viem').Chain | null;
863
+ dataSuffix?: `0x${string}`;
864
+ gas?: bigint;
865
+ gasPrice?: bigint;
866
+ maxFeePerGas?: bigint;
867
+ maxPriorityFeePerGas?: bigint;
868
+ nonce?: number;
869
+ value?: bigint;
870
+ }): Promise<void> {
871
+ return contract.simulate.rescueToken([token, beneficiary] as const, options) as Promise<void>;
872
+ },
873
+ /**
874
+ * Simulate transfer
875
+ * Returns gas estimate and result without sending transaction
876
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
877
+ */
878
+ async transfer(to: `0x${string}`, amount: bigint, options?: {
879
+ accessList?: import('viem').AccessList;
880
+ authorizationList?: import('viem').AuthorizationList;
881
+ chain?: import('viem').Chain | null;
882
+ dataSuffix?: `0x${string}`;
883
+ gas?: bigint;
884
+ gasPrice?: bigint;
885
+ maxFeePerGas?: bigint;
886
+ maxPriorityFeePerGas?: bigint;
887
+ nonce?: number;
888
+ value?: bigint;
889
+ }): Promise<boolean> {
890
+ return contract.simulate.transfer([to, amount] as const, options) as Promise<boolean>;
891
+ },
892
+ /**
893
+ * Simulate transferFrom
894
+ * Returns gas estimate and result without sending transaction
895
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
896
+ */
897
+ async transferFrom(from: `0x${string}`, to: `0x${string}`, amount: bigint, options?: {
898
+ accessList?: import('viem').AccessList;
899
+ authorizationList?: import('viem').AuthorizationList;
900
+ chain?: import('viem').Chain | null;
901
+ dataSuffix?: `0x${string}`;
902
+ gas?: bigint;
903
+ gasPrice?: bigint;
904
+ maxFeePerGas?: bigint;
905
+ maxPriorityFeePerGas?: bigint;
906
+ nonce?: number;
907
+ value?: bigint;
908
+ }): Promise<boolean> {
909
+ return contract.simulate.transferFrom([from, to, amount] as const, options) as Promise<boolean>;
910
+ },
911
+ /**
912
+ * Simulate transferOwnership
913
+ * Returns gas estimate and result without sending transaction
914
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
915
+ */
916
+ async transferOwnership(newOwner: `0x${string}`, options?: {
917
+ accessList?: import('viem').AccessList;
918
+ authorizationList?: import('viem').AuthorizationList;
919
+ chain?: import('viem').Chain | null;
920
+ dataSuffix?: `0x${string}`;
921
+ gas?: bigint;
922
+ gasPrice?: bigint;
923
+ maxFeePerGas?: bigint;
924
+ maxPriorityFeePerGas?: bigint;
925
+ nonce?: number;
926
+ value?: bigint;
927
+ }): Promise<void> {
928
+ return contract.simulate.transferOwnership([newOwner] as const, options) as Promise<void>;
929
+ },
930
+ /**
931
+ * Simulate unpause
932
+ * Returns gas estimate and result without sending transaction
933
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
934
+ */
935
+ async unpause(options?: {
936
+ accessList?: import('viem').AccessList;
937
+ authorizationList?: import('viem').AuthorizationList;
938
+ chain?: import('viem').Chain | null;
939
+ dataSuffix?: `0x${string}`;
940
+ gas?: bigint;
941
+ gasPrice?: bigint;
942
+ maxFeePerGas?: bigint;
943
+ maxPriorityFeePerGas?: bigint;
944
+ nonce?: number;
945
+ value?: bigint;
946
+ }): Promise<void> {
947
+ return contract.simulate.unpause(options) as Promise<void>;
948
+ }
949
+ };
950
+ }
951
+
952
+ /**
953
+ * Watch contract events
954
+ *
955
+ * @example
956
+ * // Watch all Transfer events
957
+ * const unwatch = contract.watch.Transfer((event) => {
958
+ * console.log('Transfer:', event);
959
+ * });
960
+ *
961
+ * // Stop watching
962
+ * unwatch();
963
+ */
964
+ get watch() {
965
+ return {
966
+ /**
967
+ * Watch Approval events
968
+ * @param callback Function to call when event is emitted
969
+ * @param filter Optional filter for indexed parameters
970
+ * @returns Unwatch function to stop listening
971
+ */
972
+ Approval: (callback: (event: { owner: `0x${string}`; spender: `0x${string}`; value: bigint }) => void, filter?: { owner?: `0x${string}` | `0x${string}`[] | null; spender?: `0x${string}` | `0x${string}`[] | null }) => {
973
+ return this.publicClient.watchContractEvent({
974
+ address: this.contractAddress,
975
+ abi: SafeTokenAbi,
976
+ eventName: 'Approval',
977
+ args: filter as any,
978
+ onLogs: (logs: any[]) => {
979
+ logs.forEach((log: any) => {
980
+ callback(log.args as any);
981
+ });
982
+ },
983
+ }) as () => void;
984
+ },
985
+ /**
986
+ * Watch OwnershipTransferred events
987
+ * @param callback Function to call when event is emitted
988
+ * @param filter Optional filter for indexed parameters
989
+ * @returns Unwatch function to stop listening
990
+ */
991
+ OwnershipTransferred: (callback: (event: { previousOwner: `0x${string}`; newOwner: `0x${string}` }) => void, filter?: { previousOwner?: `0x${string}` | `0x${string}`[] | null; newOwner?: `0x${string}` | `0x${string}`[] | null }) => {
992
+ return this.publicClient.watchContractEvent({
993
+ address: this.contractAddress,
994
+ abi: SafeTokenAbi,
995
+ eventName: 'OwnershipTransferred',
996
+ args: filter as any,
997
+ onLogs: (logs: any[]) => {
998
+ logs.forEach((log: any) => {
999
+ callback(log.args as any);
1000
+ });
1001
+ },
1002
+ }) as () => void;
1003
+ },
1004
+ /**
1005
+ * Watch Paused events
1006
+ * @param callback Function to call when event is emitted
1007
+ * @param filter Optional filter for indexed parameters
1008
+ * @returns Unwatch function to stop listening
1009
+ */
1010
+ Paused: (callback: (event: { account: `0x${string}` }) => void) => {
1011
+ return this.publicClient.watchContractEvent({
1012
+ address: this.contractAddress,
1013
+ abi: SafeTokenAbi,
1014
+ eventName: 'Paused',
1015
+
1016
+ onLogs: (logs: any[]) => {
1017
+ logs.forEach((log: any) => {
1018
+ callback(log.args as any);
1019
+ });
1020
+ },
1021
+ }) as () => void;
1022
+ },
1023
+ /**
1024
+ * Watch Transfer events
1025
+ * @param callback Function to call when event is emitted
1026
+ * @param filter Optional filter for indexed parameters
1027
+ * @returns Unwatch function to stop listening
1028
+ */
1029
+ Transfer: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from?: `0x${string}` | `0x${string}`[] | null; to?: `0x${string}` | `0x${string}`[] | null }) => {
1030
+ return this.publicClient.watchContractEvent({
1031
+ address: this.contractAddress,
1032
+ abi: SafeTokenAbi,
1033
+ eventName: 'Transfer',
1034
+ args: filter as any,
1035
+ onLogs: (logs: any[]) => {
1036
+ logs.forEach((log: any) => {
1037
+ callback(log.args as any);
1038
+ });
1039
+ },
1040
+ }) as () => void;
1041
+ },
1042
+ /**
1043
+ * Watch Unpaused events
1044
+ * @param callback Function to call when event is emitted
1045
+ * @param filter Optional filter for indexed parameters
1046
+ * @returns Unwatch function to stop listening
1047
+ */
1048
+ Unpaused: (callback: (event: { account: `0x${string}` }) => void) => {
1049
+ return this.publicClient.watchContractEvent({
1050
+ address: this.contractAddress,
1051
+ abi: SafeTokenAbi,
1052
+ eventName: 'Unpaused',
1053
+
1054
+ onLogs: (logs: any[]) => {
1055
+ logs.forEach((log: any) => {
1056
+ callback(log.args as any);
1057
+ });
1058
+ },
1059
+ }) as () => void;
1060
+ }
1061
+ };
1062
+ }
1063
+ }