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