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