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