@gitmyabi-stg/borg 0.0.1

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