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