@gitmyabi/kernel 1.0.17 → 1.0.18

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,1465 +0,0 @@
1
- import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
- import { getContract } from 'viem';
3
-
4
-
5
- /**
6
- * Call struct type
7
- */
8
- export type Call = {
9
- to: `0x${string}`;
10
- value: bigint;
11
- data: `0x${string}`;
12
- };
13
-
14
- /**
15
- * ExecutionDetail struct type
16
- */
17
- export type ExecutionDetail = {
18
- validAfter: bigint;
19
- validUntil: bigint;
20
- executor: `0x${string}`;
21
- validator: `0x${string}`;
22
- };
23
-
24
- /**
25
- * UserOperation struct type
26
- */
27
- export type UserOperation = {
28
- sender: `0x${string}`;
29
- nonce: bigint;
30
- initCode: `0x${string}`;
31
- callData: `0x${string}`;
32
- callGasLimit: bigint;
33
- verificationGasLimit: bigint;
34
- preVerificationGas: bigint;
35
- maxFeePerGas: bigint;
36
- maxPriorityFeePerGas: bigint;
37
- paymasterAndData: `0x${string}`;
38
- signature: `0x${string}`;
39
- };
40
- /**
41
- * Kernel_json ABI
42
- *
43
- * This ABI is typed using viem's type system for full type safety.
44
- */
45
- export const Kernel_jsonAbi = [
46
- {
47
- "inputs": [
48
- {
49
- "internalType": "contract IEntryPoint",
50
- "name": "_entryPoint",
51
- "type": "address"
52
- }
53
- ],
54
- "stateMutability": "nonpayable",
55
- "type": "constructor"
56
- },
57
- {
58
- "inputs": [],
59
- "name": "AlreadyInitialized",
60
- "type": "error"
61
- },
62
- {
63
- "inputs": [],
64
- "name": "DeprecatedOperation",
65
- "type": "error"
66
- },
67
- {
68
- "inputs": [],
69
- "name": "DisabledMode",
70
- "type": "error"
71
- },
72
- {
73
- "inputs": [],
74
- "name": "NotAuthorizedCaller",
75
- "type": "error"
76
- },
77
- {
78
- "inputs": [],
79
- "name": "NotEntryPoint",
80
- "type": "error"
81
- },
82
- {
83
- "anonymous": false,
84
- "inputs": [
85
- {
86
- "indexed": true,
87
- "internalType": "address",
88
- "name": "oldValidator",
89
- "type": "address"
90
- },
91
- {
92
- "indexed": true,
93
- "internalType": "address",
94
- "name": "newValidator",
95
- "type": "address"
96
- }
97
- ],
98
- "name": "DefaultValidatorChanged",
99
- "type": "event"
100
- },
101
- {
102
- "anonymous": false,
103
- "inputs": [
104
- {
105
- "indexed": true,
106
- "internalType": "bytes4",
107
- "name": "selector",
108
- "type": "bytes4"
109
- },
110
- {
111
- "indexed": true,
112
- "internalType": "address",
113
- "name": "executor",
114
- "type": "address"
115
- },
116
- {
117
- "indexed": true,
118
- "internalType": "address",
119
- "name": "validator",
120
- "type": "address"
121
- }
122
- ],
123
- "name": "ExecutionChanged",
124
- "type": "event"
125
- },
126
- {
127
- "anonymous": false,
128
- "inputs": [
129
- {
130
- "indexed": false,
131
- "internalType": "address",
132
- "name": "sender",
133
- "type": "address"
134
- },
135
- {
136
- "indexed": false,
137
- "internalType": "uint256",
138
- "name": "amount",
139
- "type": "uint256"
140
- }
141
- ],
142
- "name": "Received",
143
- "type": "event"
144
- },
145
- {
146
- "anonymous": false,
147
- "inputs": [
148
- {
149
- "indexed": true,
150
- "internalType": "address",
151
- "name": "newImplementation",
152
- "type": "address"
153
- }
154
- ],
155
- "name": "Upgraded",
156
- "type": "event"
157
- },
158
- {
159
- "stateMutability": "payable",
160
- "type": "fallback"
161
- },
162
- {
163
- "inputs": [
164
- {
165
- "internalType": "bytes4",
166
- "name": "_disableFlag",
167
- "type": "bytes4"
168
- }
169
- ],
170
- "name": "disableMode",
171
- "outputs": [],
172
- "stateMutability": "payable",
173
- "type": "function"
174
- },
175
- {
176
- "inputs": [],
177
- "name": "eip712Domain",
178
- "outputs": [
179
- {
180
- "internalType": "bytes1",
181
- "name": "fields",
182
- "type": "bytes1"
183
- },
184
- {
185
- "internalType": "string",
186
- "name": "name",
187
- "type": "string"
188
- },
189
- {
190
- "internalType": "string",
191
- "name": "version",
192
- "type": "string"
193
- },
194
- {
195
- "internalType": "uint256",
196
- "name": "chainId",
197
- "type": "uint256"
198
- },
199
- {
200
- "internalType": "address",
201
- "name": "verifyingContract",
202
- "type": "address"
203
- },
204
- {
205
- "internalType": "bytes32",
206
- "name": "salt",
207
- "type": "bytes32"
208
- },
209
- {
210
- "internalType": "uint256[]",
211
- "name": "extensions",
212
- "type": "uint256[]"
213
- }
214
- ],
215
- "stateMutability": "view",
216
- "type": "function"
217
- },
218
- {
219
- "inputs": [],
220
- "name": "entryPoint",
221
- "outputs": [
222
- {
223
- "internalType": "contract IEntryPoint",
224
- "name": "",
225
- "type": "address"
226
- }
227
- ],
228
- "stateMutability": "view",
229
- "type": "function"
230
- },
231
- {
232
- "inputs": [
233
- {
234
- "internalType": "address",
235
- "name": "to",
236
- "type": "address"
237
- },
238
- {
239
- "internalType": "uint256",
240
- "name": "value",
241
- "type": "uint256"
242
- },
243
- {
244
- "internalType": "bytes",
245
- "name": "data",
246
- "type": "bytes"
247
- },
248
- {
249
- "internalType": "enum Operation",
250
- "name": "_operation",
251
- "type": "uint8"
252
- }
253
- ],
254
- "name": "execute",
255
- "outputs": [],
256
- "stateMutability": "payable",
257
- "type": "function"
258
- },
259
- {
260
- "inputs": [
261
- {
262
- "components": [
263
- {
264
- "internalType": "address",
265
- "name": "to",
266
- "type": "address"
267
- },
268
- {
269
- "internalType": "uint256",
270
- "name": "value",
271
- "type": "uint256"
272
- },
273
- {
274
- "internalType": "bytes",
275
- "name": "data",
276
- "type": "bytes"
277
- }
278
- ],
279
- "internalType": "struct Call[]",
280
- "name": "calls",
281
- "type": "tuple[]"
282
- }
283
- ],
284
- "name": "executeBatch",
285
- "outputs": [],
286
- "stateMutability": "payable",
287
- "type": "function"
288
- },
289
- {
290
- "inputs": [
291
- {
292
- "internalType": "address",
293
- "name": "to",
294
- "type": "address"
295
- },
296
- {
297
- "internalType": "bytes",
298
- "name": "data",
299
- "type": "bytes"
300
- }
301
- ],
302
- "name": "executeDelegateCall",
303
- "outputs": [],
304
- "stateMutability": "payable",
305
- "type": "function"
306
- },
307
- {
308
- "inputs": [],
309
- "name": "getDefaultValidator",
310
- "outputs": [
311
- {
312
- "internalType": "contract IKernelValidator",
313
- "name": "validator",
314
- "type": "address"
315
- }
316
- ],
317
- "stateMutability": "view",
318
- "type": "function"
319
- },
320
- {
321
- "inputs": [],
322
- "name": "getDisabledMode",
323
- "outputs": [
324
- {
325
- "internalType": "bytes4",
326
- "name": "disabled",
327
- "type": "bytes4"
328
- }
329
- ],
330
- "stateMutability": "view",
331
- "type": "function"
332
- },
333
- {
334
- "inputs": [
335
- {
336
- "internalType": "bytes4",
337
- "name": "_selector",
338
- "type": "bytes4"
339
- }
340
- ],
341
- "name": "getExecution",
342
- "outputs": [
343
- {
344
- "components": [
345
- {
346
- "internalType": "ValidAfter",
347
- "name": "validAfter",
348
- "type": "uint48"
349
- },
350
- {
351
- "internalType": "ValidUntil",
352
- "name": "validUntil",
353
- "type": "uint48"
354
- },
355
- {
356
- "internalType": "address",
357
- "name": "executor",
358
- "type": "address"
359
- },
360
- {
361
- "internalType": "contract IKernelValidator",
362
- "name": "validator",
363
- "type": "address"
364
- }
365
- ],
366
- "internalType": "struct ExecutionDetail",
367
- "name": "",
368
- "type": "tuple"
369
- }
370
- ],
371
- "stateMutability": "view",
372
- "type": "function"
373
- },
374
- {
375
- "inputs": [],
376
- "name": "getLastDisabledTime",
377
- "outputs": [
378
- {
379
- "internalType": "uint48",
380
- "name": "",
381
- "type": "uint48"
382
- }
383
- ],
384
- "stateMutability": "view",
385
- "type": "function"
386
- },
387
- {
388
- "inputs": [
389
- {
390
- "internalType": "uint192",
391
- "name": "key",
392
- "type": "uint192"
393
- }
394
- ],
395
- "name": "getNonce",
396
- "outputs": [
397
- {
398
- "internalType": "uint256",
399
- "name": "",
400
- "type": "uint256"
401
- }
402
- ],
403
- "stateMutability": "view",
404
- "type": "function"
405
- },
406
- {
407
- "inputs": [],
408
- "name": "getNonce",
409
- "outputs": [
410
- {
411
- "internalType": "uint256",
412
- "name": "",
413
- "type": "uint256"
414
- }
415
- ],
416
- "stateMutability": "view",
417
- "type": "function"
418
- },
419
- {
420
- "inputs": [
421
- {
422
- "internalType": "contract IKernelValidator",
423
- "name": "_defaultValidator",
424
- "type": "address"
425
- },
426
- {
427
- "internalType": "bytes",
428
- "name": "_data",
429
- "type": "bytes"
430
- }
431
- ],
432
- "name": "initialize",
433
- "outputs": [],
434
- "stateMutability": "payable",
435
- "type": "function"
436
- },
437
- {
438
- "inputs": [
439
- {
440
- "internalType": "bytes32",
441
- "name": "hash",
442
- "type": "bytes32"
443
- },
444
- {
445
- "internalType": "bytes",
446
- "name": "signature",
447
- "type": "bytes"
448
- }
449
- ],
450
- "name": "isValidSignature",
451
- "outputs": [
452
- {
453
- "internalType": "bytes4",
454
- "name": "",
455
- "type": "bytes4"
456
- }
457
- ],
458
- "stateMutability": "view",
459
- "type": "function"
460
- },
461
- {
462
- "inputs": [],
463
- "name": "name",
464
- "outputs": [
465
- {
466
- "internalType": "string",
467
- "name": "",
468
- "type": "string"
469
- }
470
- ],
471
- "stateMutability": "view",
472
- "type": "function"
473
- },
474
- {
475
- "inputs": [
476
- {
477
- "internalType": "address",
478
- "name": "",
479
- "type": "address"
480
- },
481
- {
482
- "internalType": "address",
483
- "name": "",
484
- "type": "address"
485
- },
486
- {
487
- "internalType": "uint256[]",
488
- "name": "",
489
- "type": "uint256[]"
490
- },
491
- {
492
- "internalType": "uint256[]",
493
- "name": "",
494
- "type": "uint256[]"
495
- },
496
- {
497
- "internalType": "bytes",
498
- "name": "",
499
- "type": "bytes"
500
- }
501
- ],
502
- "name": "onERC1155BatchReceived",
503
- "outputs": [
504
- {
505
- "internalType": "bytes4",
506
- "name": "",
507
- "type": "bytes4"
508
- }
509
- ],
510
- "stateMutability": "pure",
511
- "type": "function"
512
- },
513
- {
514
- "inputs": [
515
- {
516
- "internalType": "address",
517
- "name": "",
518
- "type": "address"
519
- },
520
- {
521
- "internalType": "address",
522
- "name": "",
523
- "type": "address"
524
- },
525
- {
526
- "internalType": "uint256",
527
- "name": "",
528
- "type": "uint256"
529
- },
530
- {
531
- "internalType": "uint256",
532
- "name": "",
533
- "type": "uint256"
534
- },
535
- {
536
- "internalType": "bytes",
537
- "name": "",
538
- "type": "bytes"
539
- }
540
- ],
541
- "name": "onERC1155Received",
542
- "outputs": [
543
- {
544
- "internalType": "bytes4",
545
- "name": "",
546
- "type": "bytes4"
547
- }
548
- ],
549
- "stateMutability": "pure",
550
- "type": "function"
551
- },
552
- {
553
- "inputs": [
554
- {
555
- "internalType": "address",
556
- "name": "",
557
- "type": "address"
558
- },
559
- {
560
- "internalType": "address",
561
- "name": "",
562
- "type": "address"
563
- },
564
- {
565
- "internalType": "uint256",
566
- "name": "",
567
- "type": "uint256"
568
- },
569
- {
570
- "internalType": "bytes",
571
- "name": "",
572
- "type": "bytes"
573
- }
574
- ],
575
- "name": "onERC721Received",
576
- "outputs": [
577
- {
578
- "internalType": "bytes4",
579
- "name": "",
580
- "type": "bytes4"
581
- }
582
- ],
583
- "stateMutability": "pure",
584
- "type": "function"
585
- },
586
- {
587
- "inputs": [
588
- {
589
- "internalType": "contract IKernelValidator",
590
- "name": "_defaultValidator",
591
- "type": "address"
592
- },
593
- {
594
- "internalType": "bytes",
595
- "name": "_data",
596
- "type": "bytes"
597
- }
598
- ],
599
- "name": "setDefaultValidator",
600
- "outputs": [],
601
- "stateMutability": "payable",
602
- "type": "function"
603
- },
604
- {
605
- "inputs": [
606
- {
607
- "internalType": "bytes4",
608
- "name": "_selector",
609
- "type": "bytes4"
610
- },
611
- {
612
- "internalType": "address",
613
- "name": "_executor",
614
- "type": "address"
615
- },
616
- {
617
- "internalType": "contract IKernelValidator",
618
- "name": "_validator",
619
- "type": "address"
620
- },
621
- {
622
- "internalType": "ValidUntil",
623
- "name": "_validUntil",
624
- "type": "uint48"
625
- },
626
- {
627
- "internalType": "ValidAfter",
628
- "name": "_validAfter",
629
- "type": "uint48"
630
- },
631
- {
632
- "internalType": "bytes",
633
- "name": "_enableData",
634
- "type": "bytes"
635
- }
636
- ],
637
- "name": "setExecution",
638
- "outputs": [],
639
- "stateMutability": "payable",
640
- "type": "function"
641
- },
642
- {
643
- "inputs": [
644
- {
645
- "internalType": "address",
646
- "name": "_newImplementation",
647
- "type": "address"
648
- }
649
- ],
650
- "name": "upgradeTo",
651
- "outputs": [],
652
- "stateMutability": "payable",
653
- "type": "function"
654
- },
655
- {
656
- "inputs": [
657
- {
658
- "internalType": "bytes32",
659
- "name": "hash",
660
- "type": "bytes32"
661
- },
662
- {
663
- "internalType": "bytes",
664
- "name": "signature",
665
- "type": "bytes"
666
- }
667
- ],
668
- "name": "validateSignature",
669
- "outputs": [
670
- {
671
- "internalType": "ValidationData",
672
- "name": "",
673
- "type": "uint256"
674
- }
675
- ],
676
- "stateMutability": "view",
677
- "type": "function"
678
- },
679
- {
680
- "inputs": [
681
- {
682
- "components": [
683
- {
684
- "internalType": "address",
685
- "name": "sender",
686
- "type": "address"
687
- },
688
- {
689
- "internalType": "uint256",
690
- "name": "nonce",
691
- "type": "uint256"
692
- },
693
- {
694
- "internalType": "bytes",
695
- "name": "initCode",
696
- "type": "bytes"
697
- },
698
- {
699
- "internalType": "bytes",
700
- "name": "callData",
701
- "type": "bytes"
702
- },
703
- {
704
- "internalType": "uint256",
705
- "name": "callGasLimit",
706
- "type": "uint256"
707
- },
708
- {
709
- "internalType": "uint256",
710
- "name": "verificationGasLimit",
711
- "type": "uint256"
712
- },
713
- {
714
- "internalType": "uint256",
715
- "name": "preVerificationGas",
716
- "type": "uint256"
717
- },
718
- {
719
- "internalType": "uint256",
720
- "name": "maxFeePerGas",
721
- "type": "uint256"
722
- },
723
- {
724
- "internalType": "uint256",
725
- "name": "maxPriorityFeePerGas",
726
- "type": "uint256"
727
- },
728
- {
729
- "internalType": "bytes",
730
- "name": "paymasterAndData",
731
- "type": "bytes"
732
- },
733
- {
734
- "internalType": "bytes",
735
- "name": "signature",
736
- "type": "bytes"
737
- }
738
- ],
739
- "internalType": "struct UserOperation",
740
- "name": "_userOp",
741
- "type": "tuple"
742
- },
743
- {
744
- "internalType": "bytes32",
745
- "name": "userOpHash",
746
- "type": "bytes32"
747
- },
748
- {
749
- "internalType": "uint256",
750
- "name": "missingAccountFunds",
751
- "type": "uint256"
752
- }
753
- ],
754
- "name": "validateUserOp",
755
- "outputs": [
756
- {
757
- "internalType": "ValidationData",
758
- "name": "validationData",
759
- "type": "uint256"
760
- }
761
- ],
762
- "stateMutability": "payable",
763
- "type": "function"
764
- },
765
- {
766
- "inputs": [],
767
- "name": "version",
768
- "outputs": [
769
- {
770
- "internalType": "string",
771
- "name": "",
772
- "type": "string"
773
- }
774
- ],
775
- "stateMutability": "view",
776
- "type": "function"
777
- },
778
- {
779
- "stateMutability": "payable",
780
- "type": "receive"
781
- }
782
- ] as const satisfies Abi;
783
-
784
- /**
785
- * Type-safe ABI for Kernel_json
786
- */
787
- export type Kernel_jsonAbi = typeof Kernel_jsonAbi;
788
-
789
- /**
790
- * Contract instance type for Kernel_json
791
- */
792
- // Use any for contract type to avoid complex viem type issues
793
- // The runtime behavior is type-safe through viem's ABI typing
794
- export type Kernel_jsonContract = any;
795
-
796
- /**
797
- * Kernel_json Contract Class
798
- *
799
- * Provides a class-based API similar to TypeChain for interacting with the contract.
800
- *
801
- * @example
802
- * ```typescript
803
- * import { createPublicClient, createWalletClient, http } from 'viem';
804
- * import { mainnet } from 'viem/chains';
805
- * import { Kernel_json } from 'Kernel_json';
806
- *
807
- * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
808
- * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
809
- *
810
- * const contract = new Kernel_json('0x...', { publicClient, walletClient });
811
- *
812
- * // Read functions
813
- * const result = await contract.balanceOf('0x...');
814
- *
815
- * // Write functions
816
- * const hash = await contract.transfer('0x...', 1000n);
817
- *
818
- * // Simulate transactions (dry-run)
819
- * const simulation = await contract.simulate.transfer('0x...', 1000n);
820
- * console.log('Gas estimate:', simulation.request.gas);
821
- *
822
- * // Watch events
823
- * const unwatch = contract.watch.Transfer((event) => {
824
- * console.log('Transfer event:', event);
825
- * });
826
- * ```
827
- */
828
- export class Kernel_json {
829
- private contract: Kernel_jsonContract;
830
- private contractAddress: Address;
831
- private publicClient: PublicClient;
832
-
833
- constructor(
834
- address: Address,
835
- clients: {
836
- publicClient: PublicClient;
837
- walletClient?: WalletClient;
838
- }
839
- ) {
840
- this.contractAddress = address;
841
- this.publicClient = clients.publicClient;
842
- this.contract = getContract({
843
- address,
844
- abi: Kernel_jsonAbi,
845
- client: {
846
- public: clients.publicClient,
847
- wallet: clients.walletClient,
848
- },
849
- });
850
- }
851
-
852
- /**
853
- * Get the contract address
854
- */
855
- get address(): Address {
856
- return this.contractAddress;
857
- }
858
-
859
- /**
860
- * Get the underlying viem contract instance
861
- */
862
- getContract(): Kernel_jsonContract {
863
- return this.contract;
864
- }
865
-
866
- /**
867
- * eip712Domain
868
- * view
869
- */
870
- async eip712Domain(): Promise<[`0x${string}`, string, string, bigint, `0x${string}`, `0x${string}`, bigint[]]> {
871
- return this.contract.read.eip712Domain() as Promise<[`0x${string}`, string, string, bigint, `0x${string}`, `0x${string}`, bigint[]]>;
872
- }
873
-
874
- /**
875
- * entryPoint
876
- * view
877
- */
878
- async entryPoint(): Promise<`0x${string}`> {
879
- return this.contract.read.entryPoint() as Promise<`0x${string}`>;
880
- }
881
-
882
- /**
883
- * getDefaultValidator
884
- * view
885
- */
886
- async getDefaultValidator(): Promise<`0x${string}`> {
887
- return this.contract.read.getDefaultValidator() as Promise<`0x${string}`>;
888
- }
889
-
890
- /**
891
- * getDisabledMode
892
- * view
893
- */
894
- async getDisabledMode(): Promise<`0x${string}`> {
895
- return this.contract.read.getDisabledMode() as Promise<`0x${string}`>;
896
- }
897
-
898
- /**
899
- * getExecution
900
- * view
901
- */
902
- async getExecution(_selector: `0x${string}`): Promise<ExecutionDetail> {
903
- return this.contract.read.getExecution([_selector] as const) as Promise<ExecutionDetail>;
904
- }
905
-
906
- /**
907
- * getLastDisabledTime
908
- * view
909
- */
910
- async getLastDisabledTime(): Promise<bigint> {
911
- return this.contract.read.getLastDisabledTime() as Promise<bigint>;
912
- }
913
-
914
- async getNonce(key: bigint): Promise<bigint>;
915
- async getNonce(): Promise<bigint>;
916
- async getNonce(...args: any[]): Promise<any> {
917
- return this.contract.read.getNonce(args as any) as Promise<any>;
918
- }
919
-
920
- /**
921
- * isValidSignature
922
- * view
923
- */
924
- async isValidSignature(hash: `0x${string}`, signature: `0x${string}`): Promise<`0x${string}`> {
925
- return this.contract.read.isValidSignature([hash, signature] as const) as Promise<`0x${string}`>;
926
- }
927
-
928
- /**
929
- * name
930
- * view
931
- */
932
- async name(): Promise<string> {
933
- return this.contract.read.name() as Promise<string>;
934
- }
935
-
936
- /**
937
- * onERC1155BatchReceived
938
- * pure
939
- */
940
- async onERC1155BatchReceived(arg0: `0x${string}`, arg1: `0x${string}`, arg2: bigint[], arg3: bigint[], arg4: `0x${string}`): Promise<`0x${string}`> {
941
- return this.contract.read.onERC1155BatchReceived([arg0, arg1, arg2, arg3, arg4] as const) as Promise<`0x${string}`>;
942
- }
943
-
944
- /**
945
- * onERC1155Received
946
- * pure
947
- */
948
- async onERC1155Received(arg0: `0x${string}`, arg1: `0x${string}`, arg2: bigint, arg3: bigint, arg4: `0x${string}`): Promise<`0x${string}`> {
949
- return this.contract.read.onERC1155Received([arg0, arg1, arg2, arg3, arg4] as const) as Promise<`0x${string}`>;
950
- }
951
-
952
- /**
953
- * onERC721Received
954
- * pure
955
- */
956
- async onERC721Received(arg0: `0x${string}`, arg1: `0x${string}`, arg2: bigint, arg3: `0x${string}`): Promise<`0x${string}`> {
957
- return this.contract.read.onERC721Received([arg0, arg1, arg2, arg3] as const) as Promise<`0x${string}`>;
958
- }
959
-
960
- /**
961
- * validateSignature
962
- * view
963
- */
964
- async validateSignature(hash: `0x${string}`, signature: `0x${string}`): Promise<bigint> {
965
- return this.contract.read.validateSignature([hash, signature] as const) as Promise<bigint>;
966
- }
967
-
968
- /**
969
- * version
970
- * view
971
- */
972
- async version(): Promise<string> {
973
- return this.contract.read.version() as Promise<string>;
974
- }
975
-
976
- /**
977
- * disableMode
978
- * payable
979
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
980
- */
981
- async disableMode(_disableFlag: `0x${string}`, options?: {
982
- accessList?: import('viem').AccessList;
983
- authorizationList?: import('viem').AuthorizationList;
984
- chain?: import('viem').Chain | null;
985
- dataSuffix?: `0x${string}`;
986
- gas?: bigint;
987
- gasPrice?: bigint;
988
- maxFeePerGas?: bigint;
989
- maxPriorityFeePerGas?: bigint;
990
- nonce?: number;
991
- value?: bigint;
992
- }): Promise<`0x${string}`> {
993
- if (!this.contract.write) {
994
- throw new Error('Wallet client is required for write operations');
995
- }
996
- return this.contract.write.disableMode([_disableFlag] as const, options) as Promise<`0x${string}`>;
997
- }
998
-
999
- /**
1000
- * execute
1001
- * payable
1002
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1003
- */
1004
- async execute(to: `0x${string}`, value: bigint, data: `0x${string}`, _operation: bigint, options?: {
1005
- accessList?: import('viem').AccessList;
1006
- authorizationList?: import('viem').AuthorizationList;
1007
- chain?: import('viem').Chain | null;
1008
- dataSuffix?: `0x${string}`;
1009
- gas?: bigint;
1010
- gasPrice?: bigint;
1011
- maxFeePerGas?: bigint;
1012
- maxPriorityFeePerGas?: bigint;
1013
- nonce?: number;
1014
- value?: bigint;
1015
- }): Promise<`0x${string}`> {
1016
- if (!this.contract.write) {
1017
- throw new Error('Wallet client is required for write operations');
1018
- }
1019
- return this.contract.write.execute([to, value, data, _operation] as const, options) as Promise<`0x${string}`>;
1020
- }
1021
-
1022
- /**
1023
- * executeBatch
1024
- * payable
1025
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1026
- */
1027
- async executeBatch(calls: Call[], options?: {
1028
- accessList?: import('viem').AccessList;
1029
- authorizationList?: import('viem').AuthorizationList;
1030
- chain?: import('viem').Chain | null;
1031
- dataSuffix?: `0x${string}`;
1032
- gas?: bigint;
1033
- gasPrice?: bigint;
1034
- maxFeePerGas?: bigint;
1035
- maxPriorityFeePerGas?: bigint;
1036
- nonce?: number;
1037
- value?: bigint;
1038
- }): Promise<`0x${string}`> {
1039
- if (!this.contract.write) {
1040
- throw new Error('Wallet client is required for write operations');
1041
- }
1042
- return this.contract.write.executeBatch([calls] as const, options) as Promise<`0x${string}`>;
1043
- }
1044
-
1045
- /**
1046
- * executeDelegateCall
1047
- * payable
1048
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1049
- */
1050
- async executeDelegateCall(to: `0x${string}`, data: `0x${string}`, options?: {
1051
- accessList?: import('viem').AccessList;
1052
- authorizationList?: import('viem').AuthorizationList;
1053
- chain?: import('viem').Chain | null;
1054
- dataSuffix?: `0x${string}`;
1055
- gas?: bigint;
1056
- gasPrice?: bigint;
1057
- maxFeePerGas?: bigint;
1058
- maxPriorityFeePerGas?: bigint;
1059
- nonce?: number;
1060
- value?: bigint;
1061
- }): Promise<`0x${string}`> {
1062
- if (!this.contract.write) {
1063
- throw new Error('Wallet client is required for write operations');
1064
- }
1065
- return this.contract.write.executeDelegateCall([to, data] as const, options) as Promise<`0x${string}`>;
1066
- }
1067
-
1068
- /**
1069
- * initialize
1070
- * payable
1071
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1072
- */
1073
- async initialize(_defaultValidator: `0x${string}`, _data: `0x${string}`, options?: {
1074
- accessList?: import('viem').AccessList;
1075
- authorizationList?: import('viem').AuthorizationList;
1076
- chain?: import('viem').Chain | null;
1077
- dataSuffix?: `0x${string}`;
1078
- gas?: bigint;
1079
- gasPrice?: bigint;
1080
- maxFeePerGas?: bigint;
1081
- maxPriorityFeePerGas?: bigint;
1082
- nonce?: number;
1083
- value?: bigint;
1084
- }): Promise<`0x${string}`> {
1085
- if (!this.contract.write) {
1086
- throw new Error('Wallet client is required for write operations');
1087
- }
1088
- return this.contract.write.initialize([_defaultValidator, _data] as const, options) as Promise<`0x${string}`>;
1089
- }
1090
-
1091
- /**
1092
- * setDefaultValidator
1093
- * payable
1094
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1095
- */
1096
- async setDefaultValidator(_defaultValidator: `0x${string}`, _data: `0x${string}`, options?: {
1097
- accessList?: import('viem').AccessList;
1098
- authorizationList?: import('viem').AuthorizationList;
1099
- chain?: import('viem').Chain | null;
1100
- dataSuffix?: `0x${string}`;
1101
- gas?: bigint;
1102
- gasPrice?: bigint;
1103
- maxFeePerGas?: bigint;
1104
- maxPriorityFeePerGas?: bigint;
1105
- nonce?: number;
1106
- value?: bigint;
1107
- }): Promise<`0x${string}`> {
1108
- if (!this.contract.write) {
1109
- throw new Error('Wallet client is required for write operations');
1110
- }
1111
- return this.contract.write.setDefaultValidator([_defaultValidator, _data] as const, options) as Promise<`0x${string}`>;
1112
- }
1113
-
1114
- /**
1115
- * setExecution
1116
- * payable
1117
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1118
- */
1119
- async setExecution(_selector: `0x${string}`, _executor: `0x${string}`, _validator: `0x${string}`, _validUntil: bigint, _validAfter: bigint, _enableData: `0x${string}`, options?: {
1120
- accessList?: import('viem').AccessList;
1121
- authorizationList?: import('viem').AuthorizationList;
1122
- chain?: import('viem').Chain | null;
1123
- dataSuffix?: `0x${string}`;
1124
- gas?: bigint;
1125
- gasPrice?: bigint;
1126
- maxFeePerGas?: bigint;
1127
- maxPriorityFeePerGas?: bigint;
1128
- nonce?: number;
1129
- value?: bigint;
1130
- }): Promise<`0x${string}`> {
1131
- if (!this.contract.write) {
1132
- throw new Error('Wallet client is required for write operations');
1133
- }
1134
- return this.contract.write.setExecution([_selector, _executor, _validator, _validUntil, _validAfter, _enableData] as const, options) as Promise<`0x${string}`>;
1135
- }
1136
-
1137
- /**
1138
- * upgradeTo
1139
- * payable
1140
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1141
- */
1142
- async upgradeTo(_newImplementation: `0x${string}`, options?: {
1143
- accessList?: import('viem').AccessList;
1144
- authorizationList?: import('viem').AuthorizationList;
1145
- chain?: import('viem').Chain | null;
1146
- dataSuffix?: `0x${string}`;
1147
- gas?: bigint;
1148
- gasPrice?: bigint;
1149
- maxFeePerGas?: bigint;
1150
- maxPriorityFeePerGas?: bigint;
1151
- nonce?: number;
1152
- value?: bigint;
1153
- }): Promise<`0x${string}`> {
1154
- if (!this.contract.write) {
1155
- throw new Error('Wallet client is required for write operations');
1156
- }
1157
- return this.contract.write.upgradeTo([_newImplementation] as const, options) as Promise<`0x${string}`>;
1158
- }
1159
-
1160
- /**
1161
- * validateUserOp
1162
- * payable
1163
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1164
- */
1165
- async validateUserOp(_userOp: UserOperation, userOpHash: `0x${string}`, missingAccountFunds: bigint, options?: {
1166
- accessList?: import('viem').AccessList;
1167
- authorizationList?: import('viem').AuthorizationList;
1168
- chain?: import('viem').Chain | null;
1169
- dataSuffix?: `0x${string}`;
1170
- gas?: bigint;
1171
- gasPrice?: bigint;
1172
- maxFeePerGas?: bigint;
1173
- maxPriorityFeePerGas?: bigint;
1174
- nonce?: number;
1175
- value?: bigint;
1176
- }): Promise<`0x${string}`> {
1177
- if (!this.contract.write) {
1178
- throw new Error('Wallet client is required for write operations');
1179
- }
1180
- return this.contract.write.validateUserOp([_userOp, userOpHash, missingAccountFunds] as const, options) as Promise<`0x${string}`>;
1181
- }
1182
-
1183
-
1184
-
1185
- /**
1186
- * Simulate contract write operations (dry-run without sending transaction)
1187
- *
1188
- * @example
1189
- * const result = await contract.simulate.transfer('0x...', 1000n);
1190
- * console.log('Gas estimate:', result.request.gas);
1191
- * console.log('Would succeed:', result.result);
1192
- */
1193
- get simulate() {
1194
- const contract = this.contract;
1195
- if (!contract.simulate) {
1196
- throw new Error('Public client is required for simulation');
1197
- }
1198
- return {
1199
- /**
1200
- * Simulate disableMode
1201
- * Returns gas estimate and result without sending transaction
1202
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1203
- */
1204
- async disableMode(_disableFlag: `0x${string}`, options?: {
1205
- accessList?: import('viem').AccessList;
1206
- authorizationList?: import('viem').AuthorizationList;
1207
- chain?: import('viem').Chain | null;
1208
- dataSuffix?: `0x${string}`;
1209
- gas?: bigint;
1210
- gasPrice?: bigint;
1211
- maxFeePerGas?: bigint;
1212
- maxPriorityFeePerGas?: bigint;
1213
- nonce?: number;
1214
- value?: bigint;
1215
- }): Promise<void> {
1216
- return contract.simulate.disableMode([_disableFlag] as const, options) as Promise<void>;
1217
- },
1218
- /**
1219
- * Simulate execute
1220
- * Returns gas estimate and result without sending transaction
1221
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1222
- */
1223
- async execute(to: `0x${string}`, value: bigint, data: `0x${string}`, _operation: bigint, options?: {
1224
- accessList?: import('viem').AccessList;
1225
- authorizationList?: import('viem').AuthorizationList;
1226
- chain?: import('viem').Chain | null;
1227
- dataSuffix?: `0x${string}`;
1228
- gas?: bigint;
1229
- gasPrice?: bigint;
1230
- maxFeePerGas?: bigint;
1231
- maxPriorityFeePerGas?: bigint;
1232
- nonce?: number;
1233
- value?: bigint;
1234
- }): Promise<void> {
1235
- return contract.simulate.execute([to, value, data, _operation] as const, options) as Promise<void>;
1236
- },
1237
- /**
1238
- * Simulate executeBatch
1239
- * Returns gas estimate and result without sending transaction
1240
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1241
- */
1242
- async executeBatch(calls: Call[], options?: {
1243
- accessList?: import('viem').AccessList;
1244
- authorizationList?: import('viem').AuthorizationList;
1245
- chain?: import('viem').Chain | null;
1246
- dataSuffix?: `0x${string}`;
1247
- gas?: bigint;
1248
- gasPrice?: bigint;
1249
- maxFeePerGas?: bigint;
1250
- maxPriorityFeePerGas?: bigint;
1251
- nonce?: number;
1252
- value?: bigint;
1253
- }): Promise<void> {
1254
- return contract.simulate.executeBatch([calls] as const, options) as Promise<void>;
1255
- },
1256
- /**
1257
- * Simulate executeDelegateCall
1258
- * Returns gas estimate and result without sending transaction
1259
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1260
- */
1261
- async executeDelegateCall(to: `0x${string}`, data: `0x${string}`, options?: {
1262
- accessList?: import('viem').AccessList;
1263
- authorizationList?: import('viem').AuthorizationList;
1264
- chain?: import('viem').Chain | null;
1265
- dataSuffix?: `0x${string}`;
1266
- gas?: bigint;
1267
- gasPrice?: bigint;
1268
- maxFeePerGas?: bigint;
1269
- maxPriorityFeePerGas?: bigint;
1270
- nonce?: number;
1271
- value?: bigint;
1272
- }): Promise<void> {
1273
- return contract.simulate.executeDelegateCall([to, data] as const, options) as Promise<void>;
1274
- },
1275
- /**
1276
- * Simulate initialize
1277
- * Returns gas estimate and result without sending transaction
1278
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1279
- */
1280
- async initialize(_defaultValidator: `0x${string}`, _data: `0x${string}`, options?: {
1281
- accessList?: import('viem').AccessList;
1282
- authorizationList?: import('viem').AuthorizationList;
1283
- chain?: import('viem').Chain | null;
1284
- dataSuffix?: `0x${string}`;
1285
- gas?: bigint;
1286
- gasPrice?: bigint;
1287
- maxFeePerGas?: bigint;
1288
- maxPriorityFeePerGas?: bigint;
1289
- nonce?: number;
1290
- value?: bigint;
1291
- }): Promise<void> {
1292
- return contract.simulate.initialize([_defaultValidator, _data] as const, options) as Promise<void>;
1293
- },
1294
- /**
1295
- * Simulate setDefaultValidator
1296
- * Returns gas estimate and result without sending transaction
1297
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1298
- */
1299
- async setDefaultValidator(_defaultValidator: `0x${string}`, _data: `0x${string}`, options?: {
1300
- accessList?: import('viem').AccessList;
1301
- authorizationList?: import('viem').AuthorizationList;
1302
- chain?: import('viem').Chain | null;
1303
- dataSuffix?: `0x${string}`;
1304
- gas?: bigint;
1305
- gasPrice?: bigint;
1306
- maxFeePerGas?: bigint;
1307
- maxPriorityFeePerGas?: bigint;
1308
- nonce?: number;
1309
- value?: bigint;
1310
- }): Promise<void> {
1311
- return contract.simulate.setDefaultValidator([_defaultValidator, _data] as const, options) as Promise<void>;
1312
- },
1313
- /**
1314
- * Simulate setExecution
1315
- * Returns gas estimate and result without sending transaction
1316
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1317
- */
1318
- async setExecution(_selector: `0x${string}`, _executor: `0x${string}`, _validator: `0x${string}`, _validUntil: bigint, _validAfter: bigint, _enableData: `0x${string}`, options?: {
1319
- accessList?: import('viem').AccessList;
1320
- authorizationList?: import('viem').AuthorizationList;
1321
- chain?: import('viem').Chain | null;
1322
- dataSuffix?: `0x${string}`;
1323
- gas?: bigint;
1324
- gasPrice?: bigint;
1325
- maxFeePerGas?: bigint;
1326
- maxPriorityFeePerGas?: bigint;
1327
- nonce?: number;
1328
- value?: bigint;
1329
- }): Promise<void> {
1330
- return contract.simulate.setExecution([_selector, _executor, _validator, _validUntil, _validAfter, _enableData] as const, options) as Promise<void>;
1331
- },
1332
- /**
1333
- * Simulate upgradeTo
1334
- * Returns gas estimate and result without sending transaction
1335
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1336
- */
1337
- async upgradeTo(_newImplementation: `0x${string}`, options?: {
1338
- accessList?: import('viem').AccessList;
1339
- authorizationList?: import('viem').AuthorizationList;
1340
- chain?: import('viem').Chain | null;
1341
- dataSuffix?: `0x${string}`;
1342
- gas?: bigint;
1343
- gasPrice?: bigint;
1344
- maxFeePerGas?: bigint;
1345
- maxPriorityFeePerGas?: bigint;
1346
- nonce?: number;
1347
- value?: bigint;
1348
- }): Promise<void> {
1349
- return contract.simulate.upgradeTo([_newImplementation] as const, options) as Promise<void>;
1350
- },
1351
- /**
1352
- * Simulate validateUserOp
1353
- * Returns gas estimate and result without sending transaction
1354
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1355
- */
1356
- async validateUserOp(_userOp: UserOperation, userOpHash: `0x${string}`, missingAccountFunds: bigint, options?: {
1357
- accessList?: import('viem').AccessList;
1358
- authorizationList?: import('viem').AuthorizationList;
1359
- chain?: import('viem').Chain | null;
1360
- dataSuffix?: `0x${string}`;
1361
- gas?: bigint;
1362
- gasPrice?: bigint;
1363
- maxFeePerGas?: bigint;
1364
- maxPriorityFeePerGas?: bigint;
1365
- nonce?: number;
1366
- value?: bigint;
1367
- }): Promise<bigint> {
1368
- return contract.simulate.validateUserOp([_userOp, userOpHash, missingAccountFunds] as const, options) as Promise<bigint>;
1369
- }
1370
- };
1371
- }
1372
-
1373
- /**
1374
- * Watch contract events
1375
- *
1376
- * @example
1377
- * // Watch all Transfer events
1378
- * const unwatch = contract.watch.Transfer((event) => {
1379
- * console.log('Transfer:', event);
1380
- * });
1381
- *
1382
- * // Stop watching
1383
- * unwatch();
1384
- */
1385
- get watch() {
1386
- return {
1387
- /**
1388
- * Watch DefaultValidatorChanged events
1389
- * @param callback Function to call when event is emitted
1390
- * @param filter Optional filter for indexed parameters
1391
- * @returns Unwatch function to stop listening
1392
- */
1393
- DefaultValidatorChanged: (callback: (event: { oldValidator: `0x${string}`; newValidator: `0x${string}` }) => void, filter?: { oldValidator: `0x${string}`; newValidator: `0x${string}` }) => {
1394
- return this.publicClient.watchContractEvent({
1395
- address: this.contractAddress,
1396
- abi: Kernel_jsonAbi,
1397
- eventName: 'DefaultValidatorChanged',
1398
- args: filter,
1399
- onLogs: (logs: any[]) => {
1400
- logs.forEach((log: any) => {
1401
- callback(log.args as any);
1402
- });
1403
- },
1404
- }) as () => void;
1405
- },
1406
- /**
1407
- * Watch ExecutionChanged events
1408
- * @param callback Function to call when event is emitted
1409
- * @param filter Optional filter for indexed parameters
1410
- * @returns Unwatch function to stop listening
1411
- */
1412
- ExecutionChanged: (callback: (event: { selector: `0x${string}`; executor: `0x${string}`; validator: `0x${string}` }) => void, filter?: { selector: `0x${string}`; executor: `0x${string}`; validator: `0x${string}` }) => {
1413
- return this.publicClient.watchContractEvent({
1414
- address: this.contractAddress,
1415
- abi: Kernel_jsonAbi,
1416
- eventName: 'ExecutionChanged',
1417
- args: filter,
1418
- onLogs: (logs: any[]) => {
1419
- logs.forEach((log: any) => {
1420
- callback(log.args as any);
1421
- });
1422
- },
1423
- }) as () => void;
1424
- },
1425
- /**
1426
- * Watch Received events
1427
- * @param callback Function to call when event is emitted
1428
- * @param filter Optional filter for indexed parameters
1429
- * @returns Unwatch function to stop listening
1430
- */
1431
- Received: (callback: (event: { sender: `0x${string}`; amount: bigint }) => void) => {
1432
- return this.publicClient.watchContractEvent({
1433
- address: this.contractAddress,
1434
- abi: Kernel_jsonAbi,
1435
- eventName: 'Received',
1436
-
1437
- onLogs: (logs: any[]) => {
1438
- logs.forEach((log: any) => {
1439
- callback(log.args as any);
1440
- });
1441
- },
1442
- }) as () => void;
1443
- },
1444
- /**
1445
- * Watch Upgraded events
1446
- * @param callback Function to call when event is emitted
1447
- * @param filter Optional filter for indexed parameters
1448
- * @returns Unwatch function to stop listening
1449
- */
1450
- Upgraded: (callback: (event: { newImplementation: `0x${string}` }) => void, filter?: { newImplementation: `0x${string}` }) => {
1451
- return this.publicClient.watchContractEvent({
1452
- address: this.contractAddress,
1453
- abi: Kernel_jsonAbi,
1454
- eventName: 'Upgraded',
1455
- args: filter,
1456
- onLogs: (logs: any[]) => {
1457
- logs.forEach((log: any) => {
1458
- callback(log.args as any);
1459
- });
1460
- },
1461
- }) as () => void;
1462
- }
1463
- };
1464
- }
1465
- }