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