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