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