@gitmyabi/give 0.0.0-stage → 1.0.1

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