@gitmyabi/usdt 1.0.20 → 1.0.21

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