@gitmyabi/erc20 1.0.0 → 1.0.2

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