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