@gitmyabi/usdt 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,776 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USDT_json = exports.USDT_jsonAbi = void 0;
4
+ const viem_1 = require("viem");
5
+ /**
6
+ * USDT_json ABI
7
+ *
8
+ * This ABI is typed using viem's type system for full type safety.
9
+ */
10
+ exports.USDT_jsonAbi = [
11
+ {
12
+ "inputs": [
13
+ {
14
+ "internalType": "string",
15
+ "name": "name_",
16
+ "type": "string"
17
+ },
18
+ {
19
+ "internalType": "string",
20
+ "name": "symbol_",
21
+ "type": "string"
22
+ },
23
+ {
24
+ "internalType": "uint256",
25
+ "name": "decimals_",
26
+ "type": "uint256"
27
+ },
28
+ {
29
+ "internalType": "uint256",
30
+ "name": "initialBalance_",
31
+ "type": "uint256"
32
+ },
33
+ {
34
+ "internalType": "address",
35
+ "name": "tokenOwner",
36
+ "type": "address"
37
+ },
38
+ {
39
+ "internalType": "address payable",
40
+ "name": "feeReceiver_",
41
+ "type": "address"
42
+ }
43
+ ],
44
+ "stateMutability": "payable",
45
+ "type": "constructor"
46
+ },
47
+ {
48
+ "anonymous": false,
49
+ "inputs": [
50
+ {
51
+ "indexed": true,
52
+ "internalType": "address",
53
+ "name": "owner",
54
+ "type": "address"
55
+ },
56
+ {
57
+ "indexed": true,
58
+ "internalType": "address",
59
+ "name": "spender",
60
+ "type": "address"
61
+ },
62
+ {
63
+ "indexed": false,
64
+ "internalType": "uint256",
65
+ "name": "value",
66
+ "type": "uint256"
67
+ }
68
+ ],
69
+ "name": "Approval",
70
+ "type": "event"
71
+ },
72
+ {
73
+ "anonymous": false,
74
+ "inputs": [
75
+ {
76
+ "indexed": true,
77
+ "internalType": "address",
78
+ "name": "previousOwner",
79
+ "type": "address"
80
+ },
81
+ {
82
+ "indexed": true,
83
+ "internalType": "address",
84
+ "name": "newOwner",
85
+ "type": "address"
86
+ }
87
+ ],
88
+ "name": "OwnershipTransferred",
89
+ "type": "event"
90
+ },
91
+ {
92
+ "anonymous": false,
93
+ "inputs": [
94
+ {
95
+ "indexed": true,
96
+ "internalType": "address",
97
+ "name": "from",
98
+ "type": "address"
99
+ },
100
+ {
101
+ "indexed": true,
102
+ "internalType": "address",
103
+ "name": "to",
104
+ "type": "address"
105
+ },
106
+ {
107
+ "indexed": false,
108
+ "internalType": "uint256",
109
+ "name": "value",
110
+ "type": "uint256"
111
+ }
112
+ ],
113
+ "name": "Transfer",
114
+ "type": "event"
115
+ },
116
+ {
117
+ "inputs": [],
118
+ "name": "Optimization",
119
+ "outputs": [
120
+ {
121
+ "internalType": "uint256",
122
+ "name": "",
123
+ "type": "uint256"
124
+ }
125
+ ],
126
+ "stateMutability": "view",
127
+ "type": "function"
128
+ },
129
+ {
130
+ "inputs": [],
131
+ "name": "_owner",
132
+ "outputs": [
133
+ {
134
+ "internalType": "address",
135
+ "name": "",
136
+ "type": "address"
137
+ }
138
+ ],
139
+ "stateMutability": "view",
140
+ "type": "function"
141
+ },
142
+ {
143
+ "inputs": [
144
+ {
145
+ "internalType": "address",
146
+ "name": "owner",
147
+ "type": "address"
148
+ },
149
+ {
150
+ "internalType": "address",
151
+ "name": "spender",
152
+ "type": "address"
153
+ }
154
+ ],
155
+ "name": "allowance",
156
+ "outputs": [
157
+ {
158
+ "internalType": "uint256",
159
+ "name": "",
160
+ "type": "uint256"
161
+ }
162
+ ],
163
+ "stateMutability": "view",
164
+ "type": "function"
165
+ },
166
+ {
167
+ "inputs": [
168
+ {
169
+ "internalType": "address",
170
+ "name": "spender",
171
+ "type": "address"
172
+ },
173
+ {
174
+ "internalType": "uint256",
175
+ "name": "amount",
176
+ "type": "uint256"
177
+ }
178
+ ],
179
+ "name": "approve",
180
+ "outputs": [
181
+ {
182
+ "internalType": "bool",
183
+ "name": "",
184
+ "type": "bool"
185
+ }
186
+ ],
187
+ "stateMutability": "nonpayable",
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": "uint256",
215
+ "name": "",
216
+ "type": "uint256"
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": "spender",
251
+ "type": "address"
252
+ },
253
+ {
254
+ "internalType": "uint256",
255
+ "name": "addedValue",
256
+ "type": "uint256"
257
+ }
258
+ ],
259
+ "name": "increaseAllowance",
260
+ "outputs": [
261
+ {
262
+ "internalType": "bool",
263
+ "name": "",
264
+ "type": "bool"
265
+ }
266
+ ],
267
+ "stateMutability": "nonpayable",
268
+ "type": "function"
269
+ },
270
+ {
271
+ "inputs": [],
272
+ "name": "name",
273
+ "outputs": [
274
+ {
275
+ "internalType": "string",
276
+ "name": "",
277
+ "type": "string"
278
+ }
279
+ ],
280
+ "stateMutability": "view",
281
+ "type": "function"
282
+ },
283
+ {
284
+ "inputs": [],
285
+ "name": "owner",
286
+ "outputs": [
287
+ {
288
+ "internalType": "address",
289
+ "name": "",
290
+ "type": "address"
291
+ }
292
+ ],
293
+ "stateMutability": "view",
294
+ "type": "function"
295
+ },
296
+ {
297
+ "inputs": [
298
+ {
299
+ "internalType": "address",
300
+ "name": "tokenAddress",
301
+ "type": "address"
302
+ },
303
+ {
304
+ "internalType": "uint256",
305
+ "name": "tokenAmount",
306
+ "type": "uint256"
307
+ }
308
+ ],
309
+ "name": "recoverERC20",
310
+ "outputs": [],
311
+ "stateMutability": "nonpayable",
312
+ "type": "function"
313
+ },
314
+ {
315
+ "inputs": [],
316
+ "name": "renounceOwnership",
317
+ "outputs": [],
318
+ "stateMutability": "nonpayable",
319
+ "type": "function"
320
+ },
321
+ {
322
+ "inputs": [],
323
+ "name": "symbol",
324
+ "outputs": [
325
+ {
326
+ "internalType": "string",
327
+ "name": "",
328
+ "type": "string"
329
+ }
330
+ ],
331
+ "stateMutability": "view",
332
+ "type": "function"
333
+ },
334
+ {
335
+ "inputs": [],
336
+ "name": "totalSupply",
337
+ "outputs": [
338
+ {
339
+ "internalType": "uint256",
340
+ "name": "",
341
+ "type": "uint256"
342
+ }
343
+ ],
344
+ "stateMutability": "view",
345
+ "type": "function"
346
+ },
347
+ {
348
+ "inputs": [
349
+ {
350
+ "internalType": "address",
351
+ "name": "recipient",
352
+ "type": "address"
353
+ },
354
+ {
355
+ "internalType": "uint256",
356
+ "name": "amount",
357
+ "type": "uint256"
358
+ }
359
+ ],
360
+ "name": "transfer",
361
+ "outputs": [
362
+ {
363
+ "internalType": "bool",
364
+ "name": "",
365
+ "type": "bool"
366
+ }
367
+ ],
368
+ "stateMutability": "nonpayable",
369
+ "type": "function"
370
+ },
371
+ {
372
+ "inputs": [
373
+ {
374
+ "internalType": "address",
375
+ "name": "sender",
376
+ "type": "address"
377
+ },
378
+ {
379
+ "internalType": "address",
380
+ "name": "recipient",
381
+ "type": "address"
382
+ },
383
+ {
384
+ "internalType": "uint256",
385
+ "name": "amount",
386
+ "type": "uint256"
387
+ }
388
+ ],
389
+ "name": "transferFrom",
390
+ "outputs": [
391
+ {
392
+ "internalType": "bool",
393
+ "name": "",
394
+ "type": "bool"
395
+ }
396
+ ],
397
+ "stateMutability": "nonpayable",
398
+ "type": "function"
399
+ },
400
+ {
401
+ "inputs": [
402
+ {
403
+ "internalType": "address",
404
+ "name": "newOwner",
405
+ "type": "address"
406
+ }
407
+ ],
408
+ "name": "transferOwnership",
409
+ "outputs": [],
410
+ "stateMutability": "nonpayable",
411
+ "type": "function"
412
+ }
413
+ ];
414
+ /**
415
+ * USDT_json Contract Class
416
+ *
417
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
418
+ *
419
+ * @example
420
+ * ```typescript
421
+ * import { createPublicClient, createWalletClient, http } from 'viem';
422
+ * import { mainnet } from 'viem/chains';
423
+ * import { USDT_json } from 'USDT_json';
424
+ *
425
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
426
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
427
+ *
428
+ * const contract = new USDT_json('0x...', { publicClient, walletClient });
429
+ *
430
+ * // Read functions
431
+ * const result = await contract.balanceOf('0x...');
432
+ *
433
+ * // Write functions
434
+ * const hash = await contract.transfer('0x...', 1000n);
435
+ *
436
+ * // Simulate transactions (dry-run)
437
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
438
+ * console.log('Gas estimate:', simulation.request.gas);
439
+ *
440
+ * // Watch events
441
+ * const unwatch = contract.watch.Transfer((event) => {
442
+ * console.log('Transfer event:', event);
443
+ * });
444
+ * ```
445
+ */
446
+ class USDT_json {
447
+ constructor(address, clients) {
448
+ this.contractAddress = address;
449
+ this.publicClient = clients.publicClient;
450
+ this.contract = (0, viem_1.getContract)({
451
+ address,
452
+ abi: exports.USDT_jsonAbi,
453
+ client: {
454
+ public: clients.publicClient,
455
+ wallet: clients.walletClient,
456
+ },
457
+ });
458
+ }
459
+ /**
460
+ * Get the contract address
461
+ */
462
+ get address() {
463
+ return this.contractAddress;
464
+ }
465
+ /**
466
+ * Get the underlying viem contract instance
467
+ */
468
+ getContract() {
469
+ return this.contract;
470
+ }
471
+ /**
472
+ * Optimization
473
+ * view
474
+ */
475
+ async Optimization() {
476
+ return this.contract.read.Optimization();
477
+ }
478
+ /**
479
+ * _owner
480
+ * view
481
+ */
482
+ async _owner() {
483
+ return this.contract.read._owner();
484
+ }
485
+ /**
486
+ * allowance
487
+ * view
488
+ */
489
+ async allowance(owner, spender) {
490
+ return this.contract.read.allowance([owner, spender]);
491
+ }
492
+ /**
493
+ * balanceOf
494
+ * view
495
+ */
496
+ async balanceOf(account) {
497
+ return this.contract.read.balanceOf([account]);
498
+ }
499
+ /**
500
+ * decimals
501
+ * view
502
+ */
503
+ async decimals() {
504
+ return this.contract.read.decimals();
505
+ }
506
+ /**
507
+ * name
508
+ * view
509
+ */
510
+ async name() {
511
+ return this.contract.read.name();
512
+ }
513
+ /**
514
+ * owner
515
+ * view
516
+ */
517
+ async owner() {
518
+ return this.contract.read.owner();
519
+ }
520
+ /**
521
+ * symbol
522
+ * view
523
+ */
524
+ async symbol() {
525
+ return this.contract.read.symbol();
526
+ }
527
+ /**
528
+ * totalSupply
529
+ * view
530
+ */
531
+ async totalSupply() {
532
+ return this.contract.read.totalSupply();
533
+ }
534
+ /**
535
+ * approve
536
+ * nonpayable
537
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
538
+ */
539
+ async approve(spender, amount, options) {
540
+ if (!this.contract.write) {
541
+ throw new Error('Wallet client is required for write operations');
542
+ }
543
+ return this.contract.write.approve([spender, amount], options);
544
+ }
545
+ /**
546
+ * decreaseAllowance
547
+ * nonpayable
548
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
549
+ */
550
+ async decreaseAllowance(spender, subtractedValue, options) {
551
+ if (!this.contract.write) {
552
+ throw new Error('Wallet client is required for write operations');
553
+ }
554
+ return this.contract.write.decreaseAllowance([spender, subtractedValue], options);
555
+ }
556
+ /**
557
+ * increaseAllowance
558
+ * nonpayable
559
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
560
+ */
561
+ async increaseAllowance(spender, addedValue, options) {
562
+ if (!this.contract.write) {
563
+ throw new Error('Wallet client is required for write operations');
564
+ }
565
+ return this.contract.write.increaseAllowance([spender, addedValue], options);
566
+ }
567
+ /**
568
+ * recoverERC20
569
+ * nonpayable
570
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
571
+ */
572
+ async recoverERC20(tokenAddress, tokenAmount, options) {
573
+ if (!this.contract.write) {
574
+ throw new Error('Wallet client is required for write operations');
575
+ }
576
+ return this.contract.write.recoverERC20([tokenAddress, tokenAmount], options);
577
+ }
578
+ /**
579
+ * renounceOwnership
580
+ * nonpayable
581
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
582
+ */
583
+ async renounceOwnership(options) {
584
+ if (!this.contract.write) {
585
+ throw new Error('Wallet client is required for write operations');
586
+ }
587
+ return this.contract.write.renounceOwnership(options);
588
+ }
589
+ /**
590
+ * transfer
591
+ * nonpayable
592
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
593
+ */
594
+ async transfer(recipient, amount, options) {
595
+ if (!this.contract.write) {
596
+ throw new Error('Wallet client is required for write operations');
597
+ }
598
+ return this.contract.write.transfer([recipient, amount], options);
599
+ }
600
+ /**
601
+ * transferFrom
602
+ * nonpayable
603
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
604
+ */
605
+ async transferFrom(sender, recipient, amount, options) {
606
+ if (!this.contract.write) {
607
+ throw new Error('Wallet client is required for write operations');
608
+ }
609
+ return this.contract.write.transferFrom([sender, recipient, amount], options);
610
+ }
611
+ /**
612
+ * transferOwnership
613
+ * nonpayable
614
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
615
+ */
616
+ async transferOwnership(newOwner, options) {
617
+ if (!this.contract.write) {
618
+ throw new Error('Wallet client is required for write operations');
619
+ }
620
+ return this.contract.write.transferOwnership([newOwner], options);
621
+ }
622
+ /**
623
+ * Simulate contract write operations (dry-run without sending transaction)
624
+ *
625
+ * @example
626
+ * const result = await contract.simulate.transfer('0x...', 1000n);
627
+ * console.log('Gas estimate:', result.request.gas);
628
+ * console.log('Would succeed:', result.result);
629
+ */
630
+ get simulate() {
631
+ const contract = this.contract;
632
+ if (!contract.simulate) {
633
+ throw new Error('Public client is required for simulation');
634
+ }
635
+ return {
636
+ /**
637
+ * Simulate approve
638
+ * Returns gas estimate and result without sending transaction
639
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
640
+ */
641
+ async approve(spender, amount, options) {
642
+ return contract.simulate.approve([spender, amount], options);
643
+ },
644
+ /**
645
+ * Simulate decreaseAllowance
646
+ * Returns gas estimate and result without sending transaction
647
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
648
+ */
649
+ async decreaseAllowance(spender, subtractedValue, options) {
650
+ return contract.simulate.decreaseAllowance([spender, subtractedValue], options);
651
+ },
652
+ /**
653
+ * Simulate increaseAllowance
654
+ * Returns gas estimate and result without sending transaction
655
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
656
+ */
657
+ async increaseAllowance(spender, addedValue, options) {
658
+ return contract.simulate.increaseAllowance([spender, addedValue], options);
659
+ },
660
+ /**
661
+ * Simulate recoverERC20
662
+ * Returns gas estimate and result without sending transaction
663
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
664
+ */
665
+ async recoverERC20(tokenAddress, tokenAmount, options) {
666
+ return contract.simulate.recoverERC20([tokenAddress, tokenAmount], options);
667
+ },
668
+ /**
669
+ * Simulate renounceOwnership
670
+ * Returns gas estimate and result without sending transaction
671
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
672
+ */
673
+ async renounceOwnership(options) {
674
+ return contract.simulate.renounceOwnership(options);
675
+ },
676
+ /**
677
+ * Simulate transfer
678
+ * Returns gas estimate and result without sending transaction
679
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
680
+ */
681
+ async transfer(recipient, amount, options) {
682
+ return contract.simulate.transfer([recipient, amount], options);
683
+ },
684
+ /**
685
+ * Simulate transferFrom
686
+ * Returns gas estimate and result without sending transaction
687
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
688
+ */
689
+ async transferFrom(sender, recipient, amount, options) {
690
+ return contract.simulate.transferFrom([sender, recipient, amount], options);
691
+ },
692
+ /**
693
+ * Simulate transferOwnership
694
+ * Returns gas estimate and result without sending transaction
695
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
696
+ */
697
+ async transferOwnership(newOwner, options) {
698
+ return contract.simulate.transferOwnership([newOwner], options);
699
+ }
700
+ };
701
+ }
702
+ /**
703
+ * Watch contract events
704
+ *
705
+ * @example
706
+ * // Watch all Transfer events
707
+ * const unwatch = contract.watch.Transfer((event) => {
708
+ * console.log('Transfer:', event);
709
+ * });
710
+ *
711
+ * // Stop watching
712
+ * unwatch();
713
+ */
714
+ get watch() {
715
+ return {
716
+ /**
717
+ * Watch Approval events
718
+ * @param callback Function to call when event is emitted
719
+ * @param filter Optional filter for indexed parameters
720
+ * @returns Unwatch function to stop listening
721
+ */
722
+ Approval: (callback, filter) => {
723
+ return this.publicClient.watchContractEvent({
724
+ address: this.contractAddress,
725
+ abi: exports.USDT_jsonAbi,
726
+ eventName: 'Approval',
727
+ args: filter,
728
+ onLogs: (logs) => {
729
+ logs.forEach((log) => {
730
+ callback(log.args);
731
+ });
732
+ },
733
+ });
734
+ },
735
+ /**
736
+ * Watch OwnershipTransferred events
737
+ * @param callback Function to call when event is emitted
738
+ * @param filter Optional filter for indexed parameters
739
+ * @returns Unwatch function to stop listening
740
+ */
741
+ OwnershipTransferred: (callback, filter) => {
742
+ return this.publicClient.watchContractEvent({
743
+ address: this.contractAddress,
744
+ abi: exports.USDT_jsonAbi,
745
+ eventName: 'OwnershipTransferred',
746
+ args: filter,
747
+ onLogs: (logs) => {
748
+ logs.forEach((log) => {
749
+ callback(log.args);
750
+ });
751
+ },
752
+ });
753
+ },
754
+ /**
755
+ * Watch Transfer events
756
+ * @param callback Function to call when event is emitted
757
+ * @param filter Optional filter for indexed parameters
758
+ * @returns Unwatch function to stop listening
759
+ */
760
+ Transfer: (callback, filter) => {
761
+ return this.publicClient.watchContractEvent({
762
+ address: this.contractAddress,
763
+ abi: exports.USDT_jsonAbi,
764
+ eventName: 'Transfer',
765
+ args: filter,
766
+ onLogs: (logs) => {
767
+ logs.forEach((log) => {
768
+ callback(log.args);
769
+ });
770
+ },
771
+ });
772
+ }
773
+ };
774
+ }
775
+ }
776
+ exports.USDT_json = USDT_json;