@gitmyabi/usdt 1.0.21 → 1.0.23

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