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