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