@gitmyabi-stg/tel 0.0.1

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