@gitmyabi/usdt 1.0.8 → 1.0.9

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