permissionless 0.0.12 → 0.0.13

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 (141) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/_cjs/accounts/index.js +9 -2
  3. package/_cjs/accounts/index.js.map +1 -1
  4. package/_cjs/accounts/privateKeyToSafeSmartAccount.js +24 -0
  5. package/_cjs/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
  6. package/_cjs/accounts/privateKeyToSimpleSmartAccount.js +8 -160
  7. package/_cjs/accounts/privateKeyToSimpleSmartAccount.js.map +1 -1
  8. package/_cjs/accounts/signerToSafeSmartAccount.js +492 -0
  9. package/_cjs/accounts/signerToSafeSmartAccount.js.map +1 -0
  10. package/_cjs/accounts/signerToSimpleSmartAccount.js +190 -0
  11. package/_cjs/accounts/signerToSimpleSmartAccount.js.map +1 -0
  12. package/_cjs/accounts/types.js +20 -0
  13. package/_cjs/accounts/types.js.map +1 -1
  14. package/_cjs/actions/bundler/chainId.js.map +1 -1
  15. package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
  16. package/_cjs/actions/bundler/getUserOperationByHash.js.map +1 -1
  17. package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -1
  18. package/_cjs/actions/bundler/sendUserOperation.js.map +1 -1
  19. package/_cjs/actions/bundler/supportedEntryPoints.js.map +1 -1
  20. package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
  21. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +3 -1
  22. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
  23. package/_cjs/actions/smartAccount/sendTransaction.js +3 -2
  24. package/_cjs/actions/smartAccount/sendTransaction.js.map +1 -1
  25. package/_cjs/actions/smartAccount/sendTransactions.js +46 -0
  26. package/_cjs/actions/smartAccount/sendTransactions.js.map +1 -0
  27. package/_cjs/actions/smartAccount.js +3 -1
  28. package/_cjs/actions/smartAccount.js.map +1 -1
  29. package/_cjs/clients/decorators/smartAccount.js +5 -0
  30. package/_cjs/clients/decorators/smartAccount.js.map +1 -1
  31. package/_esm/accounts/index.js +6 -3
  32. package/_esm/accounts/index.js.map +1 -1
  33. package/_esm/accounts/privateKeyToSafeSmartAccount.js +26 -0
  34. package/_esm/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
  35. package/_esm/accounts/privateKeyToSimpleSmartAccount.js +9 -160
  36. package/_esm/accounts/privateKeyToSimpleSmartAccount.js.map +1 -1
  37. package/_esm/accounts/signerToSafeSmartAccount.js +499 -0
  38. package/_esm/accounts/signerToSafeSmartAccount.js.map +1 -0
  39. package/_esm/accounts/signerToSimpleSmartAccount.js +191 -0
  40. package/_esm/accounts/signerToSimpleSmartAccount.js.map +1 -0
  41. package/_esm/accounts/types.js +18 -0
  42. package/_esm/accounts/types.js.map +1 -1
  43. package/_esm/actions/bundler/chainId.js.map +1 -1
  44. package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
  45. package/_esm/actions/bundler/getUserOperationByHash.js.map +1 -1
  46. package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
  47. package/_esm/actions/bundler/sendUserOperation.js.map +1 -1
  48. package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -1
  49. package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
  50. package/_esm/actions/pimlico/getUserOperationGasPrice.js +1 -1
  51. package/_esm/actions/pimlico/getUserOperationStatus.js +1 -1
  52. package/_esm/actions/smartAccount/prepareUserOperationRequest.js +3 -1
  53. package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
  54. package/_esm/actions/smartAccount/sendTransaction.js +3 -2
  55. package/_esm/actions/smartAccount/sendTransaction.js.map +1 -1
  56. package/_esm/actions/smartAccount/sendTransactions.js +90 -0
  57. package/_esm/actions/smartAccount/sendTransactions.js.map +1 -0
  58. package/_esm/actions/smartAccount.js +2 -1
  59. package/_esm/actions/smartAccount.js.map +1 -1
  60. package/_esm/actions/stackup/accounts.js +1 -1
  61. package/_esm/actions/stackup/sponsorUserOperation.js +1 -1
  62. package/_esm/clients/decorators/pimlico.js +1 -1
  63. package/_esm/clients/decorators/smartAccount.js +5 -0
  64. package/_esm/clients/decorators/smartAccount.js.map +1 -1
  65. package/_esm/clients/pimlico.js +1 -1
  66. package/_esm/clients/stackup.js +1 -1
  67. package/_types/accounts/index.d.ts +6 -3
  68. package/_types/accounts/index.d.ts.map +1 -1
  69. package/_types/accounts/privateKeyToSafeSmartAccount.d.ts +26 -0
  70. package/_types/accounts/privateKeyToSafeSmartAccount.d.ts.map +1 -0
  71. package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts +5 -11
  72. package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts.map +1 -1
  73. package/_types/accounts/signerToSafeSmartAccount.d.ts +28 -0
  74. package/_types/accounts/signerToSafeSmartAccount.d.ts.map +1 -0
  75. package/_types/accounts/signerToSimpleSmartAccount.d.ts +15 -0
  76. package/_types/accounts/signerToSimpleSmartAccount.d.ts.map +1 -0
  77. package/_types/accounts/types.d.ts +14 -3
  78. package/_types/accounts/types.d.ts.map +1 -1
  79. package/_types/actions/bundler/chainId.d.ts +3 -2
  80. package/_types/actions/bundler/chainId.d.ts.map +1 -1
  81. package/_types/actions/bundler/estimateUserOperationGas.d.ts +3 -3
  82. package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
  83. package/_types/actions/bundler/getUserOperationByHash.d.ts +3 -3
  84. package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
  85. package/_types/actions/bundler/getUserOperationReceipt.d.ts +3 -3
  86. package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
  87. package/_types/actions/bundler/sendUserOperation.d.ts +3 -3
  88. package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
  89. package/_types/actions/bundler/supportedEntryPoints.d.ts +3 -3
  90. package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -1
  91. package/_types/actions/bundler/waitForUserOperationReceipt.d.ts +2 -3
  92. package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -1
  93. package/_types/actions/pimlico/getUserOperationGasPrice.d.ts +1 -1
  94. package/_types/actions/pimlico/getUserOperationStatus.d.ts +1 -1
  95. package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -1
  96. package/_types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
  97. package/_types/actions/smartAccount/sendTransactions.d.ts +63 -0
  98. package/_types/actions/smartAccount/sendTransactions.d.ts.map +1 -0
  99. package/_types/actions/smartAccount.d.ts +2 -1
  100. package/_types/actions/smartAccount.d.ts.map +1 -1
  101. package/_types/actions/stackup/accounts.d.ts +1 -1
  102. package/_types/actions/stackup/sponsorUserOperation.d.ts +1 -1
  103. package/_types/clients/createSmartAccountClient.d.ts +1 -0
  104. package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
  105. package/_types/clients/decorators/bundler.d.ts +1 -1
  106. package/_types/clients/decorators/pimlico.d.ts +3 -3
  107. package/_types/clients/decorators/smartAccount.d.ts +51 -0
  108. package/_types/clients/decorators/smartAccount.d.ts.map +1 -1
  109. package/_types/clients/pimlico.d.ts +1 -1
  110. package/_types/clients/stackup.d.ts +1 -1
  111. package/_types/types/index.d.ts +1 -0
  112. package/_types/types/index.d.ts.map +1 -1
  113. package/accounts/index.ts +26 -7
  114. package/accounts/privateKeyToSafeSmartAccount.ts +73 -0
  115. package/accounts/privateKeyToSimpleSmartAccount.ts +15 -191
  116. package/accounts/signerToSafeSmartAccount.ts +775 -0
  117. package/accounts/signerToSimpleSmartAccount.ts +267 -0
  118. package/accounts/types.ts +43 -12
  119. package/actions/bundler/chainId.ts +9 -1
  120. package/actions/bundler/estimateUserOperationGas.ts +8 -3
  121. package/actions/bundler/getUserOperationByHash.ts +8 -3
  122. package/actions/bundler/getUserOperationReceipt.ts +16 -3
  123. package/actions/bundler/sendUserOperation.ts +8 -3
  124. package/actions/bundler/supportedEntryPoints.ts +8 -3
  125. package/actions/bundler/waitForUserOperationReceipt.ts +15 -4
  126. package/actions/pimlico/getUserOperationGasPrice.ts +1 -1
  127. package/actions/pimlico/getUserOperationStatus.ts +1 -1
  128. package/actions/smartAccount/prepareUserOperationRequest.ts +3 -1
  129. package/actions/smartAccount/sendTransaction.ts +3 -1
  130. package/actions/smartAccount/sendTransactions.ts +141 -0
  131. package/actions/smartAccount.ts +8 -1
  132. package/actions/stackup/accounts.ts +1 -1
  133. package/actions/stackup/sponsorUserOperation.ts +1 -1
  134. package/clients/decorators/bundler.ts +1 -1
  135. package/clients/decorators/pimlico.ts +3 -3
  136. package/clients/decorators/smartAccount.ts +61 -0
  137. package/clients/pimlico.ts +1 -1
  138. package/clients/stackup.ts +1 -1
  139. package/package.json +2 -2
  140. package/types/index.ts +5 -0
  141. package/tsconfig.build.tsbuildinfo +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccount.d.ts","sourceRoot":"","sources":["../../../clients/decorators/smartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,GAAG,EACH,KAAK,EACL,MAAM,EACN,wBAAwB,EACxB,yBAAyB,EACzB,SAAS,EACT,SAAS,EACT,uBAAuB,EAC1B,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAEH,cAAc,EACjB,MAAM,8CAA8C,CAAA;AACrD,OAAO,EACH,KAAK,qCAAqC,EAC1C,KAAK,8BAA8B,EACnC,2BAA2B,EAC9B,MAAM,2DAA2D,CAAA;AAClE,OAAO,EAEH,eAAe,EAClB,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAA;AAC3E,OAAO,EAEH,aAAa,EAChB,MAAM,6CAA6C,CAAA;AAEpD,MAAM,MAAM,mBAAmB,CAC3B,MAAM,SAAS,KAAK,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AK,GAAG,SAAS,GAAG,SAAS,EAEpD,IAAI,EAAE,wBAAwB,CAC1B,IAAI,EACJ,MAAM,EACN,aAAa,EACb,cAAc,CACjB,KACA,UAAU,CACX,OAAO,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,CAAC,CACrE,CAAA;IACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;IACH,aAAa,EAAE,CACX,KAAK,CAAC,IAAI,SAAS,GAAG,GAAG,SAAS,OAAO,EAAE,EAC3C,aAAa,SAAS,MAAM,EAC5B,cAAc,SAAS,KAAK,GAAG,SAAS,GAAG,SAAS,EAEpD,IAAI,EAAE,uBAAuB,CACzB,IAAI,EACJ,aAAa,EACb,MAAM,EACN,aAAa,EACb,cAAc,CACjB,KACA,UAAU,CACX,OAAO,aAAa,CAChB,MAAM,EACN,aAAa,EACb,IAAI,EACJ,aAAa,EACb,cAAc,CACjB,CACJ,CAAA;IACD,2BAA2B,EAAE,CAAC,UAAU,SAAS,SAAS,EACtD,IAAI,EAAE,UAAU,CACZ,OAAO,2BAA2B,CAC9B,UAAU,EACV,MAAM,EACN,aAAa,CAChB,CACJ,CAAC,CAAC,CAAC,KACH,OAAO,CAAC,qCAAqC,CAAC,CAAA;CACtD,CAAA;AAED,eAAO,MAAM,mBAAmB,6BACD,8BAA8B,qQA6BvD,CAAA"}
1
+ {"version":3,"file":"smartAccount.d.ts","sourceRoot":"","sources":["../../../clients/decorators/smartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,GAAG,EACH,KAAK,EACL,MAAM,EACN,wBAAwB,EACxB,yBAAyB,EACzB,SAAS,EACT,SAAS,EACT,uBAAuB,EAC1B,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EACH,KAAK,uCAAuC,EAC5C,gBAAgB,EACnB,MAAM,+BAA+B,CAAA;AACtC,O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;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACH,gBAAgB,EAAE,CACd,IAAI,EAAE,uCAAuC,CAAC,aAAa,CAAC,KAC3D,UAAU,CAAC,OAAO,gBAAgB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAA;CAClE,CAAA;AAED,eAAO,MAAM,mBAAmB,6BACD,8BAA8B,qQAkCvD,CAAA"}
@@ -20,7 +20,7 @@ export type PimlicoPaymasterClient = Client<Transport, Chain | undefined, Accoun
20
20
  *
21
21
  * const pimlicoBundlerClient = createPimlicoBundlerClient({
22
22
  * chain: mainnet,
23
- * transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE"),
23
+ * transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE"),
24
24
  * })
25
25
  */
26
26
  export declare const createPimlicoBundlerClient: <transport extends Transport, chain extends Chain | undefined = undefined>(parameters: {
@@ -19,7 +19,7 @@ export type StackupPaymasterClient = Client<Transport, Chain | undefined, Accoun
19
19
  *
20
20
  * const stackupPaymasterClient = createStackupPaymasterClient({
21
21
  * chain: mainnet,
22
- * transport: http("https://api.stackup.sh/v1/paymaster/YOUR_API_KEY_HERE"),
22
+ * transport: http("https://api.stackup.sh/v2/paymaster/YOUR_API_KEY_HERE"),
23
23
  * })
24
24
  */
25
25
  export declare const createStackupPaymasterClient: <transport extends Transport, chain extends Chain | undefined = undefined>(parameters: {
@@ -19,4 +19,5 @@ export type Prettify<T> = {
19
19
  [K in keyof T]: T[K];
20
20
  } & {};
21
21
  export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
22
+ export type UnionOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
22
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAA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,CAAC,CAAC,IAAI;KACrB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACvB,GAAG,EAAE,CAAA;AAEN,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAG9E,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,CAAC,SAAS,GAAG,GACvD,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACV,KAAK,CAAA"}
package/accounts/index.ts CHANGED
@@ -1,14 +1,33 @@
1
+ import { privateKeyToSimpleSmartAccount } from "./privateKeyToSimpleSmartAccount.js"
2
+
1
3
  import {
2
- type PrivateKeySimpleSmartAccount,
3
- SignTransactionNotSupportedBySmartAccount,
4
- privateKeyToSimpleSmartAccount
5
- } from "./privateKeyToSimpleSmartAccount.js"
4
+ type SimpleSmartAccount,
5
+ signerToSimpleSmartAccount
6
+ } from "./signerToSimpleSmartAccount.js"
6
7
 
7
- import { type SmartAccount } from "./types.js"
8
+ import { privateKeyToSafeSmartAccount } from "./privateKeyToSafeSmartAccount.js"
9
+
10
+ import {
11
+ type SafeSmartAccount,
12
+ type SafeVersion,
13
+ signerToSafeSmartAccount
14
+ } from "./signerToSafeSmartAccount.js"
15
+
16
+ import {
17
+ SignTransactionNotSupportedBySmartAccount,
18
+ type SmartAccount,
19
+ type SmartAccountSigner
20
+ } from "./types.js"
8
21
 
9
22
  export {
23
+ type SafeVersion,
24
+ type SmartAccountSigner,
25
+ type SafeSmartAccount,
26
+ signerToSafeSmartAccount,
27
+ type SimpleSmartAccount,
28
+ signerToSimpleSmartAccount,
10
29
  SignTransactionNotSupportedBySmartAccount,
11
- type PrivateKeySimpleSmartAccount,
12
30
  privateKeyToSimpleSmartAccount,
13
- type SmartAccount
31
+ type SmartAccount,
32
+ privateKeyToSafeSmartAccount
14
33
  }
@@ -0,0 +1,73 @@
1
+ import {
2
+ type Address,
3
+ type Chain,
4
+ type Client,
5
+ type Hex,
6
+ type Transport
7
+ } from "viem"
8
+ import { privateKeyToAccount } from "viem/accounts"
9
+ import {
10
+ type SafeSmartAccount,
11
+ type SafeVersion,
12
+ signerToSafeSmartAccount
13
+ } from "./signerToSafeSmartAccount.js"
14
+
15
+ /**
16
+ * @description Creates an Simple Account from a private key.
17
+ *
18
+ * @returns A Private Key Simple Account.
19
+ */
20
+ export async function privateKeyToSafeSmartAccount<
21
+ TTransport extends Transport = Transport,
22
+ TChain extends Chain | undefined = Chain | undefined
23
+ >(
24
+ client: Client<TTransport, TChain>,
25
+ {
26
+ privateKey,
27
+ safeVersion,
28
+ entryPoint,
29
+ addModuleLibAddress: _addModuleLibAddress,
30
+ safe4337ModuleAddress: _safe4337ModuleAddress,
31
+ safeProxyFactoryAddress: _safeProxyFactoryAddress,
32
+ safeSingletonAddress: _safeSingletonAddress,
33
+ multiSendAddress: _multiSendAddress,
34
+ multiSendCallOnlyAddress: _multiSendCallOnlyAddress,
35
+ saltNonce = 0n,
36
+ safeModules = [],
37
+ setupTransactions = []
38
+ }: {
39
+ safeVersion: SafeVersion
40
+ privateKey: Hex
41
+ entryPoint: Address
42
+ addModuleLibAddress?: Address
43
+ safe4337ModuleAddress?: Address
44
+ safeProxyFactoryAddress?: Address
45
+ safeSingletonAddress?: Address
46
+ multiSendAddress?: Address
47
+ multiSendCallOnlyAddress?: Address
48
+ saltNonce?: bigint
49
+ setupTransactions?: {
50
+ to: Address
51
+ data: Address
52
+ value: bigint
53
+ }[]
54
+ safeModules?: Address[]
55
+ }
56
+ ): Promise<SafeSmartAccount<TTransport, TChain>> {
57
+ const privateKeyAccount = privateKeyToAccount(privateKey)
58
+
59
+ return signerToSafeSmartAccount(client, {
60
+ signer: privateKeyAccount,
61
+ safeVersion,
62
+ entryPoint,
63
+ addModuleLibAddress: _addModuleLibAddress,
64
+ safe4337ModuleAddress: _safe4337ModuleAddress,
65
+ safeProxyFactoryAddress: _safeProxyFactoryAddress,
66
+ safeSingletonAddress: _safeSingletonAddress,
67
+ multiSendAddress: _multiSendAddress,
68
+ multiSendCallOnlyAddress: _multiSendCallOnlyAddress,
69
+ saltNonce,
70
+ safeModules,
71
+ setupTransactions
72
+ })
73
+ }
@@ -1,104 +1,15 @@
1
1
  import {
2
2
  type Address,
3
- BaseError,
4
3
  type Chain,
5
4
  type Client,
6
5
  type Hex,
7
- type Transport,
8
- concatHex,
9
- encodeFunctionData
6
+ type Transport
10
7
  } from "viem"
11
- import { privateKeyToAccount, toAccount } from "viem/accounts"
12
- import { getBytecode, getChainId } from "viem/actions"
13
- import { getAccountNonce } from "../actions/public/getAccountNonce.js"
14
- import { getSenderAddress } from "../actions/public/getSenderAddress.js"
15
- import { getUserOperationHash } from "../utils/getUserOperationHash.js"
16
- import { type SmartAccount } from "./types.js"
17
-
18
- export class SignTransactionNotSupportedBySmartAccount extends BaseError {
19
- override name = "SignTransactionNotSupportedBySmartAccount"
20
- constructor({ docsPath }: { docsPath?: string } = {}) {
21
- super(
22
- [
23
- "A smart account cannot sign or send transaction, it can only sign message or userOperation.",
24
- "Please send user operation instead."
25
- ].join("\n"),
26
- {
27
- docsPath,
28
- docsSlug: "account"
29
- }
30
- )
31
- }
32
- }
33
-
34
- export type PrivateKeySimpleSmartAccount<
35
- transport extends Transport = Transport,
36
- chain extends Chain | undefined = Chain | undefined
37
- > = SmartAccount<"privateKeySimpleSmartAccount", transport, chain>
38
-
39
- const getAccountInitCode = async (
40
- factoryAddress: Address,
41
- owner: Address,
42
- index = 0n
43
- ): Promise<Hex> => {
44
- if (!owner) throw new Error("Owner account not found")
45
-
46
- return concatHex([
47
- factoryAddress,
48
- encodeFunctionData({
49
- abi: [
50
- {
51
- inputs: [
52
- {
53
- internalType: "address",
54
- name: "owner",
55
- type: "address"
56
- },
57
- {
58
- internalType: "uint256",
59
- name: "salt",
60
- type: "uint256"
61
- }
62
- ],
63
- name: "createAccount",
64
- outputs: [
65
- {
66
- internalType: "contract SimpleAccount",
67
- name: "ret",
68
- type: "address"
69
- }
70
- ],
71
- stateMutability: "nonpayable",
72
- type: "function"
73
- }
74
- ],
75
- functionName: "createAccount",
76
- args: [owner, index]
77
- }) as Hex
78
- ])
79
- }
80
-
81
- const getAccountAddress = async <
82
- TTransport extends Transport = Transport,
83
- TChain extends Chain | undefined = Chain | undefined
84
- >({
85
- client,
86
- factoryAddress,
87
- entryPoint,
88
- owner
89
- }: {
90
- client: Client<TTransport, TChain>
91
- factoryAddress: Address
92
- owner: Address
93
- entryPoint: Address
94
- }): Promise<Address> => {
95
- const initCode = await getAccountInitCode(factoryAddress, owner)
96
-
97
- return getSenderAddress(client, {
98
- initCode,
99
- entryPoint
100
- })
101
- }
8
+ import { privateKeyToAccount } from "viem/accounts"
9
+ import {
10
+ type SimpleSmartAccount,
11
+ signerToSimpleSmartAccount
12
+ } from "./signerToSimpleSmartAccount.js"
102
13
 
103
14
  /**
104
15
  * @description Creates an Simple Account from a private key.
@@ -113,108 +24,21 @@ export async function privateKeyToSimpleSmartAccount<
113
24
  {
114
25
  privateKey,
115
26
  factoryAddress,
116
- entryPoint
27
+ entryPoint,
28
+ index = 0n
117
29
  }: {
118
30
  privateKey: Hex
119
31
  factoryAddress: Address
120
32
  entryPoint: Address
33
+ index?: bigint
121
34
  }
122
- ): Promise<PrivateKeySimpleSmartAccount<TTransport, TChain>> {
35
+ ): Promise<SimpleSmartAccount<TTransport, TChain>> {
123
36
  const privateKeyAccount = privateKeyToAccount(privateKey)
124
37
 
125
- const [accountAddress, chainId] = await Promise.all([
126
- getAccountAddress<TTransport, TChain>({
127
- client,
128
- factoryAddress,
129
- entryPoint,
130
- owner: privateKeyAccount.address
131
- }),
132
- getChainId(client)
133
- ])
134
-
135
- if (!accountAddress) throw new Error("Account address not found")
136
-
137
- const account = toAccount({
138
- address: accountAddress,
139
- async signMessage({ message }) {
140
- return privateKeyAccount.signMessage({ message })
141
- },
142
- async signTransaction(_, __) {
143
- throw new SignTransactionNotSupportedBySmartAccount()
144
- },
145
- async signTypedData(typedData) {
146
- return privateKeyAccount.signTypedData({ ...typedData, privateKey })
147
- }
38
+ return signerToSimpleSmartAccount(client, {
39
+ signer: privateKeyAccount,
40
+ factoryAddress,
41
+ entryPoint,
42
+ index
148
43
  })
149
-
150
- return {
151
- ...account,
152
- client: client,
153
- publicKey: accountAddress,
154
- entryPoint: entryPoint,
155
- source: "privateKeySimpleSmartAccount",
156
- async getNonce() {
157
- return getAccountNonce(client, {
158
- sender: accountAddress,
159
- entryPoint: entryPoint
160
- })
161
- },
162
- async signUserOperation(userOperation) {
163
- return account.signMessage({
164
- message: {
165
- raw: getUserOperationHash({
166
- userOperation,
167
- entryPoint: entryPoint,
168
- chainId: chainId
169
- })
170
- }
171
- })
172
- },
173
- async getInitCode() {
174
- const contractCode = await getBytecode(client, {
175
- address: accountAddress
176
- })
177
-
178
- if ((contractCode?.length ?? 0) > 2) return "0x"
179
-
180
- return getAccountInitCode(factoryAddress, privateKeyAccount.address)
181
- },
182
- async encodeDeployCallData(_) {
183
- throw new Error("Simple account doesn't support account deployment")
184
- },
185
- async encodeCallData({ to, value, data }) {
186
- return encodeFunctionData({
187
- abi: [
188
- {
189
- inputs: [
190
- {
191
- internalType: "address",
192
- name: "dest",
193
- type: "address"
194
- },
195
- {
196
- internalType: "uint256",
197
- name: "value",
198
- type: "uint256"
199
- },
200
- {
201
- internalType: "bytes",
202
- name: "func",
203
- type: "bytes"
204
- }
205
- ],
206
- name: "execute",
207
- outputs: [],
208
- stateMutability: "nonpayable",
209
- type: "function"
210
- }
211
- ],
212
- functionName: "execute",
213
- args: [to, value, data]
214
- })
215
- },
216
- async getDummySignature() {
217
- return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
218
- }
219
- }
220
44
  }