permissionless 0.2.47 → 0.2.49

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 (56) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/_cjs/accounts/index.js +5 -1
  3. package/_cjs/accounts/index.js.map +1 -1
  4. package/_cjs/accounts/kernel/to7702KernelSmartAccount.js +11 -0
  5. package/_cjs/accounts/kernel/to7702KernelSmartAccount.js.map +1 -0
  6. package/_cjs/accounts/kernel/toKernelSmartAccount.js +60 -17
  7. package/_cjs/accounts/kernel/toKernelSmartAccount.js.map +1 -1
  8. package/_cjs/accounts/simple/to7702SimpleSmartAccount.js +11 -0
  9. package/_cjs/accounts/simple/to7702SimpleSmartAccount.js.map +1 -0
  10. package/_cjs/accounts/simple/toSimpleSmartAccount.js +50 -18
  11. package/_cjs/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  12. package/_cjs/actions/erc7579/installModule.js +2 -1
  13. package/_cjs/actions/erc7579/installModule.js.map +1 -1
  14. package/_cjs/actions/erc7579/installModules.js +2 -1
  15. package/_cjs/actions/erc7579/installModules.js.map +1 -1
  16. package/_esm/accounts/index.js +3 -1
  17. package/_esm/accounts/index.js.map +1 -1
  18. package/_esm/accounts/kernel/to7702KernelSmartAccount.js +8 -0
  19. package/_esm/accounts/kernel/to7702KernelSmartAccount.js.map +1 -0
  20. package/_esm/accounts/kernel/toKernelSmartAccount.js +61 -22
  21. package/_esm/accounts/kernel/toKernelSmartAccount.js.map +1 -1
  22. package/_esm/accounts/simple/to7702SimpleSmartAccount.js +8 -0
  23. package/_esm/accounts/simple/to7702SimpleSmartAccount.js.map +1 -0
  24. package/_esm/accounts/simple/toSimpleSmartAccount.js +51 -20
  25. package/_esm/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  26. package/_esm/actions/erc7579/installModule.js +2 -1
  27. package/_esm/actions/erc7579/installModule.js.map +1 -1
  28. package/_esm/actions/erc7579/installModules.js +2 -1
  29. package/_esm/actions/erc7579/installModules.js.map +1 -1
  30. package/_types/accounts/index.d.ts +3 -1
  31. package/_types/accounts/index.d.ts.map +1 -1
  32. package/_types/accounts/kernel/to7702KernelSmartAccount.d.ts +8 -0
  33. package/_types/accounts/kernel/to7702KernelSmartAccount.d.ts.map +1 -0
  34. package/_types/accounts/kernel/toKernelSmartAccount.d.ts +29 -9
  35. package/_types/accounts/kernel/toKernelSmartAccount.d.ts.map +1 -1
  36. package/_types/accounts/simple/to7702SimpleSmartAccount.d.ts +8 -0
  37. package/_types/accounts/simple/to7702SimpleSmartAccount.d.ts.map +1 -0
  38. package/_types/accounts/simple/toSimpleSmartAccount.d.ts +20 -7
  39. package/_types/accounts/simple/toSimpleSmartAccount.d.ts.map +1 -1
  40. package/_types/actions/erc7579/installModule.d.ts +2 -1
  41. package/_types/actions/erc7579/installModule.d.ts.map +1 -1
  42. package/_types/actions/erc7579/installModules.d.ts +2 -1
  43. package/_types/actions/erc7579/installModules.d.ts.map +1 -1
  44. package/accounts/index.ts +23 -1
  45. package/accounts/kernel/to7702KernelSmartAccount.ts +63 -0
  46. package/accounts/kernel/toKernelSmartAccount.ts +154 -63
  47. package/accounts/simple/to7702SimpleSmartAccount.ts +51 -0
  48. package/accounts/simple/toSimpleSmartAccount.ts +116 -46
  49. package/actions/erc7579/installModule.test.ts +44 -4
  50. package/actions/erc7579/installModule.ts +4 -1
  51. package/actions/erc7579/installModules.test.ts +41 -2
  52. package/actions/erc7579/installModules.ts +11 -1
  53. package/actions/erc7579/uninstallModule.test.ts +25 -3
  54. package/actions/smartAccount/sendTransaction.test.ts +79 -29
  55. package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +69 -257
  56. package/package.json +2 -2
@@ -1,18 +1,31 @@
1
1
  import { type Account, type Address, type Assign, type Chain, type Client, type JsonRpcAccount, type LocalAccount, type OneOf, type Transport, type WalletClient } from "viem";
2
2
  import { type EntryPointVersion, type SmartAccount, type SmartAccountImplementation } from "viem/account-abstraction";
3
3
  import { type EthereumProvider } from "../../utils/toOwner.js";
4
- export type ToSimpleSmartAccountParameters<entryPointVersion extends EntryPointVersion> = {
4
+ export type ToSimpleSmartAccountParameters<entryPointVersion extends EntryPointVersion, owner extends OneOf<EthereumProvider | WalletClient<Transport, Chain | undefined, Account> | LocalAccount>, eip7702 extends boolean = false> = {
5
5
  client: Client<Transport, Chain | undefined, JsonRpcAccount | LocalAccount | undefined>;
6
- owner: OneOf<EthereumProvider | WalletClient<Transport, Chain | undefined, Account> | LocalAccount>;
7
- factoryAddress?: Address;
6
+ owner: owner;
7
+ eip7702?: eip7702;
8
+ } & (eip7702 extends true ? {
9
+ entryPoint?: {
10
+ address: Address;
11
+ version: "0.8";
12
+ };
13
+ factoryAddress?: never;
14
+ index?: never;
15
+ address?: never;
16
+ nonceKey?: never;
17
+ accountLogicAddress?: Address;
18
+ } : {
8
19
  entryPoint?: {
9
20
  address: Address;
10
21
  version: entryPointVersion;
11
22
  };
23
+ factoryAddress?: Address;
12
24
  index?: bigint;
13
25
  address?: Address;
14
26
  nonceKey?: bigint;
15
- };
27
+ accountLogicAddress?: Address;
28
+ });
16
29
  declare const getEntryPointAbi: (entryPointVersion: EntryPointVersion) => readonly [{
17
30
  readonly inputs: readonly [];
18
31
  readonly stateMutability: "nonpayable";
@@ -2308,15 +2321,15 @@ declare const getEntryPointAbi: (entryPointVersion: EntryPointVersion) => readon
2308
2321
  readonly stateMutability: "payable";
2309
2322
  readonly type: "receive";
2310
2323
  }];
2311
- export type SimpleSmartAccountImplementation<entryPointVersion extends EntryPointVersion = "0.7"> = Assign<SmartAccountImplementation<ReturnType<typeof getEntryPointAbi>, entryPointVersion>, {
2324
+ export type SimpleSmartAccountImplementation<entryPointVersion extends EntryPointVersion = "0.7", eip7702 extends boolean = false> = Assign<SmartAccountImplementation<ReturnType<typeof getEntryPointAbi>, entryPointVersion, eip7702 extends true ? object : object, eip7702>, {
2312
2325
  sign: NonNullable<SmartAccountImplementation["sign"]>;
2313
2326
  }>;
2314
- export type ToSimpleSmartAccountReturnType<entryPointVersion extends EntryPointVersion = "0.7"> = SmartAccount<SimpleSmartAccountImplementation<entryPointVersion>>;
2327
+ export type ToSimpleSmartAccountReturnType<entryPointVersion extends EntryPointVersion = "0.7", eip7702 extends boolean = false> = eip7702 extends true ? SmartAccount<SimpleSmartAccountImplementation<entryPointVersion, true>> : SmartAccount<SimpleSmartAccountImplementation<entryPointVersion, false>>;
2315
2328
  /**
2316
2329
  * @description Creates an Simple Account from a private key.
2317
2330
  *
2318
2331
  * @returns A Private Key Simple Account.
2319
2332
  */
2320
- export declare function toSimpleSmartAccount<entryPointVersion extends EntryPointVersion>(parameters: ToSimpleSmartAccountParameters<entryPointVersion>): Promise<ToSimpleSmartAccountReturnType<entryPointVersion>>;
2333
+ export declare function toSimpleSmartAccount<entryPointVersion extends EntryPointVersion, owner extends OneOf<EthereumProvider | WalletClient<Transport, Chain | undefined, Account> | LocalAccount>, eip7702 extends boolean = false>(parameters: ToSimpleSmartAccountParameters<entryPointVersion, owner, eip7702>): Promise<ToSimpleSmartAccountReturnType<entryPointVersion, eip7702>>;
2321
2334
  export {};
2322
2335
  //# sourceMappingURL=toSimpleSmartAccount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toSimpleSmartAccount.d.ts","sourceRoot":"","sources":["../../../accounts/simple/toSimpleSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,KAAK,EACV,KAAK,MAAM,EAEX,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,YAAY,EAGpB,MAAM,MAAM,CAAA;AACb,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EASlC,MAAM,0BAA0B,CAAA;AAKjC,OAAO,EAAE,KAAK,gBAAgB,EAAW,MAAM,wBAAwB,CAAA;AAwC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CAAgC,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAErE;;;;GAIG;AACH,wBAAsB,oBAAoB,CACtC,iBAAiB,SAAS,iBAAiB,EAE3C,UAAU,EAAE,8BAA8B,CAAC,iBAAiB,CAAC,GAC9D,OAAO,CAAC,8BAA8B,CAAC,iBAAiB,CAAC,CAAC,CAgQ5D"}
1
+ {"version":3,"file":"toSimpleSmartAccount.d.ts","sourceRoot":"","sources":["../../../accounts/simple/toSimpleSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,KAAK,EACV,KAAK,MAAM,EAEX,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,KAAK,EAEV,KAAK,SAAS,EACd,KAAK,YAAY,EAGpB,MAAM,MAAM,CAAA;AACb,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAUlC,MAAM,0BAA0B,CAAA;AAKjC,OAAO,EAAE,KAAK,gBAAgB,EAAW,MAAM,wBAAwB,CAAA;AAwCvE,MAAM,MAAM,8BAA8B,CACtC,iBAAiB,SAAS,iBAAiB,EAC3C,KAAK,SAAS,KAAK,CACb,gBAAgB,GAChB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,OAAO,CAAC,GACnD,YAAY,CACjB,EACD,OAAO,SAAS,OAAO,GAAG,KAAK,IAC/B;IACA,MAAM,EAAE,MAAM,CACV,SAAS,EACT,KAAK,GAAG,SAAS,EACjB,cAAc,GAAG,YAAY,GAAG,SAAS,CAC5C,CAAA;IACD,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB,GAAG,CAAC,OAAO,SAAS,IAAI,GACnB;IACI,UAAU,CAAC,EAAE;QACT,OAAO,EAAE,OAAO,CAAA;QAChB,OAAO,EAAE,KAAK,CAAA;KACjB,CAAA;IACD,cAAc,CAAC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AAK,EACnD,OAAO,SAAS,OAAO,GAAG,KAAK,IAC/B,OAAO,SAAS,IAAI,GAClB,YAAY,CAAC,gCAAgC,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,GACvE,YAAY,CAAC,gCAAgC,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC,CAAA;AAE9E;;;;GAIG;AACH,wBAAsB,oBAAoB,CACtC,iBAAiB,SAAS,iBAAiB,EAC3C,KAAK,SAAS,KAAK,CACb,gBAAgB,GAChB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,OAAO,CAAC,GACnD,YAAY,CACjB,EACD,OAAO,SAAS,OAAO,GAAG,KAAK,EAE/B,UAAU,EAAE,8BAA8B,CACtC,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,GACF,OAAO,CAAC,8BAA8B,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAmSrE"}
@@ -1,7 +1,8 @@
1
- import type { Address, Client, Hex, OneOf } from "viem";
1
+ import type { Address, Client, Hex, OneOf, SignedAuthorization } from "viem";
2
2
  import { type GetSmartAccountParameter, type PaymasterActions, type SmartAccount } from "viem/account-abstraction";
3
3
  import type { ModuleType } from "./supportsModule.js";
4
4
  export type InstallModuleParameters<TSmartAccount extends SmartAccount | undefined> = GetSmartAccountParameter<TSmartAccount> & {
5
+ authorization?: SignedAuthorization<number> | undefined;
5
6
  type: ModuleType;
6
7
  address: Address;
7
8
  maxFeePerGas?: bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"installModule.d.ts","sourceRoot":"","sources":["../../../actions/erc7579/installModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AACvD,OAAO,EACH,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAEpB,MAAM,0BAA0B,CAAA;AAIjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,MAAM,uBAAuB,CAC/B,aAAa,SAAS,YAAY,GAAG,SAAS,IAC9C,wBAAwB,CAAC,aAAa,CAAC,GAAG;IAC1C,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,SAAS;QACb,EAAE,EAAE,OAAO,CAAA;QACX,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;KACzB,EAAE,CAAA;IACH,SAAS,CAAC,EACJ,OAAO,GACP,IAAI,GACJ;QACI,uGAAuG;QACvG,gBAAgB,CAAC,EACX,gBAAgB,CAAC,kBAAkB,CAAC,GACpC,SAAS,CAAA;QACf,2FAA2F;QAC3F,oBAAoB,CAAC,EACf,gBAAgB,CAAC,sBAAsB,CAAC,GACxC,SAAS,CAAA;KAClB,GACD,SAAS,CAAA;IACf,wFAAwF;IACxF,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACzC,GAAG,KAAK,CACC;IACI,OAAO,EAAE,GAAG,CAAA;CACf,GACD;IACI,QAAQ,EAAE,GAAG,CAAA;CAChB,CACN,CAAA;AAEL,wBAAgB,aAAa,CAAC,aAAa,SAAS,YAAY,GAAG,SAAS,EACxE,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,uBAAuB,CAAC,aAAa,CAAC,GACnD,OAAO,CAAC,GAAG,CAAC,CA0Cd"}
1
+ {"version":3,"file":"installModule.d.ts","sourceRoot":"","sources":["../../../actions/erc7579/installModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CA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,GAAG,CAAC,CA4Cd"}
@@ -1,7 +1,8 @@
1
- import type { Address, Chain, Client, Hex, Transport } from "viem";
1
+ import type { Address, Chain, Client, Hex, SignedAuthorization, Transport } from "viem";
2
2
  import { type PaymasterActions, type SmartAccount } from "viem/account-abstraction";
3
3
  import { type EncodeInstallModuleParameters } from "../../utils/encodeInstallModule.js";
4
4
  export type InstallModulesParameters<TSmartAccount extends SmartAccount | undefined> = EncodeInstallModuleParameters<TSmartAccount> & {
5
+ authorization?: SignedAuthorization<number> | undefined;
5
6
  maxFeePerGas?: bigint;
6
7
  maxPriorityFeePerGas?: bigint;
7
8
  nonce?: bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"installModules.d.ts","sourceRoot":"","sources":["../../../actions/erc7579/installModules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAClE,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAEpB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EACH,KAAK,6BAA6B,EAErC,MAAM,oCAAoC,CAAA;AAE3C,MAAM,MAAM,wBAAwB,CAChC,aAAa,SAAS,YAAY,GAAG,SAAS,IAC9C,6BAA6B,CAAC,aAAa,CAAC,GAAG;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,SAAS;QACb,EAAE,EAAE,OAAO,CAAA;QACX,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;KACzB,EAAE,CAAA;IACH,SAAS,CAAC,EACJ,OAAO,GACP,IAAI,GACJ;QACI,uGAAuG;QACvG,gBAAgB,CAAC,EACX,gBAAgB,CAAC,kBAAkB,CAAC,GACpC,SAAS,CAAA;QACf,2FAA2F;QAC3F,oBAAoB,CAAC,EACf,gBAAgB,CAAC,sBAAsB,CAAC,GACxC,SAAS,CAAA;KAClB,GACD,SAAS,CAAA;IACf,wFAAwF;IACxF,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACzC,CAAA;AAED,wBAAsB,cAAc,CAChC,aAAa,SAAS,YAAY,GAAG,SAAS,EAE9C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,aAAa,CAAC,EAC3D,UAAU,EAAE,wBAAwB,CAAC,aAAa,CAAC,GACpD,OAAO,CAAC,GAAG,CAAC,CAsCd"}
1
+ {"version":3,"file":"installModules.d.ts","sourceRoot":"","sources":["../../../actions/erc7579/installModules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,OAAO,EACP,KAAK,EACL,MAAM,EACN,GAAG,EACH,mBAAmB,EACnB,SAAS,EACZ,MAAM,MAAM,CAAA;AACb,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAEpB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EACH,KAAK,6BAA6B,EAErC,MAAM,oCAAoC,CAAA;AAE3C,MAAM,MAAM,wBAAwB,CAChC,aAAa,SAAS,YAAY,GAAG,SAAS,IAC9C,6BAA6B,CAAC,aAAa,CAAC,GAAG;IAC/C,aAAa,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IACvD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,SAAS;QACb,EAAE,EAAE,OAAO,CAAA;QACX,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;KACzB,EAAE,CAAA;IACH,SAAS,CAAC,EACJ,OAAO,GACP,IAAI,GACJ;QACI,uGAAuG;QACvG,gBAAgB,CAAC,EACX,gBAAgB,CAAC,kBAAkB,CAAC,GACpC,SAAS,CAAA;QACf,2FAA2F;QAC3F,oBAAoB,CAAC,EACf,gBAAgB,CAAC,sBAAsB,CAAC,GACxC,SAAS,CAAA;KAClB,GACD,SAAS,CAAA;IACf,wFAAwF;IACxF,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACzC,CAAA;AAED,wBAAsB,cAAc,CAChC,aAAa,SAAS,YAAY,GAAG,SAAS,EAE9C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,aAAa,CAAC,EAC3D,UAAU,EAAE,wBAAwB,CAAC,aAAa,CAAC,GACpD,OAAO,CAAC,GAAG,CAAC,CAwCd"}
package/accounts/index.ts CHANGED
@@ -5,6 +5,13 @@ import {
5
5
  toSimpleSmartAccount
6
6
  } from "./simple/toSimpleSmartAccount.js"
7
7
 
8
+ import {
9
+ type To7702SimpleSmartAccountImplementation,
10
+ type To7702SimpleSmartAccountParameters,
11
+ type To7702SimpleSmartAccountReturnType,
12
+ to7702SimpleSmartAccount
13
+ } from "./simple/to7702SimpleSmartAccount.js"
14
+
8
15
  import {
9
16
  type LightAccountVersion,
10
17
  type LightSmartAccountImplementation,
@@ -42,6 +49,13 @@ import {
42
49
  toEcdsaKernelSmartAccount
43
50
  } from "./kernel/toEcdsaKernelSmartAccount.js"
44
51
 
52
+ import {
53
+ type To7702KernelSmartAccountImplementation,
54
+ type To7702KernelSmartAccountParameters,
55
+ type To7702KernelSmartAccountReturnType,
56
+ to7702KernelSmartAccount
57
+ } from "./kernel/to7702KernelSmartAccount.js"
58
+
45
59
  import {
46
60
  type KernelSmartAccountImplementation,
47
61
  type KernelVersion,
@@ -76,6 +90,10 @@ export {
76
90
  type SimpleSmartAccountImplementation,
77
91
  type ToSimpleSmartAccountReturnType,
78
92
  toSimpleSmartAccount,
93
+ type To7702SimpleSmartAccountParameters,
94
+ type To7702SimpleSmartAccountImplementation,
95
+ type To7702SimpleSmartAccountReturnType,
96
+ to7702SimpleSmartAccount,
79
97
  type LightAccountVersion,
80
98
  type ToLightSmartAccountParameters,
81
99
  type LightSmartAccountImplementation,
@@ -114,5 +132,9 @@ export {
114
132
  type ToEtherspotSmartAccountParameters,
115
133
  type EtherspotSmartAccountImplementation,
116
134
  type ToEtherspotSmartAccountReturnType,
117
- toEtherspotSmartAccount
135
+ toEtherspotSmartAccount,
136
+ type To7702KernelSmartAccountParameters,
137
+ type To7702KernelSmartAccountImplementation,
138
+ type To7702KernelSmartAccountReturnType,
139
+ to7702KernelSmartAccount
118
140
  }
@@ -0,0 +1,63 @@
1
+ import type {
2
+ Account,
3
+ Chain,
4
+ LocalAccount,
5
+ OneOf,
6
+ Prettify,
7
+ Transport,
8
+ WalletClient
9
+ } from "viem"
10
+ import type { EthereumProvider } from "../../utils/toOwner.js"
11
+ import {
12
+ type KernelSmartAccountImplementation,
13
+ type KernelVersion,
14
+ type ToKernelSmartAccountParameters,
15
+ type ToKernelSmartAccountReturnType,
16
+ toKernelSmartAccount
17
+ } from "./toKernelSmartAccount.js"
18
+
19
+ export type To7702KernelSmartAccountParameters<
20
+ entryPointVersion extends "0.7",
21
+ kernelVersion extends KernelVersion<entryPointVersion>,
22
+ owner extends OneOf<
23
+ | EthereumProvider
24
+ | WalletClient<Transport, Chain | undefined, Account>
25
+ | LocalAccount
26
+ >
27
+ > = ToKernelSmartAccountParameters<
28
+ entryPointVersion,
29
+ kernelVersion,
30
+ owner,
31
+ true
32
+ >
33
+
34
+ export type To7702KernelSmartAccountImplementation<
35
+ entryPointVersion extends "0.7" = "0.7"
36
+ > = KernelSmartAccountImplementation<entryPointVersion, true>
37
+
38
+ export type To7702KernelSmartAccountReturnType<
39
+ entryPointVersion extends "0.7" = "0.7"
40
+ > = ToKernelSmartAccountReturnType<entryPointVersion, true>
41
+
42
+ export async function to7702KernelSmartAccount<
43
+ entryPointVersion extends "0.7",
44
+ kernelVersion extends KernelVersion<entryPointVersion>,
45
+ owner extends OneOf<
46
+ | EthereumProvider
47
+ | WalletClient<Transport, Chain | undefined, Account>
48
+ | LocalAccount
49
+ >
50
+ >(
51
+ parameters: Prettify<
52
+ To7702KernelSmartAccountParameters<
53
+ entryPointVersion,
54
+ kernelVersion,
55
+ owner
56
+ >
57
+ >
58
+ ): Promise<To7702KernelSmartAccountReturnType<entryPointVersion>> {
59
+ return toKernelSmartAccount({
60
+ ...parameters,
61
+ eip7702: true
62
+ })
63
+ }
@@ -5,6 +5,7 @@ import type {
5
5
  Chain,
6
6
  JsonRpcAccount,
7
7
  OneOf,
8
+ PrivateKeyAccount,
8
9
  Transport,
9
10
  WalletClient
10
11
  } from "viem"
@@ -31,7 +32,7 @@ import {
31
32
  getUserOperationHash,
32
33
  toSmartAccount
33
34
  } from "viem/account-abstraction"
34
- import { signMessage as _signMessage, getChainId } from "viem/actions"
35
+ import { getChainId } from "viem/actions"
35
36
  import { getAction } from "viem/utils"
36
37
  import { getAccountNonce } from "../../actions/public/getAccountNonce.js"
37
38
  import { getSenderAddress } from "../../actions/public/getSenderAddress.js"
@@ -56,6 +57,8 @@ import { isWebAuthnAccount } from "./utils/isWebAuthnAccount.js"
56
57
  import { signMessage } from "./utils/signMessage.js"
57
58
  import { signTypedData } from "./utils/signTypedData.js"
58
59
 
60
+ type EntryPointVersion = "0.6" | "0.7"
61
+
59
62
  /**
60
63
  * The account creation ABI for a kernel smart account (from the KernelFactory)
61
64
  */
@@ -91,7 +94,7 @@ const createAccountAbi = [
91
94
  }
92
95
  ] as const
93
96
 
94
- export type KernelVersion<entryPointVersion extends "0.6" | "0.7"> =
97
+ export type KernelVersion<entryPointVersion extends EntryPointVersion> =
95
98
  entryPointVersion extends "0.6"
96
99
  ? "0.2.1" | "0.2.2" | "0.2.3" | "0.2.4"
97
100
  : "0.3.0-beta" | "0.3.1" | "0.3.2" | "0.3.3"
@@ -100,7 +103,7 @@ export type KernelVersion<entryPointVersion extends "0.6" | "0.7"> =
100
103
  * Default addresses map for different kernel smart account versions
101
104
  */
102
105
  export const KERNEL_VERSION_TO_ADDRESSES_MAP: {
103
- [key in KernelVersion<"0.6" | "0.7">]: {
106
+ [key in KernelVersion<EntryPointVersion>]: {
104
107
  ECDSA_VALIDATOR: Address
105
108
  WEB_AUTHN_VALIDATOR?: Address
106
109
  ACCOUNT_LOGIC: Address
@@ -150,8 +153,8 @@ export const KERNEL_VERSION_TO_ADDRESSES_MAP: {
150
153
  },
151
154
  "0.3.3": {
152
155
  ECDSA_VALIDATOR: "0x845ADb2C711129d4f3966735eD98a9F09fC4cE57",
153
- ACCOUNT_LOGIC: "0xE264dCCc54e4b6906c0D1Fee11D4326c06D33c80",
154
- FACTORY_ADDRESS: "0xE30c76Dc9eCF1c19F6Fec070674E1b4eFfE069FA",
156
+ ACCOUNT_LOGIC: "0xd6CEDDe84be40893d153Be9d467CD6aD37875b28",
157
+ FACTORY_ADDRESS: "0x2577507b78c2008Ff367261CB6285d44ba5eF2E9",
155
158
  META_FACTORY_ADDRESS: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5"
156
159
  }
157
160
  }
@@ -160,10 +163,15 @@ export const KERNEL_VERSION_TO_ADDRESSES_MAP: {
160
163
  * Get supported Kernel Smart Account version based on entryPoint
161
164
  * @param entryPoint
162
165
  */
163
- const getDefaultKernelVersion = <TEntryPointVersion extends "0.6" | "0.7">(
166
+ const getDefaultKernelVersion = <TEntryPointVersion extends EntryPointVersion>(
164
167
  entryPointVersion: TEntryPointVersion,
165
- version?: KernelVersion<TEntryPointVersion>
168
+ version?: KernelVersion<TEntryPointVersion>,
169
+ eip7702?: boolean
166
170
  ): KernelVersion<TEntryPointVersion> => {
171
+ if (eip7702) {
172
+ return "0.3.3" as KernelVersion<TEntryPointVersion>
173
+ }
174
+
167
175
  if (version) {
168
176
  return version
169
177
  }
@@ -195,7 +203,7 @@ const getDefaultAddresses = ({
195
203
  kernelVersion,
196
204
  isWebAuthn
197
205
  }: Partial<KERNEL_ADDRESSES> & {
198
- kernelVersion: KernelVersion<"0.6" | "0.7">
206
+ kernelVersion: KernelVersion<EntryPointVersion>
199
207
  isWebAuthn: boolean
200
208
  }): KERNEL_ADDRESSES => {
201
209
  const addresses = KERNEL_VERSION_TO_ADDRESSES_MAP[kernelVersion]
@@ -227,7 +235,7 @@ export const getEcdsaRootIdentifierForKernelV3 = (
227
235
  * @param owner
228
236
  * @param ecdsaValidatorAddress
229
237
  */
230
- const getInitializationData = <entryPointVersion extends "0.6" | "0.7">({
238
+ const getInitializationData = <entryPointVersion extends EntryPointVersion>({
231
239
  entryPoint: { version: entryPointVersion },
232
240
  kernelVersion,
233
241
  validatorData,
@@ -322,7 +330,7 @@ const getValidatorData = async (owner: WebAuthnAccount | LocalAccount) => {
322
330
  * @param accountLogicAddress
323
331
  * @param ecdsaValidatorAddress
324
332
  */
325
- const getAccountInitCode = async <entryPointVersion extends "0.6" | "0.7">({
333
+ const getAccountInitCode = async <entryPointVersion extends EntryPointVersion>({
326
334
  entryPointVersion,
327
335
  kernelVersion,
328
336
  validatorData,
@@ -375,44 +383,74 @@ const getAccountInitCode = async <entryPointVersion extends "0.6" | "0.7">({
375
383
  }
376
384
 
377
385
  export type ToKernelSmartAccountParameters<
378
- entryPointVersion extends "0.6" | "0.7",
386
+ entryPointVersion extends EntryPointVersion,
379
387
  kernelVersion extends KernelVersion<entryPointVersion>,
380
388
  owner extends OneOf<
381
389
  | EthereumProvider
382
390
  | WalletClient<Transport, Chain | undefined, Account>
383
391
  | LocalAccount
384
392
  | WebAuthnAccount
385
- >
393
+ >,
394
+ eip7702 extends boolean = false
386
395
  > = {
387
396
  client: Client<
388
397
  Transport,
389
398
  Chain | undefined,
390
399
  JsonRpcAccount | LocalAccount | undefined
391
400
  >
392
- owners: [owner]
393
- entryPoint?: {
394
- address: Address
395
- version: entryPointVersion
396
- }
397
- address?: Address
398
401
  version?: kernelVersion
399
- index?: bigint
400
- factoryAddress?: Address
401
- metaFactoryAddress?: Address
402
- accountLogicAddress?: Address
403
- validatorAddress?: Address
404
- nonceKey?: bigint
405
- useMetaFactory?: boolean | "optional"
406
- }
402
+ eip7702?: eip7702
403
+ } & (eip7702 extends true
404
+ ? {
405
+ owner: OneOf<
406
+ | EthereumProvider
407
+ | WalletClient<Transport, Chain | undefined, Account>
408
+ | LocalAccount
409
+ >
410
+ entryPoint?: {
411
+ address: Address
412
+ version: "0.7"
413
+ }
414
+ address?: never
415
+ index?: never
416
+ factoryAddress?: never
417
+ metaFactoryAddress?: never
418
+ accountLogicAddress?: never
419
+ validatorAddress?: never
420
+ nonceKey?: never
421
+ useMetaFactory?: never
422
+ }
423
+ : {
424
+ entryPoint?: {
425
+ address: Address
426
+ version: entryPointVersion
427
+ }
428
+ owners: [owner]
429
+ address?: Address
430
+ index?: bigint
431
+ factoryAddress?: Address
432
+ metaFactoryAddress?: Address
433
+ accountLogicAddress?: Address
434
+ validatorAddress?: Address
435
+ nonceKey?: bigint
436
+ useMetaFactory?: boolean | "optional"
437
+ })
407
438
 
408
439
  export type KernelSmartAccountImplementation<
409
- entryPointVersion extends "0.6" | "0.7" = "0.7"
440
+ entryPointVersion extends EntryPointVersion = "0.7",
441
+ eip7702 extends boolean = false
410
442
  > = Assign<
411
443
  SmartAccountImplementation<
412
444
  entryPointVersion extends "0.6"
413
445
  ? typeof entryPoint06Abi
414
446
  : typeof entryPoint07Abi,
415
- entryPointVersion
447
+ entryPointVersion,
448
+ eip7702 extends true
449
+ ? {
450
+ implementation: Address
451
+ }
452
+ : object,
453
+ eip7702
416
454
  // {
417
455
  // // entryPoint === ENTRYPOINT_ADDRESS_V06 ? "0.2.2" : "0.3.0-beta"
418
456
  // abi: entryPointVersion extends "0.6" ? typeof BiconomyAbi
@@ -423,8 +461,11 @@ export type KernelSmartAccountImplementation<
423
461
  >
424
462
 
425
463
  export type ToKernelSmartAccountReturnType<
426
- entryPointVersion extends "0.6" | "0.7" = "0.7"
427
- > = SmartAccount<KernelSmartAccountImplementation<entryPointVersion>>
464
+ entryPointVersion extends EntryPointVersion = "0.7",
465
+ eip7702 extends boolean = false
466
+ > = eip7702 extends true
467
+ ? SmartAccount<KernelSmartAccountImplementation<entryPointVersion, true>>
468
+ : SmartAccount<KernelSmartAccountImplementation<entryPointVersion, false>>
428
469
  /**
429
470
  * Build a kernel smart account from a private key, that use the ECDSA or passkeys signer behind the scene
430
471
  * @param client
@@ -436,56 +477,86 @@ export type ToKernelSmartAccountReturnType<
436
477
  * @param validatorAddress
437
478
  */
438
479
  export async function toKernelSmartAccount<
439
- entryPointVersion extends "0.6" | "0.7",
480
+ entryPointVersion extends EntryPointVersion,
440
481
  kernelVersion extends KernelVersion<entryPointVersion>,
441
482
  owner extends OneOf<
442
483
  | EthereumProvider
443
484
  | WalletClient<Transport, Chain | undefined, Account>
444
485
  | LocalAccount
445
486
  | WebAuthnAccount
446
- >
487
+ >,
488
+ eip7702 extends boolean = false
447
489
  >(
448
490
  parameters: ToKernelSmartAccountParameters<
449
491
  entryPointVersion,
450
492
  kernelVersion,
451
- owner
493
+ owner,
494
+ eip7702
452
495
  >
453
- ): Promise<ToKernelSmartAccountReturnType<entryPointVersion>> {
496
+ ): Promise<ToKernelSmartAccountReturnType<entryPointVersion, eip7702>> {
454
497
  const {
455
498
  client,
456
499
  address,
457
500
  index = 0n,
458
- owners,
459
501
  version,
460
502
  validatorAddress: _validatorAddress,
461
503
  factoryAddress: _factoryAddress,
462
504
  metaFactoryAddress: _metaFactoryAddress,
463
505
  accountLogicAddress: _accountLogicAddress,
464
- useMetaFactory = true
506
+ useMetaFactory = true,
507
+ eip7702 = false
465
508
  } = parameters
466
509
 
510
+ const owners = (() => {
511
+ if (eip7702 && "owner" in parameters) {
512
+ return [parameters.owner]
513
+ }
514
+
515
+ if ("owners" in parameters) {
516
+ return parameters.owners
517
+ }
518
+
519
+ throw new Error("Invalid parameters")
520
+ })()
521
+
467
522
  const isWebAuthn = owners[0].type === "webAuthn"
468
523
 
469
- const owner = isWebAuthn
470
- ? (owners[0] as WebAuthnAccount)
471
- : await toOwner({
472
- owner: owners[0] as OneOf<
473
- | EthereumProvider
474
- | WalletClient<Transport, Chain | undefined, Account>
475
- | LocalAccount
476
- >
477
- })
478
-
479
- const entryPoint = {
480
- address: parameters.entryPoint?.address ?? entryPoint07Address,
481
- abi:
482
- (parameters.entryPoint?.version ?? "0.7") === "0.6"
483
- ? entryPoint06Abi
484
- : entryPoint07Abi,
485
- version: parameters.entryPoint?.version ?? "0.7"
486
- } as const
487
-
488
- const kernelVersion = getDefaultKernelVersion(entryPoint.version, version)
524
+ const owner = await (() => {
525
+ if (isWebAuthn) {
526
+ return owners[0] as WebAuthnAccount
527
+ }
528
+ return toOwner({
529
+ owner: owners[0] as OneOf<
530
+ | EthereumProvider
531
+ | WalletClient<Transport, Chain | undefined, Account>
532
+ | LocalAccount
533
+ >
534
+ })
535
+ })()
536
+
537
+ const entryPoint = (() => {
538
+ const address = parameters.entryPoint?.address ?? entryPoint07Address
539
+ const version = parameters.entryPoint?.version ?? "0.7"
540
+
541
+ let abi: typeof entryPoint06Abi | typeof entryPoint07Abi =
542
+ entryPoint07Abi
543
+
544
+ if (version === "0.6") {
545
+ abi = entryPoint06Abi
546
+ }
547
+
548
+ return {
549
+ address,
550
+ abi,
551
+ version
552
+ } as const
553
+ })()
554
+
555
+ const kernelVersion = getDefaultKernelVersion(
556
+ entryPoint.version,
557
+ version,
558
+ eip7702
559
+ )
489
560
 
490
561
  const {
491
562
  accountLogicAddress,
@@ -539,6 +610,18 @@ export async function toKernelSmartAccount<
539
610
  }
540
611
 
541
612
  const { accountAddress, getFactoryArgs } = await (async () => {
613
+ if (eip7702) {
614
+ return {
615
+ accountAddress: (owner as LocalAccount).address,
616
+ getFactoryArgs: async () => {
617
+ return {
618
+ factory: undefined,
619
+ factoryData: undefined
620
+ }
621
+ }
622
+ }
623
+ }
624
+
542
625
  let getFactoryArgs = getFactoryArgsFunc(
543
626
  useMetaFactory === "optional" ? true : useMetaFactory
544
627
  )
@@ -577,6 +660,17 @@ export async function toKernelSmartAccount<
577
660
  client,
578
661
  entryPoint,
579
662
  getFactoryArgs,
663
+ extend: eip7702
664
+ ? {
665
+ implementation: accountLogicAddress
666
+ }
667
+ : undefined,
668
+ authorization: eip7702
669
+ ? {
670
+ address: accountLogicAddress,
671
+ account: owner as PrivateKeyAccount
672
+ }
673
+ : undefined,
580
674
  async getAddress() {
581
675
  return accountAddress
582
676
  },
@@ -633,9 +727,7 @@ export async function toKernelSmartAccount<
633
727
  owner,
634
728
  message,
635
729
  accountAddress: await this.getAddress(),
636
- kernelVersion:
637
- // TODO: remove this once 0.3.3 is released
638
- kernelVersion === "0.3.3" ? "0.3.2" : kernelVersion,
730
+ kernelVersion: kernelVersion,
639
731
  chainId: await getMemoizedChainId()
640
732
  })
641
733
 
@@ -654,9 +746,7 @@ export async function toKernelSmartAccount<
654
746
  chainId: await getMemoizedChainId(),
655
747
  ...(typedData as TypedDataDefinition),
656
748
  accountAddress: await this.getAddress(),
657
- kernelVersion:
658
- // TODO: remove this once 0.3.3 is released
659
- kernelVersion === "0.3.3" ? "0.3.2" : kernelVersion
749
+ kernelVersion: kernelVersion
660
750
  })
661
751
 
662
752
  if (isKernelV2(kernelVersion)) {
@@ -683,6 +773,7 @@ export async function toKernelSmartAccount<
683
773
  entryPointVersion: entryPoint.version,
684
774
  chainId: chainId
685
775
  })
776
+
686
777
  const signature = isWebAuthnAccount(owner)
687
778
  ? await signMessage({
688
779
  owner,
@@ -701,5 +792,5 @@ export async function toKernelSmartAccount<
701
792
  }
702
793
  return signature
703
794
  }
704
- }) as Promise<ToKernelSmartAccountReturnType<entryPointVersion>>
795
+ }) as Promise<ToKernelSmartAccountReturnType<entryPointVersion, eip7702>>
705
796
  }
@@ -0,0 +1,51 @@
1
+ import type {
2
+ Account,
3
+ Chain,
4
+ LocalAccount,
5
+ OneOf,
6
+ Prettify,
7
+ Transport,
8
+ WalletClient
9
+ } from "viem"
10
+ import type { EthereumProvider } from "../../utils/toOwner.js"
11
+ import {
12
+ type SimpleSmartAccountImplementation,
13
+ type ToSimpleSmartAccountParameters,
14
+ type ToSimpleSmartAccountReturnType,
15
+ toSimpleSmartAccount
16
+ } from "./toSimpleSmartAccount.js"
17
+
18
+ export type To7702SimpleSmartAccountParameters<
19
+ entryPointVersion extends "0.8",
20
+ owner extends OneOf<
21
+ | EthereumProvider
22
+ | WalletClient<Transport, Chain | undefined, Account>
23
+ | LocalAccount
24
+ >
25
+ > = ToSimpleSmartAccountParameters<entryPointVersion, owner, true>
26
+
27
+ export type To7702SimpleSmartAccountImplementation<
28
+ entryPointVersion extends "0.8" = "0.8"
29
+ > = SimpleSmartAccountImplementation<entryPointVersion, true>
30
+
31
+ export type To7702SimpleSmartAccountReturnType<
32
+ entryPointVersion extends "0.8" = "0.8"
33
+ > = ToSimpleSmartAccountReturnType<entryPointVersion, true>
34
+
35
+ export async function to7702SimpleSmartAccount<
36
+ entryPointVersion extends "0.8",
37
+ owner extends OneOf<
38
+ | EthereumProvider
39
+ | WalletClient<Transport, Chain | undefined, Account>
40
+ | LocalAccount
41
+ >
42
+ >(
43
+ parameters: Prettify<
44
+ To7702SimpleSmartAccountParameters<entryPointVersion, owner>
45
+ >
46
+ ): Promise<To7702SimpleSmartAccountReturnType<entryPointVersion>> {
47
+ return toSimpleSmartAccount<entryPointVersion, owner, true>({
48
+ ...parameters,
49
+ eip7702: true
50
+ })
51
+ }