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