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