@gitmyabi/usdt 1.0.13 → 1.0.15

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