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