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