@zerodev/sdk 5.4.34 → 5.4.36

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.
Files changed (42) hide show
  1. package/_cjs/accounts/kernel/createKernelAccount.js +88 -43
  2. package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
  3. package/_cjs/accounts/kernel/utils/common/accountMetadata.js +1 -6
  4. package/_cjs/accounts/kernel/utils/common/accountMetadata.js.map +1 -1
  5. package/_cjs/accounts/utils/signerTo7702Validator.js +66 -0
  6. package/_cjs/accounts/utils/signerTo7702Validator.js.map +1 -0
  7. package/_cjs/accounts/utils/toKernelPluginManager.js +1 -1
  8. package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
  9. package/_cjs/actions/account-client/uninstallPlugin.js +2 -2
  10. package/_cjs/actions/account-client/uninstallPlugin.js.map +1 -1
  11. package/_cjs/clients/kernelAccountClient.js +29 -0
  12. package/_cjs/clients/kernelAccountClient.js.map +1 -1
  13. package/_cjs/utils/toSigner.js.map +1 -1
  14. package/_esm/accounts/kernel/createKernelAccount.js +93 -49
  15. package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
  16. package/_esm/accounts/kernel/utils/common/accountMetadata.js +1 -6
  17. package/_esm/accounts/kernel/utils/common/accountMetadata.js.map +1 -1
  18. package/_esm/accounts/utils/signerTo7702Validator.js +66 -0
  19. package/_esm/accounts/utils/signerTo7702Validator.js.map +1 -0
  20. package/_esm/accounts/utils/toKernelPluginManager.js +1 -1
  21. package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
  22. package/_esm/actions/account-client/uninstallPlugin.js +2 -2
  23. package/_esm/actions/account-client/uninstallPlugin.js.map +1 -1
  24. package/_esm/clients/kernelAccountClient.js +30 -1
  25. package/_esm/clients/kernelAccountClient.js.map +1 -1
  26. package/_esm/utils/toSigner.js.map +1 -1
  27. package/_types/accounts/kernel/createKernelAccount.d.ts +12 -8
  28. package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
  29. package/_types/accounts/kernel/utils/common/accountMetadata.d.ts.map +1 -1
  30. package/_types/accounts/utils/signerTo7702Validator.d.ts +9 -0
  31. package/_types/accounts/utils/signerTo7702Validator.d.ts.map +1 -0
  32. package/_types/actions/account-client/uninstallPlugin.d.ts.map +1 -1
  33. package/_types/clients/kernelAccountClient.d.ts.map +1 -1
  34. package/_types/utils/toSigner.d.ts.map +1 -1
  35. package/accounts/kernel/createKernelAccount.ts +145 -68
  36. package/accounts/kernel/utils/common/accountMetadata.ts +1 -7
  37. package/accounts/utils/signerTo7702Validator.ts +107 -0
  38. package/accounts/utils/toKernelPluginManager.ts +1 -1
  39. package/actions/account-client/uninstallPlugin.ts +7 -2
  40. package/clients/kernelAccountClient.ts +41 -0
  41. package/package.json +1 -1
  42. package/utils/toSigner.ts +1 -5
@@ -0,0 +1,9 @@
1
+ import type { Client } from "viem";
2
+ import { type EntryPointVersion } from "viem/account-abstraction";
3
+ import type { EntryPointType, GetKernelVersion, KernelValidator, Signer } from "../../types/index.js";
4
+ export declare function signerTo7702Validator<entryPointVersion extends EntryPointVersion>(client: Client, { signer, entryPoint, kernelVersion }: {
5
+ signer: Signer;
6
+ entryPoint: EntryPointType<entryPointVersion>;
7
+ kernelVersion: GetKernelVersion<entryPointVersion>;
8
+ }): Promise<KernelValidator<"EIP7702Validator">>;
9
+ //# sourceMappingURL=signerTo7702Validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signerTo7702Validator.d.ts","sourceRoot":"","sources":["../../../accounts/utils/signerTo7702Validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,MAAM,EAA4B,MAAM,MAAM,CAAA;AACrE,OAAO,EACH,KAAK,iBAAiB,EAGzB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EACR,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,MAAM,EACT,MAAM,sBAAsB,CAAA;AAG7B,wBAAsB,qBAAqB,CACvC,iBAAi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qDf"}
@@ -1 +1 @@
1
- {"version":3,"file":"kernelAccountClient.d.ts","sourceRoot":"","sources":["../../clients/kernelAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,4BAA4B,EACjC,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EAEjB,MAAM,MAAM,CAAA;AACb,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAGxB,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAEzB,KAAK,oBAAoB,IAAI,wBAAwB,EACxD,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EACH,KAAK,0BAA0B,EAElC,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,mBAAmB,CAC3B,SAAS,SAAS,SAAS,GAAG,SAAS,EACvC,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACnD,OAAO,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,EACnE,MAAM,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACtD,SAAS,SAAS,SAAS,GAAG,SAAS,GAAG,SAAS,IACnD,QAAQ,CACR,MAAM,CACF,SAAS,EACT,KAAK,SAAS,KAAK,GACb,KAAK,GAEL,MAAM,SAAS,MAAM,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,GACrC,KAAK,GACL,SAAS,EACjB,OAAO,EACP,SAAS,SAAS,SAAS,GACrB,CAAC,GAAG,gBAAgB,EAAE,GAAG,SAAS,CAAC,GACnC,gBAAgB,EACtB,cAAc,CAAC,OAAO,CAAC,GAAG,0BAA0B,CAAC,KAAK,EAAE,OAAO,CAAC,CACvE,CACJ,GAAG;IACA,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,mBAAmB,CAAC,WAAW,CAAC,GAAG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@@
1
- {"version":3,"file":"toSigner.d.ts","sourceRoot":"","sources":["../../utils/toSigner.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,OAAO,EAKZ,KAAK,YAAY,EAOpB,MAAM,MAAM,CAAA;AAQb,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C,wBAAsB,QAAQ,CAAC,EAC3B,MAAM,EACN,OAAO,EACV,EAAE;IACC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB,GAAG,OAAO,CAAC,YAAY,CAAC,CAqFxB"}
1
+ {"version":3,"file":"toSigner.d.ts","sourceRoot":"","sources":["../../utils/toSigner.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,OAAO,EAKZ,KAAK,YAAY,EAOpB,MAAM,MAAM,CAAA;AAIb,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C,wBAAsB,QAAQ,CAAC,EAC3B,MAAM,EACN,OAAO,EACV,EAAE;IACC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB,GAAG,OAAO,CAAC,YAAY,CAAC,CAqFxB"}
@@ -1,14 +1,14 @@
1
+ import { satisfies } from "semver"
1
2
  import {
2
- http,
3
3
  type Address,
4
4
  type Assign,
5
5
  type EncodeDeployDataParameters,
6
6
  type Hex,
7
+ type LocalAccount,
7
8
  type SignableMessage,
8
9
  type TypedDataDefinition,
9
10
  concatHex,
10
11
  createNonceManager,
11
- createWalletClient,
12
12
  encodeFunctionData,
13
13
  getTypesForEIP712Domain,
14
14
  hashMessage,
@@ -28,12 +28,16 @@ import {
28
28
  entryPoint07Address,
29
29
  toSmartAccount
30
30
  } from "viem/account-abstraction"
31
- import {
32
- type SignAuthorizationReturnType,
33
- privateKeyToAccount
31
+ import type {
32
+ PrivateKeyAccount,
33
+ SignAuthorizationReturnType
34
34
  } from "viem/accounts"
35
- import { getChainId, getCode, sendTransaction } from "viem/actions"
36
- import { getAction } from "viem/utils"
35
+ import {
36
+ getChainId,
37
+ getCode,
38
+ signAuthorization as signAuthorizationAction
39
+ } from "viem/actions"
40
+ import { getAction, verifyAuthorization } from "viem/utils"
37
41
  import {
38
42
  getAccountNonce,
39
43
  getSenderAddress,
@@ -50,12 +54,15 @@ import type {
50
54
  GetKernelVersion,
51
55
  KernelPluginManager,
52
56
  KernelPluginManagerParams,
57
+ KernelValidator,
53
58
  PluginMigrationData
54
59
  } from "../../types/kernel.js"
55
60
  import type { Signer } from "../../types/utils.js"
56
61
  import { KERNEL_FEATURES, hasKernelFeature } from "../../utils.js"
57
62
  import { validateKernelVersionWithEntryPoint } from "../../utils.js"
58
63
  import { toSigner } from "../../utils/toSigner.js"
64
+ import { addressToEmptyAccount } from "../addressToEmptyAccount.js"
65
+ import { signerTo7702Validator } from "../utils/signerTo7702Validator.js"
59
66
  import {
60
67
  isKernelPluginManager,
61
68
  toKernelPluginManager
@@ -107,7 +114,9 @@ export type KernelSmartAccountImplementation<
107
114
  bytecode
108
115
  }: EncodeDeployDataParameters) => Promise<Hex>
109
116
  signMessage: (parameters: SignMessageParameters) => Promise<Hex>
110
- eip7702Auth?: SignAuthorizationReturnType
117
+ eip7702Authorization?:
118
+ | (() => Promise<SignAuthorizationReturnType | undefined>)
119
+ | undefined
111
120
  }
112
121
  >
113
122
 
@@ -119,12 +128,6 @@ export type CreateKernelAccountParameters<
119
128
  entryPointVersion extends EntryPointVersion,
120
129
  KernelVerion extends GetKernelVersion<entryPointVersion>
121
130
  > = {
122
- plugins:
123
- | Omit<
124
- KernelPluginManagerParams<entryPointVersion>,
125
- "entryPoint" | "kernelVersion"
126
- >
127
- | KernelPluginManager<entryPointVersion>
128
131
  entryPoint: EntryPointType<entryPointVersion>
129
132
  index?: bigint
130
133
  factoryAddress?: Address
@@ -134,11 +137,30 @@ export type CreateKernelAccountParameters<
134
137
  kernelVersion: GetKernelVersion<entryPointVersion>
135
138
  initConfig?: KernelVerion extends "0.3.1" ? Hex[] : never
136
139
  useMetaFactory?: boolean
137
- eip7702?: boolean
138
- eip7702Auth?: SignAuthorizationReturnType
139
- eip7702SponsorAccount?: Signer
140
140
  pluginMigrations?: PluginMigrationData[]
141
- }
141
+ } & (
142
+ | {
143
+ eip7702Auth?: SignAuthorizationReturnType | undefined
144
+ eip7702Account: Signer
145
+ plugins?:
146
+ | Omit<
147
+ KernelPluginManagerParams<entryPointVersion>,
148
+ "entryPoint" | "kernelVersion"
149
+ >
150
+ | KernelPluginManager<entryPointVersion>
151
+ | undefined
152
+ }
153
+ | {
154
+ eip7702Auth?: SignAuthorizationReturnType | undefined
155
+ eip7702Account?: Signer | undefined
156
+ plugins:
157
+ | Omit<
158
+ KernelPluginManagerParams<entryPointVersion>,
159
+ "entryPoint" | "kernelVersion"
160
+ >
161
+ | KernelPluginManager<entryPointVersion>
162
+ }
163
+ )
142
164
 
143
165
  /**
144
166
  * The account creation ABI for a kernel smart account (from the KernelFactory)
@@ -383,10 +405,26 @@ export async function createKernelAccount<
383
405
  initConfig,
384
406
  useMetaFactory: _useMetaFactory = true,
385
407
  eip7702Auth,
386
- eip7702SponsorAccount,
408
+ eip7702Account,
387
409
  pluginMigrations
388
410
  }: CreateKernelAccountParameters<entryPointVersion, KernelVersion>
389
411
  ): Promise<CreateKernelAccountReturnType<entryPointVersion>> {
412
+ const isEip7702 = !!eip7702Account || !!eip7702Auth
413
+ if (isEip7702 && !satisfies(kernelVersion, ">=0.3.3")) {
414
+ throw new Error("EIP-7702 is recommended for kernel version >=0.3.3")
415
+ }
416
+ const localAccount = eip7702Account
417
+ ? await toSigner({ signer: eip7702Account, address })
418
+ : undefined
419
+
420
+ let eip7702Validator: KernelValidator<"EIP7702Validator"> | undefined
421
+ if (localAccount) {
422
+ eip7702Validator = await signerTo7702Validator(client, {
423
+ signer: localAccount,
424
+ entryPoint,
425
+ kernelVersion
426
+ })
427
+ }
390
428
  let useMetaFactory = _useMetaFactory
391
429
  const { accountImplementationAddress, factoryAddress, metaFactoryAddress } =
392
430
  getDefaultAddresses(entryPoint.version, kernelVersion, {
@@ -422,11 +460,11 @@ export async function createKernelAccount<
422
460
  )
423
461
  ? plugins
424
462
  : await toKernelPluginManager<entryPointVersion>(client, {
425
- sudo: plugins.sudo,
426
- regular: plugins.regular,
427
- hook: plugins.hook,
428
- action: plugins.action,
429
- pluginEnableSignature: plugins.pluginEnableSignature,
463
+ sudo: localAccount ? eip7702Validator : plugins?.sudo,
464
+ regular: plugins?.regular,
465
+ hook: plugins?.hook,
466
+ action: plugins?.action,
467
+ pluginEnableSignature: plugins?.pluginEnableSignature,
430
468
  entryPoint,
431
469
  kernelVersion,
432
470
  chainId: await getMemoizedChainId()
@@ -439,11 +477,14 @@ export async function createKernelAccount<
439
477
  ? plugins.hook &&
440
478
  plugins.getIdentifier() ===
441
479
  plugins.sudoValidator?.getIdentifier()
442
- : plugins.hook && !plugins.regular
480
+ : plugins?.hook && !plugins?.regular
443
481
  )
444
482
 
445
483
  // Helper to generate the init code for the smart account
446
484
  const generateInitCode = async () => {
485
+ if (isEip7702) {
486
+ return "0x" as `0x${string}`
487
+ }
447
488
  if (!accountImplementationAddress || !factoryAddress)
448
489
  throw new Error("Missing account logic address or factory address")
449
490
  return getAccountInitCode<entryPointVersion>({
@@ -460,6 +501,12 @@ export async function createKernelAccount<
460
501
  }
461
502
 
462
503
  const getFactoryArgs = async () => {
504
+ if (isEip7702) {
505
+ return {
506
+ factory: undefined,
507
+ factoryData: undefined
508
+ }
509
+ }
463
510
  return {
464
511
  factory:
465
512
  entryPoint.version === "0.6" || useMetaFactory === false
@@ -472,16 +519,21 @@ export async function createKernelAccount<
472
519
  // Fetch account address
473
520
  let accountAddress =
474
521
  address ??
475
- (await (async () => {
476
- const { factory, factoryData } = await getFactoryArgs()
477
-
478
- // Get the sender address based on the init code
479
- return await getSenderAddress(client, {
480
- factory,
481
- factoryData,
482
- entryPointAddress: entryPoint.address
483
- })
484
- })())
522
+ (isEip7702
523
+ ? (localAccount?.address ?? zeroAddress)
524
+ : await (async () => {
525
+ const { factory, factoryData } = await getFactoryArgs()
526
+ if (!factory || !factoryData) {
527
+ throw new Error("Missing factory address or factory data")
528
+ }
529
+
530
+ // Get the sender address based on the init code
531
+ return await getSenderAddress(client, {
532
+ factory,
533
+ factoryData,
534
+ entryPointAddress: entryPoint.address
535
+ })
536
+ })())
485
537
 
486
538
  // If account is zeroAddress try without meta factory
487
539
  if (isAddressEqual(accountAddress, zeroAddress) && useMetaFactory) {
@@ -504,35 +556,6 @@ export async function createKernelAccount<
504
556
  version: entryPoint?.version ?? "0.7"
505
557
  } as const
506
558
 
507
- if (eip7702Auth) {
508
- let code = await getCode(client, { address: accountAddress })
509
- const isEip7702Authorized =
510
- code?.length && code.length > 0 && code.startsWith("0xef")
511
- if (!isEip7702Authorized) {
512
- const sponsorAccount = eip7702SponsorAccount
513
- ? await toSigner({ signer: eip7702SponsorAccount })
514
- : privateKeyToAccount(
515
- // NOTE: Don't worry about this private key, it's just for testing
516
- "0x688b84097239bc2bca41079d02fae599964a5844bc9e64f524206ad53a927bb9"
517
- )
518
- const sponsorWalletClient = createWalletClient({
519
- account: sponsorAccount,
520
- chain: client.chain,
521
- transport: http(client.transport.url)
522
- })
523
- await sendTransaction(sponsorWalletClient, {
524
- to: accountAddress,
525
- data: "0x",
526
- authorizationList: [eip7702Auth],
527
- chain: client.chain
528
- })
529
- code = await getCode(client, { address: accountAddress })
530
- while (code?.length === undefined || code.length === 0) {
531
- code = await getCode(client, { address: accountAddress })
532
- }
533
- }
534
- }
535
-
536
559
  // Cache for plugin installation status
537
560
  const pluginCache: PluginInstallationCache = {
538
561
  pendingPlugins: pluginMigrations || [],
@@ -563,14 +586,64 @@ export async function createKernelAccount<
563
586
  pluginCache.allInstalled = pluginCache.pendingPlugins.length === 0
564
587
  }
565
588
 
589
+ const signAuthorization = async () => {
590
+ const code = await getCode(client, { address: accountAddress })
591
+ // check if account has not activated 7702 with implementation address
592
+ if (
593
+ !code ||
594
+ code.length === 0 ||
595
+ !code
596
+ .toLowerCase()
597
+ .startsWith(
598
+ `0xef0100${accountImplementationAddress.slice(2).toLowerCase()}`
599
+ )
600
+ ) {
601
+ if (
602
+ eip7702Auth &&
603
+ !isAddressEqual(
604
+ eip7702Auth.address,
605
+ accountImplementationAddress
606
+ )
607
+ ) {
608
+ throw new Error(
609
+ "EIP-7702 authorization delegate address does not match account implementation address"
610
+ )
611
+ }
612
+
613
+ const auth =
614
+ eip7702Auth ??
615
+ (await signAuthorizationAction(client, {
616
+ account: localAccount as LocalAccount,
617
+ address: accountImplementationAddress as `0x${string}`,
618
+ chainId: await getMemoizedChainId()
619
+ }))
620
+ const verified = await verifyAuthorization({
621
+ authorization: auth,
622
+ address: accountAddress
623
+ })
624
+ if (!verified) {
625
+ throw new Error("Authorization verification failed")
626
+ }
627
+ return auth
628
+ }
629
+ return undefined
630
+ }
631
+
566
632
  await checkPluginInstallationStatus()
567
633
 
568
634
  return toSmartAccount<KernelSmartAccountImplementation<entryPointVersion>>({
569
- eip7702Auth,
635
+ authorization: isEip7702
636
+ ? {
637
+ account:
638
+ (localAccount as PrivateKeyAccount) ??
639
+ addressToEmptyAccount(accountAddress),
640
+ address: accountImplementationAddress
641
+ }
642
+ : undefined,
570
643
  kernelVersion,
571
644
  kernelPluginManager,
572
645
  accountImplementationAddress,
573
- factoryAddress: (await getFactoryArgs()).factory,
646
+ factoryAddress: (await getFactoryArgs()).factory as Address,
574
647
  generateInitCode,
575
648
  encodeModuleInstallCallData: async () => {
576
649
  return await kernelPluginManager.encodeModuleInstallCallData(
@@ -587,6 +660,9 @@ export async function createKernelAccount<
587
660
  if (accountAddress) return accountAddress
588
661
 
589
662
  const { factory, factoryData } = await getFactoryArgs()
663
+ if (!factory || !factoryData) {
664
+ throw new Error("Missing factory address or factory data")
665
+ }
590
666
 
591
667
  // Get the sender address based on the init code
592
668
  accountAddress = await getSenderAddress(client, {
@@ -624,7 +700,7 @@ export async function createKernelAccount<
624
700
  return encodeCallDataEpV07(
625
701
  [...calls, ...pluginInstallCalls],
626
702
  callType,
627
- plugins.hook ? true : undefined
703
+ plugins?.hook ? true : undefined
628
704
  )
629
705
  }
630
706
 
@@ -639,11 +715,12 @@ export async function createKernelAccount<
639
715
  return encodeCallDataEpV06(calls, callType)
640
716
  }
641
717
 
642
- if (plugins.hook) {
718
+ if (plugins?.hook) {
643
719
  return encodeCallDataEpV07(calls, callType, true)
644
720
  }
645
721
  return encodeCallDataEpV07(calls, callType)
646
722
  },
723
+ eip7702Authorization: signAuthorization,
647
724
  async sign({ hash }) {
648
725
  return this.signMessage({ message: hash })
649
726
  },
@@ -49,13 +49,7 @@ export const accountMetadata = async (
49
49
  } catch (error) {}
50
50
  return {
51
51
  name: KERNEL_NAME,
52
- version:
53
- kernelVersion === "0.3.0"
54
- ? "0.3.0-beta"
55
- : // TODO: remove this once 0.3.3 is released
56
- kernelVersion === "0.3.3"
57
- ? "0.3.2"
58
- : kernelVersion,
52
+ version: kernelVersion === "0.3.0" ? "0.3.0-beta" : kernelVersion,
59
53
  chainId: BigInt(
60
54
  chainId ??
61
55
  (client.chain
@@ -0,0 +1,107 @@
1
+ import type { TypedData } from "abitype"
2
+ import type { Address, Client, Hex, TypedDataDefinition } from "viem"
3
+ import {
4
+ type EntryPointVersion,
5
+ type UserOperation,
6
+ getUserOperationHash
7
+ } from "viem/account-abstraction"
8
+ import { toAccount } from "viem/accounts"
9
+ import { getChainId, signMessage } from "viem/actions"
10
+ import type {
11
+ EntryPointType,
12
+ GetKernelVersion,
13
+ KernelValidator,
14
+ Signer
15
+ } from "../../types/index.js"
16
+ import { toSigner } from "../../utils/toSigner.js"
17
+
18
+ export async function signerTo7702Validator<
19
+ entryPointVersion extends EntryPointVersion
20
+ >(
21
+ client: Client,
22
+ {
23
+ signer,
24
+ entryPoint,
25
+ kernelVersion
26
+ }: {
27
+ signer: Signer
28
+ entryPoint: EntryPointType<entryPointVersion>
29
+ kernelVersion: GetKernelVersion<entryPointVersion>
30
+ }
31
+ ): Promise<KernelValidator<"EIP7702Validator">> {
32
+ const viemSigner = await toSigner({ signer })
33
+
34
+ // Fetch chain id
35
+ const chainId = client.chain?.id ?? (await getChainId(client))
36
+
37
+ // Build the EOA Signer
38
+ const account = toAccount({
39
+ address: viemSigner.address,
40
+ async signMessage({ message }) {
41
+ return signMessage(client, { account: viemSigner, message })
42
+ },
43
+ async signTransaction(_, __) {
44
+ throw new Error(
45
+ "Smart account signer doesn't need to sign transactions"
46
+ )
47
+ },
48
+ async signTypedData<
49
+ const TTypedData extends TypedData | Record<string, unknown>,
50
+ TPrimaryType extends
51
+ | keyof TTypedData
52
+ | "EIP712Domain" = keyof TTypedData
53
+ >(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) {
54
+ return viemSigner.signTypedData(typedData)
55
+ }
56
+ })
57
+
58
+ return {
59
+ ...account,
60
+ supportedKernelVersions: kernelVersion,
61
+ validatorType: "SECONDARY",
62
+ address: viemSigner.address,
63
+ source: "EIP7702Validator",
64
+ getIdentifier() {
65
+ return "0x"
66
+ },
67
+
68
+ async getEnableData() {
69
+ return viemSigner.address
70
+ },
71
+ async getNonceKey(_accountAddress?: Address, customNonceKey?: bigint) {
72
+ if (customNonceKey) {
73
+ return customNonceKey
74
+ }
75
+ return 0n
76
+ },
77
+ // Sign a user operation
78
+ async signUserOperation(userOperation) {
79
+ const hash = getUserOperationHash({
80
+ userOperation: {
81
+ ...userOperation,
82
+ signature: "0x"
83
+ } as UserOperation<entryPointVersion>,
84
+ entryPointAddress: entryPoint.address,
85
+ entryPointVersion: entryPoint.version,
86
+ chainId: chainId
87
+ })
88
+ const signature = await signMessage(client, {
89
+ account: viemSigner,
90
+ message: { raw: hash }
91
+ })
92
+ return signature
93
+ },
94
+
95
+ // Get simple dummy signature
96
+ async getStubSignature() {
97
+ return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
98
+ },
99
+
100
+ async isEnabled(
101
+ _kernelAccountAddress: Address,
102
+ _selector: Hex
103
+ ): Promise<boolean> {
104
+ return false
105
+ }
106
+ }
107
+ }
@@ -39,7 +39,7 @@ export function isKernelPluginManager<
39
39
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
40
40
  plugin: any
41
41
  ): plugin is KernelPluginManager<entryPointVersion> {
42
- return plugin.getPluginEnableSignature !== undefined
42
+ return plugin?.getPluginEnableSignature !== undefined
43
43
  }
44
44
 
45
45
  export async function toKernelPluginManager<
@@ -37,7 +37,12 @@ export async function uninstallPlugin<
37
37
  client: Client<Transport, chain, account>,
38
38
  args: UninstallPluginParameters<account, accountOverride, calls>
39
39
  ): Promise<Hash> {
40
- const { account: account_ = client.account, plugin, hook } = args
40
+ const {
41
+ account: account_ = client.account,
42
+ plugin,
43
+ hook,
44
+ ...restArgs
45
+ } = args
41
46
  if (!account_)
42
47
  throw new AccountNotFoundError({
43
48
  docsPath: "/docs/actions/wallet/sendTransaction"
@@ -70,7 +75,7 @@ export async function uninstallPlugin<
70
75
  sendUserOperation,
71
76
  "sendUserOperation"
72
77
  )({
73
- ...args,
78
+ ...restArgs,
74
79
  calls: [
75
80
  {
76
81
  to: account.address,
@@ -21,8 +21,10 @@ import {
21
21
  type SmartAccount,
22
22
  type UserOperationRequest,
23
23
  bundlerActions,
24
+ prepareUserOperation,
24
25
  type prepareUserOperation as viemPrepareUserOperation
25
26
  } from "viem/account-abstraction"
27
+ import type { KernelSmartAccountImplementation } from "../accounts/index.js"
26
28
  import { getUserOperationGasPrice } from "../actions/index.js"
27
29
  import {
28
30
  type KernelAccountClientActions,
@@ -256,5 +258,44 @@ export function createKernelAccountClient(
256
258
 
257
259
  return client
258
260
  .extend(bundlerActions)
261
+ .extend((_client) => ({
262
+ prepareUserOperation: async (
263
+ args: PrepareUserOperationParameters
264
+ ) => {
265
+ let _args = args
266
+ if (_client.account?.authorization) {
267
+ const authorization =
268
+ args.authorization ||
269
+ (await (
270
+ _client.account as SmartAccount<KernelSmartAccountImplementation>
271
+ )?.eip7702Authorization?.())
272
+ _args = {
273
+ ...args,
274
+ authorization
275
+ }
276
+ }
277
+ return await prepareUserOperation(_client, _args)
278
+ }
279
+ }))
280
+ .extend(bundlerActions)
281
+ .extend((_client) => ({
282
+ prepareUserOperation: async (
283
+ args: PrepareUserOperationParameters
284
+ ) => {
285
+ let _args = args
286
+ if (_client.account?.authorization) {
287
+ const authorization =
288
+ args.authorization ||
289
+ (await (
290
+ _client.account as SmartAccount<KernelSmartAccountImplementation>
291
+ )?.eip7702Authorization?.())
292
+ _args = {
293
+ ...args,
294
+ authorization
295
+ }
296
+ }
297
+ return await prepareUserOperation(_client, _args)
298
+ }
299
+ }))
259
300
  .extend(kernelAccountClientActions()) as KernelAccountClient
260
301
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerodev/sdk",
3
- "version": "5.4.34",
3
+ "version": "5.4.36",
4
4
  "author": "ZeroDev",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
package/utils/toSigner.ts CHANGED
@@ -16,11 +16,7 @@ import {
16
16
  } from "viem"
17
17
  import { toAccount } from "viem/accounts"
18
18
 
19
- import {
20
- signAuthorization,
21
- signMessage,
22
- signTypedData
23
- } from "viem/actions"
19
+ import { signAuthorization, signMessage, signTypedData } from "viem/actions"
24
20
  import type { Signer } from "../types/index.js"
25
21
 
26
22
  export async function toSigner({