@gitmyabi/usdt 1.0.8 → 1.0.9

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