@gitmyabi/dot 1.0.1 → 1.0.2

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,959 +0,0 @@
1
- import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
- import { getContract } from 'viem';
3
-
4
- /**
5
- * Token_json ABI
6
- *
7
- * This ABI is typed using viem's type system for full type safety.
8
- */
9
- export const Token_jsonAbi = [
10
- {
11
- "inputs": [
12
- {
13
- "internalType": "string",
14
- "name": "_name",
15
- "type": "string"
16
- },
17
- {
18
- "internalType": "string",
19
- "name": "_symbol",
20
- "type": "string"
21
- },
22
- {
23
- "internalType": "uint8",
24
- "name": "_decimals",
25
- "type": "uint8"
26
- }
27
- ],
28
- "stateMutability": "nonpayable",
29
- "type": "constructor"
30
- },
31
- {
32
- "inputs": [
33
- {
34
- "internalType": "address",
35
- "name": "spender",
36
- "type": "address"
37
- },
38
- {
39
- "internalType": "uint256",
40
- "name": "allowance",
41
- "type": "uint256"
42
- },
43
- {
44
- "internalType": "uint256",
45
- "name": "needed",
46
- "type": "uint256"
47
- }
48
- ],
49
- "name": "InsufficientAllowance",
50
- "type": "error"
51
- },
52
- {
53
- "inputs": [
54
- {
55
- "internalType": "address",
56
- "name": "sender",
57
- "type": "address"
58
- },
59
- {
60
- "internalType": "uint256",
61
- "name": "balance",
62
- "type": "uint256"
63
- },
64
- {
65
- "internalType": "uint256",
66
- "name": "needed",
67
- "type": "uint256"
68
- }
69
- ],
70
- "name": "InsufficientBalance",
71
- "type": "error"
72
- },
73
- {
74
- "inputs": [
75
- {
76
- "internalType": "address",
77
- "name": "",
78
- "type": "address"
79
- }
80
- ],
81
- "name": "InvalidApprover",
82
- "type": "error"
83
- },
84
- {
85
- "inputs": [
86
- {
87
- "internalType": "address",
88
- "name": "",
89
- "type": "address"
90
- }
91
- ],
92
- "name": "InvalidReceiver",
93
- "type": "error"
94
- },
95
- {
96
- "inputs": [
97
- {
98
- "internalType": "address",
99
- "name": "",
100
- "type": "address"
101
- }
102
- ],
103
- "name": "InvalidSender",
104
- "type": "error"
105
- },
106
- {
107
- "inputs": [],
108
- "name": "InvalidSignature",
109
- "type": "error"
110
- },
111
- {
112
- "inputs": [
113
- {
114
- "internalType": "address",
115
- "name": "",
116
- "type": "address"
117
- }
118
- ],
119
- "name": "InvalidSpender",
120
- "type": "error"
121
- },
122
- {
123
- "inputs": [],
124
- "name": "PermitExpired",
125
- "type": "error"
126
- },
127
- {
128
- "inputs": [],
129
- "name": "Unauthorized",
130
- "type": "error"
131
- },
132
- {
133
- "anonymous": false,
134
- "inputs": [
135
- {
136
- "indexed": true,
137
- "internalType": "address",
138
- "name": "owner",
139
- "type": "address"
140
- },
141
- {
142
- "indexed": true,
143
- "internalType": "address",
144
- "name": "spender",
145
- "type": "address"
146
- },
147
- {
148
- "indexed": false,
149
- "internalType": "uint256",
150
- "name": "value",
151
- "type": "uint256"
152
- }
153
- ],
154
- "name": "Approval",
155
- "type": "event"
156
- },
157
- {
158
- "anonymous": false,
159
- "inputs": [
160
- {
161
- "indexed": true,
162
- "internalType": "address",
163
- "name": "from",
164
- "type": "address"
165
- },
166
- {
167
- "indexed": true,
168
- "internalType": "address",
169
- "name": "to",
170
- "type": "address"
171
- },
172
- {
173
- "indexed": false,
174
- "internalType": "uint256",
175
- "name": "value",
176
- "type": "uint256"
177
- }
178
- ],
179
- "name": "Transfer",
180
- "type": "event"
181
- },
182
- {
183
- "inputs": [],
184
- "name": "DOMAIN_SEPARATOR",
185
- "outputs": [
186
- {
187
- "internalType": "bytes32",
188
- "name": "",
189
- "type": "bytes32"
190
- }
191
- ],
192
- "stateMutability": "view",
193
- "type": "function"
194
- },
195
- {
196
- "inputs": [
197
- {
198
- "internalType": "address",
199
- "name": "_owner",
200
- "type": "address"
201
- },
202
- {
203
- "internalType": "address",
204
- "name": "spender",
205
- "type": "address"
206
- }
207
- ],
208
- "name": "allowance",
209
- "outputs": [
210
- {
211
- "internalType": "uint256",
212
- "name": "",
213
- "type": "uint256"
214
- }
215
- ],
216
- "stateMutability": "view",
217
- "type": "function"
218
- },
219
- {
220
- "inputs": [
221
- {
222
- "internalType": "address",
223
- "name": "spender",
224
- "type": "address"
225
- },
226
- {
227
- "internalType": "uint256",
228
- "name": "amount",
229
- "type": "uint256"
230
- }
231
- ],
232
- "name": "approve",
233
- "outputs": [
234
- {
235
- "internalType": "bool",
236
- "name": "",
237
- "type": "bool"
238
- }
239
- ],
240
- "stateMutability": "nonpayable",
241
- "type": "function"
242
- },
243
- {
244
- "inputs": [
245
- {
246
- "internalType": "address",
247
- "name": "account",
248
- "type": "address"
249
- }
250
- ],
251
- "name": "balanceOf",
252
- "outputs": [
253
- {
254
- "internalType": "uint256",
255
- "name": "",
256
- "type": "uint256"
257
- }
258
- ],
259
- "stateMutability": "view",
260
- "type": "function"
261
- },
262
- {
263
- "inputs": [
264
- {
265
- "internalType": "address",
266
- "name": "account",
267
- "type": "address"
268
- },
269
- {
270
- "internalType": "uint256",
271
- "name": "amount",
272
- "type": "uint256"
273
- }
274
- ],
275
- "name": "burn",
276
- "outputs": [],
277
- "stateMutability": "nonpayable",
278
- "type": "function"
279
- },
280
- {
281
- "inputs": [],
282
- "name": "decimals",
283
- "outputs": [
284
- {
285
- "internalType": "uint8",
286
- "name": "",
287
- "type": "uint8"
288
- }
289
- ],
290
- "stateMutability": "view",
291
- "type": "function"
292
- },
293
- {
294
- "inputs": [],
295
- "name": "gateway",
296
- "outputs": [
297
- {
298
- "internalType": "address",
299
- "name": "",
300
- "type": "address"
301
- }
302
- ],
303
- "stateMutability": "view",
304
- "type": "function"
305
- },
306
- {
307
- "inputs": [
308
- {
309
- "internalType": "address",
310
- "name": "account",
311
- "type": "address"
312
- },
313
- {
314
- "internalType": "uint256",
315
- "name": "amount",
316
- "type": "uint256"
317
- }
318
- ],
319
- "name": "mint",
320
- "outputs": [],
321
- "stateMutability": "nonpayable",
322
- "type": "function"
323
- },
324
- {
325
- "inputs": [],
326
- "name": "name",
327
- "outputs": [
328
- {
329
- "internalType": "string",
330
- "name": "",
331
- "type": "string"
332
- }
333
- ],
334
- "stateMutability": "view",
335
- "type": "function"
336
- },
337
- {
338
- "inputs": [
339
- {
340
- "internalType": "address",
341
- "name": "account",
342
- "type": "address"
343
- }
344
- ],
345
- "name": "nonces",
346
- "outputs": [
347
- {
348
- "internalType": "uint256",
349
- "name": "",
350
- "type": "uint256"
351
- }
352
- ],
353
- "stateMutability": "view",
354
- "type": "function"
355
- },
356
- {
357
- "inputs": [
358
- {
359
- "internalType": "address",
360
- "name": "issuer",
361
- "type": "address"
362
- },
363
- {
364
- "internalType": "address",
365
- "name": "spender",
366
- "type": "address"
367
- },
368
- {
369
- "internalType": "uint256",
370
- "name": "value",
371
- "type": "uint256"
372
- },
373
- {
374
- "internalType": "uint256",
375
- "name": "deadline",
376
- "type": "uint256"
377
- },
378
- {
379
- "internalType": "uint8",
380
- "name": "v",
381
- "type": "uint8"
382
- },
383
- {
384
- "internalType": "bytes32",
385
- "name": "r",
386
- "type": "bytes32"
387
- },
388
- {
389
- "internalType": "bytes32",
390
- "name": "s",
391
- "type": "bytes32"
392
- }
393
- ],
394
- "name": "permit",
395
- "outputs": [],
396
- "stateMutability": "nonpayable",
397
- "type": "function"
398
- },
399
- {
400
- "inputs": [],
401
- "name": "symbol",
402
- "outputs": [
403
- {
404
- "internalType": "string",
405
- "name": "",
406
- "type": "string"
407
- }
408
- ],
409
- "stateMutability": "view",
410
- "type": "function"
411
- },
412
- {
413
- "inputs": [],
414
- "name": "totalSupply",
415
- "outputs": [
416
- {
417
- "internalType": "uint256",
418
- "name": "",
419
- "type": "uint256"
420
- }
421
- ],
422
- "stateMutability": "view",
423
- "type": "function"
424
- },
425
- {
426
- "inputs": [
427
- {
428
- "internalType": "address",
429
- "name": "recipient",
430
- "type": "address"
431
- },
432
- {
433
- "internalType": "uint256",
434
- "name": "amount",
435
- "type": "uint256"
436
- }
437
- ],
438
- "name": "transfer",
439
- "outputs": [
440
- {
441
- "internalType": "bool",
442
- "name": "",
443
- "type": "bool"
444
- }
445
- ],
446
- "stateMutability": "nonpayable",
447
- "type": "function"
448
- },
449
- {
450
- "inputs": [
451
- {
452
- "internalType": "address",
453
- "name": "sender",
454
- "type": "address"
455
- },
456
- {
457
- "internalType": "address",
458
- "name": "recipient",
459
- "type": "address"
460
- },
461
- {
462
- "internalType": "uint256",
463
- "name": "amount",
464
- "type": "uint256"
465
- }
466
- ],
467
- "name": "transferFrom",
468
- "outputs": [
469
- {
470
- "internalType": "bool",
471
- "name": "",
472
- "type": "bool"
473
- }
474
- ],
475
- "stateMutability": "nonpayable",
476
- "type": "function"
477
- }
478
- ] as const satisfies Abi;
479
-
480
- /**
481
- * Type-safe ABI for Token_json
482
- */
483
- export type Token_jsonAbi = typeof Token_jsonAbi;
484
-
485
- /**
486
- * Contract instance type for Token_json
487
- */
488
- // Use any for contract type to avoid complex viem type issues
489
- // The runtime behavior is type-safe through viem's ABI typing
490
- export type Token_jsonContract = any;
491
-
492
- /**
493
- * Token_json Contract Class
494
- *
495
- * Provides a class-based API similar to TypeChain for interacting with the contract.
496
- *
497
- * @example
498
- * ```typescript
499
- * import { createPublicClient, createWalletClient, http } from 'viem';
500
- * import { mainnet } from 'viem/chains';
501
- * import { Token_json } from 'Token_json';
502
- *
503
- * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
504
- * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
505
- *
506
- * const contract = new Token_json('0x...', { publicClient, walletClient });
507
- *
508
- * // Read functions
509
- * const result = await contract.balanceOf('0x...');
510
- *
511
- * // Write functions
512
- * const hash = await contract.transfer('0x...', 1000n);
513
- *
514
- * // Simulate transactions (dry-run)
515
- * const simulation = await contract.simulate.transfer('0x...', 1000n);
516
- * console.log('Gas estimate:', simulation.request.gas);
517
- *
518
- * // Watch events
519
- * const unwatch = contract.watch.Transfer((event) => {
520
- * console.log('Transfer event:', event);
521
- * });
522
- * ```
523
- */
524
- export class Token_json {
525
- private contract: Token_jsonContract;
526
- private contractAddress: Address;
527
- private publicClient: PublicClient;
528
-
529
- constructor(
530
- address: Address,
531
- clients: {
532
- publicClient: PublicClient;
533
- walletClient?: WalletClient;
534
- }
535
- ) {
536
- this.contractAddress = address;
537
- this.publicClient = clients.publicClient;
538
- this.contract = getContract({
539
- address,
540
- abi: Token_jsonAbi,
541
- client: {
542
- public: clients.publicClient,
543
- wallet: clients.walletClient,
544
- },
545
- });
546
- }
547
-
548
- /**
549
- * Get the contract address
550
- */
551
- get address(): Address {
552
- return this.contractAddress;
553
- }
554
-
555
- /**
556
- * Get the underlying viem contract instance
557
- */
558
- getContract(): Token_jsonContract {
559
- return this.contract;
560
- }
561
-
562
- /**
563
- * DOMAIN_SEPARATOR
564
- * view
565
- */
566
- async DOMAIN_SEPARATOR(): Promise<`0x${string}`> {
567
- return this.contract.read.DOMAIN_SEPARATOR() as Promise<`0x${string}`>;
568
- }
569
-
570
- /**
571
- * allowance
572
- * view
573
- */
574
- async allowance(_owner: `0x${string}`, spender: `0x${string}`): Promise<bigint> {
575
- return this.contract.read.allowance([_owner, spender] as const) as Promise<bigint>;
576
- }
577
-
578
- /**
579
- * balanceOf
580
- * view
581
- */
582
- async balanceOf(account: `0x${string}`): Promise<bigint> {
583
- return this.contract.read.balanceOf([account] as const) as Promise<bigint>;
584
- }
585
-
586
- /**
587
- * decimals
588
- * view
589
- */
590
- async decimals(): Promise<bigint> {
591
- return this.contract.read.decimals() as Promise<bigint>;
592
- }
593
-
594
- /**
595
- * gateway
596
- * view
597
- */
598
- async gateway(): Promise<`0x${string}`> {
599
- return this.contract.read.gateway() as Promise<`0x${string}`>;
600
- }
601
-
602
- /**
603
- * name
604
- * view
605
- */
606
- async name(): Promise<string> {
607
- return this.contract.read.name() as Promise<string>;
608
- }
609
-
610
- /**
611
- * nonces
612
- * view
613
- */
614
- async nonces(account: `0x${string}`): Promise<bigint> {
615
- return this.contract.read.nonces([account] as const) as Promise<bigint>;
616
- }
617
-
618
- /**
619
- * symbol
620
- * view
621
- */
622
- async symbol(): Promise<string> {
623
- return this.contract.read.symbol() as Promise<string>;
624
- }
625
-
626
- /**
627
- * totalSupply
628
- * view
629
- */
630
- async totalSupply(): Promise<bigint> {
631
- return this.contract.read.totalSupply() as Promise<bigint>;
632
- }
633
-
634
- /**
635
- * approve
636
- * nonpayable
637
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
638
- */
639
- async approve(spender: `0x${string}`, amount: bigint, options?: {
640
- accessList?: import('viem').AccessList;
641
- authorizationList?: import('viem').AuthorizationList;
642
- chain?: import('viem').Chain | null;
643
- dataSuffix?: `0x${string}`;
644
- gas?: bigint;
645
- gasPrice?: bigint;
646
- maxFeePerGas?: bigint;
647
- maxPriorityFeePerGas?: bigint;
648
- nonce?: number;
649
- value?: bigint;
650
- }): Promise<`0x${string}`> {
651
- if (!this.contract.write) {
652
- throw new Error('Wallet client is required for write operations');
653
- }
654
- return this.contract.write.approve([spender, amount] as const, options) as Promise<`0x${string}`>;
655
- }
656
-
657
- /**
658
- * burn
659
- * nonpayable
660
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
661
- */
662
- async burn(account: `0x${string}`, amount: bigint, options?: {
663
- accessList?: import('viem').AccessList;
664
- authorizationList?: import('viem').AuthorizationList;
665
- chain?: import('viem').Chain | null;
666
- dataSuffix?: `0x${string}`;
667
- gas?: bigint;
668
- gasPrice?: bigint;
669
- maxFeePerGas?: bigint;
670
- maxPriorityFeePerGas?: bigint;
671
- nonce?: number;
672
- value?: bigint;
673
- }): Promise<`0x${string}`> {
674
- if (!this.contract.write) {
675
- throw new Error('Wallet client is required for write operations');
676
- }
677
- return this.contract.write.burn([account, amount] as const, options) as Promise<`0x${string}`>;
678
- }
679
-
680
- /**
681
- * mint
682
- * nonpayable
683
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
684
- */
685
- async mint(account: `0x${string}`, amount: bigint, options?: {
686
- accessList?: import('viem').AccessList;
687
- authorizationList?: import('viem').AuthorizationList;
688
- chain?: import('viem').Chain | null;
689
- dataSuffix?: `0x${string}`;
690
- gas?: bigint;
691
- gasPrice?: bigint;
692
- maxFeePerGas?: bigint;
693
- maxPriorityFeePerGas?: bigint;
694
- nonce?: number;
695
- value?: bigint;
696
- }): Promise<`0x${string}`> {
697
- if (!this.contract.write) {
698
- throw new Error('Wallet client is required for write operations');
699
- }
700
- return this.contract.write.mint([account, amount] as const, options) as Promise<`0x${string}`>;
701
- }
702
-
703
- /**
704
- * permit
705
- * nonpayable
706
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
707
- */
708
- async permit(issuer: `0x${string}`, spender: `0x${string}`, value: bigint, deadline: bigint, v: bigint, r: `0x${string}`, s: `0x${string}`, options?: {
709
- accessList?: import('viem').AccessList;
710
- authorizationList?: import('viem').AuthorizationList;
711
- chain?: import('viem').Chain | null;
712
- dataSuffix?: `0x${string}`;
713
- gas?: bigint;
714
- gasPrice?: bigint;
715
- maxFeePerGas?: bigint;
716
- maxPriorityFeePerGas?: bigint;
717
- nonce?: number;
718
- value?: bigint;
719
- }): Promise<`0x${string}`> {
720
- if (!this.contract.write) {
721
- throw new Error('Wallet client is required for write operations');
722
- }
723
- return this.contract.write.permit([issuer, spender, value, deadline, v, r, s] as const, options) as Promise<`0x${string}`>;
724
- }
725
-
726
- /**
727
- * transfer
728
- * nonpayable
729
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
730
- */
731
- async transfer(recipient: `0x${string}`, amount: bigint, options?: {
732
- accessList?: import('viem').AccessList;
733
- authorizationList?: import('viem').AuthorizationList;
734
- chain?: import('viem').Chain | null;
735
- dataSuffix?: `0x${string}`;
736
- gas?: bigint;
737
- gasPrice?: bigint;
738
- maxFeePerGas?: bigint;
739
- maxPriorityFeePerGas?: bigint;
740
- nonce?: number;
741
- value?: bigint;
742
- }): Promise<`0x${string}`> {
743
- if (!this.contract.write) {
744
- throw new Error('Wallet client is required for write operations');
745
- }
746
- return this.contract.write.transfer([recipient, amount] as const, options) as Promise<`0x${string}`>;
747
- }
748
-
749
- /**
750
- * transferFrom
751
- * nonpayable
752
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
753
- */
754
- async transferFrom(sender: `0x${string}`, recipient: `0x${string}`, amount: bigint, options?: {
755
- accessList?: import('viem').AccessList;
756
- authorizationList?: import('viem').AuthorizationList;
757
- chain?: import('viem').Chain | null;
758
- dataSuffix?: `0x${string}`;
759
- gas?: bigint;
760
- gasPrice?: bigint;
761
- maxFeePerGas?: bigint;
762
- maxPriorityFeePerGas?: bigint;
763
- nonce?: number;
764
- value?: bigint;
765
- }): Promise<`0x${string}`> {
766
- if (!this.contract.write) {
767
- throw new Error('Wallet client is required for write operations');
768
- }
769
- return this.contract.write.transferFrom([sender, recipient, amount] as const, options) as Promise<`0x${string}`>;
770
- }
771
-
772
-
773
-
774
- /**
775
- * Simulate contract write operations (dry-run without sending transaction)
776
- *
777
- * @example
778
- * const result = await contract.simulate.transfer('0x...', 1000n);
779
- * console.log('Gas estimate:', result.request.gas);
780
- * console.log('Would succeed:', result.result);
781
- */
782
- get simulate() {
783
- const contract = this.contract;
784
- if (!contract.simulate) {
785
- throw new Error('Public client is required for simulation');
786
- }
787
- return {
788
- /**
789
- * Simulate approve
790
- * Returns gas estimate and result without sending transaction
791
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
792
- */
793
- async approve(spender: `0x${string}`, amount: 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<boolean> {
805
- return contract.simulate.approve([spender, amount] as const, options) as Promise<boolean>;
806
- },
807
- /**
808
- * Simulate burn
809
- * Returns gas estimate and result without sending transaction
810
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
811
- */
812
- async burn(account: `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<void> {
824
- return contract.simulate.burn([account, amount] as const, options) as Promise<void>;
825
- },
826
- /**
827
- * Simulate mint
828
- * Returns gas estimate and result without sending transaction
829
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
830
- */
831
- async mint(account: `0x${string}`, amount: bigint, options?: {
832
- accessList?: import('viem').AccessList;
833
- authorizationList?: import('viem').AuthorizationList;
834
- chain?: import('viem').Chain | null;
835
- dataSuffix?: `0x${string}`;
836
- gas?: bigint;
837
- gasPrice?: bigint;
838
- maxFeePerGas?: bigint;
839
- maxPriorityFeePerGas?: bigint;
840
- nonce?: number;
841
- value?: bigint;
842
- }): Promise<void> {
843
- return contract.simulate.mint([account, amount] as const, options) as Promise<void>;
844
- },
845
- /**
846
- * Simulate permit
847
- * Returns gas estimate and result without sending transaction
848
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
849
- */
850
- async permit(issuer: `0x${string}`, spender: `0x${string}`, value: bigint, deadline: bigint, v: bigint, r: `0x${string}`, s: `0x${string}`, options?: {
851
- accessList?: import('viem').AccessList;
852
- authorizationList?: import('viem').AuthorizationList;
853
- chain?: import('viem').Chain | null;
854
- dataSuffix?: `0x${string}`;
855
- gas?: bigint;
856
- gasPrice?: bigint;
857
- maxFeePerGas?: bigint;
858
- maxPriorityFeePerGas?: bigint;
859
- nonce?: number;
860
- value?: bigint;
861
- }): Promise<void> {
862
- return contract.simulate.permit([issuer, spender, value, deadline, v, r, s] as const, options) as Promise<void>;
863
- },
864
- /**
865
- * Simulate transfer
866
- * Returns gas estimate and result without sending transaction
867
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
868
- */
869
- async transfer(recipient: `0x${string}`, amount: bigint, options?: {
870
- accessList?: import('viem').AccessList;
871
- authorizationList?: import('viem').AuthorizationList;
872
- chain?: import('viem').Chain | null;
873
- dataSuffix?: `0x${string}`;
874
- gas?: bigint;
875
- gasPrice?: bigint;
876
- maxFeePerGas?: bigint;
877
- maxPriorityFeePerGas?: bigint;
878
- nonce?: number;
879
- value?: bigint;
880
- }): Promise<boolean> {
881
- return contract.simulate.transfer([recipient, amount] as const, options) as Promise<boolean>;
882
- },
883
- /**
884
- * Simulate transferFrom
885
- * Returns gas estimate and result without sending transaction
886
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
887
- */
888
- async transferFrom(sender: `0x${string}`, recipient: `0x${string}`, amount: bigint, 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<boolean> {
900
- return contract.simulate.transferFrom([sender, recipient, amount] as const, options) as Promise<boolean>;
901
- }
902
- };
903
- }
904
-
905
- /**
906
- * Watch contract events
907
- *
908
- * @example
909
- * // Watch all Transfer events
910
- * const unwatch = contract.watch.Transfer((event) => {
911
- * console.log('Transfer:', event);
912
- * });
913
- *
914
- * // Stop watching
915
- * unwatch();
916
- */
917
- get watch() {
918
- return {
919
- /**
920
- * Watch Approval events
921
- * @param callback Function to call when event is emitted
922
- * @param filter Optional filter for indexed parameters
923
- * @returns Unwatch function to stop listening
924
- */
925
- Approval: (callback: (event: { owner: `0x${string}`; spender: `0x${string}`; value: bigint }) => void, filter?: { owner: `0x${string}`; spender: `0x${string}` }) => {
926
- return this.publicClient.watchContractEvent({
927
- address: this.contractAddress,
928
- abi: Token_jsonAbi,
929
- eventName: 'Approval',
930
- args: filter,
931
- onLogs: (logs: any[]) => {
932
- logs.forEach((log: any) => {
933
- callback(log.args as any);
934
- });
935
- },
936
- }) as () => void;
937
- },
938
- /**
939
- * Watch Transfer events
940
- * @param callback Function to call when event is emitted
941
- * @param filter Optional filter for indexed parameters
942
- * @returns Unwatch function to stop listening
943
- */
944
- Transfer: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from: `0x${string}`; to: `0x${string}` }) => {
945
- return this.publicClient.watchContractEvent({
946
- address: this.contractAddress,
947
- abi: Token_jsonAbi,
948
- eventName: 'Transfer',
949
- args: filter,
950
- onLogs: (logs: any[]) => {
951
- logs.forEach((log: any) => {
952
- callback(log.args as any);
953
- });
954
- },
955
- }) as () => void;
956
- }
957
- };
958
- }
959
- }