@gitmyabi/tsl 1.0.0

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