@gitmyabi/dfi 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1423 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * DFI_json ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const DFI_jsonAbi = [
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": "bytes32",
46
+ "name": "role",
47
+ "type": "bytes32"
48
+ },
49
+ {
50
+ "indexed": true,
51
+ "internalType": "bytes32",
52
+ "name": "previousAdminRole",
53
+ "type": "bytes32"
54
+ },
55
+ {
56
+ "indexed": true,
57
+ "internalType": "bytes32",
58
+ "name": "newAdminRole",
59
+ "type": "bytes32"
60
+ }
61
+ ],
62
+ "name": "RoleAdminChanged",
63
+ "type": "event"
64
+ },
65
+ {
66
+ "anonymous": false,
67
+ "inputs": [
68
+ {
69
+ "indexed": true,
70
+ "internalType": "bytes32",
71
+ "name": "role",
72
+ "type": "bytes32"
73
+ },
74
+ {
75
+ "indexed": true,
76
+ "internalType": "address",
77
+ "name": "account",
78
+ "type": "address"
79
+ },
80
+ {
81
+ "indexed": true,
82
+ "internalType": "address",
83
+ "name": "sender",
84
+ "type": "address"
85
+ }
86
+ ],
87
+ "name": "RoleGranted",
88
+ "type": "event"
89
+ },
90
+ {
91
+ "anonymous": false,
92
+ "inputs": [
93
+ {
94
+ "indexed": true,
95
+ "internalType": "bytes32",
96
+ "name": "role",
97
+ "type": "bytes32"
98
+ },
99
+ {
100
+ "indexed": true,
101
+ "internalType": "address",
102
+ "name": "account",
103
+ "type": "address"
104
+ },
105
+ {
106
+ "indexed": true,
107
+ "internalType": "address",
108
+ "name": "sender",
109
+ "type": "address"
110
+ }
111
+ ],
112
+ "name": "RoleRevoked",
113
+ "type": "event"
114
+ },
115
+ {
116
+ "anonymous": false,
117
+ "inputs": [
118
+ {
119
+ "indexed": true,
120
+ "internalType": "address",
121
+ "name": "from",
122
+ "type": "address"
123
+ },
124
+ {
125
+ "indexed": true,
126
+ "internalType": "address",
127
+ "name": "to",
128
+ "type": "address"
129
+ },
130
+ {
131
+ "indexed": false,
132
+ "internalType": "uint256",
133
+ "name": "value",
134
+ "type": "uint256"
135
+ }
136
+ ],
137
+ "name": "Transfer",
138
+ "type": "event"
139
+ },
140
+ {
141
+ "inputs": [],
142
+ "name": "DEFAULT_ADMIN_ROLE",
143
+ "outputs": [
144
+ {
145
+ "internalType": "bytes32",
146
+ "name": "",
147
+ "type": "bytes32"
148
+ }
149
+ ],
150
+ "stateMutability": "view",
151
+ "type": "function"
152
+ },
153
+ {
154
+ "inputs": [],
155
+ "name": "MINTER_ROLE",
156
+ "outputs": [
157
+ {
158
+ "internalType": "bytes32",
159
+ "name": "",
160
+ "type": "bytes32"
161
+ }
162
+ ],
163
+ "stateMutability": "view",
164
+ "type": "function"
165
+ },
166
+ {
167
+ "inputs": [
168
+ {
169
+ "internalType": "address",
170
+ "name": "owner",
171
+ "type": "address"
172
+ },
173
+ {
174
+ "internalType": "address",
175
+ "name": "spender",
176
+ "type": "address"
177
+ }
178
+ ],
179
+ "name": "allowance",
180
+ "outputs": [
181
+ {
182
+ "internalType": "uint256",
183
+ "name": "",
184
+ "type": "uint256"
185
+ }
186
+ ],
187
+ "stateMutability": "view",
188
+ "type": "function"
189
+ },
190
+ {
191
+ "inputs": [
192
+ {
193
+ "internalType": "address",
194
+ "name": "spender",
195
+ "type": "address"
196
+ },
197
+ {
198
+ "internalType": "uint256",
199
+ "name": "amount",
200
+ "type": "uint256"
201
+ }
202
+ ],
203
+ "name": "approve",
204
+ "outputs": [
205
+ {
206
+ "internalType": "bool",
207
+ "name": "",
208
+ "type": "bool"
209
+ }
210
+ ],
211
+ "stateMutability": "nonpayable",
212
+ "type": "function"
213
+ },
214
+ {
215
+ "inputs": [],
216
+ "name": "backingAddress",
217
+ "outputs": [
218
+ {
219
+ "internalType": "string",
220
+ "name": "",
221
+ "type": "string"
222
+ }
223
+ ],
224
+ "stateMutability": "view",
225
+ "type": "function"
226
+ },
227
+ {
228
+ "inputs": [
229
+ {
230
+ "internalType": "address",
231
+ "name": "account",
232
+ "type": "address"
233
+ }
234
+ ],
235
+ "name": "balanceOf",
236
+ "outputs": [
237
+ {
238
+ "internalType": "uint256",
239
+ "name": "",
240
+ "type": "uint256"
241
+ }
242
+ ],
243
+ "stateMutability": "view",
244
+ "type": "function"
245
+ },
246
+ {
247
+ "inputs": [
248
+ {
249
+ "internalType": "uint256",
250
+ "name": "amount",
251
+ "type": "uint256"
252
+ }
253
+ ],
254
+ "name": "burn",
255
+ "outputs": [],
256
+ "stateMutability": "nonpayable",
257
+ "type": "function"
258
+ },
259
+ {
260
+ "inputs": [
261
+ {
262
+ "internalType": "address",
263
+ "name": "account",
264
+ "type": "address"
265
+ },
266
+ {
267
+ "internalType": "uint256",
268
+ "name": "amount",
269
+ "type": "uint256"
270
+ }
271
+ ],
272
+ "name": "burnFrom",
273
+ "outputs": [],
274
+ "stateMutability": "nonpayable",
275
+ "type": "function"
276
+ },
277
+ {
278
+ "inputs": [],
279
+ "name": "decimals",
280
+ "outputs": [
281
+ {
282
+ "internalType": "uint8",
283
+ "name": "",
284
+ "type": "uint8"
285
+ }
286
+ ],
287
+ "stateMutability": "view",
288
+ "type": "function"
289
+ },
290
+ {
291
+ "inputs": [
292
+ {
293
+ "internalType": "address",
294
+ "name": "spender",
295
+ "type": "address"
296
+ },
297
+ {
298
+ "internalType": "uint256",
299
+ "name": "subtractedValue",
300
+ "type": "uint256"
301
+ }
302
+ ],
303
+ "name": "decreaseAllowance",
304
+ "outputs": [
305
+ {
306
+ "internalType": "bool",
307
+ "name": "",
308
+ "type": "bool"
309
+ }
310
+ ],
311
+ "stateMutability": "nonpayable",
312
+ "type": "function"
313
+ },
314
+ {
315
+ "inputs": [
316
+ {
317
+ "internalType": "bytes32",
318
+ "name": "role",
319
+ "type": "bytes32"
320
+ }
321
+ ],
322
+ "name": "getRoleAdmin",
323
+ "outputs": [
324
+ {
325
+ "internalType": "bytes32",
326
+ "name": "",
327
+ "type": "bytes32"
328
+ }
329
+ ],
330
+ "stateMutability": "view",
331
+ "type": "function"
332
+ },
333
+ {
334
+ "inputs": [
335
+ {
336
+ "internalType": "bytes32",
337
+ "name": "role",
338
+ "type": "bytes32"
339
+ },
340
+ {
341
+ "internalType": "uint256",
342
+ "name": "index",
343
+ "type": "uint256"
344
+ }
345
+ ],
346
+ "name": "getRoleMember",
347
+ "outputs": [
348
+ {
349
+ "internalType": "address",
350
+ "name": "",
351
+ "type": "address"
352
+ }
353
+ ],
354
+ "stateMutability": "view",
355
+ "type": "function"
356
+ },
357
+ {
358
+ "inputs": [
359
+ {
360
+ "internalType": "bytes32",
361
+ "name": "role",
362
+ "type": "bytes32"
363
+ }
364
+ ],
365
+ "name": "getRoleMemberCount",
366
+ "outputs": [
367
+ {
368
+ "internalType": "uint256",
369
+ "name": "",
370
+ "type": "uint256"
371
+ }
372
+ ],
373
+ "stateMutability": "view",
374
+ "type": "function"
375
+ },
376
+ {
377
+ "inputs": [
378
+ {
379
+ "internalType": "bytes32",
380
+ "name": "role",
381
+ "type": "bytes32"
382
+ },
383
+ {
384
+ "internalType": "address",
385
+ "name": "account",
386
+ "type": "address"
387
+ }
388
+ ],
389
+ "name": "grantRole",
390
+ "outputs": [],
391
+ "stateMutability": "nonpayable",
392
+ "type": "function"
393
+ },
394
+ {
395
+ "inputs": [
396
+ {
397
+ "internalType": "bytes32",
398
+ "name": "role",
399
+ "type": "bytes32"
400
+ },
401
+ {
402
+ "internalType": "address",
403
+ "name": "account",
404
+ "type": "address"
405
+ }
406
+ ],
407
+ "name": "hasRole",
408
+ "outputs": [
409
+ {
410
+ "internalType": "bool",
411
+ "name": "",
412
+ "type": "bool"
413
+ }
414
+ ],
415
+ "stateMutability": "view",
416
+ "type": "function"
417
+ },
418
+ {
419
+ "inputs": [
420
+ {
421
+ "internalType": "address",
422
+ "name": "spender",
423
+ "type": "address"
424
+ },
425
+ {
426
+ "internalType": "uint256",
427
+ "name": "addedValue",
428
+ "type": "uint256"
429
+ }
430
+ ],
431
+ "name": "increaseAllowance",
432
+ "outputs": [
433
+ {
434
+ "internalType": "bool",
435
+ "name": "",
436
+ "type": "bool"
437
+ }
438
+ ],
439
+ "stateMutability": "nonpayable",
440
+ "type": "function"
441
+ },
442
+ {
443
+ "inputs": [
444
+ {
445
+ "internalType": "address",
446
+ "name": "to",
447
+ "type": "address"
448
+ },
449
+ {
450
+ "internalType": "uint256",
451
+ "name": "amount",
452
+ "type": "uint256"
453
+ }
454
+ ],
455
+ "name": "mint",
456
+ "outputs": [],
457
+ "stateMutability": "nonpayable",
458
+ "type": "function"
459
+ },
460
+ {
461
+ "inputs": [],
462
+ "name": "name",
463
+ "outputs": [
464
+ {
465
+ "internalType": "string",
466
+ "name": "",
467
+ "type": "string"
468
+ }
469
+ ],
470
+ "stateMutability": "view",
471
+ "type": "function"
472
+ },
473
+ {
474
+ "inputs": [
475
+ {
476
+ "internalType": "bytes32",
477
+ "name": "role",
478
+ "type": "bytes32"
479
+ },
480
+ {
481
+ "internalType": "address",
482
+ "name": "account",
483
+ "type": "address"
484
+ }
485
+ ],
486
+ "name": "renounceRole",
487
+ "outputs": [],
488
+ "stateMutability": "nonpayable",
489
+ "type": "function"
490
+ },
491
+ {
492
+ "inputs": [
493
+ {
494
+ "internalType": "bytes32",
495
+ "name": "role",
496
+ "type": "bytes32"
497
+ },
498
+ {
499
+ "internalType": "address",
500
+ "name": "account",
501
+ "type": "address"
502
+ }
503
+ ],
504
+ "name": "revokeRole",
505
+ "outputs": [],
506
+ "stateMutability": "nonpayable",
507
+ "type": "function"
508
+ },
509
+ {
510
+ "inputs": [
511
+ {
512
+ "internalType": "string",
513
+ "name": "backingAddress_",
514
+ "type": "string"
515
+ }
516
+ ],
517
+ "name": "setBackingAddress",
518
+ "outputs": [],
519
+ "stateMutability": "nonpayable",
520
+ "type": "function"
521
+ },
522
+ {
523
+ "inputs": [],
524
+ "name": "symbol",
525
+ "outputs": [
526
+ {
527
+ "internalType": "string",
528
+ "name": "",
529
+ "type": "string"
530
+ }
531
+ ],
532
+ "stateMutability": "view",
533
+ "type": "function"
534
+ },
535
+ {
536
+ "inputs": [],
537
+ "name": "totalSupply",
538
+ "outputs": [
539
+ {
540
+ "internalType": "uint256",
541
+ "name": "",
542
+ "type": "uint256"
543
+ }
544
+ ],
545
+ "stateMutability": "view",
546
+ "type": "function"
547
+ },
548
+ {
549
+ "inputs": [
550
+ {
551
+ "internalType": "address",
552
+ "name": "recipient",
553
+ "type": "address"
554
+ },
555
+ {
556
+ "internalType": "uint256",
557
+ "name": "amount",
558
+ "type": "uint256"
559
+ }
560
+ ],
561
+ "name": "transfer",
562
+ "outputs": [
563
+ {
564
+ "internalType": "bool",
565
+ "name": "",
566
+ "type": "bool"
567
+ }
568
+ ],
569
+ "stateMutability": "nonpayable",
570
+ "type": "function"
571
+ },
572
+ {
573
+ "inputs": [
574
+ {
575
+ "internalType": "address",
576
+ "name": "sender",
577
+ "type": "address"
578
+ },
579
+ {
580
+ "internalType": "address",
581
+ "name": "recipient",
582
+ "type": "address"
583
+ },
584
+ {
585
+ "internalType": "uint256",
586
+ "name": "amount",
587
+ "type": "uint256"
588
+ }
589
+ ],
590
+ "name": "transferFrom",
591
+ "outputs": [
592
+ {
593
+ "internalType": "bool",
594
+ "name": "",
595
+ "type": "bool"
596
+ }
597
+ ],
598
+ "stateMutability": "nonpayable",
599
+ "type": "function"
600
+ }
601
+ ] as const satisfies Abi;
602
+
603
+ /**
604
+ * Type-safe ABI for DFI_json
605
+ */
606
+ export type DFI_jsonAbi = typeof DFI_jsonAbi;
607
+
608
+ /**
609
+ * Contract instance type for DFI_json
610
+ */
611
+ // Use any for contract type to avoid complex viem type issues
612
+ // The runtime behavior is type-safe through viem's ABI typing
613
+ export type DFI_jsonContract = any;
614
+
615
+ /**
616
+ * DFI_json Contract Class
617
+ *
618
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
619
+ *
620
+ * @example
621
+ * ```typescript
622
+ * import { createPublicClient, createWalletClient, http } from 'viem';
623
+ * import { mainnet } from 'viem/chains';
624
+ * import { DFI_json } from 'DFI_json';
625
+ *
626
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
627
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
628
+ *
629
+ * const contract = new DFI_json('0x...', { publicClient, walletClient });
630
+ *
631
+ * // Read functions
632
+ * const result = await contract.balanceOf('0x...');
633
+ *
634
+ * // Write functions
635
+ * const hash = await contract.transfer('0x...', 1000n);
636
+ *
637
+ * // Simulate transactions (dry-run)
638
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
639
+ * console.log('Gas estimate:', simulation.request.gas);
640
+ *
641
+ * // Watch events
642
+ * const unwatch = contract.watch.Transfer((event) => {
643
+ * console.log('Transfer event:', event);
644
+ * });
645
+ * ```
646
+ */
647
+ export class DFI_json {
648
+ private contract: DFI_jsonContract;
649
+ private contractAddress: Address;
650
+ private publicClient: PublicClient;
651
+
652
+ constructor(
653
+ address: Address,
654
+ clients: {
655
+ publicClient: PublicClient;
656
+ walletClient?: WalletClient;
657
+ }
658
+ ) {
659
+ this.contractAddress = address;
660
+ this.publicClient = clients.publicClient;
661
+ this.contract = getContract({
662
+ address,
663
+ abi: DFI_jsonAbi,
664
+ client: {
665
+ public: clients.publicClient,
666
+ wallet: clients.walletClient,
667
+ },
668
+ });
669
+ }
670
+
671
+ /**
672
+ * Get the contract address
673
+ */
674
+ get address(): Address {
675
+ return this.contractAddress;
676
+ }
677
+
678
+ /**
679
+ * Get the underlying viem contract instance
680
+ */
681
+ getContract(): DFI_jsonContract {
682
+ return this.contract;
683
+ }
684
+
685
+ /**
686
+ * DEFAULT_ADMIN_ROLE
687
+ * view
688
+ */
689
+ async DEFAULT_ADMIN_ROLE(): Promise<`0x${string}`> {
690
+ return this.contract.read.DEFAULT_ADMIN_ROLE() as Promise<`0x${string}`>;
691
+ }
692
+
693
+ /**
694
+ * MINTER_ROLE
695
+ * view
696
+ */
697
+ async MINTER_ROLE(): Promise<`0x${string}`> {
698
+ return this.contract.read.MINTER_ROLE() as Promise<`0x${string}`>;
699
+ }
700
+
701
+ /**
702
+ * allowance
703
+ * view
704
+ */
705
+ async allowance(owner: `0x${string}`, spender: `0x${string}`): Promise<bigint> {
706
+ return this.contract.read.allowance([owner, spender] as const) as Promise<bigint>;
707
+ }
708
+
709
+ /**
710
+ * backingAddress
711
+ * view
712
+ */
713
+ async backingAddress(): Promise<string> {
714
+ return this.contract.read.backingAddress() as Promise<string>;
715
+ }
716
+
717
+ /**
718
+ * balanceOf
719
+ * view
720
+ */
721
+ async balanceOf(account: `0x${string}`): Promise<bigint> {
722
+ return this.contract.read.balanceOf([account] as const) as Promise<bigint>;
723
+ }
724
+
725
+ /**
726
+ * decimals
727
+ * view
728
+ */
729
+ async decimals(): Promise<bigint> {
730
+ return this.contract.read.decimals() as Promise<bigint>;
731
+ }
732
+
733
+ /**
734
+ * getRoleAdmin
735
+ * view
736
+ */
737
+ async getRoleAdmin(role: `0x${string}`): Promise<`0x${string}`> {
738
+ return this.contract.read.getRoleAdmin([role] as const) as Promise<`0x${string}`>;
739
+ }
740
+
741
+ /**
742
+ * getRoleMember
743
+ * view
744
+ */
745
+ async getRoleMember(role: `0x${string}`, index: bigint): Promise<`0x${string}`> {
746
+ return this.contract.read.getRoleMember([role, index] as const) as Promise<`0x${string}`>;
747
+ }
748
+
749
+ /**
750
+ * getRoleMemberCount
751
+ * view
752
+ */
753
+ async getRoleMemberCount(role: `0x${string}`): Promise<bigint> {
754
+ return this.contract.read.getRoleMemberCount([role] as const) as Promise<bigint>;
755
+ }
756
+
757
+ /**
758
+ * hasRole
759
+ * view
760
+ */
761
+ async hasRole(role: `0x${string}`, account: `0x${string}`): Promise<boolean> {
762
+ return this.contract.read.hasRole([role, account] as const) as Promise<boolean>;
763
+ }
764
+
765
+ /**
766
+ * name
767
+ * view
768
+ */
769
+ async name(): Promise<string> {
770
+ return this.contract.read.name() as Promise<string>;
771
+ }
772
+
773
+ /**
774
+ * symbol
775
+ * view
776
+ */
777
+ async symbol(): Promise<string> {
778
+ return this.contract.read.symbol() as Promise<string>;
779
+ }
780
+
781
+ /**
782
+ * totalSupply
783
+ * view
784
+ */
785
+ async totalSupply(): Promise<bigint> {
786
+ return this.contract.read.totalSupply() as Promise<bigint>;
787
+ }
788
+
789
+ /**
790
+ * approve
791
+ * nonpayable
792
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
793
+ */
794
+ async approve(spender: `0x${string}`, amount: bigint, options?: {
795
+ accessList?: import('viem').AccessList;
796
+ authorizationList?: import('viem').AuthorizationList;
797
+ chain?: import('viem').Chain | null;
798
+ dataSuffix?: `0x${string}`;
799
+ gas?: bigint;
800
+ gasPrice?: bigint;
801
+ maxFeePerGas?: bigint;
802
+ maxPriorityFeePerGas?: bigint;
803
+ nonce?: number;
804
+ value?: bigint;
805
+ }): Promise<`0x${string}`> {
806
+ if (!this.contract.write) {
807
+ throw new Error('Wallet client is required for write operations');
808
+ }
809
+ return this.contract.write.approve([spender, amount] as const, options) as Promise<`0x${string}`>;
810
+ }
811
+
812
+ /**
813
+ * burn
814
+ * nonpayable
815
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
816
+ */
817
+ async burn(amount: bigint, options?: {
818
+ accessList?: import('viem').AccessList;
819
+ authorizationList?: import('viem').AuthorizationList;
820
+ chain?: import('viem').Chain | null;
821
+ dataSuffix?: `0x${string}`;
822
+ gas?: bigint;
823
+ gasPrice?: bigint;
824
+ maxFeePerGas?: bigint;
825
+ maxPriorityFeePerGas?: bigint;
826
+ nonce?: number;
827
+ value?: bigint;
828
+ }): Promise<`0x${string}`> {
829
+ if (!this.contract.write) {
830
+ throw new Error('Wallet client is required for write operations');
831
+ }
832
+ return this.contract.write.burn([amount] as const, options) as Promise<`0x${string}`>;
833
+ }
834
+
835
+ /**
836
+ * burnFrom
837
+ * nonpayable
838
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
839
+ */
840
+ async burnFrom(account: `0x${string}`, amount: bigint, 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<`0x${string}`> {
852
+ if (!this.contract.write) {
853
+ throw new Error('Wallet client is required for write operations');
854
+ }
855
+ return this.contract.write.burnFrom([account, amount] as const, options) as Promise<`0x${string}`>;
856
+ }
857
+
858
+ /**
859
+ * decreaseAllowance
860
+ * nonpayable
861
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
862
+ */
863
+ async decreaseAllowance(spender: `0x${string}`, subtractedValue: bigint, options?: {
864
+ accessList?: import('viem').AccessList;
865
+ authorizationList?: import('viem').AuthorizationList;
866
+ chain?: import('viem').Chain | null;
867
+ dataSuffix?: `0x${string}`;
868
+ gas?: bigint;
869
+ gasPrice?: bigint;
870
+ maxFeePerGas?: bigint;
871
+ maxPriorityFeePerGas?: bigint;
872
+ nonce?: number;
873
+ value?: bigint;
874
+ }): Promise<`0x${string}`> {
875
+ if (!this.contract.write) {
876
+ throw new Error('Wallet client is required for write operations');
877
+ }
878
+ return this.contract.write.decreaseAllowance([spender, subtractedValue] as const, options) as Promise<`0x${string}`>;
879
+ }
880
+
881
+ /**
882
+ * grantRole
883
+ * nonpayable
884
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
885
+ */
886
+ async grantRole(role: `0x${string}`, account: `0x${string}`, options?: {
887
+ accessList?: import('viem').AccessList;
888
+ authorizationList?: import('viem').AuthorizationList;
889
+ chain?: import('viem').Chain | null;
890
+ dataSuffix?: `0x${string}`;
891
+ gas?: bigint;
892
+ gasPrice?: bigint;
893
+ maxFeePerGas?: bigint;
894
+ maxPriorityFeePerGas?: bigint;
895
+ nonce?: number;
896
+ value?: bigint;
897
+ }): Promise<`0x${string}`> {
898
+ if (!this.contract.write) {
899
+ throw new Error('Wallet client is required for write operations');
900
+ }
901
+ return this.contract.write.grantRole([role, account] as const, options) as Promise<`0x${string}`>;
902
+ }
903
+
904
+ /**
905
+ * increaseAllowance
906
+ * nonpayable
907
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
908
+ */
909
+ async increaseAllowance(spender: `0x${string}`, addedValue: bigint, options?: {
910
+ accessList?: import('viem').AccessList;
911
+ authorizationList?: import('viem').AuthorizationList;
912
+ chain?: import('viem').Chain | null;
913
+ dataSuffix?: `0x${string}`;
914
+ gas?: bigint;
915
+ gasPrice?: bigint;
916
+ maxFeePerGas?: bigint;
917
+ maxPriorityFeePerGas?: bigint;
918
+ nonce?: number;
919
+ value?: bigint;
920
+ }): Promise<`0x${string}`> {
921
+ if (!this.contract.write) {
922
+ throw new Error('Wallet client is required for write operations');
923
+ }
924
+ return this.contract.write.increaseAllowance([spender, addedValue] as const, options) as Promise<`0x${string}`>;
925
+ }
926
+
927
+ /**
928
+ * mint
929
+ * nonpayable
930
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
931
+ */
932
+ async mint(to: `0x${string}`, amount: bigint, options?: {
933
+ accessList?: import('viem').AccessList;
934
+ authorizationList?: import('viem').AuthorizationList;
935
+ chain?: import('viem').Chain | null;
936
+ dataSuffix?: `0x${string}`;
937
+ gas?: bigint;
938
+ gasPrice?: bigint;
939
+ maxFeePerGas?: bigint;
940
+ maxPriorityFeePerGas?: bigint;
941
+ nonce?: number;
942
+ value?: bigint;
943
+ }): Promise<`0x${string}`> {
944
+ if (!this.contract.write) {
945
+ throw new Error('Wallet client is required for write operations');
946
+ }
947
+ return this.contract.write.mint([to, amount] as const, options) as Promise<`0x${string}`>;
948
+ }
949
+
950
+ /**
951
+ * renounceRole
952
+ * nonpayable
953
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
954
+ */
955
+ async renounceRole(role: `0x${string}`, account: `0x${string}`, options?: {
956
+ accessList?: import('viem').AccessList;
957
+ authorizationList?: import('viem').AuthorizationList;
958
+ chain?: import('viem').Chain | null;
959
+ dataSuffix?: `0x${string}`;
960
+ gas?: bigint;
961
+ gasPrice?: bigint;
962
+ maxFeePerGas?: bigint;
963
+ maxPriorityFeePerGas?: bigint;
964
+ nonce?: number;
965
+ value?: bigint;
966
+ }): Promise<`0x${string}`> {
967
+ if (!this.contract.write) {
968
+ throw new Error('Wallet client is required for write operations');
969
+ }
970
+ return this.contract.write.renounceRole([role, account] as const, options) as Promise<`0x${string}`>;
971
+ }
972
+
973
+ /**
974
+ * revokeRole
975
+ * nonpayable
976
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
977
+ */
978
+ async revokeRole(role: `0x${string}`, account: `0x${string}`, options?: {
979
+ accessList?: import('viem').AccessList;
980
+ authorizationList?: import('viem').AuthorizationList;
981
+ chain?: import('viem').Chain | null;
982
+ dataSuffix?: `0x${string}`;
983
+ gas?: bigint;
984
+ gasPrice?: bigint;
985
+ maxFeePerGas?: bigint;
986
+ maxPriorityFeePerGas?: bigint;
987
+ nonce?: number;
988
+ value?: bigint;
989
+ }): Promise<`0x${string}`> {
990
+ if (!this.contract.write) {
991
+ throw new Error('Wallet client is required for write operations');
992
+ }
993
+ return this.contract.write.revokeRole([role, account] as const, options) as Promise<`0x${string}`>;
994
+ }
995
+
996
+ /**
997
+ * setBackingAddress
998
+ * nonpayable
999
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1000
+ */
1001
+ async setBackingAddress(backingAddress_: string, options?: {
1002
+ accessList?: import('viem').AccessList;
1003
+ authorizationList?: import('viem').AuthorizationList;
1004
+ chain?: import('viem').Chain | null;
1005
+ dataSuffix?: `0x${string}`;
1006
+ gas?: bigint;
1007
+ gasPrice?: bigint;
1008
+ maxFeePerGas?: bigint;
1009
+ maxPriorityFeePerGas?: bigint;
1010
+ nonce?: number;
1011
+ value?: bigint;
1012
+ }): Promise<`0x${string}`> {
1013
+ if (!this.contract.write) {
1014
+ throw new Error('Wallet client is required for write operations');
1015
+ }
1016
+ return this.contract.write.setBackingAddress([backingAddress_] as const, options) as Promise<`0x${string}`>;
1017
+ }
1018
+
1019
+ /**
1020
+ * transfer
1021
+ * nonpayable
1022
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1023
+ */
1024
+ async transfer(recipient: `0x${string}`, amount: bigint, options?: {
1025
+ accessList?: import('viem').AccessList;
1026
+ authorizationList?: import('viem').AuthorizationList;
1027
+ chain?: import('viem').Chain | null;
1028
+ dataSuffix?: `0x${string}`;
1029
+ gas?: bigint;
1030
+ gasPrice?: bigint;
1031
+ maxFeePerGas?: bigint;
1032
+ maxPriorityFeePerGas?: bigint;
1033
+ nonce?: number;
1034
+ value?: bigint;
1035
+ }): Promise<`0x${string}`> {
1036
+ if (!this.contract.write) {
1037
+ throw new Error('Wallet client is required for write operations');
1038
+ }
1039
+ return this.contract.write.transfer([recipient, amount] as const, options) as Promise<`0x${string}`>;
1040
+ }
1041
+
1042
+ /**
1043
+ * transferFrom
1044
+ * nonpayable
1045
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1046
+ */
1047
+ async transferFrom(sender: `0x${string}`, recipient: `0x${string}`, amount: bigint, options?: {
1048
+ accessList?: import('viem').AccessList;
1049
+ authorizationList?: import('viem').AuthorizationList;
1050
+ chain?: import('viem').Chain | null;
1051
+ dataSuffix?: `0x${string}`;
1052
+ gas?: bigint;
1053
+ gasPrice?: bigint;
1054
+ maxFeePerGas?: bigint;
1055
+ maxPriorityFeePerGas?: bigint;
1056
+ nonce?: number;
1057
+ value?: bigint;
1058
+ }): Promise<`0x${string}`> {
1059
+ if (!this.contract.write) {
1060
+ throw new Error('Wallet client is required for write operations');
1061
+ }
1062
+ return this.contract.write.transferFrom([sender, recipient, amount] as const, options) as Promise<`0x${string}`>;
1063
+ }
1064
+
1065
+
1066
+
1067
+ /**
1068
+ * Simulate contract write operations (dry-run without sending transaction)
1069
+ *
1070
+ * @example
1071
+ * const result = await contract.simulate.transfer('0x...', 1000n);
1072
+ * console.log('Gas estimate:', result.request.gas);
1073
+ * console.log('Would succeed:', result.result);
1074
+ */
1075
+ get simulate() {
1076
+ const contract = this.contract;
1077
+ if (!contract.simulate) {
1078
+ throw new Error('Public client is required for simulation');
1079
+ }
1080
+ return {
1081
+ /**
1082
+ * Simulate approve
1083
+ * Returns gas estimate and result without sending transaction
1084
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1085
+ */
1086
+ async approve(spender: `0x${string}`, amount: bigint, options?: {
1087
+ accessList?: import('viem').AccessList;
1088
+ authorizationList?: import('viem').AuthorizationList;
1089
+ chain?: import('viem').Chain | null;
1090
+ dataSuffix?: `0x${string}`;
1091
+ gas?: bigint;
1092
+ gasPrice?: bigint;
1093
+ maxFeePerGas?: bigint;
1094
+ maxPriorityFeePerGas?: bigint;
1095
+ nonce?: number;
1096
+ value?: bigint;
1097
+ }): Promise<boolean> {
1098
+ return contract.simulate.approve([spender, amount] as const, options) as Promise<boolean>;
1099
+ },
1100
+ /**
1101
+ * Simulate burn
1102
+ * Returns gas estimate and result without sending transaction
1103
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1104
+ */
1105
+ async burn(amount: bigint, options?: {
1106
+ accessList?: import('viem').AccessList;
1107
+ authorizationList?: import('viem').AuthorizationList;
1108
+ chain?: import('viem').Chain | null;
1109
+ dataSuffix?: `0x${string}`;
1110
+ gas?: bigint;
1111
+ gasPrice?: bigint;
1112
+ maxFeePerGas?: bigint;
1113
+ maxPriorityFeePerGas?: bigint;
1114
+ nonce?: number;
1115
+ value?: bigint;
1116
+ }): Promise<void> {
1117
+ return contract.simulate.burn([amount] as const, options) as Promise<void>;
1118
+ },
1119
+ /**
1120
+ * Simulate burnFrom
1121
+ * Returns gas estimate and result without sending transaction
1122
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1123
+ */
1124
+ async burnFrom(account: `0x${string}`, amount: bigint, options?: {
1125
+ accessList?: import('viem').AccessList;
1126
+ authorizationList?: import('viem').AuthorizationList;
1127
+ chain?: import('viem').Chain | null;
1128
+ dataSuffix?: `0x${string}`;
1129
+ gas?: bigint;
1130
+ gasPrice?: bigint;
1131
+ maxFeePerGas?: bigint;
1132
+ maxPriorityFeePerGas?: bigint;
1133
+ nonce?: number;
1134
+ value?: bigint;
1135
+ }): Promise<void> {
1136
+ return contract.simulate.burnFrom([account, amount] as const, options) as Promise<void>;
1137
+ },
1138
+ /**
1139
+ * Simulate decreaseAllowance
1140
+ * Returns gas estimate and result without sending transaction
1141
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1142
+ */
1143
+ async decreaseAllowance(spender: `0x${string}`, subtractedValue: bigint, options?: {
1144
+ accessList?: import('viem').AccessList;
1145
+ authorizationList?: import('viem').AuthorizationList;
1146
+ chain?: import('viem').Chain | null;
1147
+ dataSuffix?: `0x${string}`;
1148
+ gas?: bigint;
1149
+ gasPrice?: bigint;
1150
+ maxFeePerGas?: bigint;
1151
+ maxPriorityFeePerGas?: bigint;
1152
+ nonce?: number;
1153
+ value?: bigint;
1154
+ }): Promise<boolean> {
1155
+ return contract.simulate.decreaseAllowance([spender, subtractedValue] as const, options) as Promise<boolean>;
1156
+ },
1157
+ /**
1158
+ * Simulate grantRole
1159
+ * Returns gas estimate and result without sending transaction
1160
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1161
+ */
1162
+ async grantRole(role: `0x${string}`, account: `0x${string}`, options?: {
1163
+ accessList?: import('viem').AccessList;
1164
+ authorizationList?: import('viem').AuthorizationList;
1165
+ chain?: import('viem').Chain | null;
1166
+ dataSuffix?: `0x${string}`;
1167
+ gas?: bigint;
1168
+ gasPrice?: bigint;
1169
+ maxFeePerGas?: bigint;
1170
+ maxPriorityFeePerGas?: bigint;
1171
+ nonce?: number;
1172
+ value?: bigint;
1173
+ }): Promise<void> {
1174
+ return contract.simulate.grantRole([role, account] as const, options) as Promise<void>;
1175
+ },
1176
+ /**
1177
+ * Simulate increaseAllowance
1178
+ * Returns gas estimate and result without sending transaction
1179
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1180
+ */
1181
+ async increaseAllowance(spender: `0x${string}`, addedValue: bigint, options?: {
1182
+ accessList?: import('viem').AccessList;
1183
+ authorizationList?: import('viem').AuthorizationList;
1184
+ chain?: import('viem').Chain | null;
1185
+ dataSuffix?: `0x${string}`;
1186
+ gas?: bigint;
1187
+ gasPrice?: bigint;
1188
+ maxFeePerGas?: bigint;
1189
+ maxPriorityFeePerGas?: bigint;
1190
+ nonce?: number;
1191
+ value?: bigint;
1192
+ }): Promise<boolean> {
1193
+ return contract.simulate.increaseAllowance([spender, addedValue] as const, options) as Promise<boolean>;
1194
+ },
1195
+ /**
1196
+ * Simulate mint
1197
+ * Returns gas estimate and result without sending transaction
1198
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1199
+ */
1200
+ async mint(to: `0x${string}`, amount: bigint, options?: {
1201
+ accessList?: import('viem').AccessList;
1202
+ authorizationList?: import('viem').AuthorizationList;
1203
+ chain?: import('viem').Chain | null;
1204
+ dataSuffix?: `0x${string}`;
1205
+ gas?: bigint;
1206
+ gasPrice?: bigint;
1207
+ maxFeePerGas?: bigint;
1208
+ maxPriorityFeePerGas?: bigint;
1209
+ nonce?: number;
1210
+ value?: bigint;
1211
+ }): Promise<void> {
1212
+ return contract.simulate.mint([to, amount] as const, options) as Promise<void>;
1213
+ },
1214
+ /**
1215
+ * Simulate renounceRole
1216
+ * Returns gas estimate and result without sending transaction
1217
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1218
+ */
1219
+ async renounceRole(role: `0x${string}`, account: `0x${string}`, options?: {
1220
+ accessList?: import('viem').AccessList;
1221
+ authorizationList?: import('viem').AuthorizationList;
1222
+ chain?: import('viem').Chain | null;
1223
+ dataSuffix?: `0x${string}`;
1224
+ gas?: bigint;
1225
+ gasPrice?: bigint;
1226
+ maxFeePerGas?: bigint;
1227
+ maxPriorityFeePerGas?: bigint;
1228
+ nonce?: number;
1229
+ value?: bigint;
1230
+ }): Promise<void> {
1231
+ return contract.simulate.renounceRole([role, account] as const, options) as Promise<void>;
1232
+ },
1233
+ /**
1234
+ * Simulate revokeRole
1235
+ * Returns gas estimate and result without sending transaction
1236
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1237
+ */
1238
+ async revokeRole(role: `0x${string}`, account: `0x${string}`, options?: {
1239
+ accessList?: import('viem').AccessList;
1240
+ authorizationList?: import('viem').AuthorizationList;
1241
+ chain?: import('viem').Chain | null;
1242
+ dataSuffix?: `0x${string}`;
1243
+ gas?: bigint;
1244
+ gasPrice?: bigint;
1245
+ maxFeePerGas?: bigint;
1246
+ maxPriorityFeePerGas?: bigint;
1247
+ nonce?: number;
1248
+ value?: bigint;
1249
+ }): Promise<void> {
1250
+ return contract.simulate.revokeRole([role, account] as const, options) as Promise<void>;
1251
+ },
1252
+ /**
1253
+ * Simulate setBackingAddress
1254
+ * Returns gas estimate and result without sending transaction
1255
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1256
+ */
1257
+ async setBackingAddress(backingAddress_: string, options?: {
1258
+ accessList?: import('viem').AccessList;
1259
+ authorizationList?: import('viem').AuthorizationList;
1260
+ chain?: import('viem').Chain | null;
1261
+ dataSuffix?: `0x${string}`;
1262
+ gas?: bigint;
1263
+ gasPrice?: bigint;
1264
+ maxFeePerGas?: bigint;
1265
+ maxPriorityFeePerGas?: bigint;
1266
+ nonce?: number;
1267
+ value?: bigint;
1268
+ }): Promise<void> {
1269
+ return contract.simulate.setBackingAddress([backingAddress_] as const, options) as Promise<void>;
1270
+ },
1271
+ /**
1272
+ * Simulate transfer
1273
+ * Returns gas estimate and result without sending transaction
1274
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1275
+ */
1276
+ async transfer(recipient: `0x${string}`, amount: bigint, options?: {
1277
+ accessList?: import('viem').AccessList;
1278
+ authorizationList?: import('viem').AuthorizationList;
1279
+ chain?: import('viem').Chain | null;
1280
+ dataSuffix?: `0x${string}`;
1281
+ gas?: bigint;
1282
+ gasPrice?: bigint;
1283
+ maxFeePerGas?: bigint;
1284
+ maxPriorityFeePerGas?: bigint;
1285
+ nonce?: number;
1286
+ value?: bigint;
1287
+ }): Promise<boolean> {
1288
+ return contract.simulate.transfer([recipient, amount] as const, options) as Promise<boolean>;
1289
+ },
1290
+ /**
1291
+ * Simulate transferFrom
1292
+ * Returns gas estimate and result without sending transaction
1293
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1294
+ */
1295
+ async transferFrom(sender: `0x${string}`, recipient: `0x${string}`, amount: bigint, options?: {
1296
+ accessList?: import('viem').AccessList;
1297
+ authorizationList?: import('viem').AuthorizationList;
1298
+ chain?: import('viem').Chain | null;
1299
+ dataSuffix?: `0x${string}`;
1300
+ gas?: bigint;
1301
+ gasPrice?: bigint;
1302
+ maxFeePerGas?: bigint;
1303
+ maxPriorityFeePerGas?: bigint;
1304
+ nonce?: number;
1305
+ value?: bigint;
1306
+ }): Promise<boolean> {
1307
+ return contract.simulate.transferFrom([sender, recipient, amount] as const, options) as Promise<boolean>;
1308
+ }
1309
+ };
1310
+ }
1311
+
1312
+ /**
1313
+ * Watch contract events
1314
+ *
1315
+ * @example
1316
+ * // Watch all Transfer events
1317
+ * const unwatch = contract.watch.Transfer((event) => {
1318
+ * console.log('Transfer:', event);
1319
+ * });
1320
+ *
1321
+ * // Stop watching
1322
+ * unwatch();
1323
+ */
1324
+ get watch() {
1325
+ return {
1326
+ /**
1327
+ * Watch Approval events
1328
+ * @param callback Function to call when event is emitted
1329
+ * @param filter Optional filter for indexed parameters
1330
+ * @returns Unwatch function to stop listening
1331
+ */
1332
+ Approval: (callback: (event: { owner: `0x${string}`; spender: `0x${string}`; value: bigint }) => void, filter?: { owner: `0x${string}`; spender: `0x${string}` }) => {
1333
+ return this.publicClient.watchContractEvent({
1334
+ address: this.contractAddress,
1335
+ abi: DFI_jsonAbi,
1336
+ eventName: 'Approval',
1337
+ args: filter,
1338
+ onLogs: (logs: any[]) => {
1339
+ logs.forEach((log: any) => {
1340
+ callback(log.args as any);
1341
+ });
1342
+ },
1343
+ }) as () => void;
1344
+ },
1345
+ /**
1346
+ * Watch RoleAdminChanged events
1347
+ * @param callback Function to call when event is emitted
1348
+ * @param filter Optional filter for indexed parameters
1349
+ * @returns Unwatch function to stop listening
1350
+ */
1351
+ RoleAdminChanged: (callback: (event: { role: `0x${string}`; previousAdminRole: `0x${string}`; newAdminRole: `0x${string}` }) => void, filter?: { role: `0x${string}`; previousAdminRole: `0x${string}`; newAdminRole: `0x${string}` }) => {
1352
+ return this.publicClient.watchContractEvent({
1353
+ address: this.contractAddress,
1354
+ abi: DFI_jsonAbi,
1355
+ eventName: 'RoleAdminChanged',
1356
+ args: filter,
1357
+ onLogs: (logs: any[]) => {
1358
+ logs.forEach((log: any) => {
1359
+ callback(log.args as any);
1360
+ });
1361
+ },
1362
+ }) as () => void;
1363
+ },
1364
+ /**
1365
+ * Watch RoleGranted events
1366
+ * @param callback Function to call when event is emitted
1367
+ * @param filter Optional filter for indexed parameters
1368
+ * @returns Unwatch function to stop listening
1369
+ */
1370
+ RoleGranted: (callback: (event: { role: `0x${string}`; account: `0x${string}`; sender: `0x${string}` }) => void, filter?: { role: `0x${string}`; account: `0x${string}`; sender: `0x${string}` }) => {
1371
+ return this.publicClient.watchContractEvent({
1372
+ address: this.contractAddress,
1373
+ abi: DFI_jsonAbi,
1374
+ eventName: 'RoleGranted',
1375
+ args: filter,
1376
+ onLogs: (logs: any[]) => {
1377
+ logs.forEach((log: any) => {
1378
+ callback(log.args as any);
1379
+ });
1380
+ },
1381
+ }) as () => void;
1382
+ },
1383
+ /**
1384
+ * Watch RoleRevoked events
1385
+ * @param callback Function to call when event is emitted
1386
+ * @param filter Optional filter for indexed parameters
1387
+ * @returns Unwatch function to stop listening
1388
+ */
1389
+ RoleRevoked: (callback: (event: { role: `0x${string}`; account: `0x${string}`; sender: `0x${string}` }) => void, filter?: { role: `0x${string}`; account: `0x${string}`; sender: `0x${string}` }) => {
1390
+ return this.publicClient.watchContractEvent({
1391
+ address: this.contractAddress,
1392
+ abi: DFI_jsonAbi,
1393
+ eventName: 'RoleRevoked',
1394
+ args: filter,
1395
+ onLogs: (logs: any[]) => {
1396
+ logs.forEach((log: any) => {
1397
+ callback(log.args as any);
1398
+ });
1399
+ },
1400
+ }) as () => void;
1401
+ },
1402
+ /**
1403
+ * Watch Transfer events
1404
+ * @param callback Function to call when event is emitted
1405
+ * @param filter Optional filter for indexed parameters
1406
+ * @returns Unwatch function to stop listening
1407
+ */
1408
+ Transfer: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from: `0x${string}`; to: `0x${string}` }) => {
1409
+ return this.publicClient.watchContractEvent({
1410
+ address: this.contractAddress,
1411
+ abi: DFI_jsonAbi,
1412
+ eventName: 'Transfer',
1413
+ args: filter,
1414
+ onLogs: (logs: any[]) => {
1415
+ logs.forEach((log: any) => {
1416
+ callback(log.args as any);
1417
+ });
1418
+ },
1419
+ }) as () => void;
1420
+ }
1421
+ };
1422
+ }
1423
+ }