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