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

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 (264) 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/client/actions/createAccount.d.ts +27 -2
  5. package/dist/esm/client/actions/createAccount.js +25 -0
  6. package/dist/esm/client/actions/createAccount.js.map +1 -1
  7. package/dist/esm/client/actions/formatSign.d.ts +28 -0
  8. package/dist/esm/client/actions/formatSign.js +30 -0
  9. package/dist/esm/client/actions/formatSign.js.map +1 -0
  10. package/dist/esm/client/actions/getCallsStatus.d.ts +22 -4
  11. package/dist/esm/client/actions/getCallsStatus.js +19 -0
  12. package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
  13. package/dist/esm/client/actions/grantPermissions.d.ts +63 -6
  14. package/dist/esm/client/actions/grantPermissions.js +63 -3
  15. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  16. package/dist/esm/client/actions/listAccounts.d.ts +32 -4
  17. package/dist/esm/client/actions/listAccounts.js +35 -2
  18. package/dist/esm/client/actions/listAccounts.js.map +1 -1
  19. package/dist/esm/client/actions/prepareCalls.d.ts +32 -6
  20. package/dist/esm/client/actions/prepareCalls.js +39 -5
  21. package/dist/esm/client/actions/prepareCalls.js.map +1 -1
  22. package/dist/esm/client/actions/prepareSign.d.ts +25 -0
  23. package/dist/esm/client/actions/prepareSign.js +28 -0
  24. package/dist/esm/client/actions/prepareSign.js.map +1 -0
  25. package/dist/esm/client/actions/requestAccount.d.ts +25 -7
  26. package/dist/esm/client/actions/requestAccount.js +39 -8
  27. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  28. package/dist/esm/client/actions/sendPreparedCalls.d.ts +33 -4
  29. package/dist/esm/client/actions/sendPreparedCalls.js +37 -1
  30. package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
  31. package/dist/esm/client/actions/signMessage.d.ts +25 -5
  32. package/dist/esm/client/actions/signMessage.js +23 -3
  33. package/dist/esm/client/actions/signMessage.js.map +1 -1
  34. package/dist/esm/client/actions/signPreparedCalls.d.ts +14 -0
  35. package/dist/esm/client/actions/signPreparedCalls.js +43 -0
  36. package/dist/esm/client/actions/signPreparedCalls.js.map +1 -0
  37. package/dist/esm/client/actions/signSignatureRequest.d.ts +39 -5
  38. package/dist/esm/client/actions/signSignatureRequest.js +70 -12
  39. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  40. package/dist/esm/client/actions/signTypedData.d.ts +37 -4
  41. package/dist/esm/client/actions/signTypedData.js +35 -2
  42. package/dist/esm/client/actions/signTypedData.js.map +1 -1
  43. package/dist/esm/client/client.e2e-test.js +211 -46
  44. package/dist/esm/client/client.e2e-test.js.map +1 -1
  45. package/dist/esm/client/decorator.d.ts +19 -15
  46. package/dist/esm/client/decorator.js +13 -11
  47. package/dist/esm/client/decorator.js.map +1 -1
  48. package/dist/esm/client/index.d.ts +39 -13
  49. package/dist/esm/client/index.js +3 -6
  50. package/dist/esm/client/index.js.map +1 -1
  51. package/dist/esm/exports/index.d.ts +12 -13
  52. package/dist/esm/exports/index.js +12 -14
  53. package/dist/esm/exports/index.js.map +1 -1
  54. package/dist/esm/exports/internal.d.ts +4 -13
  55. package/dist/esm/exports/internal.js +2 -14
  56. package/dist/esm/exports/internal.js.map +1 -1
  57. package/dist/esm/internal/decorator.d.ts +2 -0
  58. package/dist/esm/internal/decorator.js +10 -0
  59. package/dist/esm/internal/decorator.js.map +1 -0
  60. package/dist/esm/isomorphic/actions/createSession.d.ts +2 -3
  61. package/dist/esm/isomorphic/actions/createSession.js +41 -12
  62. package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
  63. package/dist/esm/isomorphic/actions/formatSign.d.ts +8 -0
  64. package/dist/esm/isomorphic/actions/formatSign.js +42 -0
  65. package/dist/esm/isomorphic/actions/formatSign.js.map +1 -0
  66. package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +1 -15
  67. package/dist/esm/isomorphic/actions/getCallsStatus.js +39 -28
  68. package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
  69. package/dist/esm/isomorphic/actions/prepareCalls.d.ts +1 -2
  70. package/dist/esm/isomorphic/actions/prepareCalls.js +80 -22
  71. package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
  72. package/dist/esm/isomorphic/actions/prepareSign.d.ts +7 -0
  73. package/dist/esm/isomorphic/actions/prepareSign.js +49 -0
  74. package/dist/esm/isomorphic/actions/prepareSign.js.map +1 -0
  75. package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +3 -4
  76. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +138 -25
  77. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
  78. package/dist/esm/isomorphic/client.d.ts +209 -32
  79. package/dist/esm/isomorphic/client.js +10 -6
  80. package/dist/esm/isomorphic/client.js.map +1 -1
  81. package/dist/esm/isomorphic/utils/7702.d.ts +19 -0
  82. package/dist/esm/isomorphic/utils/7702.js +70 -0
  83. package/dist/esm/isomorphic/utils/7702.js.map +1 -0
  84. package/dist/esm/isomorphic/utils/createAccount.d.ts +5 -4
  85. package/dist/esm/isomorphic/utils/createAccount.js +85 -11
  86. package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
  87. package/dist/esm/isomorphic/utils/createDummySigner.js +3 -3
  88. package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -1
  89. package/dist/esm/isomorphic/utils/decodeSignature.d.ts +3 -0
  90. package/dist/esm/isomorphic/utils/decodeSignature.js +15 -0
  91. package/dist/esm/isomorphic/utils/decodeSignature.js.map +1 -0
  92. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +6 -5
  93. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +19 -6
  94. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
  95. package/dist/esm/isomorphic/utils/supportsFeature.d.ts +4 -0
  96. package/dist/esm/isomorphic/utils/supportsFeature.js +21 -0
  97. package/dist/esm/isomorphic/utils/supportsFeature.js.map +1 -0
  98. package/dist/esm/local/client.d.ts +3 -3
  99. package/dist/esm/local/client.js +14 -7
  100. package/dist/esm/local/client.js.map +1 -1
  101. package/dist/esm/remote/client.d.ts +9 -3
  102. package/dist/esm/remote/client.js +11 -12
  103. package/dist/esm/remote/client.js.map +1 -1
  104. package/dist/esm/types.d.ts +27 -13
  105. package/dist/esm/types.js.map +1 -1
  106. package/dist/esm/utils.d.ts +1 -0
  107. package/dist/esm/utils.js.map +1 -1
  108. package/dist/types/abi/index.d.ts +8 -8
  109. package/dist/types/abi/index.d.ts.map +1 -1
  110. package/dist/types/client/actions/createAccount.d.ts +27 -2
  111. package/dist/types/client/actions/createAccount.d.ts.map +1 -1
  112. package/dist/types/client/actions/formatSign.d.ts +29 -0
  113. package/dist/types/client/actions/formatSign.d.ts.map +1 -0
  114. package/dist/types/client/actions/getCallsStatus.d.ts +22 -4
  115. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  116. package/dist/types/client/actions/grantPermissions.d.ts +63 -6
  117. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  118. package/dist/types/client/actions/listAccounts.d.ts +32 -4
  119. package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
  120. package/dist/types/client/actions/prepareCalls.d.ts +32 -6
  121. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  122. package/dist/types/client/actions/prepareSign.d.ts +26 -0
  123. package/dist/types/client/actions/prepareSign.d.ts.map +1 -0
  124. package/dist/types/client/actions/requestAccount.d.ts +25 -7
  125. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  126. package/dist/types/client/actions/sendPreparedCalls.d.ts +33 -4
  127. package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
  128. package/dist/types/client/actions/signMessage.d.ts +25 -5
  129. package/dist/types/client/actions/signMessage.d.ts.map +1 -1
  130. package/dist/types/client/actions/signPreparedCalls.d.ts +15 -0
  131. package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -0
  132. package/dist/types/client/actions/signSignatureRequest.d.ts +39 -5
  133. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  134. package/dist/types/client/actions/signTypedData.d.ts +37 -4
  135. package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
  136. package/dist/types/client/decorator.d.ts +19 -15
  137. package/dist/types/client/decorator.d.ts.map +1 -1
  138. package/dist/types/client/index.d.ts +39 -13
  139. package/dist/types/client/index.d.ts.map +1 -1
  140. package/dist/types/exports/index.d.ts +12 -13
  141. package/dist/types/exports/index.d.ts.map +1 -1
  142. package/dist/types/exports/internal.d.ts +4 -13
  143. package/dist/types/exports/internal.d.ts.map +1 -1
  144. package/dist/types/internal/decorator.d.ts +3 -0
  145. package/dist/types/internal/decorator.d.ts.map +1 -0
  146. package/dist/types/isomorphic/actions/createSession.d.ts +2 -3
  147. package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
  148. package/dist/types/isomorphic/actions/formatSign.d.ts +9 -0
  149. package/dist/types/isomorphic/actions/formatSign.d.ts.map +1 -0
  150. package/dist/types/isomorphic/actions/getCallsStatus.d.ts +1 -15
  151. package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -1
  152. package/dist/types/isomorphic/actions/prepareCalls.d.ts +1 -2
  153. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
  154. package/dist/types/isomorphic/actions/prepareSign.d.ts +8 -0
  155. package/dist/types/isomorphic/actions/prepareSign.d.ts.map +1 -0
  156. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +3 -4
  157. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
  158. package/dist/types/isomorphic/client.d.ts +209 -32
  159. package/dist/types/isomorphic/client.d.ts.map +1 -1
  160. package/dist/types/isomorphic/utils/7702.d.ts +20 -0
  161. package/dist/types/isomorphic/utils/7702.d.ts.map +1 -0
  162. package/dist/types/isomorphic/utils/createAccount.d.ts +5 -4
  163. package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
  164. package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +1 -1
  165. package/dist/types/isomorphic/utils/decodeSignature.d.ts +4 -0
  166. package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +1 -0
  167. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +6 -5
  168. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
  169. package/dist/types/isomorphic/utils/supportsFeature.d.ts +5 -0
  170. package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +1 -0
  171. package/dist/types/local/client.d.ts +3 -3
  172. package/dist/types/local/client.d.ts.map +1 -1
  173. package/dist/types/remote/client.d.ts +9 -3
  174. package/dist/types/remote/client.d.ts.map +1 -1
  175. package/dist/types/types.d.ts +27 -13
  176. package/dist/types/types.d.ts.map +1 -1
  177. package/dist/types/utils.d.ts +1 -0
  178. package/dist/types/utils.d.ts.map +1 -1
  179. package/package.json +15 -7
  180. package/src/abi/index.ts +8 -8
  181. package/src/client/actions/createAccount.ts +27 -2
  182. package/src/client/actions/formatSign.ts +53 -0
  183. package/src/client/actions/getCallsStatus.ts +21 -12
  184. package/src/client/actions/grantPermissions.ts +69 -26
  185. package/src/client/actions/listAccounts.ts +44 -6
  186. package/src/client/actions/prepareCalls.ts +46 -26
  187. package/src/client/actions/prepareSign.ts +46 -0
  188. package/src/client/actions/requestAccount.ts +62 -43
  189. package/src/client/actions/sendPreparedCalls.ts +44 -7
  190. package/src/client/actions/signMessage.ts +27 -22
  191. package/src/client/actions/signPreparedCalls.ts +67 -0
  192. package/src/client/actions/signSignatureRequest.ts +85 -21
  193. package/src/client/actions/signTypedData.ts +41 -20
  194. package/src/client/client.e2e-test.ts +257 -55
  195. package/src/client/decorator.ts +41 -39
  196. package/src/client/index.ts +55 -42
  197. package/src/exports/index.ts +13 -21
  198. package/src/exports/internal.ts +5 -13
  199. package/src/internal/decorator.ts +12 -0
  200. package/src/isomorphic/actions/createSession.ts +65 -22
  201. package/src/isomorphic/actions/formatSign.ts +76 -0
  202. package/src/isomorphic/actions/getCallsStatus.ts +49 -35
  203. package/src/isomorphic/actions/prepareCalls.ts +97 -25
  204. package/src/isomorphic/actions/prepareSign.ts +91 -0
  205. package/src/isomorphic/actions/sendPreparedCalls.ts +181 -42
  206. package/src/isomorphic/client.ts +17 -6
  207. package/src/isomorphic/utils/7702.ts +135 -0
  208. package/src/isomorphic/utils/createAccount.ts +102 -14
  209. package/src/isomorphic/utils/createDummySigner.ts +3 -2
  210. package/src/isomorphic/utils/decodeSignature.ts +21 -0
  211. package/src/isomorphic/utils/parsePermissionsContext.ts +29 -11
  212. package/src/isomorphic/utils/supportsFeature.ts +34 -0
  213. package/src/local/client.ts +61 -58
  214. package/src/remote/client.ts +20 -20
  215. package/src/types.ts +29 -23
  216. package/src/utils.ts +2 -0
  217. package/dist/esm/capabilities/index.d.ts +0 -31
  218. package/dist/esm/capabilities/index.js +0 -10
  219. package/dist/esm/capabilities/index.js.map +0 -1
  220. package/dist/esm/capabilities/overrides.d.ts +0 -26
  221. package/dist/esm/capabilities/overrides.js +0 -14
  222. package/dist/esm/capabilities/overrides.js.map +0 -1
  223. package/dist/esm/capabilities/paymaster.d.ts +0 -3
  224. package/dist/esm/capabilities/paymaster.js +0 -5
  225. package/dist/esm/capabilities/paymaster.js.map +0 -1
  226. package/dist/esm/capabilities/permissions/index.d.ts +0 -138
  227. package/dist/esm/capabilities/permissions/index.js +0 -71
  228. package/dist/esm/capabilities/permissions/index.js.map +0 -1
  229. package/dist/esm/capabilities/permissions/mav2.d.ts +0 -36
  230. package/dist/esm/capabilities/permissions/mav2.js +0 -79
  231. package/dist/esm/capabilities/permissions/mav2.js.map +0 -1
  232. package/dist/esm/rpc/request.d.ts +0 -352
  233. package/dist/esm/rpc/request.js +0 -204
  234. package/dist/esm/rpc/request.js.map +0 -1
  235. package/dist/esm/rpc/schema.d.ts +0 -342
  236. package/dist/esm/rpc/schema.js +0 -5
  237. package/dist/esm/rpc/schema.js.map +0 -1
  238. package/dist/esm/schemas.d.ts +0 -216
  239. package/dist/esm/schemas.js +0 -211
  240. package/dist/esm/schemas.js.map +0 -1
  241. package/dist/types/capabilities/index.d.ts +0 -32
  242. package/dist/types/capabilities/index.d.ts.map +0 -1
  243. package/dist/types/capabilities/overrides.d.ts +0 -27
  244. package/dist/types/capabilities/overrides.d.ts.map +0 -1
  245. package/dist/types/capabilities/paymaster.d.ts +0 -4
  246. package/dist/types/capabilities/paymaster.d.ts.map +0 -1
  247. package/dist/types/capabilities/permissions/index.d.ts +0 -139
  248. package/dist/types/capabilities/permissions/index.d.ts.map +0 -1
  249. package/dist/types/capabilities/permissions/mav2.d.ts +0 -37
  250. package/dist/types/capabilities/permissions/mav2.d.ts.map +0 -1
  251. package/dist/types/rpc/request.d.ts +0 -353
  252. package/dist/types/rpc/request.d.ts.map +0 -1
  253. package/dist/types/rpc/schema.d.ts +0 -343
  254. package/dist/types/rpc/schema.d.ts.map +0 -1
  255. package/dist/types/schemas.d.ts +0 -217
  256. package/dist/types/schemas.d.ts.map +0 -1
  257. package/src/capabilities/index.ts +0 -13
  258. package/src/capabilities/overrides.ts +0 -20
  259. package/src/capabilities/paymaster.ts +0 -5
  260. package/src/capabilities/permissions/index.ts +0 -142
  261. package/src/capabilities/permissions/mav2.ts +0 -127
  262. package/src/rpc/request.ts +0 -273
  263. package/src/rpc/schema.ts +0 -40
  264. package/src/schemas.ts +0 -257
@@ -1,15 +1,73 @@
1
- import {} from "viem";
2
- import { TypeSignatureRequest } from "../../schemas";
3
- import { assertNever } from "../../utils";
1
+ import { hexToNumber, serializeSignature } from "viem";
2
+ import { assertNever } from "../../utils.js";
3
+ import {} from "@alchemy/wallet-api-types";
4
+ import { vToYParity } from "ox/Signature";
5
+ /**
6
+ * Signs a signature request using the provided signer.
7
+ * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
8
+ *
9
+ * @param {SmartAccountSigner} signer - The signer to use for signing the request
10
+ * @param {SignSignatureRequestParams} params - The signature request parameters
11
+ * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
12
+ * @param {any} params.data - The data to sign, format depends on the signature type
13
+ * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
14
+ * @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)
15
+ * @returns {Hex} result.signature - The hex-encoded signature
16
+ * @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
17
+ *
18
+ * @example
19
+ * // Sign a personal message
20
+ * const result = await client.signSignatureRequest({
21
+ * type: 'personal_sign',
22
+ * data: 'Hello, world!'
23
+ * });
24
+ *
25
+ * @example
26
+ * // Sign typed data (EIP-712)
27
+ * const result = await client.signSignatureRequest({
28
+ * type: 'eth_signTypedData_v4',
29
+ * data: {
30
+ * domain: { ... },
31
+ * types: { ... },
32
+ * primaryType: '...',
33
+ * message: { ... }
34
+ * }
35
+ * });
36
+ */
4
37
  export async function signSignatureRequest(signer, params) {
5
- const signature = params.type === "personal_sign"
6
- ? await signer.signMessage(params.data)
7
- : params.type === "eth_signTypedData_v4"
8
- ? await signer.signTypedData(params.data)
9
- : assertNever(params, "Unexpected signature request type");
10
- return {
11
- type: "ecdsa",
12
- signature,
13
- };
38
+ switch (params.type) {
39
+ case "personal_sign": {
40
+ return {
41
+ type: "secp256k1",
42
+ data: await signer.signMessage(params.data),
43
+ };
44
+ }
45
+ case "eth_signTypedData_v4": {
46
+ return {
47
+ type: "secp256k1",
48
+ data: await signer.signTypedData(params.data),
49
+ };
50
+ }
51
+ case "eip7702Auth": {
52
+ if (!signer.signAuthorization) {
53
+ throw new Error("Signer does not implement signAuthorization");
54
+ }
55
+ const { r, s, v, yParity } = await signer.signAuthorization({
56
+ ...params.data,
57
+ chainId: hexToNumber(params.data.chainId),
58
+ nonce: hexToNumber(params.data.nonce),
59
+ });
60
+ return {
61
+ type: "secp256k1",
62
+ data: serializeSignature({
63
+ r,
64
+ s,
65
+ yParity: yParity ?? vToYParity(Number(v)),
66
+ }),
67
+ };
68
+ }
69
+ default:
70
+ return assertNever(params, `Unexpected signature request type.`);
71
+ }
14
72
  }
15
73
  //# 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,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":"AACA,OAAO,EAAY,WAAW,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAKN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,MAAkC;IAElC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;aAC5C,CAAC;QACJ,CAAC;QACD,KAAK,sBAAsB,CAAC,CAAC,CAAC;YAC5B,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC;aAC9C,CAAC;QACJ,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;gBAC1D,GAAG,MAAM,CAAC,IAAI;gBACd,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;gBACzC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACtC,CAAC,CAAC;YAEH,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB,CAAC;oBACvB,CAAC;oBACD,CAAC;oBACD,OAAO,EAAE,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;iBAC1C,CAAC;aACH,CAAC;QACJ,CAAC;QACD;YACE,OAAO,WAAW,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Hex, hexToNumber, serializeSignature } from \"viem\";\nimport { assertNever } from \"../../utils.js\";\nimport {\n type TypePersonalSignSignatureRequest,\n type TypeTypedDataSignatureRequest,\n type TypeAuthorizationSignatureRequest,\n type TypeEip7702UnsignedAuth,\n} from \"@alchemy/wallet-api-types\";\nimport { vToYParity } from \"ox/Signature\";\nimport type { WithoutRawPayload } from \"../../types.ts\";\n\nexport type SignSignatureRequestParams = WithoutRawPayload<\n | TypePersonalSignSignatureRequest\n | TypeTypedDataSignatureRequest\n | (TypeAuthorizationSignatureRequest & {\n data: TypeEip7702UnsignedAuth;\n })\n>;\n\nexport type SignSignatureRequestResult = {\n type: \"secp256k1\";\n data: 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, eth_signTypedData_v4, and authorization.\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 'secp256k1' 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 */\n\nexport async function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\n switch (params.type) {\n case \"personal_sign\": {\n return {\n type: \"secp256k1\",\n data: await signer.signMessage(params.data),\n };\n }\n case \"eth_signTypedData_v4\": {\n return {\n type: \"secp256k1\",\n data: await signer.signTypedData(params.data),\n };\n }\n case \"eip7702Auth\": {\n if (!signer.signAuthorization) {\n throw new Error(\"Signer does not implement signAuthorization\");\n }\n const { r, s, v, yParity } = await signer.signAuthorization({\n ...params.data,\n chainId: hexToNumber(params.data.chainId),\n nonce: hexToNumber(params.data.nonce),\n });\n\n return {\n type: \"secp256k1\",\n data: serializeSignature({\n r,\n s,\n yParity: yParity ?? vToYParity(Number(v)),\n }),\n };\n }\n default:\n return assertNever(params, `Unexpected signature request type.`);\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 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;
6
- export declare function signTypedData<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, signer: SmartAccountSigner, params: SignTypedDataParams): Promise<SignTypedDataResult>;
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
+ */
39
+ export declare function signTypedData(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SignTypedDataParams): Promise<SignTypedDataResult>;
@@ -1,7 +1,40 @@
1
1
  import {} from "viem";
2
- import { requestAccount } from "./requestAccount";
2
+ import { requestAccount } from "./requestAccount.js";
3
+ /**
4
+ * Signs typed data (EIP-712) using the smart account.
5
+ * This method requests the account associated with the signer and uses it to sign the typed data.
6
+ *
7
+ * @param {InnerWalletApiClient} client - The wallet API client to use for the request
8
+ * @param {SmartAccountSigner} signer - The signer of the smart account
9
+ * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
10
+ * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
11
+ *
12
+ * @example
13
+ * // Sign typed data
14
+ * const signature = await client.signTypedData({
15
+ * domain: {
16
+ * name: 'Example DApp',
17
+ * version: '1',
18
+ * chainId: 1,
19
+ * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
20
+ * },
21
+ * types: {
22
+ * Person: [
23
+ * { name: 'name', type: 'string' },
24
+ * { name: 'wallet', type: 'address' }
25
+ * ]
26
+ * },
27
+ * primaryType: 'Person',
28
+ * message: {
29
+ * name: 'John Doe',
30
+ * wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'
31
+ * }
32
+ * });
33
+ */
3
34
  export async function signTypedData(client, signer, params) {
4
- const account = await requestAccount(client, signer);
35
+ const account = await requestAccount(client, signer, {
36
+ accountAddress: params.account ?? client.account?.address,
37
+ });
5
38
  return account.signTypedDataWith6492(params);
6
39
  }
7
40
  //# 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,EAAoD,MAAM,MAAM,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,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 { type Address, type Hex, type TypedDataDefinition } 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 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,7 @@ 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 { createSmartWalletClient } from "./index.js";
7
6
  describe("Client E2E Tests", () => {
8
7
  const transport = alchemy(process.env.ALCHEMY_PROXY_RPC_URL
9
8
  ? {
@@ -13,7 +12,7 @@ describe("Client E2E Tests", () => {
13
12
  apiKey: process.env.TEST_ALCHEMY_API_KEY,
14
13
  });
15
14
  describe("Local Mode Tests", () => {
16
- const signer = LocalAccountSigner.privateKeyToAccountSigner("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff81");
15
+ const signer = LocalAccountSigner.privateKeyToAccountSigner("0xbaca22d9b6846ec09a4da378ffa07e2f14ce7d65675d135911b6fd281416bb03");
17
16
  const client = createSmartWalletClient({
18
17
  transport,
19
18
  chain: arbitrumSepolia,
@@ -26,19 +25,30 @@ describe("Client E2E Tests", () => {
26
25
  });
27
26
  it("should successfully get a counterfactual address", async () => {
28
27
  const account = await client.requestAccount();
29
- expect(account.address).toMatchInlineSnapshot(`"0x26809de7733F9CcB5c0c61210a4f78d6F1daFc58"`);
28
+ expect(account.address).toMatchInlineSnapshot(`"0xa46944b7a39c35d931D514ACAc3ac77c226a81ff"`);
29
+ });
30
+ it("should successfully request account with different salt", async () => {
31
+ const account = await client.requestAccount({
32
+ id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
33
+ creationHint: { salt: "0x1" },
34
+ });
35
+ expect(account.address).toMatchInlineSnapshot(`"0xA692f0E5AfAD20F771443D89C635146C6A592f06"`);
36
+ });
37
+ it("should not cache account if different inputs provided", async () => {
38
+ const account = await client.requestAccount();
39
+ const account2 = await client.requestAccount({
40
+ id: "52ab44be-b03e-47ed-ad65-43014ea5fbfc",
41
+ creationHint: { salt: "0x2" },
42
+ });
43
+ expect(account.address).not.toEqual(account2.address);
30
44
  });
31
45
  it("can correctly sign a message", async () => {
32
46
  const account = await client.requestAccount();
33
47
  const message = "hello world";
34
- const signature = await client.signMessage(message);
35
- const publicClient = createPublicClient({
36
- chain: arbitrumSepolia,
37
- transport,
38
- });
48
+ const signature = await client.signMessage({ message });
39
49
  const isValid = await publicClient.verifyMessage({
40
50
  address: account.address,
41
- message: "hello world",
51
+ message,
42
52
  signature,
43
53
  });
44
54
  expect(isValid).toBeTrue();
@@ -53,9 +63,53 @@ describe("Client E2E Tests", () => {
53
63
  });
54
64
  expect(isValid).toBeTrue();
55
65
  });
56
- it("should successfully send a UO with paymaster", async () => {
57
- const account = await client.requestAccount();
58
- const preparedUO = await client.prepareCalls({
66
+ it("can correctly sign a message with a different account", async () => {
67
+ const account = await client.requestAccount({
68
+ id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
69
+ creationHint: { salt: "0x1" },
70
+ });
71
+ const message = "hello world";
72
+ const signature = await client.signMessage({
73
+ message,
74
+ account: account.address,
75
+ });
76
+ const isValid = await publicClient.verifyMessage({
77
+ address: account.address,
78
+ message,
79
+ signature,
80
+ });
81
+ expect(isValid).toBeTrue();
82
+ });
83
+ it("can correctly sign typed data with a different account", async () => {
84
+ const account = await client.requestAccount({
85
+ id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
86
+ creationHint: { salt: "0x1" },
87
+ });
88
+ const signature = await client.signTypedData({
89
+ ...givenTypedData,
90
+ account: account.address,
91
+ });
92
+ const isValid = await publicClient.verifyTypedData({
93
+ ...givenTypedData,
94
+ signature,
95
+ address: account.address,
96
+ });
97
+ expect(isValid).toBeTrue();
98
+ });
99
+ it("should successfully send a UO with paymaster using 7702", async () => {
100
+ const _signer = LocalAccountSigner.privateKeyToAccountSigner("0x49daf21e92c997093e9ffdf7e7ddbf8970e9eadc5d4847d0f690db25d5128e1f");
101
+ const _client = createSmartWalletClient({
102
+ transport,
103
+ chain: arbitrumSepolia,
104
+ mode: "local",
105
+ signer: _signer,
106
+ });
107
+ const account = await _client.requestAccount({
108
+ creationHint: {
109
+ accountType: "7702",
110
+ },
111
+ });
112
+ const preparedCalls = await _client.prepareCalls({
59
113
  calls: [{ to: zeroAddress, value: "0x0" }],
60
114
  from: account.address,
61
115
  capabilities: {
@@ -64,17 +118,23 @@ describe("Client E2E Tests", () => {
64
118
  },
65
119
  },
66
120
  });
67
- if (preparedUO.signatureRequest.type !== "personal_sign") {
68
- throw new Error("Invalid signature request type");
69
- }
70
- const signature = await signer.signMessage(preparedUO.signatureRequest.data);
71
- const result = await client.sendPreparedCalls({
72
- ...preparedUO,
73
- signature: {
74
- type: "ecdsa",
75
- signature,
121
+ const signedCalls = await _client.signPreparedCalls(preparedCalls);
122
+ const result = await _client.sendPreparedCalls(signedCalls);
123
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
124
+ });
125
+ it("should successfully send a UO with paymaster", async () => {
126
+ const account = await client.requestAccount();
127
+ const preparedCalls = await client.prepareCalls({
128
+ calls: [{ to: zeroAddress, value: "0x0" }],
129
+ from: account.address,
130
+ capabilities: {
131
+ paymasterService: {
132
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID,
133
+ },
76
134
  },
77
135
  });
136
+ const signedCalls = await client.signPreparedCalls(preparedCalls);
137
+ const result = await client.sendPreparedCalls(signedCalls);
78
138
  expect(result.preparedCallIds).toBeArrayOfSize(1);
79
139
  });
80
140
  it("should successfully create a session with grantPermissions and send a UO", async () => {
@@ -82,14 +142,20 @@ describe("Client E2E Tests", () => {
82
142
  const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
83
143
  const permissions = await client.grantPermissions({
84
144
  account: account.address,
85
- expiry: Math.floor(Date.now() / 1000) + 60 * 60,
145
+ expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
86
146
  key: {
87
147
  publicKey: await sessionKey.getAddress(),
88
148
  type: "secp256k1",
89
149
  },
90
150
  permissions: [{ type: "root" }],
91
151
  });
92
- const preparedUO = await client.prepareCalls({
152
+ const sessionKeyClient = createSmartWalletClient({
153
+ transport,
154
+ chain: arbitrumSepolia,
155
+ mode: "local",
156
+ signer: sessionKey,
157
+ });
158
+ const preparedCalls = await sessionKeyClient.prepareCalls({
93
159
  calls: [{ to: zeroAddress, value: "0x0" }],
94
160
  from: account.address,
95
161
  capabilities: {
@@ -99,10 +165,9 @@ describe("Client E2E Tests", () => {
99
165
  permissions,
100
166
  },
101
167
  });
102
- const signature = await signSignatureRequest(sessionKey, preparedUO.signatureRequest);
103
- const result = await client.sendPreparedCalls({
104
- ...preparedUO,
105
- signature,
168
+ const signedCalls = await sessionKeyClient.signPreparedCalls(preparedCalls);
169
+ const result = await sessionKeyClient.sendPreparedCalls({
170
+ ...signedCalls,
106
171
  capabilities: {
107
172
  permissions,
108
173
  },
@@ -111,7 +176,7 @@ describe("Client E2E Tests", () => {
111
176
  });
112
177
  });
113
178
  describe("Remote Mode Tests", () => {
114
- const signer = LocalAccountSigner.privateKeyToAccountSigner("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80");
179
+ const signer = LocalAccountSigner.privateKeyToAccountSigner("0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d");
115
180
  const client = createSmartWalletClient({
116
181
  transport,
117
182
  chain: arbitrumSepolia,
@@ -124,16 +189,27 @@ describe("Client E2E Tests", () => {
124
189
  });
125
190
  it("should successfully get a counterfactual address", async () => {
126
191
  const account = await client.requestAccount();
127
- expect(account.address).toMatchInlineSnapshot(`"0x65b5DE0251f553B2208762a4724303E750294D96"`);
192
+ expect(account.address).toMatchInlineSnapshot(`"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`);
193
+ });
194
+ it("should successfully request account with different salt", async () => {
195
+ const account = await client.requestAccount({
196
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
197
+ creationHint: { salt: "0x1" },
198
+ });
199
+ expect(account.address).toMatchInlineSnapshot(`"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`);
200
+ });
201
+ it("should not cache account if different inputs provided", async () => {
202
+ const account = await client.requestAccount();
203
+ const account2 = await client.requestAccount({
204
+ id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
205
+ creationHint: { salt: "0x2" },
206
+ });
207
+ expect(account.address).not.toEqual(account2.address);
128
208
  });
129
209
  it("can correctly sign a message", async () => {
130
210
  const account = await client.requestAccount();
131
211
  const message = "hello world";
132
- const signature = await client.signMessage(message);
133
- const publicClient = createPublicClient({
134
- chain: arbitrumSepolia,
135
- transport,
136
- });
212
+ const signature = await client.signMessage({ message });
137
213
  const isValid = await publicClient.verifyMessage({
138
214
  address: account.address,
139
215
  message: "hello world",
@@ -151,9 +227,42 @@ describe("Client E2E Tests", () => {
151
227
  });
152
228
  expect(isValid).toBeTrue();
153
229
  });
230
+ it("can correctly sign a message with a different account", async () => {
231
+ const account = await client.requestAccount({
232
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
233
+ creationHint: { salt: "0x1" },
234
+ });
235
+ const message = "hello world";
236
+ const signature = await client.signMessage({
237
+ message,
238
+ account: account.address,
239
+ });
240
+ const isValid = await publicClient.verifyMessage({
241
+ address: account.address,
242
+ message: "hello world",
243
+ signature,
244
+ });
245
+ expect(isValid).toBeTrue();
246
+ });
247
+ it("can correctly sign typed data with a different account", async () => {
248
+ const account = await client.requestAccount({
249
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
250
+ creationHint: { salt: "0x1" },
251
+ });
252
+ const signature = await client.signTypedData({
253
+ ...givenTypedData,
254
+ account: account.address,
255
+ });
256
+ const isValid = await publicClient.verifyTypedData({
257
+ ...givenTypedData,
258
+ signature,
259
+ address: account.address,
260
+ });
261
+ expect(isValid).toBeTrue();
262
+ });
154
263
  it("should successfully send a UO with paymaster", async () => {
155
264
  const account = await client.requestAccount();
156
- const preparedUO = await client.prepareCalls({
265
+ const preparedCalls = await client.prepareCalls({
157
266
  calls: [{ to: zeroAddress, value: "0x0" }],
158
267
  from: account.address,
159
268
  capabilities: {
@@ -162,11 +271,62 @@ describe("Client E2E Tests", () => {
162
271
  },
163
272
  },
164
273
  });
165
- const signature = await client.signSignatureRequest(preparedUO.signatureRequest);
166
- const result = await client.sendPreparedCalls({
167
- ...preparedUO,
168
- signature,
274
+ const signedCalls = await client.signPreparedCalls(preparedCalls);
275
+ const result = await client.sendPreparedCalls(signedCalls);
276
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
277
+ });
278
+ it("should successfully drop and replace a UO with repeat calls", async () => {
279
+ const account = await client.requestAccount();
280
+ const preparedCalls = await client.prepareCalls({
281
+ calls: [{ to: zeroAddress, value: "0x0" }],
282
+ from: account.address,
283
+ capabilities: {
284
+ paymasterService: {
285
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID,
286
+ },
287
+ },
169
288
  });
289
+ const signedCalls = await client.signPreparedCalls(preparedCalls);
290
+ const result = await client.sendPreparedCalls(signedCalls);
291
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
292
+ const prepareCalls2 = await client.prepareCalls({
293
+ calls: [{ to: zeroAddress, value: "0x0" }],
294
+ from: account.address,
295
+ capabilities: {
296
+ paymasterService: {
297
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID,
298
+ },
299
+ },
300
+ });
301
+ const signedCalls2 = await client.signPreparedCalls(prepareCalls2);
302
+ const result2 = await client.sendPreparedCalls(signedCalls2);
303
+ expect(result2.preparedCallIds).toBeArrayOfSize(1);
304
+ });
305
+ it("should successfully send a UO with paymaster using 7702", async () => {
306
+ const _signer = LocalAccountSigner.privateKeyToAccountSigner("0x00d35c6d307b5cddeb70aeed96ee27a551fee58bf1a43858477e6c11f9172ba8");
307
+ const _client = createSmartWalletClient({
308
+ transport,
309
+ chain: arbitrumSepolia,
310
+ mode: "remote",
311
+ signer: _signer,
312
+ });
313
+ const account = await _client.requestAccount({
314
+ creationHint: {
315
+ accountType: "7702",
316
+ },
317
+ });
318
+ expect(account.address).toBe(await _signer.getAddress());
319
+ const preparedCalls = await _client.prepareCalls({
320
+ calls: [{ to: zeroAddress, value: "0x0" }],
321
+ from: account.address,
322
+ capabilities: {
323
+ paymasterService: {
324
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID,
325
+ },
326
+ },
327
+ });
328
+ const signedCalls = await _client.signPreparedCalls(preparedCalls);
329
+ const result = await _client.sendPreparedCalls(signedCalls);
170
330
  expect(result.preparedCallIds).toBeArrayOfSize(1);
171
331
  });
172
332
  it("should successfully create a session with grantPermissions and send a UO", async () => {
@@ -174,14 +334,20 @@ describe("Client E2E Tests", () => {
174
334
  const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
175
335
  const permissions = await client.grantPermissions({
176
336
  account: account.address,
177
- expiry: Math.floor(Date.now() / 1000) + 60 * 60,
337
+ expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
178
338
  key: {
179
339
  publicKey: await sessionKey.getAddress(),
180
340
  type: "secp256k1",
181
341
  },
182
342
  permissions: [{ type: "root" }],
183
343
  });
184
- const preparedUO = await client.prepareCalls({
344
+ const sessionKeyClient = createSmartWalletClient({
345
+ transport,
346
+ chain: arbitrumSepolia,
347
+ mode: "remote",
348
+ signer: sessionKey,
349
+ });
350
+ const preparedCalls = await sessionKeyClient.prepareCalls({
185
351
  calls: [{ to: zeroAddress, value: "0x0" }],
186
352
  from: account.address,
187
353
  capabilities: {
@@ -191,10 +357,9 @@ describe("Client E2E Tests", () => {
191
357
  permissions,
192
358
  },
193
359
  });
194
- const signature = await signSignatureRequest(sessionKey, preparedUO.signatureRequest);
195
- const result = await client.sendPreparedCalls({
196
- ...preparedUO,
197
- signature,
360
+ const signedCalls = await sessionKeyClient.signPreparedCalls(preparedCalls);
361
+ const result = await sessionKeyClient.sendPreparedCalls({
362
+ ...signedCalls,
198
363
  capabilities: {
199
364
  permissions,
200
365
  },