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