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