@gitmyabi/usdt 1.0.18 → 1.0.20

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