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