@gitmyabi/kernel 1.0.2 → 1.0.4

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