@gitmyabi/usdt 1.0.17 → 1.0.18

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