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