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