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