@gitmyabi/usdt 1.0.0 → 1.0.2

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