@account-kit/wallet-client 0.1.0-alpha.1 → 0.1.0-alpha.3

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 (188) hide show
  1. package/dist/esm/capabilities/index.d.ts +5 -2
  2. package/dist/esm/capabilities/index.js +1 -1
  3. package/dist/esm/capabilities/index.js.map +1 -1
  4. package/dist/esm/capabilities/overrides.js +8 -8
  5. package/dist/esm/capabilities/overrides.js.map +1 -1
  6. package/dist/esm/capabilities/permissions/index.d.ts +10 -3
  7. package/dist/esm/capabilities/permissions/index.js +11 -2
  8. package/dist/esm/capabilities/permissions/index.js.map +1 -1
  9. package/dist/esm/capabilities/permissions/mav2.d.ts +3 -3
  10. package/dist/esm/capabilities/permissions/mav2.js +9 -1
  11. package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
  12. package/dist/esm/client/actions/createAccount.d.ts +27 -2
  13. package/dist/esm/client/actions/createAccount.js +25 -0
  14. package/dist/esm/client/actions/createAccount.js.map +1 -1
  15. package/dist/esm/client/actions/getCallsStatus.d.ts +21 -2
  16. package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
  17. package/dist/esm/client/actions/grantPermissions.d.ts +114 -2
  18. package/dist/esm/client/actions/grantPermissions.js +1 -0
  19. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  20. package/dist/esm/client/actions/listAccounts.d.ts +26 -2
  21. package/dist/esm/client/actions/listAccounts.js +24 -0
  22. package/dist/esm/client/actions/listAccounts.js.map +1 -1
  23. package/dist/esm/client/actions/prepareCalls.d.ts +28 -2
  24. package/dist/esm/client/actions/prepareCalls.js.map +1 -1
  25. package/dist/esm/client/actions/requestAccount.d.ts +21 -2
  26. package/dist/esm/client/actions/requestAccount.js +15 -4
  27. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  28. package/dist/esm/client/actions/sendPreparedCalls.d.ts +39 -2
  29. package/dist/esm/client/actions/sendPreparedCalls.js +37 -0
  30. package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
  31. package/dist/esm/client/actions/signMessage.d.ts +22 -2
  32. package/dist/esm/client/actions/signMessage.js +4 -2
  33. package/dist/esm/client/actions/signMessage.js.map +1 -1
  34. package/dist/esm/client/actions/signSignatureRequest.d.ts +34 -0
  35. package/dist/esm/client/actions/signSignatureRequest.js +22 -1
  36. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  37. package/dist/esm/client/actions/signTypedData.d.ts +35 -2
  38. package/dist/esm/client/actions/signTypedData.js +3 -1
  39. package/dist/esm/client/actions/signTypedData.js.map +1 -1
  40. package/dist/esm/client/client.e2e-test.js +112 -30
  41. package/dist/esm/client/client.e2e-test.js.map +1 -1
  42. package/dist/esm/client/decorator.d.ts +7 -5
  43. package/dist/esm/client/decorator.js +1 -1
  44. package/dist/esm/client/decorator.js.map +1 -1
  45. package/dist/esm/client/index.d.ts +4 -4
  46. package/dist/esm/client/index.js +29 -3
  47. package/dist/esm/client/index.js.map +1 -1
  48. package/dist/esm/exports/index.d.ts +1 -0
  49. package/dist/esm/exports/index.js +1 -0
  50. package/dist/esm/exports/index.js.map +1 -1
  51. package/dist/esm/exports/internal.d.ts +1 -1
  52. package/dist/esm/exports/internal.js.map +1 -1
  53. package/dist/esm/internal/decorator.d.ts +2 -0
  54. package/dist/esm/internal/decorator.js +10 -0
  55. package/dist/esm/internal/decorator.js.map +1 -0
  56. package/dist/esm/isomorphic/actions/createSession.js +25 -7
  57. package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
  58. package/dist/esm/isomorphic/actions/prepareCalls.js +35 -12
  59. package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
  60. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +26 -6
  61. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
  62. package/dist/esm/isomorphic/client.d.ts +11 -5
  63. package/dist/esm/isomorphic/utils/7702.d.ts +11 -0
  64. package/dist/esm/isomorphic/utils/7702.js +26 -0
  65. package/dist/esm/isomorphic/utils/7702.js.map +1 -0
  66. package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -1
  67. package/dist/esm/isomorphic/utils/createAccount.js +30 -5
  68. package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
  69. package/dist/esm/isomorphic/utils/createDummySigner.js +3 -3
  70. package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -1
  71. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +2 -1
  72. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +17 -5
  73. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
  74. package/dist/esm/local/client.d.ts +1 -1
  75. package/dist/esm/local/client.js +10 -2
  76. package/dist/esm/local/client.js.map +1 -1
  77. package/dist/esm/remote/client.d.ts +1 -1
  78. package/dist/esm/remote/client.js +12 -3
  79. package/dist/esm/remote/client.js.map +1 -1
  80. package/dist/esm/rpc/examples.d.ts +230 -0
  81. package/dist/esm/rpc/examples.js +314 -0
  82. package/dist/esm/rpc/examples.js.map +1 -0
  83. package/dist/esm/rpc/request.d.ts +48 -17
  84. package/dist/esm/rpc/request.js +53 -14
  85. package/dist/esm/rpc/request.js.map +1 -1
  86. package/dist/esm/rpc/schema.d.ts +43 -12
  87. package/dist/esm/schemas.d.ts +29 -7
  88. package/dist/esm/schemas.js +120 -38
  89. package/dist/esm/schemas.js.map +1 -1
  90. package/dist/esm/types.d.ts +15 -4
  91. package/dist/esm/types.js.map +1 -1
  92. package/dist/types/capabilities/index.d.ts +5 -2
  93. package/dist/types/capabilities/index.d.ts.map +1 -1
  94. package/dist/types/capabilities/overrides.d.ts.map +1 -1
  95. package/dist/types/capabilities/permissions/index.d.ts +10 -3
  96. package/dist/types/capabilities/permissions/index.d.ts.map +1 -1
  97. package/dist/types/capabilities/permissions/mav2.d.ts +3 -3
  98. package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -1
  99. package/dist/types/client/actions/createAccount.d.ts +27 -2
  100. package/dist/types/client/actions/createAccount.d.ts.map +1 -1
  101. package/dist/types/client/actions/getCallsStatus.d.ts +21 -2
  102. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  103. package/dist/types/client/actions/grantPermissions.d.ts +114 -2
  104. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  105. package/dist/types/client/actions/listAccounts.d.ts +26 -2
  106. package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
  107. package/dist/types/client/actions/prepareCalls.d.ts +28 -2
  108. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  109. package/dist/types/client/actions/requestAccount.d.ts +21 -2
  110. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  111. package/dist/types/client/actions/sendPreparedCalls.d.ts +39 -2
  112. package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
  113. package/dist/types/client/actions/signMessage.d.ts +22 -2
  114. package/dist/types/client/actions/signMessage.d.ts.map +1 -1
  115. package/dist/types/client/actions/signSignatureRequest.d.ts +34 -0
  116. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  117. package/dist/types/client/actions/signTypedData.d.ts +35 -2
  118. package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
  119. package/dist/types/client/decorator.d.ts +7 -5
  120. package/dist/types/client/decorator.d.ts.map +1 -1
  121. package/dist/types/client/index.d.ts +4 -4
  122. package/dist/types/client/index.d.ts.map +1 -1
  123. package/dist/types/exports/index.d.ts +1 -0
  124. package/dist/types/exports/index.d.ts.map +1 -1
  125. package/dist/types/exports/internal.d.ts +1 -1
  126. package/dist/types/exports/internal.d.ts.map +1 -1
  127. package/dist/types/internal/decorator.d.ts +3 -0
  128. package/dist/types/internal/decorator.d.ts.map +1 -0
  129. package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
  130. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
  131. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
  132. package/dist/types/isomorphic/client.d.ts +11 -5
  133. package/dist/types/isomorphic/client.d.ts.map +1 -1
  134. package/dist/types/isomorphic/utils/7702.d.ts +12 -0
  135. package/dist/types/isomorphic/utils/7702.d.ts.map +1 -0
  136. package/dist/types/isomorphic/utils/createAccount.d.ts +2 -1
  137. package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
  138. package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +1 -1
  139. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +2 -1
  140. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
  141. package/dist/types/local/client.d.ts +1 -1
  142. package/dist/types/local/client.d.ts.map +1 -1
  143. package/dist/types/remote/client.d.ts +1 -1
  144. package/dist/types/remote/client.d.ts.map +1 -1
  145. package/dist/types/rpc/examples.d.ts +231 -0
  146. package/dist/types/rpc/examples.d.ts.map +1 -0
  147. package/dist/types/rpc/request.d.ts +48 -17
  148. package/dist/types/rpc/request.d.ts.map +1 -1
  149. package/dist/types/rpc/schema.d.ts +43 -12
  150. package/dist/types/rpc/schema.d.ts.map +1 -1
  151. package/dist/types/schemas.d.ts +29 -7
  152. package/dist/types/schemas.d.ts.map +1 -1
  153. package/dist/types/types.d.ts +15 -4
  154. package/dist/types/types.d.ts.map +1 -1
  155. package/package.json +8 -6
  156. package/src/capabilities/index.ts +5 -8
  157. package/src/capabilities/overrides.ts +23 -8
  158. package/src/capabilities/permissions/index.ts +21 -5
  159. package/src/capabilities/permissions/mav2.ts +13 -3
  160. package/src/client/actions/createAccount.ts +27 -2
  161. package/src/client/actions/getCallsStatus.ts +21 -2
  162. package/src/client/actions/grantPermissions.ts +114 -2
  163. package/src/client/actions/listAccounts.ts +26 -2
  164. package/src/client/actions/prepareCalls.ts +28 -2
  165. package/src/client/actions/requestAccount.ts +41 -7
  166. package/src/client/actions/sendPreparedCalls.ts +39 -2
  167. package/src/client/actions/signMessage.ts +24 -4
  168. package/src/client/actions/signSignatureRequest.ts +61 -2
  169. package/src/client/actions/signTypedData.ts +39 -3
  170. package/src/client/client.e2e-test.ts +134 -32
  171. package/src/client/decorator.ts +10 -12
  172. package/src/client/index.ts +41 -10
  173. package/src/exports/index.ts +1 -0
  174. package/src/exports/internal.ts +1 -1
  175. package/src/internal/decorator.ts +12 -0
  176. package/src/isomorphic/actions/createSession.ts +28 -7
  177. package/src/isomorphic/actions/prepareCalls.ts +38 -11
  178. package/src/isomorphic/actions/sendPreparedCalls.ts +47 -20
  179. package/src/isomorphic/utils/7702.ts +58 -0
  180. package/src/isomorphic/utils/createAccount.ts +38 -6
  181. package/src/isomorphic/utils/createDummySigner.ts +3 -2
  182. package/src/isomorphic/utils/parsePermissionsContext.ts +23 -7
  183. package/src/local/client.ts +54 -45
  184. package/src/remote/client.ts +22 -7
  185. package/src/rpc/examples.ts +343 -0
  186. package/src/rpc/request.ts +75 -26
  187. package/src/schemas.ts +218 -87
  188. package/src/types.ts +18 -4
@@ -1,6 +1,6 @@
1
1
  import { type Address, type IsUndefined, type JsonRpcAccount } from "viem";
2
- import type { PrepareCallsParams as IsomorphicPrepareCallsParams, PrepareCallsResult as IsomorphicPrepareCallsResult } from "../../isomorphic/actions/prepareCalls";
3
- import type { InnerWalletApiClient } from "../../types";
2
+ import type { PrepareCallsParams as IsomorphicPrepareCallsParams, PrepareCallsResult as IsomorphicPrepareCallsResult } from "../../isomorphic/actions/prepareCalls.ts";
3
+ import type { InnerWalletApiClient } from "../../types.ts";
4
4
  export type GetAccountParam<TAccount> = IsUndefined<TAccount> extends true ? {
5
5
  account: Address;
6
6
  } : {
@@ -12,4 +12,30 @@ export type PrepareCallsParams<TAccount extends JsonRpcAccount<Address> | undefi
12
12
  from?: never;
13
13
  });
14
14
  export type PrepareCallsResult = IsomorphicPrepareCallsResult;
15
+ /**
16
+ * Prepares a set of contract calls for execution by building a user operation.
17
+ * Returns the built user operation and a signature request that needs to be signed
18
+ * before submitting to sendPreparedCalls.
19
+ *
20
+ * @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request
21
+ * @param {PrepareCallsParams<TAccount>} params - Parameters for preparing calls
22
+ * @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
23
+ * @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
24
+ * @param {object} [params.capabilities] - Optional capabilities to include with the request
25
+ * @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing
26
+ * the user operation data and signature request
27
+ *
28
+ * @example
29
+ * // Prepare a sponosored user operation call
30
+ * const result = await client.prepareCalls({
31
+ * calls: [{
32
+ * to: "0x1234...",
33
+ * data: "0xabcdef...",
34
+ * value: "0x0"
35
+ * }],
36
+ * capabilities: {
37
+ * paymasterService: { policyId: "your-policy-id" }
38
+ * }
39
+ * });
40
+ */
15
41
  export declare function prepareCalls<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, params: PrepareCallsParams<TAccount>): Promise<PrepareCallsResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAIN,MAAM,MAAM,CAAC;AA8Bd,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE,CAAC;QAC9D,MAAM,CAAC,YAAY,GAAG;YACpB,GAAG,MAAM,CAAC,YAAY;YACtB,gBAAgB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IACvC,CAAC;IAED,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n toHex,\n type Address,\n type IsUndefined,\n type JsonRpcAccount,\n} from \"viem\";\nimport type {\n PrepareCallsParams as IsomorphicPrepareCallsParams,\n PrepareCallsResult as IsomorphicPrepareCallsResult,\n} from \"../../isomorphic/actions/prepareCalls\";\nimport type { InnerWalletApiClient } from \"../../types\";\n\nexport type GetAccountParam<TAccount> =\n IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never };\n\nexport type PrepareCallsParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = Omit<IsomorphicPrepareCallsParams, \"from\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareCallsResult = IsomorphicPrepareCallsResult;\n\nexport async function prepareCalls<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n params: PrepareCallsParams<TAccount>,\n): Promise<PrepareCallsResult>;\n\nexport async function prepareCalls(\n client: InnerWalletApiClient,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n if (client.policyId && !params.capabilities?.paymasterService) {\n params.capabilities = {\n ...params.capabilities,\n paymasterService: { policyId: client.policyId },\n };\n }\n\n if (client.account && !params.from) {\n params.from = client.account.address;\n }\n\n return await client.request({\n method: \"wallet_prepareCalls\",\n params: [{ ...params, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
1
+ {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAIN,MAAM,MAAM,CAAC;AAwDd,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE,CAAC;QAC9D,MAAM,CAAC,YAAY,GAAG;YACpB,GAAG,MAAM,CAAC,YAAY;YACtB,gBAAgB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IACvC,CAAC;IAED,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n toHex,\n type Address,\n type IsUndefined,\n type JsonRpcAccount,\n} from \"viem\";\nimport type {\n PrepareCallsParams as IsomorphicPrepareCallsParams,\n PrepareCallsResult as IsomorphicPrepareCallsResult,\n} from \"../../isomorphic/actions/prepareCalls.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GetAccountParam<TAccount> =\n IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never };\n\nexport type PrepareCallsParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = Omit<IsomorphicPrepareCallsParams, \"from\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareCallsResult = IsomorphicPrepareCallsResult;\n\n/**\n * Prepares a set of contract calls for execution by building a user operation.\n * Returns the built user operation and a signature request that needs to be signed\n * before submitting to sendPreparedCalls.\n *\n * @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request\n * @param {PrepareCallsParams<TAccount>} params - Parameters for preparing calls\n * @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute\n * @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request\n * @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing\n * the user operation data and signature request\n *\n * @example\n * // Prepare a sponosored user operation call\n * const result = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n */\nexport async function prepareCalls<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n params: PrepareCallsParams<TAccount>,\n): Promise<PrepareCallsResult>;\n\nexport async function prepareCalls(\n client: InnerWalletApiClient,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n if (client.policyId && !params.capabilities?.paymasterService) {\n params.capabilities = {\n ...params.capabilities,\n paymasterService: { policyId: client.policyId },\n };\n }\n\n if (client.account && !params.from) {\n params.from = client.account.address;\n }\n\n return await client.request({\n method: \"wallet_prepareCalls\",\n params: [{ ...params, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { SmartAccountSigner, SmartContractAccount } from "@aa-sdk/core";
1
+ import { type SmartAccountSigner, type SmartContractAccount } from "@aa-sdk/core";
2
2
  import type { Static } from "@sinclair/typebox";
3
3
  import type { Address } from "abitype";
4
4
  import { type IsUndefined, type JsonRpcAccount } from "viem";
@@ -6,6 +6,25 @@ import type { wallet_requestAccount } from "../../rpc/request.js";
6
6
  import type { InnerWalletApiClient } from "../../types.js";
7
7
  export type RequestAccountParams<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined> = IsUndefined<TAccount> extends true ? Omit<Extract<Static<typeof wallet_requestAccount>["Request"]["params"][0], {
8
8
  signerAddress: Address;
9
- }>, "signerAddress" | "includeCounterfactualInfo"> : never;
9
+ }>, "signerAddress" | "includeCounterfactualInfo"> & {
10
+ accountAddress?: Address;
11
+ } : never;
10
12
  export type RequestAccountResult = SmartContractAccount;
13
+ /**
14
+ * Requests an account for the provided signer using the wallet API client.
15
+ * If an account already exists for the signer, it will always return that account unless a new ID is specified.
16
+ * If an account already exists, the creationHint will be ignored.
17
+ *
18
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
19
+ * @param {SmartAccountSigner} signer - The signer that will be associated with the account
20
+ * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
21
+ * @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer
22
+ * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
23
+ * @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance
24
+ *
25
+ * @example
26
+ * // Request an account with default parameters using a local signer
27
+ * const signer = LocalAccountSigner.privateKeyToAccountSigner("0x...");
28
+ * const account = await client.requestAccount(signer);
29
+ */
11
30
  export declare function requestAccount<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, signer: SmartAccountSigner, params?: RequestAccountParams<TAccount>): Promise<RequestAccountResult>;
@@ -1,11 +1,13 @@
1
+ import {} from "@aa-sdk/core";
1
2
  import { Value } from "@sinclair/typebox/value";
2
3
  import { custom } from "viem";
3
4
  import { createAccount } from "../../isomorphic/utils/createAccount.js";
4
5
  import { TypeSerializedInitcode } from "../../schemas.js";
6
+ import deepEqual from "deep-equal";
5
7
  export async function requestAccount(client, signer, params) {
6
- const args = client.account && !params
8
+ const args = (client.account && !params) || params?.accountAddress
7
9
  ? {
8
- accountAddress: client.account.address,
10
+ accountAddress: params?.accountAddress ?? client.account.address,
9
11
  includeCounterfactualInfo: true,
10
12
  }
11
13
  : {
@@ -13,16 +15,25 @@ export async function requestAccount(client, signer, params) {
13
15
  signerAddress: await signer.getAddress(),
14
16
  includeCounterfactualInfo: true,
15
17
  };
18
+ const cachedAccount = client.internal.getAccount();
19
+ if (cachedAccount &&
20
+ ((args.accountAddress &&
21
+ cachedAccount.account.address === args.accountAddress) ||
22
+ deepEqual(cachedAccount.requestParams, args, { strict: true }))) {
23
+ return cachedAccount.account;
24
+ }
16
25
  const { counterfactualInfo, accountAddress } = await client.request({
17
26
  method: "wallet_requestAccount",
18
27
  params: [args],
19
28
  });
20
- return createAccount({
21
- accountAddress: accountAddress,
29
+ const account = await createAccount({
30
+ accountAddress,
22
31
  counterfactualInfo: Value.Parse(TypeSerializedInitcode, counterfactualInfo),
23
32
  chain: client.chain,
24
33
  transport: custom(client.transport),
25
34
  signer,
26
35
  });
36
+ client.internal.setAccount({ account, requestParams: args });
37
+ return account;
27
38
  }
28
39
  //# sourceMappingURL=requestAccount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAyC,MAAM,MAAM,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AA+B1D,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA0B,EAC1B,MAA6B;IAE7B,MAAM,IAAI,GACR,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM;QACvB,CAAC,CAAC;YACE,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO;YACtC,yBAAyB,EAAE,IAAI;SAChC;QACH,CAAC,CAAC;YACE,GAAG,MAAM;YACT,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;YACxC,yBAAyB,EAAE,IAAI;SAChC,CAAC;IAER,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClE,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC;QACnB,cAAc,EAAE,cAAc;QAC9B,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAC7B,sBAAsB,EACtB,kBAAmB,CACpB;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM;KACP,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { SmartAccountSigner, SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport type { Address } from \"abitype\";\nimport { custom, type IsUndefined, type JsonRpcAccount } from \"viem\";\nimport { createAccount } from \"../../isomorphic/utils/createAccount.js\";\nimport type { wallet_requestAccount } from \"../../rpc/request.js\";\nimport { TypeSerializedInitcode } from \"../../schemas.js\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\n\nexport type RequestAccountParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> =\n IsUndefined<TAccount> extends true\n ? Omit<\n Extract<\n Static<typeof wallet_requestAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n >\n : never;\n\n// TODO: this could be more specific potentially :shrug:\nexport type RequestAccountResult = SmartContractAccount;\n\nexport function requestAccount<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params?: RequestAccountParams<TAccount>,\n): Promise<RequestAccountResult>;\n\nexport async function requestAccount(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n const args =\n client.account && !params\n ? {\n accountAddress: client.account.address,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress: await signer.getAddress(),\n includeCounterfactualInfo: true,\n };\n\n const { counterfactualInfo, accountAddress } = await client.request({\n method: \"wallet_requestAccount\",\n params: [args],\n });\n\n return createAccount({\n accountAddress: accountAddress,\n counterfactualInfo: Value.Parse(\n TypeSerializedInitcode,\n counterfactualInfo!,\n ),\n chain: client.chain,\n transport: custom(client.transport),\n signer,\n });\n}\n"]}
1
+ {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAyC,MAAM,MAAM,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,SAAS,MAAM,YAAY,CAAC;AA8CnC,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA0B,EAC1B,MAA6B;IAE7B,MAAM,IAAI,GACR,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,cAAc;QACnD,CAAC,CAAC;YACE,cAAc,EAAE,MAAM,EAAE,cAAc,IAAI,MAAM,CAAC,OAAQ,CAAC,OAAO;YACjE,yBAAyB,EAAE,IAAI;SAChC;QACH,CAAC,CAAC;YACE,GAAG,MAAM;YACT,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;YACxC,yBAAyB,EAAE,IAAI;SAChC,CAAC;IAER,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACnD,IACE,aAAa;QACb,CAAC,CAAC,IAAI,CAAC,cAAc;YACnB,aAAa,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,cAAc,CAAC;YACtD,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EACjE,CAAC;QACD,OAAO,aAAa,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClE,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,cAAc;QACd,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAC7B,sBAAsB,EACtB,kBAAmB,CACpB;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n type SmartAccountSigner,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport type { Address } from \"abitype\";\nimport { custom, type IsUndefined, type JsonRpcAccount } from \"viem\";\nimport { createAccount } from \"../../isomorphic/utils/createAccount.js\";\nimport type { wallet_requestAccount } from \"../../rpc/request.js\";\nimport { TypeSerializedInitcode } from \"../../schemas.js\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport deepEqual from \"deep-equal\";\n\nexport type RequestAccountParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> =\n IsUndefined<TAccount> extends true\n ? Omit<\n Extract<\n Static<typeof wallet_requestAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n > & { accountAddress?: Address }\n : never;\n\nexport type RequestAccountResult = SmartContractAccount;\n\n/**\n * Requests an account for the provided signer using the wallet API client.\n * If an account already exists for the signer, it will always return that account unless a new ID is specified.\n * If an account already exists, the creationHint will be ignored.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer that will be associated with the account\n * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account\n * @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer\n * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists\n * @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance\n *\n * @example\n * // Request an account with default parameters using a local signer\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(\"0x...\");\n * const account = await client.requestAccount(signer);\n */\nexport function requestAccount<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params?: RequestAccountParams<TAccount>,\n): Promise<RequestAccountResult>;\n\nexport async function requestAccount(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n const args =\n (client.account && !params) || params?.accountAddress\n ? {\n accountAddress: params?.accountAddress ?? client.account!.address,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress: await signer.getAddress(),\n includeCounterfactualInfo: true,\n };\n\n const cachedAccount = client.internal.getAccount();\n if (\n cachedAccount &&\n ((args.accountAddress &&\n cachedAccount.account.address === args.accountAddress) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n return cachedAccount.account;\n }\n\n const { counterfactualInfo, accountAddress } = await client.request({\n method: \"wallet_requestAccount\",\n params: [args],\n });\n\n const account = await createAccount({\n accountAddress,\n counterfactualInfo: Value.Parse(\n TypeSerializedInitcode,\n counterfactualInfo!,\n ),\n chain: client.chain,\n transport: custom(client.transport),\n signer,\n });\n\n client.internal.setAccount({ account, requestParams: args });\n\n return account;\n}\n"]}
@@ -1,6 +1,43 @@
1
1
  import type { Static, StaticDecode } from "@sinclair/typebox";
2
- import type { wallet_sendPreparedCalls } from "../../rpc/request";
3
- import type { InnerWalletApiClient } from "../../types";
2
+ import type { wallet_sendPreparedCalls } from "../../rpc/request.ts";
3
+ import type { InnerWalletApiClient } from "../../types.ts";
4
4
  export type SendPreparedCallsParams = Omit<StaticDecode<typeof wallet_sendPreparedCalls>["Request"]["params"][0], "chainId">;
5
5
  export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["ReturnType"];
6
+ /**
7
+ * Sends prepared calls by submitting a signed user operation.
8
+ * This method is used after signing the signature request returned from prepareCalls.
9
+ *
10
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
11
+ * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
12
+ * @param {string} params.type - The user operation type ('user-operation-v060' or 'user-operation-v070')
13
+ * @param {object} params.data - The user operation data without signature
14
+ * @param {string} params.chainId - The chain ID in hex format
15
+ * @param {object} params.signature - The signature object
16
+ * @param {string} params.signature.type - The signature type (must be 'ecdsa')
17
+ * @param {string} params.signature.signature - The hex-encoded signature value
18
+ * @param {object} [params.capabilities] - Optional capabilities to include with the request
19
+ * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
20
+ *
21
+ * @example
22
+ * // First prepare the calls
23
+ * const preparedCalls = await client.prepareCalls({
24
+ * calls: [{
25
+ * to: "0x1234...",
26
+ * data: "0xabcdef...",
27
+ * value: "0x0"
28
+ * }],
29
+ * capabilities: {
30
+ * paymasterService: { policyId: "your-policy-id" }
31
+ * }
32
+ * });
33
+ *
34
+ * // Sign the signature request using signSignatureRequest with your signer
35
+ * const signedRequest = await client.signSignatureRequest(preparedCalls.signatureRequest);
36
+ *
37
+ * // Then send the prepared calls with the signature
38
+ * const result = await client.sendPreparedCalls({
39
+ * ...preparedCalls,
40
+ * signature: signedRequest.signature,
41
+ * });
42
+ */
6
43
  export declare function sendPreparedCalls(client: InnerWalletApiClient, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;
@@ -1,4 +1,41 @@
1
1
  import { toHex } from "viem";
2
+ /**
3
+ * Sends prepared calls by submitting a signed user operation.
4
+ * This method is used after signing the signature request returned from prepareCalls.
5
+ *
6
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
7
+ * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
8
+ * @param {string} params.type - The user operation type ('user-operation-v060' or 'user-operation-v070')
9
+ * @param {object} params.data - The user operation data without signature
10
+ * @param {string} params.chainId - The chain ID in hex format
11
+ * @param {object} params.signature - The signature object
12
+ * @param {string} params.signature.type - The signature type (must be 'ecdsa')
13
+ * @param {string} params.signature.signature - The hex-encoded signature value
14
+ * @param {object} [params.capabilities] - Optional capabilities to include with the request
15
+ * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
16
+ *
17
+ * @example
18
+ * // First prepare the calls
19
+ * const preparedCalls = await client.prepareCalls({
20
+ * calls: [{
21
+ * to: "0x1234...",
22
+ * data: "0xabcdef...",
23
+ * value: "0x0"
24
+ * }],
25
+ * capabilities: {
26
+ * paymasterService: { policyId: "your-policy-id" }
27
+ * }
28
+ * });
29
+ *
30
+ * // Sign the signature request using signSignatureRequest with your signer
31
+ * const signedRequest = await client.signSignatureRequest(preparedCalls.signatureRequest);
32
+ *
33
+ * // Then send the prepared calls with the signature
34
+ * const result = await client.sendPreparedCalls({
35
+ * ...preparedCalls,
36
+ * signature: signedRequest.signature,
37
+ * });
38
+ */
2
39
  export async function sendPreparedCalls(client, params) {
3
40
  return client.request({
4
41
  method: "wallet_sendPreparedCalls",
@@ -1 +1 @@
1
- {"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAa7B,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static, StaticDecode } from \"@sinclair/typebox\";\nimport { toHex } from \"viem\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request\";\nimport type { InnerWalletApiClient } from \"../../types\";\n\nexport type SendPreparedCallsParams = Omit<\n StaticDecode<typeof wallet_sendPreparedCalls>[\"Request\"][\"params\"][0],\n \"chainId\"\n>;\n\nexport type SendPreparedCallsResult = Static<\n typeof wallet_sendPreparedCalls\n>[\"ReturnType\"];\n\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [{ ...params, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
1
+ {"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAa7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static, StaticDecode } from \"@sinclair/typebox\";\nimport { toHex } from \"viem\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type SendPreparedCallsParams = Omit<\n StaticDecode<typeof wallet_sendPreparedCalls>[\"Request\"][\"params\"][0],\n \"chainId\"\n>;\n\nexport type SendPreparedCallsResult = Static<\n typeof wallet_sendPreparedCalls\n>[\"ReturnType\"];\n\n/**\n * Sends prepared calls by submitting a signed user operation.\n * This method is used after signing the signature request returned from prepareCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls\n * @param {string} params.type - The user operation type ('user-operation-v060' or 'user-operation-v070')\n * @param {object} params.data - The user operation data without signature\n * @param {string} params.chainId - The chain ID in hex format\n * @param {object} params.signature - The signature object\n * @param {string} params.signature.type - The signature type (must be 'ecdsa')\n * @param {string} params.signature.signature - The hex-encoded signature value\n * @param {object} [params.capabilities] - Optional capabilities to include with the request\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs\n *\n * @example\n * // First prepare the calls\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Sign the signature request using signSignatureRequest with your signer\n * const signedRequest = await client.signSignatureRequest(preparedCalls.signatureRequest);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * ...preparedCalls,\n * signature: signedRequest.signature,\n * });\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [{ ...params, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
@@ -1,6 +1,26 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import { type Address, type Hex, type JsonRpcAccount, type SignableMessage } from "viem";
3
- import type { InnerWalletApiClient } from "../../types";
4
- export type SignMessageParams = SignableMessage;
3
+ import type { InnerWalletApiClient } from "../../types.ts";
4
+ export type SignMessageParams = {
5
+ message: SignableMessage;
6
+ account?: Address;
7
+ };
5
8
  export type SignMessageResult = Hex;
9
+ /**
10
+ * Signs a message using the smart account.
11
+ * This method requests the account associated with the signer and uses it to sign the message.
12
+ *
13
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
14
+ * @param {SmartAccountSigner} signer - The signer of the smart account
15
+ * @param {SignableMessage} message - The message to sign
16
+ * @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string
17
+ *
18
+ * @example
19
+ * // Sign a simple text message
20
+ * const signature = await client.signMessage("Hello, world!");
21
+ *
22
+ * @example
23
+ * // Sign a raw hex message
24
+ * const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
25
+ */
6
26
  export declare function signMessage<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, signer: SmartAccountSigner, params: SignMessageParams): Promise<SignMessageResult>;
@@ -1,7 +1,9 @@
1
1
  import {} from "viem";
2
2
  import { requestAccount } from "./requestAccount.js";
3
3
  export async function signMessage(client, signer, params) {
4
- const account = await requestAccount(client, signer);
5
- return account.signMessageWith6492({ message: params });
4
+ const account = await requestAccount(client, signer, {
5
+ accountAddress: params.account ?? client.account?.address,
6
+ });
7
+ return account.signMessageWith6492({ message: params.message });
6
8
  }
7
9
  //# sourceMappingURL=signMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAKN,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAgBrD,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAA0B,EAC1B,MAAyB;IAEzB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n type Address,\n type Hex,\n type JsonRpcAccount,\n type SignableMessage,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types\";\nimport { requestAccount } from \"./requestAccount.js\";\n\nexport type SignMessageParams = SignableMessage;\n\nexport type SignMessageResult = Hex;\n\nexport async function signMessage<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult>;\n\nexport async function signMessage(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult> {\n const account = await requestAccount(client, signer);\n return account.signMessageWith6492({ message: params });\n}\n"]}
1
+ {"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAKN,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAiCrD,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAA0B,EAC1B,MAAyB;IAEzB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n type Address,\n type Hex,\n type JsonRpcAccount,\n type SignableMessage,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\n\nexport type SignMessageParams = { message: SignableMessage; account?: Address };\n\nexport type SignMessageResult = Hex;\n\n/**\n * Signs a message using the smart account.\n * This method requests the account associated with the signer and uses it to sign the message.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {SignableMessage} message - The message to sign\n * @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string\n *\n * @example\n * // Sign a simple text message\n * const signature = await client.signMessage(\"Hello, world!\");\n *\n * @example\n * // Sign a raw hex message\n * const signature = await client.signMessage({ raw: \"0x48656c6c6f2c20776f726c6421\" });\n */\nexport async function signMessage<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult>;\n\nexport async function signMessage(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult> {\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signMessageWith6492({ message: params.message });\n}\n"]}
@@ -2,9 +2,43 @@ import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import type { Static } from "@sinclair/typebox";
3
3
  import { type Hex } from "viem";
4
4
  import { TypeSignatureRequest } from "../../schemas.js";
5
+ import type { Eip7702ExtendedFields } from "@aa-sdk/core";
5
6
  export type SignSignatureRequestParams = Static<typeof TypeSignatureRequest>;
6
7
  export type SignSignatureRequestResult = {
7
8
  type: "ecdsa";
8
9
  signature: Hex;
10
+ signedAuthorization?: Eip7702ExtendedFields["eip7702Auth"];
9
11
  };
12
+ /**
13
+ * Signs a signature request using the provided signer.
14
+ * This method handles different types of signature requests including personal_sign and eth_signTypedData_v4.
15
+ *
16
+ * @param {SmartAccountSigner} signer - The signer to use for signing the request
17
+ * @param {SignSignatureRequestParams} params - The signature request parameters
18
+ * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
19
+ * @param {any} params.data - The data to sign, format depends on the signature type
20
+ * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
21
+ * @returns {string} result.type - The signature type (currently only 'ecdsa' is supported)
22
+ * @returns {Hex} result.signature - The hex-encoded signature
23
+ * @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
24
+ *
25
+ * @example
26
+ * // Sign a personal message
27
+ * const result = await client.signSignatureRequest({
28
+ * type: 'personal_sign',
29
+ * data: 'Hello, world!'
30
+ * });
31
+ *
32
+ * @example
33
+ * // Sign typed data (EIP-712)
34
+ * const result = await client.signSignatureRequest({
35
+ * type: 'eth_signTypedData_v4',
36
+ * data: {
37
+ * domain: { ... },
38
+ * types: { ... },
39
+ * primaryType: '...',
40
+ * message: { ... }
41
+ * }
42
+ * });
43
+ */
10
44
  export declare function signSignatureRequest(signer: SmartAccountSigner, params: SignSignatureRequestParams): Promise<SignSignatureRequestResult>;
@@ -1,4 +1,4 @@
1
- import {} from "viem";
1
+ import { toHex } from "viem";
2
2
  import { TypeSignatureRequest } from "../../schemas.js";
3
3
  import { assertNever } from "../../utils.js";
4
4
  export async function signSignatureRequest(signer, params) {
@@ -7,9 +7,30 @@ export async function signSignatureRequest(signer, params) {
7
7
  : params.type === "eth_signTypedData_v4"
8
8
  ? await signer.signTypedData(params.data)
9
9
  : assertNever(params, "Unexpected signature request type");
10
+ if (!params.authorizationRequest) {
11
+ return {
12
+ type: "ecdsa",
13
+ signature,
14
+ };
15
+ }
16
+ if (!signer.signAuthorization) {
17
+ throw new Error("Signer does not implement signAuthorization");
18
+ }
19
+ const authSig = await signer.signAuthorization(params.authorizationRequest);
20
+ const { r, s } = authSig;
21
+ const yParity = toHex(authSig.yParity ?? authSig.v - 27n);
22
+ const signedAuthorization = {
23
+ chainId: toHex(params.authorizationRequest.chainId),
24
+ nonce: toHex(params.authorizationRequest.nonce),
25
+ address: params.authorizationRequest.address,
26
+ r,
27
+ s,
28
+ yParity,
29
+ };
10
30
  return {
11
31
  type: "ecdsa",
12
32
  signature,
33
+ signedAuthorization,
13
34
  };
14
35
  }
15
36
  //# sourceMappingURL=signSignatureRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAc7C,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,MAAkC;IAElC,MAAM,SAAS,GACb,MAAM,CAAC,IAAI,KAAK,eAAe;QAC7B,CAAC,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QACvC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAsB;YACtC,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC;YACzC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;IAEjE,OAAO;QACL,IAAI,EAAE,OAAO;QACb,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { type Hex } from \"viem\";\nimport { TypeSignatureRequest } from \"../../schemas.js\";\nimport { assertNever } from \"../../utils.js\";\n\nexport type SignSignatureRequestParams = Static<typeof TypeSignatureRequest>;\n\nexport type SignSignatureRequestResult = {\n type: \"ecdsa\";\n signature: Hex;\n};\n\nexport function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult>;\n\nexport async function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\n const signature =\n params.type === \"personal_sign\"\n ? await signer.signMessage(params.data)\n : params.type === \"eth_signTypedData_v4\"\n ? await signer.signTypedData(params.data)\n : assertNever(params, \"Unexpected signature request type\");\n\n return {\n type: \"ecdsa\",\n signature,\n };\n}\n"]}
1
+ {"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAgD7C,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,MAAkC;IAElC,MAAM,SAAS,GACb,MAAM,CAAC,IAAI,KAAK,eAAe;QAC7B,CAAC,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;QACvC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAsB;YACtC,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC;YACzC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;IAEjE,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACjC,OAAO;YACL,IAAI,EAAE,OAAgB;YACtB,SAAS;SACV,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAC5E,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC;IACzB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAE1D,MAAM,mBAAmB,GAAG;QAC1B,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC;QACnD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC;QAC/C,OAAO,EAAE,MAAM,CAAC,oBAAoB,CAAC,OAAO;QAC5C,CAAC;QACD,CAAC;QACD,OAAO;KACR,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,OAAgB;QACtB,SAAS;QACT,mBAAmB;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { type Hex, toHex } from \"viem\";\nimport { TypeSignatureRequest } from \"../../schemas.js\";\nimport { assertNever } from \"../../utils.js\";\nimport type { Eip7702ExtendedFields } from \"@aa-sdk/core\";\n\nexport type SignSignatureRequestParams = Static<typeof TypeSignatureRequest>;\n\nexport type SignSignatureRequestResult = {\n type: \"ecdsa\";\n signature: Hex;\n signedAuthorization?: Eip7702ExtendedFields[\"eip7702Auth\"];\n};\n\n/**\n * Signs a signature request using the provided signer.\n * This method handles different types of signature requests including personal_sign and eth_signTypedData_v4.\n *\n * @param {SmartAccountSigner} signer - The signer to use for signing the request\n * @param {SignSignatureRequestParams} params - The signature request parameters\n * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')\n * @param {any} params.data - The data to sign, format depends on the signature type\n * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result\n * @returns {string} result.type - The signature type (currently only 'ecdsa' is supported)\n * @returns {Hex} result.signature - The hex-encoded signature\n * @returns {Eip7702ExtendedFields[\"eip7702Auth\"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable\n *\n * @example\n * // Sign a personal message\n * const result = await client.signSignatureRequest({\n * type: 'personal_sign',\n * data: 'Hello, world!'\n * });\n *\n * @example\n * // Sign typed data (EIP-712)\n * const result = await client.signSignatureRequest({\n * type: 'eth_signTypedData_v4',\n * data: {\n * domain: { ... },\n * types: { ... },\n * primaryType: '...',\n * message: { ... }\n * }\n * });\n */\nexport function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult>;\n\nexport async function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\n const signature =\n params.type === \"personal_sign\"\n ? await signer.signMessage(params.data)\n : params.type === \"eth_signTypedData_v4\"\n ? await signer.signTypedData(params.data)\n : assertNever(params, \"Unexpected signature request type\");\n\n if (!params.authorizationRequest) {\n return {\n type: \"ecdsa\" as const,\n signature,\n };\n }\n\n if (!signer.signAuthorization) {\n throw new Error(\"Signer does not implement signAuthorization\");\n }\n\n const authSig = await signer.signAuthorization(params.authorizationRequest);\n const { r, s } = authSig;\n const yParity = toHex(authSig.yParity ?? authSig.v - 27n);\n\n const signedAuthorization = {\n chainId: toHex(params.authorizationRequest.chainId),\n nonce: toHex(params.authorizationRequest.nonce),\n address: params.authorizationRequest.address,\n r,\n s,\n yParity,\n };\n\n return {\n type: \"ecdsa\" as const,\n signature,\n signedAuthorization,\n };\n}\n"]}
@@ -1,6 +1,39 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import { type Address, type Hex, type JsonRpcAccount, type TypedDataDefinition } from "viem";
3
- import type { InnerWalletApiClient } from "../../types";
4
- export type SignTypedDataParams = TypedDataDefinition;
3
+ import type { InnerWalletApiClient } from "../../types.ts";
4
+ export type SignTypedDataParams = TypedDataDefinition & {
5
+ account?: Address;
6
+ };
5
7
  export type SignTypedDataResult = Hex;
8
+ /**
9
+ * Signs typed data (EIP-712) using the smart account.
10
+ * This method requests the account associated with the signer and uses it to sign the typed data.
11
+ *
12
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
13
+ * @param {SmartAccountSigner} signer - The signer of the smart account
14
+ * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
15
+ * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
16
+ *
17
+ * @example
18
+ * // Sign typed data
19
+ * const signature = await client.signTypedData({
20
+ * domain: {
21
+ * name: 'Example DApp',
22
+ * version: '1',
23
+ * chainId: 1,
24
+ * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
25
+ * },
26
+ * types: {
27
+ * Person: [
28
+ * { name: 'name', type: 'string' },
29
+ * { name: 'wallet', type: 'address' }
30
+ * ]
31
+ * },
32
+ * primaryType: 'Person',
33
+ * message: {
34
+ * name: 'John Doe',
35
+ * wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'
36
+ * }
37
+ * });
38
+ */
6
39
  export declare function signTypedData<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, signer: SmartAccountSigner, params: SignTypedDataParams): Promise<SignTypedDataResult>;
@@ -1,7 +1,9 @@
1
1
  import {} from "viem";
2
2
  import { requestAccount } from "./requestAccount.js";
3
3
  export async function signTypedData(client, signer, params) {
4
- const account = await requestAccount(client, signer);
4
+ const account = await requestAccount(client, signer, {
5
+ accountAddress: params.account ?? client.account?.address,
6
+ });
5
7
  return account.signTypedDataWith6492(params);
6
8
  }
7
9
  //# sourceMappingURL=signTypedData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../../src/client/actions/signTypedData.ts"],"names":[],"mappings":"AACA,OAAO,EAKN,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAgBrD,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA0B,EAC1B,MAA2B;IAE3B,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n type Address,\n type Hex,\n type JsonRpcAccount,\n type TypedDataDefinition,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types\";\nimport { requestAccount } from \"./requestAccount.js\";\n\nexport type SignTypedDataParams = TypedDataDefinition;\n\nexport type SignTypedDataResult = Hex;\n\nexport async function signTypedData<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params: SignTypedDataParams,\n): Promise<SignTypedDataResult>;\n\nexport async function signTypedData(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: SignTypedDataParams,\n): Promise<SignTypedDataResult> {\n const account = await requestAccount(client, signer);\n return account.signTypedDataWith6492(params);\n}\n"]}
1
+ {"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../../src/client/actions/signTypedData.ts"],"names":[],"mappings":"AACA,OAAO,EAKN,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAiDrD,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA0B,EAC1B,MAA2B;IAE3B,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n type Address,\n type Hex,\n type JsonRpcAccount,\n type TypedDataDefinition,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\n\nexport type SignTypedDataParams = TypedDataDefinition & {\n account?: Address;\n};\n\nexport type SignTypedDataResult = Hex;\n\n/**\n * Signs typed data (EIP-712) using the smart account.\n * This method requests the account associated with the signer and uses it to sign the typed data.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format\n * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string\n *\n * @example\n * // Sign typed data\n * const signature = await client.signTypedData({\n * domain: {\n * name: 'Example DApp',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' }\n * ]\n * },\n * primaryType: 'Person',\n * message: {\n * name: 'John Doe',\n * wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'\n * }\n * });\n */\nexport async function signTypedData<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params: SignTypedDataParams,\n): Promise<SignTypedDataResult>;\n\nexport async function signTypedData(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: SignTypedDataParams,\n): Promise<SignTypedDataResult> {\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signTypedDataWith6492(params);\n}\n"]}