@account-kit/wallet-client 0.1.0-alpha.0 → 0.1.0-alpha.2

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 (179) hide show
  1. package/dist/esm/abi/index.d.ts +8 -8
  2. package/dist/esm/abi/index.js +8 -8
  3. package/dist/esm/abi/index.js.map +1 -1
  4. package/dist/esm/capabilities/index.js +3 -3
  5. package/dist/esm/capabilities/index.js.map +1 -1
  6. package/dist/esm/capabilities/overrides.js +1 -1
  7. package/dist/esm/capabilities/overrides.js.map +1 -1
  8. package/dist/esm/capabilities/permissions/index.js +1 -1
  9. package/dist/esm/capabilities/permissions/index.js.map +1 -1
  10. package/dist/esm/capabilities/permissions/mav2.d.ts +2 -2
  11. package/dist/esm/capabilities/permissions/mav2.js +1 -1
  12. package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
  13. package/dist/esm/client/actions/createAccount.d.ts +27 -2
  14. package/dist/esm/client/actions/createAccount.js +25 -0
  15. package/dist/esm/client/actions/createAccount.js.map +1 -1
  16. package/dist/esm/client/actions/getCallsStatus.d.ts +21 -2
  17. package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
  18. package/dist/esm/client/actions/grantPermissions.d.ts +60 -2
  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 +23 -4
  26. package/dist/esm/client/actions/requestAccount.js +16 -5
  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 +23 -3
  32. package/dist/esm/client/actions/signMessage.js +5 -3
  33. package/dist/esm/client/actions/signMessage.js.map +1 -1
  34. package/dist/esm/client/actions/signSignatureRequest.d.ts +32 -1
  35. package/dist/esm/client/actions/signSignatureRequest.js +2 -2
  36. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  37. package/dist/esm/client/actions/signTypedData.d.ts +36 -3
  38. package/dist/esm/client/actions/signTypedData.js +4 -2
  39. package/dist/esm/client/actions/signTypedData.js.map +1 -1
  40. package/dist/esm/client/client.e2e-test.js +101 -13
  41. package/dist/esm/client/client.e2e-test.js.map +1 -1
  42. package/dist/esm/client/decorator.d.ts +14 -12
  43. package/dist/esm/client/decorator.js +10 -10
  44. package/dist/esm/client/decorator.js.map +1 -1
  45. package/dist/esm/client/index.d.ts +5 -5
  46. package/dist/esm/client/index.js +32 -6
  47. package/dist/esm/client/index.js.map +1 -1
  48. package/dist/esm/exports/index.d.ts +14 -13
  49. package/dist/esm/exports/index.js +14 -13
  50. package/dist/esm/exports/index.js.map +1 -1
  51. package/dist/esm/exports/internal.d.ts +13 -13
  52. package/dist/esm/exports/internal.js +11 -11
  53. package/dist/esm/exports/internal.js.map +1 -1
  54. package/dist/esm/internal/decorator.d.ts +2 -0
  55. package/dist/esm/internal/decorator.js +10 -0
  56. package/dist/esm/internal/decorator.js.map +1 -0
  57. package/dist/esm/isomorphic/actions/createSession.d.ts +3 -3
  58. package/dist/esm/isomorphic/actions/createSession.js +5 -5
  59. package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
  60. package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +2 -2
  61. package/dist/esm/isomorphic/actions/getCallsStatus.js +3 -3
  62. package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
  63. package/dist/esm/isomorphic/actions/prepareCalls.d.ts +2 -2
  64. package/dist/esm/isomorphic/actions/prepareCalls.js +2 -2
  65. package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
  66. package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +2 -2
  67. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +2 -2
  68. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
  69. package/dist/esm/isomorphic/client.d.ts +6 -6
  70. package/dist/esm/isomorphic/client.js +4 -4
  71. package/dist/esm/isomorphic/client.js.map +1 -1
  72. package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -2
  73. package/dist/esm/isomorphic/utils/createAccount.js +1 -1
  74. package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
  75. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +4 -4
  76. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +1 -1
  77. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
  78. package/dist/esm/local/client.d.ts +1 -1
  79. package/dist/esm/local/client.js +12 -5
  80. package/dist/esm/local/client.js.map +1 -1
  81. package/dist/esm/remote/client.d.ts +1 -1
  82. package/dist/esm/remote/client.js +9 -4
  83. package/dist/esm/remote/client.js.map +1 -1
  84. package/dist/esm/rpc/request.js +3 -3
  85. package/dist/esm/rpc/request.js.map +1 -1
  86. package/dist/esm/rpc/schema.d.ts +1 -1
  87. package/dist/esm/rpc/schema.js +1 -1
  88. package/dist/esm/rpc/schema.js.map +1 -1
  89. package/dist/esm/types.d.ts +15 -4
  90. package/dist/esm/types.js.map +1 -1
  91. package/dist/types/abi/index.d.ts +8 -8
  92. package/dist/types/abi/index.d.ts.map +1 -1
  93. package/dist/types/capabilities/permissions/mav2.d.ts +2 -2
  94. package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -1
  95. package/dist/types/client/actions/createAccount.d.ts +27 -2
  96. package/dist/types/client/actions/createAccount.d.ts.map +1 -1
  97. package/dist/types/client/actions/getCallsStatus.d.ts +21 -2
  98. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  99. package/dist/types/client/actions/grantPermissions.d.ts +60 -2
  100. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  101. package/dist/types/client/actions/listAccounts.d.ts +26 -2
  102. package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
  103. package/dist/types/client/actions/prepareCalls.d.ts +28 -2
  104. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  105. package/dist/types/client/actions/requestAccount.d.ts +23 -4
  106. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  107. package/dist/types/client/actions/sendPreparedCalls.d.ts +39 -2
  108. package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
  109. package/dist/types/client/actions/signMessage.d.ts +23 -3
  110. package/dist/types/client/actions/signMessage.d.ts.map +1 -1
  111. package/dist/types/client/actions/signSignatureRequest.d.ts +32 -1
  112. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  113. package/dist/types/client/actions/signTypedData.d.ts +36 -3
  114. package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
  115. package/dist/types/client/decorator.d.ts +14 -12
  116. package/dist/types/client/decorator.d.ts.map +1 -1
  117. package/dist/types/client/index.d.ts +5 -5
  118. package/dist/types/client/index.d.ts.map +1 -1
  119. package/dist/types/exports/index.d.ts +14 -13
  120. package/dist/types/exports/index.d.ts.map +1 -1
  121. package/dist/types/exports/internal.d.ts +13 -13
  122. package/dist/types/exports/internal.d.ts.map +1 -1
  123. package/dist/types/internal/decorator.d.ts +3 -0
  124. package/dist/types/internal/decorator.d.ts.map +1 -0
  125. package/dist/types/isomorphic/actions/createSession.d.ts +3 -3
  126. package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
  127. package/dist/types/isomorphic/actions/getCallsStatus.d.ts +2 -2
  128. package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -1
  129. package/dist/types/isomorphic/actions/prepareCalls.d.ts +2 -2
  130. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
  131. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +2 -2
  132. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
  133. package/dist/types/isomorphic/client.d.ts +6 -6
  134. package/dist/types/isomorphic/client.d.ts.map +1 -1
  135. package/dist/types/isomorphic/utils/createAccount.d.ts +2 -2
  136. package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
  137. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +4 -4
  138. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
  139. package/dist/types/local/client.d.ts +1 -1
  140. package/dist/types/local/client.d.ts.map +1 -1
  141. package/dist/types/remote/client.d.ts +1 -1
  142. package/dist/types/remote/client.d.ts.map +1 -1
  143. package/dist/types/rpc/schema.d.ts +1 -1
  144. package/dist/types/types.d.ts +15 -4
  145. package/dist/types/types.d.ts.map +1 -1
  146. package/package.json +14 -7
  147. package/src/abi/index.ts +8 -8
  148. package/src/capabilities/index.ts +3 -3
  149. package/src/capabilities/overrides.ts +1 -1
  150. package/src/capabilities/permissions/index.ts +1 -1
  151. package/src/capabilities/permissions/mav2.ts +3 -3
  152. package/src/client/actions/createAccount.ts +27 -2
  153. package/src/client/actions/getCallsStatus.ts +21 -2
  154. package/src/client/actions/grantPermissions.ts +60 -2
  155. package/src/client/actions/listAccounts.ts +26 -2
  156. package/src/client/actions/prepareCalls.ts +28 -2
  157. package/src/client/actions/requestAccount.ts +44 -9
  158. package/src/client/actions/sendPreparedCalls.ts +39 -2
  159. package/src/client/actions/signMessage.ts +26 -6
  160. package/src/client/actions/signSignatureRequest.ts +33 -2
  161. package/src/client/actions/signTypedData.ts +41 -5
  162. package/src/client/client.e2e-test.ts +122 -13
  163. package/src/client/decorator.ts +25 -27
  164. package/src/client/index.ts +47 -13
  165. package/src/exports/index.ts +14 -13
  166. package/src/exports/internal.ts +13 -13
  167. package/src/internal/decorator.ts +12 -0
  168. package/src/isomorphic/actions/createSession.ts +15 -15
  169. package/src/isomorphic/actions/getCallsStatus.ts +6 -6
  170. package/src/isomorphic/actions/prepareCalls.ts +4 -4
  171. package/src/isomorphic/actions/sendPreparedCalls.ts +4 -4
  172. package/src/isomorphic/client.ts +8 -5
  173. package/src/isomorphic/utils/createAccount.ts +3 -3
  174. package/src/isomorphic/utils/parsePermissionsContext.ts +3 -3
  175. package/src/local/client.ts +56 -46
  176. package/src/remote/client.ts +13 -8
  177. package/src/rpc/request.ts +3 -3
  178. package/src/rpc/schema.ts +1 -1
  179. package/src/types.ts +18 -4
@@ -1,11 +1,13 @@
1
+ import {} from "@aa-sdk/core";
1
2
  import { Value } from "@sinclair/typebox/value";
3
+ import deepEqual from "deep-equal";
2
4
  import { custom } from "viem";
3
- import { createAccount } from "../../isomorphic/utils/createAccount";
4
- import { TypeSerializedInitcode } from "../../schemas";
5
+ import { createAccount } from "../../isomorphic/utils/createAccount.js";
6
+ import { TypeSerializedInitcode } from "../../schemas.js";
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({
29
+ const account = await createAccount({
21
30
  accountAddress: 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,sCAAsC,CAAC;AAErE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AA+BvD,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\";\nimport type { wallet_requestAccount } from \"../../rpc/request\";\nimport { TypeSerializedInitcode } from \"../../schemas\";\nimport type { InnerWalletApiClient } from \"../../types\";\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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AAsB,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 deepEqual from \"deep-equal\";\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 > & { accountAddress?: Address }\n : never;\n\n// TODO: this could be more specific potentially :shrug:\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: 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
- import { type Address, type Hex, type JsonRpcAccount, type SignableMessage } from "viem";
2
- import type { InnerWalletApiClient } from "../../types";
3
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
4
- export type SignMessageParams = SignableMessage;
2
+ import { type Address, type Hex, type JsonRpcAccount, type SignableMessage } from "viem";
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
- import { requestAccount } from "./requestAccount";
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":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAgBlD,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 {\n type Address,\n type Hex,\n type JsonRpcAccount,\n type SignableMessage,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types\";\nimport type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { requestAccount } from \"./requestAccount\";\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"]}
@@ -1,10 +1,41 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import type { Static } from "@sinclair/typebox";
3
3
  import { type Hex } from "viem";
4
- import { TypeSignatureRequest } from "../../schemas";
4
+ import { TypeSignatureRequest } from "../../schemas.js";
5
5
  export type SignSignatureRequestParams = Static<typeof TypeSignatureRequest>;
6
6
  export type SignSignatureRequestResult = {
7
7
  type: "ecdsa";
8
8
  signature: Hex;
9
9
  };
10
+ /**
11
+ * Signs a signature request using the provided signer.
12
+ * This method handles different types of signature requests including personal_sign and eth_signTypedData_v4.
13
+ *
14
+ * @param {SmartAccountSigner} signer - The signer to use for signing the request
15
+ * @param {SignSignatureRequestParams} params - The signature request parameters
16
+ * @param {string} params.type - The type of signature request ('personal_sign' or 'eth_signTypedData_v4')
17
+ * @param {any} params.data - The data to sign, format depends on the signature type
18
+ * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
19
+ * @returns {string} result.type - The signature type (currently only 'ecdsa' is supported)
20
+ * @returns {Hex} result.signature - The hex-encoded signature
21
+ *
22
+ * @example
23
+ * // Sign a personal message
24
+ * const result = await client.signSignatureRequest({
25
+ * type: 'personal_sign',
26
+ * data: 'Hello, world!'
27
+ * });
28
+ *
29
+ * @example
30
+ * // Sign typed data (EIP-712)
31
+ * const result = await client.signSignatureRequest({
32
+ * type: 'eth_signTypedData_v4',
33
+ * data: {
34
+ * domain: { ... },
35
+ * types: { ... },
36
+ * primaryType: '...',
37
+ * message: { ... }
38
+ * }
39
+ * });
40
+ */
10
41
  export declare function signSignatureRequest(signer: SmartAccountSigner, params: SignSignatureRequestParams): Promise<SignSignatureRequestResult>;
@@ -1,6 +1,6 @@
1
1
  import {} from "viem";
2
- import { TypeSignatureRequest } from "../../schemas";
3
- import { assertNever } from "../../utils";
2
+ import { TypeSignatureRequest } from "../../schemas.js";
3
+ import { assertNever } from "../../utils.js";
4
4
  export async function signSignatureRequest(signer, params) {
5
5
  const signature = params.type === "personal_sign"
6
6
  ? await signer.signMessage(params.data)
@@ -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,eAAe,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAc1C,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\";\nimport { assertNever } from \"../../utils\";\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,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA6C7C,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\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' or 'eth_signTypedData_v4')\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 *\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 return {\n type: \"ecdsa\",\n signature,\n };\n}\n"]}
@@ -1,6 +1,39 @@
1
- import { type Address, type Hex, type JsonRpcAccount, type TypedDataDefinition } from "viem";
2
- import type { InnerWalletApiClient } from "../../types";
3
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
4
- export type SignTypedDataParams = TypedDataDefinition;
2
+ import { type Address, type Hex, type JsonRpcAccount, type TypedDataDefinition } from "viem";
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
- import { requestAccount } from "./requestAccount";
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":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAgBlD,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 {\n type Address,\n type Hex,\n type JsonRpcAccount,\n type TypedDataDefinition,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types\";\nimport type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { requestAccount } from \"./requestAccount\";\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"]}
@@ -2,8 +2,8 @@ import { LocalAccountSigner } from "@aa-sdk/core";
2
2
  import { alchemy, arbitrumSepolia } from "@account-kit/infra";
3
3
  import { describe, expect, it } from "bun:test";
4
4
  import { createPublicClient, zeroAddress } from "viem";
5
- import { createSmartWalletClient } from ".";
6
- import { signSignatureRequest } from "./actions/signSignatureRequest";
5
+ import { signSignatureRequest } from "./actions/signSignatureRequest.js";
6
+ import { createSmartWalletClient } from "./index.js";
7
7
  describe("Client E2E Tests", () => {
8
8
  const transport = alchemy(process.env.ALCHEMY_PROXY_RPC_URL
9
9
  ? {
@@ -24,6 +24,21 @@ describe("Client E2E Tests", () => {
24
24
  chain: arbitrumSepolia,
25
25
  transport,
26
26
  });
27
+ it("should successfully request account with different salt", async () => {
28
+ const account = await client.requestAccount({
29
+ id: "2d00c64e-2e55-4925-832e-e288dbf1139e",
30
+ creationHint: { salt: "0x1" },
31
+ });
32
+ expect(account.address).toMatchInlineSnapshot(`"0x569bCECaC47Ef9706c4b2370f2891bccd4cdE30c"`);
33
+ });
34
+ it("should not cache account if different inputs provided", async () => {
35
+ const account = await client.requestAccount();
36
+ const account2 = await client.requestAccount({
37
+ id: "2d00c64e-2e55-4925-832e-e288dbf1139e",
38
+ creationHint: { salt: "0x1" },
39
+ });
40
+ expect(account.address).not.toEqual(account2.address);
41
+ });
27
42
  it("should successfully get a counterfactual address", async () => {
28
43
  const account = await client.requestAccount();
29
44
  expect(account.address).toMatchInlineSnapshot(`"0x26809de7733F9CcB5c0c61210a4f78d6F1daFc58"`);
@@ -31,14 +46,10 @@ describe("Client E2E Tests", () => {
31
46
  it("can correctly sign a message", async () => {
32
47
  const account = await client.requestAccount();
33
48
  const message = "hello world";
34
- const signature = await client.signMessage(message);
35
- const publicClient = createPublicClient({
36
- chain: arbitrumSepolia,
37
- transport,
38
- });
49
+ const signature = await client.signMessage({ message });
39
50
  const isValid = await publicClient.verifyMessage({
40
51
  address: account.address,
41
- message: "hello world",
52
+ message,
42
53
  signature,
43
54
  });
44
55
  expect(isValid).toBeTrue();
@@ -53,6 +64,39 @@ describe("Client E2E Tests", () => {
53
64
  });
54
65
  expect(isValid).toBeTrue();
55
66
  });
67
+ it("can correctly sign a message with a different account", async () => {
68
+ const account = await client.requestAccount({
69
+ id: "2d00c64e-2e55-4925-832e-e288dbf1139e",
70
+ creationHint: { salt: "0x1" },
71
+ });
72
+ const message = "hello world";
73
+ const signature = await client.signMessage({
74
+ message,
75
+ account: account.address,
76
+ });
77
+ const isValid = await publicClient.verifyMessage({
78
+ address: account.address,
79
+ message,
80
+ signature,
81
+ });
82
+ expect(isValid).toBeTrue();
83
+ });
84
+ it("can correctly sign typed data with a different account", async () => {
85
+ const account = await client.requestAccount({
86
+ id: "2d00c64e-2e55-4925-832e-e288dbf1139e",
87
+ creationHint: { salt: "0x1" },
88
+ });
89
+ const signature = await client.signTypedData({
90
+ ...givenTypedData,
91
+ account: account.address,
92
+ });
93
+ const isValid = await publicClient.verifyTypedData({
94
+ ...givenTypedData,
95
+ signature,
96
+ address: account.address,
97
+ });
98
+ expect(isValid).toBeTrue();
99
+ });
56
100
  it("should successfully send a UO with paymaster", async () => {
57
101
  const account = await client.requestAccount();
58
102
  const preparedUO = await client.prepareCalls({
@@ -126,14 +170,25 @@ describe("Client E2E Tests", () => {
126
170
  const account = await client.requestAccount();
127
171
  expect(account.address).toMatchInlineSnapshot(`"0x65b5DE0251f553B2208762a4724303E750294D96"`);
128
172
  });
173
+ it("should successfully request account with different salt", async () => {
174
+ const account = await client.requestAccount({
175
+ id: "8670d2d8-2781-49e9-a75c-1eb980271ca9",
176
+ creationHint: { salt: "0x1" },
177
+ });
178
+ expect(account.address).toMatchInlineSnapshot(`"0xC9B8271E44f14be83CecfDE1dDb325e9fa15e9Ff"`);
179
+ });
180
+ it("should not cache account if different inputs provided", async () => {
181
+ const account = await client.requestAccount();
182
+ const account2 = await client.requestAccount({
183
+ id: "8670d2d8-2781-49e9-a75c-1eb980271ca9",
184
+ creationHint: { salt: "0x1" },
185
+ });
186
+ expect(account.address).not.toEqual(account2.address);
187
+ });
129
188
  it("can correctly sign a message", async () => {
130
189
  const account = await client.requestAccount();
131
190
  const message = "hello world";
132
- const signature = await client.signMessage(message);
133
- const publicClient = createPublicClient({
134
- chain: arbitrumSepolia,
135
- transport,
136
- });
191
+ const signature = await client.signMessage({ message });
137
192
  const isValid = await publicClient.verifyMessage({
138
193
  address: account.address,
139
194
  message: "hello world",
@@ -151,6 +206,39 @@ describe("Client E2E Tests", () => {
151
206
  });
152
207
  expect(isValid).toBeTrue();
153
208
  });
209
+ it("can correctly sign a message with a different account", async () => {
210
+ const account = await client.requestAccount({
211
+ id: "8670d2d8-2781-49e9-a75c-1eb980271ca9",
212
+ creationHint: { salt: "0x1" },
213
+ });
214
+ const message = "hello world";
215
+ const signature = await client.signMessage({
216
+ message,
217
+ account: account.address,
218
+ });
219
+ const isValid = await publicClient.verifyMessage({
220
+ address: account.address,
221
+ message: "hello world",
222
+ signature,
223
+ });
224
+ expect(isValid).toBeTrue();
225
+ });
226
+ it("can correctly sign typed data with a different account", async () => {
227
+ const account = await client.requestAccount({
228
+ id: "8670d2d8-2781-49e9-a75c-1eb980271ca9",
229
+ creationHint: { salt: "0x1" },
230
+ });
231
+ const signature = await client.signTypedData({
232
+ ...givenTypedData,
233
+ account: account.address,
234
+ });
235
+ const isValid = await publicClient.verifyTypedData({
236
+ ...givenTypedData,
237
+ signature,
238
+ address: account.address,
239
+ });
240
+ expect(isValid).toBeTrue();
241
+ });
154
242
  it("should successfully send a UO with paymaster", async () => {
155
243
  const account = await client.requestAccount();
156
244
  const preparedUO = await client.prepareCalls({
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"@aa-sdk/core\";\nimport { alchemy, arbitrumSepolia } from \"@account-kit/infra\";\nimport { describe, expect, it } from \"bun:test\";\nimport { createPublicClient, zeroAddress, type Address } from \"viem\";\nimport { createSmartWalletClient } from \".\";\nimport { signSignatureRequest } from \"./actions/signSignatureRequest\";\n\ndescribe(\"Client E2E Tests\", () => {\n const transport = alchemy(\n process.env.ALCHEMY_PROXY_RPC_URL\n ? {\n rpcUrl: process.env.ALCHEMY_PROXY_RPC_URL,\n }\n : {\n apiKey: process.env.TEST_ALCHEMY_API_KEY!,\n },\n );\n describe(\"Local Mode Tests\", () => {\n const signer = LocalAccountSigner.privateKeyToAccountSigner(\n \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff81\",\n );\n\n const client = createSmartWalletClient({\n transport,\n chain: arbitrumSepolia,\n mode: \"local\",\n signer,\n });\n\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n\n it(\"should successfully get a counterfactual address\", async () => {\n const account = await client.requestAccount();\n expect(account.address).toMatchInlineSnapshot(\n `\"0x26809de7733F9CcB5c0c61210a4f78d6F1daFc58\"`,\n );\n });\n\n it(\"can correctly sign a message\", async () => {\n const account = await client.requestAccount();\n const message = \"hello world\";\n const signature = await client.signMessage(message);\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message: \"hello world\",\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data\", async () => {\n const account = await client.requestAccount();\n const signature = await client.signTypedData(givenTypedData);\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"should successfully send a UO with paymaster\", async () => {\n const account = await client.requestAccount();\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n },\n });\n\n if (preparedUO.signatureRequest.type !== \"personal_sign\") {\n throw new Error(\"Invalid signature request type\");\n }\n\n const signature = await signer.signMessage(\n preparedUO.signatureRequest.data,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature: {\n type: \"ecdsa\",\n signature,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n\n it(\"should successfully create a session with grantPermissions and send a UO\", async () => {\n const account = await client.requestAccount();\n\n const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n\n const permissions = await client.grantPermissions({\n account: account.address,\n expiry: Math.floor(Date.now() / 1000) + 60 * 60,\n key: {\n publicKey: await sessionKey.getAddress(),\n type: \"secp256k1\",\n },\n permissions: [{ type: \"root\" }],\n });\n\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n permissions,\n },\n });\n\n const signature = await signSignatureRequest(\n sessionKey,\n preparedUO.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature,\n capabilities: {\n permissions,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n });\n\n describe(\"Remote Mode Tests\", () => {\n const signer = LocalAccountSigner.privateKeyToAccountSigner(\n \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\",\n );\n\n const client = createSmartWalletClient({\n transport,\n chain: arbitrumSepolia,\n mode: \"remote\",\n signer,\n });\n\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n\n it(\"should successfully get a counterfactual address\", async () => {\n const account = await client.requestAccount();\n expect(account.address).toMatchInlineSnapshot(\n `\"0x65b5DE0251f553B2208762a4724303E750294D96\"`,\n );\n });\n\n it(\"can correctly sign a message\", async () => {\n const account = await client.requestAccount();\n const message = \"hello world\";\n const signature = await client.signMessage(message);\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message: \"hello world\",\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data\", async () => {\n const account = await client.requestAccount();\n const signature = await client.signTypedData(givenTypedData);\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"should successfully send a UO with paymaster\", async () => {\n const account = await client.requestAccount();\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n },\n });\n\n const signature = await client.signSignatureRequest(\n preparedUO.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature,\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n\n it(\"should successfully create a session with grantPermissions and send a UO\", async () => {\n const account = await client.requestAccount();\n\n const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n\n const permissions = await client.grantPermissions({\n account: account.address,\n expiry: Math.floor(Date.now() / 1000) + 60 * 60,\n key: {\n publicKey: await sessionKey.getAddress(),\n type: \"secp256k1\",\n },\n permissions: [{ type: \"root\" }],\n });\n\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n permissions,\n },\n });\n\n const signature = await signSignatureRequest(\n sessionKey,\n preparedUO.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature,\n capabilities: {\n permissions,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n });\n\n const givenTypedData = {\n types: {\n Person: [\n { name: \"name\", type: \"string\" },\n { name: \"wallet\", type: \"address\" },\n ],\n Mail: [\n { name: \"from\", type: \"Person\" },\n { name: \"to\", type: \"Person\" },\n { name: \"contents\", type: \"string\" },\n ],\n },\n primaryType: \"Mail\" as const,\n domain: {\n name: \"Ether Mail\",\n version: \"1\",\n chainId: 1,\n verifyingContract:\n \"0xbbc68f94D29d52EE8D4994E54d6ED0fEAeb99C2c\" as Address,\n },\n message: {\n from: {\n name: \"Alice\",\n wallet: \"0xFC24e57486116026740634F629ffC4E5C95A6893\",\n },\n to: {\n name: \"Bob\",\n wallet: \"0xe7a26f006EAA562308C5df235C02BFB9a5849177\",\n },\n contents: \"Hello, Bob!\",\n },\n } as const;\n});\n"]}
1
+ {"version":3,"file":"client.e2e-test.js","sourceRoot":"","sources":["../../../src/client/client.e2e-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAgB,MAAM,MAAM,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,SAAS,GAAG,OAAO,CACvB,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC/B,CAAC,CAAC;YACE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;SAC1C;QACH,CAAC,CAAC;YACE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;SAC1C,CACN,CAAC;IACF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,MAAM,GAAG,kBAAkB,CAAC,yBAAyB,CACzD,oEAAoE,CACrE,CAAC;QAEF,MAAM,MAAM,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E,4CAA4C;aACrD;YACD,EAAE,EAAE;gBACF,IAAI,EAAE,KAAK;gBACX,MAAM,EAAE,4CAA4C;aACrD;YACD,QAAQ,EAAE,aAAa;SACxB;KACO,CAAC;AACb,CAAC,CAAC,CAAC","sourcesContent":["import { LocalAccountSigner } from \"@aa-sdk/core\";\nimport { alchemy, arbitrumSepolia } from \"@account-kit/infra\";\nimport { describe, expect, it } from \"bun:test\";\nimport { createPublicClient, zeroAddress, type Address } from \"viem\";\nimport { signSignatureRequest } from \"./actions/signSignatureRequest.js\";\nimport { createSmartWalletClient } from \"./index.js\";\n\ndescribe(\"Client E2E Tests\", () => {\n const transport = alchemy(\n process.env.ALCHEMY_PROXY_RPC_URL\n ? {\n rpcUrl: process.env.ALCHEMY_PROXY_RPC_URL,\n }\n : {\n apiKey: process.env.TEST_ALCHEMY_API_KEY!,\n },\n );\n describe(\"Local Mode Tests\", () => {\n const signer = LocalAccountSigner.privateKeyToAccountSigner(\n \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff81\",\n );\n\n const client = createSmartWalletClient({\n transport,\n chain: arbitrumSepolia,\n mode: \"local\",\n signer,\n });\n\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n\n it(\"should successfully request account with different salt\", async () => {\n const account = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).toMatchInlineSnapshot(\n `\"0x569bCECaC47Ef9706c4b2370f2891bccd4cdE30c\"`,\n );\n });\n\n it(\"should not cache account if different inputs provided\", async () => {\n const account = await client.requestAccount();\n const account2 = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).not.toEqual(account2.address);\n });\n\n it(\"should successfully get a counterfactual address\", async () => {\n const account = await client.requestAccount();\n expect(account.address).toMatchInlineSnapshot(\n `\"0x26809de7733F9CcB5c0c61210a4f78d6F1daFc58\"`,\n );\n });\n\n it(\"can correctly sign a message\", async () => {\n const account = await client.requestAccount();\n const message = \"hello world\";\n const signature = await client.signMessage({ message });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message,\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data\", async () => {\n const account = await client.requestAccount();\n const signature = await client.signTypedData(givenTypedData);\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign a message with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n const message = \"hello world\";\n\n const signature = await client.signMessage({\n message,\n account: account.address,\n });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message,\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"2d00c64e-2e55-4925-832e-e288dbf1139e\",\n creationHint: { salt: \"0x1\" },\n });\n\n const signature = await client.signTypedData({\n ...givenTypedData,\n account: account.address,\n });\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"should successfully send a UO with paymaster\", async () => {\n const account = await client.requestAccount();\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n },\n });\n\n if (preparedUO.signatureRequest.type !== \"personal_sign\") {\n throw new Error(\"Invalid signature request type\");\n }\n\n const signature = await signer.signMessage(\n preparedUO.signatureRequest.data,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature: {\n type: \"ecdsa\",\n signature,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n\n it(\"should successfully create a session with grantPermissions and send a UO\", async () => {\n const account = await client.requestAccount();\n\n const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n\n const permissions = await client.grantPermissions({\n account: account.address,\n expiry: Math.floor(Date.now() / 1000) + 60 * 60,\n key: {\n publicKey: await sessionKey.getAddress(),\n type: \"secp256k1\",\n },\n permissions: [{ type: \"root\" }],\n });\n\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n permissions,\n },\n });\n\n const signature = await signSignatureRequest(\n sessionKey,\n preparedUO.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature,\n capabilities: {\n permissions,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n });\n\n describe(\"Remote Mode Tests\", () => {\n const signer = LocalAccountSigner.privateKeyToAccountSigner(\n \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\",\n );\n\n const client = createSmartWalletClient({\n transport,\n chain: arbitrumSepolia,\n mode: \"remote\",\n signer,\n });\n\n const publicClient = createPublicClient({\n chain: arbitrumSepolia,\n transport,\n });\n\n it(\"should successfully get a counterfactual address\", async () => {\n const account = await client.requestAccount();\n expect(account.address).toMatchInlineSnapshot(\n `\"0x65b5DE0251f553B2208762a4724303E750294D96\"`,\n );\n });\n\n it(\"should successfully request account with different salt\", async () => {\n const account = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).toMatchInlineSnapshot(\n `\"0xC9B8271E44f14be83CecfDE1dDb325e9fa15e9Ff\"`,\n );\n });\n\n it(\"should not cache account if different inputs provided\", async () => {\n const account = await client.requestAccount();\n const account2 = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n expect(account.address).not.toEqual(account2.address);\n });\n\n it(\"can correctly sign a message\", async () => {\n const account = await client.requestAccount();\n const message = \"hello world\";\n const signature = await client.signMessage({ message });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message: \"hello world\",\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data\", async () => {\n const account = await client.requestAccount();\n const signature = await client.signTypedData(givenTypedData);\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign a message with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n const message = \"hello world\";\n const signature = await client.signMessage({\n message,\n account: account.address,\n });\n const isValid = await publicClient.verifyMessage({\n address: account.address,\n message: \"hello world\",\n signature,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"can correctly sign typed data with a different account\", async () => {\n const account = await client.requestAccount({\n id: \"8670d2d8-2781-49e9-a75c-1eb980271ca9\",\n creationHint: { salt: \"0x1\" },\n });\n\n const signature = await client.signTypedData({\n ...givenTypedData,\n account: account.address,\n });\n\n const isValid = await publicClient.verifyTypedData({\n ...givenTypedData,\n signature,\n address: account.address,\n });\n expect(isValid).toBeTrue();\n });\n\n it(\"should successfully send a UO with paymaster\", async () => {\n const account = await client.requestAccount();\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n },\n });\n\n const signature = await client.signSignatureRequest(\n preparedUO.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature,\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n\n it(\"should successfully create a session with grantPermissions and send a UO\", async () => {\n const account = await client.requestAccount();\n\n const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n\n const permissions = await client.grantPermissions({\n account: account.address,\n expiry: Math.floor(Date.now() / 1000) + 60 * 60,\n key: {\n publicKey: await sessionKey.getAddress(),\n type: \"secp256k1\",\n },\n permissions: [{ type: \"root\" }],\n });\n\n const preparedUO = await client.prepareCalls({\n calls: [{ to: zeroAddress, value: \"0x0\" }],\n from: account.address,\n capabilities: {\n paymasterService: {\n policyId: process.env.TEST_PAYMASTER_POLICY_ID!,\n },\n permissions,\n },\n });\n\n const signature = await signSignatureRequest(\n sessionKey,\n preparedUO.signatureRequest,\n );\n\n const result = await client.sendPreparedCalls({\n ...preparedUO,\n signature,\n capabilities: {\n permissions,\n },\n });\n\n expect(result.preparedCallIds).toBeArrayOfSize(1);\n });\n });\n\n const givenTypedData = {\n types: {\n Person: [\n { name: \"name\", type: \"string\" },\n { name: \"wallet\", type: \"address\" },\n ],\n Mail: [\n { name: \"from\", type: \"Person\" },\n { name: \"to\", type: \"Person\" },\n { name: \"contents\", type: \"string\" },\n ],\n },\n primaryType: \"Mail\" as const,\n domain: {\n name: \"Ether Mail\",\n version: \"1\",\n chainId: 1,\n verifyingContract:\n \"0xbbc68f94D29d52EE8D4994E54d6ED0fEAeb99C2c\" as Address,\n },\n message: {\n from: {\n name: \"Alice\",\n wallet: \"0xFC24e57486116026740634F629ffC4E5C95A6893\",\n },\n to: {\n name: \"Bob\",\n wallet: \"0xe7a26f006EAA562308C5df235C02BFB9a5849177\",\n },\n contents: \"Hello, Bob!\",\n },\n } as const;\n});\n"]}