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