@gitmyabi/usdt 1.0.14 → 1.0.16

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