@gitmyabi/zc 1.0.0 → 1.0.2

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