@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 +1 @@
1
- {"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAGzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAGlB,MAAM,EACN,WAAW,EAEX,KAAK,GACN,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,kBAAk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KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,OAAO;KACR,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAE3B,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAAC,mBAAmB,CAAC;QAC5D,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;QACpE,kBAAkB,EAAE,kBAAkB,CAAC,MAAM,CAAC;KAC/C,CAAC,CAAC;IAEH,MAAM,EAAE,SAAS,EAAE,oCAAoC,EAAE,GACvD,MAAM,IAAI,iBAAiB,CAAC;QAC1B,MAAM,EAAE,OAAO;QACf,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,QAAQ;QACR,KAAK;QACL,QAAQ,EAAE,MAAM,CAAC,MAAM;KACxB,CAAC;SACC,cAAc,CAAC;QACd,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CACjD,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CACzC;KACF,CAAC;SACD,eAAe,EAAE,CAAC;IAEvB,OAAO;QACL,SAAS,EAAE,IAAI,EAAE,kDAAkD;QACnE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;QACzB,gBAAgB,EAAE;YAChB,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,SAAS;SAChB;QACD,oCAAoC;KACrC,CAAC;AACJ,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport {\n ChainNotFoundError,\n type Chain,\n type Transport,\n custom,\n hexToNumber,\n type Hex,\n toHex,\n} from \"viem\";\nimport type { wallet_createSession } from \"../../rpc/request\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { isGlobalValidation } from \"../../capabilities/permissions/mav2\";\nimport {\n deferralActions,\n PermissionBuilder,\n} from \"@account-kit/smart-contracts/experimental\";\nimport { createDummySigner } from \"../utils/createDummySigner\";\nimport { createAccount, isModularAccountV2 } from \"../utils/createAccount\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport { TypePermission } from \"../../capabilities/permissions\";\n\nexport type CreateSessionParams = Omit<\n Static<\n (typeof wallet_createSession)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n> & {\n entityId?: Hex;\n};\n\nexport type CreateSessionResult = Omit<\n Static<(typeof wallet_createSession)[\"properties\"][\"ReturnType\"]>,\n \"sessionId\"\n> & {\n sessionId: Hex | null;\n entityId: Hex;\n fullPreSignatureDeferredActionDigest: Hex;\n};\n\nexport async function createSession(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: CreateSessionParams,\n): Promise<CreateSessionResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const { counterfactualInfo } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n includeCounterfactualInfo: true,\n accountAddress: params.account,\n },\n ],\n });\n if (!counterfactualInfo) {\n throw new Error(\"No counterfactual info found.\");\n }\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(params.account),\n accountAddress: params.account,\n counterfactualInfo,\n });\n\n if (!isModularAccountV2(account)) {\n throw new Error(\"Sessions are currently only supported by MAv2 accounts.\");\n }\n\n const _client = createSmartAccountClient({\n chain: client.chain,\n transport: custom(client.transport),\n account,\n }).extend(deferralActions);\n\n const { entityId, nonce } = await _client.getEntityIdAndNonce({\n entityId: params.entityId ? hexToNumber(params.entityId) : undefined,\n isGlobalValidation: isGlobalValidation(params),\n });\n\n const { typedData, fullPreSignatureDeferredActionDigest } =\n await new PermissionBuilder({\n client: _client,\n key: params.key,\n entityId,\n nonce,\n deadline: params.expiry,\n })\n .addPermissions({\n permissions: params.permissions.map((permission) =>\n Value.Encode(TypePermission, permission),\n ),\n })\n .compileDeferred();\n\n return {\n sessionId: null, // In remote mode, the server will set this later.\n entityId: toHex(entityId),\n signatureRequest: {\n type: \"eth_signTypedData_v4\",\n data: typedData,\n },\n fullPreSignatureDeferredActionDigest,\n };\n}\n"]}
1
+ {"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAGzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,aAAa,EACb,WAAW,EACX,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EACL,cAAc,EACd,kBAAkB,GACnB,MAAM,wCAAwC,CAAC;AAKhD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAoB/C,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAMC,EACD,MAA2B;IAE3B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAC9D,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE;YACN;gBACE,cAA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port {\n deferralActions,\n PermissionBuilder,\n} from \"@account-kit/smart-contracts/experimental\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n ChainNotFoundError,\n custom,\n hashTypedData,\n hexToNumber,\n toHex,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\nimport {\n TypePermission,\n isGlobalValidation,\n} from \"@alchemy/wallet-api-types/capabilities\";\nimport type {\n wallet_createSession,\n WalletServerViemRpcSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport { createAccount, isModularAccountV2 } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\nimport { supportsFeature } from \"../utils/supportsFeature.js\";\nimport { isDelegated } from \"../utils/7702.js\";\n\nexport type CreateSessionParams = Omit<\n Static<\n (typeof wallet_createSession)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n> & {\n entityId?: Hex;\n};\n\nexport type CreateSessionResult = Omit<\n Static<(typeof wallet_createSession)[\"properties\"][\"ReturnType\"]>,\n \"sessionId\"\n> & {\n sessionId: Hex | null;\n entityId: Hex;\n fullPreSignatureDeferredActionDigest: Hex;\n};\n\nexport async function createSession(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: CreateSessionParams,\n): Promise<CreateSessionResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const { counterfactualInfo, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.account,\n includeCounterfactualInfo: true,\n },\n ],\n });\n\n if (\n delegation &&\n !(await isDelegated(client, {\n address: params.account,\n delegation,\n }))\n ) {\n throw new InvalidRequestError({\n message:\n \"7702 account must be delegated before calling `wallet_createSession`\",\n });\n }\n\n if (!delegation && !counterfactualInfo) {\n throw new InvalidRequestError({\n message: \"No counterfactual info found.\",\n });\n }\n\n if (\n counterfactualInfo &&\n !supportsFeature(counterfactualInfo, \"permissions\")\n ) {\n throw new InvalidRequestError({\n message: \"Account type does not support createSession\",\n });\n }\n\n // At this point we know the account supports the permission feature\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(params.account),\n accountAddress: params.account,\n counterfactualInfo,\n delegation,\n });\n\n if (!isModularAccountV2(account)) {\n throw new InvalidRequestError({\n message: \"Sessions are currently only supported by MAv2 accounts.\",\n });\n }\n\n const _client = createSmartAccountClient({\n chain: client.chain,\n transport: custom(client.transport),\n account,\n }).extend(deferralActions);\n\n const { entityId, nonce } = await _client.getEntityIdAndNonce({\n entityId: params.entityId ? hexToNumber(params.entityId) : undefined,\n isGlobalValidation: isGlobalValidation(params),\n });\n\n const { typedData, fullPreSignatureDeferredActionDigest } =\n await new PermissionBuilder({\n client: _client,\n key: {\n ...params.key,\n // Alias 'ecdsa' to 'secp256k1'\n type: params.key.type === \"ecdsa\" ? \"secp256k1\" : params.key.type,\n },\n entityId,\n nonce,\n deadline: params.expirySec,\n })\n .addPermissions({\n permissions: params.permissions.map((permission) =>\n Value.Encode(TypePermission, permission),\n ),\n })\n .compileDeferred();\n\n return {\n sessionId: null, // In remote mode, the server will set this later.\n chainId: toHex(client.chain.id),\n entityId: toHex(entityId),\n signatureRequest: {\n type: \"eth_signTypedData_v4\" as const,\n data: typedData,\n rawPayload: hashTypedData(typedData),\n },\n fullPreSignatureDeferredActionDigest,\n };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { Static } from "@sinclair/typebox";
2
+ import type { wallet_formatSign } from "@alchemy/wallet-api-types/rpc";
3
+ import type { SmartAccountClient, SmartContractAccount } from "@aa-sdk/core";
4
+ import { type Chain, type Transport } from "viem";
5
+ import type { WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
6
+ export type FormatSignParams = Static<(typeof wallet_formatSign)["properties"]["Request"]["properties"]["params"]>[0];
7
+ export type FormatSignResult = Static<(typeof wallet_formatSign)["properties"]["ReturnType"]>;
8
+ export declare function formatSign(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: FormatSignParams): Promise<FormatSignResult>;
@@ -0,0 +1,42 @@
1
+ import { ChainNotFoundError, concat, custom, encodeAbiParameters, parseAbiParameters, } from "viem";
2
+ import { createAccount } from "../utils/createAccount.js";
3
+ import { createDummySigner } from "../utils/createDummySigner.js";
4
+ import { magicBytes } from "ox/erc6492/WrappedSignature";
5
+ export async function formatSign(client, params) {
6
+ if (!client.chain) {
7
+ throw new ChainNotFoundError();
8
+ }
9
+ const { counterfactualInfo, delegation } = await client.request({
10
+ method: "wallet_requestAccount",
11
+ params: [
12
+ {
13
+ accountAddress: params.from,
14
+ includeCounterfactualInfo: true,
15
+ },
16
+ ],
17
+ });
18
+ const account = await createAccount({
19
+ chain: client.chain,
20
+ transport: custom(client.transport),
21
+ signer: createDummySigner(params.from),
22
+ accountAddress: params.from,
23
+ counterfactualInfo,
24
+ permissions: params.capabilities?.permissions,
25
+ delegation,
26
+ });
27
+ let formattedSignature = await account.formatSign(params.signature.data);
28
+ if (counterfactualInfo && !(await account.isAccountDeployed())) {
29
+ formattedSignature = concat([
30
+ encodeAbiParameters(parseAbiParameters("address, bytes, bytes"), [
31
+ counterfactualInfo.factoryAddress,
32
+ counterfactualInfo.factoryData,
33
+ formattedSignature,
34
+ ]),
35
+ magicBytes,
36
+ ]);
37
+ }
38
+ return {
39
+ signature: formattedSignature,
40
+ };
41
+ }
42
+ //# sourceMappingURL=formatSign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatSign.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/formatSign.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,MAAM,EACN,mBAAmB,EACnB,kBAAkB,GAGnB,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,aAAa,EAAE,MAAM,2B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O;QACL,SAAS,EAAE,kBAAkB;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type { wallet_formatSign } from \"@alchemy/wallet-api-types/rpc\";\nimport type { SmartAccountClient, SmartContractAccount } from \"@aa-sdk/core\";\nimport {\n ChainNotFoundError,\n concat,\n custom,\n encodeAbiParameters,\n parseAbiParameters,\n type Chain,\n type Transport,\n} from \"viem\";\nimport type { WalletServerViemRpcSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { createAccount } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\nimport { magicBytes } from \"ox/erc6492/WrappedSignature\";\n\nexport type FormatSignParams = Static<\n (typeof wallet_formatSign)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\nexport type FormatSignResult = Static<\n (typeof wallet_formatSign)[\"properties\"][\"ReturnType\"]\n>;\n\nexport async function formatSign(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: FormatSignParams,\n): Promise<FormatSignResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const { counterfactualInfo, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.from,\n includeCounterfactualInfo: true,\n },\n ],\n });\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(params.from),\n accountAddress: params.from,\n counterfactualInfo,\n permissions: params.capabilities?.permissions,\n delegation,\n });\n\n let formattedSignature = await account.formatSign(params.signature.data);\n\n if (counterfactualInfo && !(await account.isAccountDeployed())) {\n formattedSignature = concat([\n encodeAbiParameters(parseAbiParameters(\"address, bytes, bytes\"), [\n counterfactualInfo.factoryAddress,\n counterfactualInfo.factoryData,\n formattedSignature,\n ]),\n magicBytes,\n ]);\n }\n\n return {\n signature: formattedSignature,\n };\n}\n"]}
@@ -1,21 +1,7 @@
1
1
  import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
2
2
  import type { Static } from "@sinclair/typebox";
3
3
  import { type Chain, type Transport } from "viem";
4
- import type { wallet_getCallsStatus } from "../../rpc/request";
5
- import type { WalletServerViemRpcSchema } from "../../rpc/schema";
4
+ import { type wallet_getCallsStatus, type WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
6
5
  export type GetCallsStatusParams = Static<(typeof wallet_getCallsStatus)["properties"]["Request"]["properties"]["params"]>[0];
7
6
  export type GetCallsStatusResponse = Static<(typeof wallet_getCallsStatus)["properties"]["ReturnType"]>;
8
- /** EIP-5792 call status codes */
9
- export declare const CallStatusCode: {
10
- /** Batch has been received by the wallet but has not completed execution onchain */
11
- readonly PENDING: 100;
12
- /** Batch has been included onchain without reverts, receipts array contains info of all calls */
13
- readonly CONFIRMED: 200;
14
- /** Batch has not been included onchain and wallet will not retry */
15
- readonly OFFCHAIN_FAILURE: 400;
16
- /** Batch reverted *completely* and only changes related to gas charge may have been included onchain */
17
- readonly CHAIN_RULES_FAILURE: 500;
18
- /** Batch reverted *partially* and some changes related to batch calls may have been included onchain */
19
- readonly PARTIAL_CHAIN_RULES_FAILURE: 600;
20
- };
21
7
  export declare function getCallsStatus(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, callId: GetCallsStatusParams): Promise<GetCallsStatusResponse>;
@@ -1,43 +1,54 @@
1
1
  import {} from "@aa-sdk/core";
2
- import { ChainNotFoundError, isHex, } from "viem";
3
- import { TypeCallId } from "../../schemas";
4
- import { castToHex } from "../../utils";
5
2
  import { Value } from "@sinclair/typebox/value";
6
- const ReceiptStatus = {
7
- reverted: "0x0",
8
- success: "0x1",
9
- };
10
- /** EIP-5792 call status codes */
11
- export const CallStatusCode = {
12
- /** Batch has been received by the wallet but has not completed execution onchain */
13
- PENDING: 100,
14
- /** Batch has been included onchain without reverts, receipts array contains info of all calls */
15
- CONFIRMED: 200,
16
- /** Batch has not been included onchain and wallet will not retry */
17
- OFFCHAIN_FAILURE: 400,
18
- /** Batch reverted *completely* and only changes related to gas charge may have been included onchain */
19
- CHAIN_RULES_FAILURE: 500,
20
- /** Batch reverted *partially* and some changes related to batch calls may have been included onchain */
21
- PARTIAL_CHAIN_RULES_FAILURE: 600,
22
- };
3
+ import { ChainNotFoundError, isHex, } from "viem";
4
+ import { BaseError } from "ox/RpcResponse";
5
+ import { CallStatusCode, CallStatusErrorCode, } from "@alchemy/wallet-api-types/rpc";
6
+ import { TypeCallId } from "@alchemy/wallet-api-types";
7
+ import { castToHex } from "../../utils.js";
23
8
  export async function getCallsStatus(client, callId) {
24
9
  if (!client.chain) {
25
10
  throw new ChainNotFoundError();
26
11
  }
27
12
  const { chainId, hash } = Value.Decode(TypeCallId, callId);
28
- const result = await client.getUserOperationReceipt(hash);
29
- return {
13
+ const baseResp = {
30
14
  id: callId,
31
15
  chainId,
32
16
  atomic: true,
33
- status: !result?.receipt
34
- ? CallStatusCode.PENDING
35
- : result.success
36
- ? CallStatusCode.CONFIRMED
37
- : CallStatusCode.CHAIN_RULES_FAILURE,
38
- receipts: !result?.receipt ? undefined : [transformReceipt(result.receipt)],
17
+ };
18
+ const result = await client.getUserOperationByHash(hash);
19
+ if (!result) {
20
+ throw new BaseError({
21
+ message: `callId ${callId} not found`,
22
+ code: CallStatusErrorCode.UNKNOWN_BUNDLE_ID,
23
+ });
24
+ }
25
+ if (result && !result.transactionHash) {
26
+ // A result but no txn hash means it's valid but pending.
27
+ return {
28
+ ...baseResp,
29
+ status: CallStatusCode.PENDING,
30
+ };
31
+ }
32
+ const receipt = await client.getUserOperationReceipt(hash);
33
+ if (!receipt) {
34
+ // Handles edge case of hash being retrieved immediately before the 150 block limit falloff.
35
+ throw new BaseError({
36
+ message: `callId ${callId} not found`,
37
+ code: CallStatusErrorCode.UNKNOWN_BUNDLE_ID,
38
+ });
39
+ }
40
+ return {
41
+ ...baseResp,
42
+ status: receipt.success
43
+ ? CallStatusCode.CONFIRMED
44
+ : CallStatusCode.CHAIN_RULES_FAILURE,
45
+ receipts: [transformReceipt(receipt.receipt)],
39
46
  };
40
47
  }
48
+ const ReceiptStatus = {
49
+ reverted: "0x0",
50
+ success: "0x1",
51
+ };
41
52
  function transformReceipt(receipt) {
42
53
  return {
43
54
  // viem's type for status is "success" | "reverted", but the actual value seems to already be 0x0 or 0x1
@@ -1 +1 @@
1
- {"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAKlB,KAAK,GACN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAUhD,MAAM,aAAa,GAA8C;IAC/D,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;CACf,CAAC;AAEF,iCAAiC;AACjC,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,oFAAoF;IACpF,OAAO,EAAE,GAAG;IACZ,iGAAiG;IACjG,SAAS,EAAE,GAAG;IACd,oEAAoE;IACpE,gBAAgB,EAAE,GAAG;IACrB,wGAAwG;IACxG,mBAAmB,EAAE,GAAG;IACxB,wGAAwG;IACxG,2BAA2B,EAAE,GAAG;CACxB,CAAC;AAEX,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAMC,EACD,MAA4B;IAE5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAE3D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAE1D,OAAO;QACL,EAAE,EAAE,MAAM;QACV,OAAO;QACP,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO;YACtB,CAAC,CAAC,cAAc,CAAC,OAAO;YACxB,CAAC,CAAC,MAAM,CAAC,OAAO;gBACd,CAAC,CAAC,cAAc,CAAC,SAAS;gBAC1B,CAAC,CAAC,cAAc,CAAC,mBAAmB;QACxC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KAC5E,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,OAA2B;IAE3B,OAAO;QACL,wGAAwG;QACxG,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAC3B,CAAC,CAAC,OAAO,CAAC,MAAM;YAChB,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC;QACjC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,+FAA+F;QAC/F,WAAW,EAAE,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;QAC3C,2FAA2F;QAC3F,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;QACnC,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC/B,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import {\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport {\n ChainNotFoundError,\n type Chain,\n type Hex,\n type TransactionReceipt,\n type Transport,\n isHex,\n} from \"viem\";\nimport type { wallet_getCallsStatus } from \"../../rpc/request\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema\";\nimport { TypeCallId } from \"../../schemas\";\nimport { castToHex } from \"../../utils\";\nimport { Value } from \"@sinclair/typebox/value\";\n\nexport type GetCallsStatusParams = Static<\n (typeof wallet_getCallsStatus)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\nexport type GetCallsStatusResponse = Static<\n (typeof wallet_getCallsStatus)[\"properties\"][\"ReturnType\"]\n>;\n\nconst ReceiptStatus: Record<TransactionReceipt[\"status\"], Hex> = {\n reverted: \"0x0\",\n success: \"0x1\",\n};\n\n/** EIP-5792 call status codes */\nexport const CallStatusCode = {\n /** Batch has been received by the wallet but has not completed execution onchain */\n PENDING: 100,\n /** Batch has been included onchain without reverts, receipts array contains info of all calls */\n CONFIRMED: 200,\n /** Batch has not been included onchain and wallet will not retry */\n OFFCHAIN_FAILURE: 400,\n /** Batch reverted *completely* and only changes related to gas charge may have been included onchain */\n CHAIN_RULES_FAILURE: 500,\n /** Batch reverted *partially* and some changes related to batch calls may have been included onchain */\n PARTIAL_CHAIN_RULES_FAILURE: 600,\n} as const;\n\nexport async function getCallsStatus(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n callId: GetCallsStatusParams,\n): Promise<GetCallsStatusResponse> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const { chainId, hash } = Value.Decode(TypeCallId, callId);\n\n const result = await client.getUserOperationReceipt(hash);\n\n return {\n id: callId,\n chainId,\n atomic: true,\n status: !result?.receipt\n ? CallStatusCode.PENDING\n : result.success\n ? CallStatusCode.CONFIRMED\n : CallStatusCode.CHAIN_RULES_FAILURE,\n receipts: !result?.receipt ? undefined : [transformReceipt(result.receipt)],\n };\n}\n\nfunction transformReceipt(\n receipt: TransactionReceipt,\n): NonNullable<GetCallsStatusResponse[\"receipts\"]>[number] {\n return {\n // viem's type for status is \"success\" | \"reverted\", but the actual value seems to already be 0x0 or 0x1\n status: isHex(receipt.status)\n ? receipt.status\n : ReceiptStatus[receipt.status],\n blockHash: receipt.blockHash,\n // viem's type for blockNumber is bigint, but the actual value seems to already be a hex string\n blockNumber: castToHex(receipt.blockNumber),\n // viem's type for gasUsed is bigint, but the actual value seems to already be a hex string\n gasUsed: castToHex(receipt.gasUsed),\n transactionHash: receipt.transactionHash,\n logs: receipt.logs.map((log) => ({\n address: log.address,\n data: log.data,\n topics: log.topics,\n })),\n };\n}\n"]}
1
+ {"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,KAAK,GAKN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,mBAAmB,GAGpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAU3C,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAMC,EACD,MAA4B;IAE5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IACD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAE3D,MAAM,QAAQ,GAAG;QACf,EAAE,EAAE,MAAM;QACV,OAAO;QACP,MAAM,EAAE,IAAI;KACb,CAAC;IAEF,MAAM,MA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+F;QAC/F,WAAW,EAAE,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;QAC3C,2FAA2F;QAC3F,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;QACnC,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC/B,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import {\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n ChainNotFoundError,\n isHex,\n type Chain,\n type Hex,\n type TransactionReceipt,\n type Transport,\n} from \"viem\";\nimport { BaseError } from \"ox/RpcResponse\";\nimport {\n CallStatusCode,\n CallStatusErrorCode,\n type wallet_getCallsStatus,\n type WalletServerViemRpcSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport { TypeCallId } from \"@alchemy/wallet-api-types\";\nimport { castToHex } from \"../../utils.js\";\n\nexport type GetCallsStatusParams = Static<\n (typeof wallet_getCallsStatus)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\nexport type GetCallsStatusResponse = Static<\n (typeof wallet_getCallsStatus)[\"properties\"][\"ReturnType\"]\n>;\n\nexport async function getCallsStatus(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n callId: GetCallsStatusParams,\n): Promise<GetCallsStatusResponse> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n const { chainId, hash } = Value.Decode(TypeCallId, callId);\n\n const baseResp = {\n id: callId,\n chainId,\n atomic: true,\n };\n\n const result = await client.getUserOperationByHash(hash);\n if (!result) {\n throw new BaseError({\n message: `callId ${callId} not found`,\n code: CallStatusErrorCode.UNKNOWN_BUNDLE_ID,\n });\n }\n if (result && !result.transactionHash) {\n // A result but no txn hash means it's valid but pending.\n return {\n ...baseResp,\n status: CallStatusCode.PENDING,\n };\n }\n\n const receipt = await client.getUserOperationReceipt(hash);\n if (!receipt) {\n // Handles edge case of hash being retrieved immediately before the 150 block limit falloff.\n throw new BaseError({\n message: `callId ${callId} not found`,\n code: CallStatusErrorCode.UNKNOWN_BUNDLE_ID,\n });\n }\n\n return {\n ...baseResp,\n status: receipt.success\n ? CallStatusCode.CONFIRMED\n : CallStatusCode.CHAIN_RULES_FAILURE,\n receipts: [transformReceipt(receipt.receipt)],\n };\n}\n\nconst ReceiptStatus: Record<TransactionReceipt[\"status\"], Hex> = {\n reverted: \"0x0\",\n success: \"0x1\",\n};\n\nfunction transformReceipt(\n receipt: TransactionReceipt,\n): NonNullable<GetCallsStatusResponse[\"receipts\"]>[number] {\n return {\n // viem's type for status is \"success\" | \"reverted\", but the actual value seems to already be 0x0 or 0x1\n status: isHex(receipt.status)\n ? receipt.status\n : ReceiptStatus[receipt.status],\n blockHash: receipt.blockHash,\n // viem's type for blockNumber is bigint, but the actual value seems to already be a hex string\n blockNumber: castToHex(receipt.blockNumber),\n // viem's type for gasUsed is bigint, but the actual value seems to already be a hex string\n gasUsed: castToHex(receipt.gasUsed),\n transactionHash: receipt.transactionHash,\n logs: receipt.logs.map((log) => ({\n address: log.address,\n data: log.data,\n topics: log.topics,\n })),\n };\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
2
2
  import type { Static } from "@sinclair/typebox";
3
3
  import { type Chain, type Transport } from "viem";
4
- import type { wallet_prepareCalls } from "../../rpc/request";
5
- import type { WalletServerViemRpcSchema } from "../../rpc/schema";
4
+ import type { wallet_prepareCalls, WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
6
5
  export type PrepareCallsParams = Omit<Static<(typeof wallet_prepareCalls)["properties"]["Request"]["properties"]["params"]>[0], "chainId">;
7
6
  export type PrepareCallsResult = Static<(typeof wallet_prepareCalls)["properties"]["ReturnType"]>;
8
7
  export declare function prepareCalls(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: PrepareCallsParams): Promise<PrepareCallsResult>;
@@ -1,33 +1,69 @@
1
- import { deepHexlify, } from "@aa-sdk/core";
2
- import { ChainNotFoundError, custom, fromHex, toHex, zeroAddress, } from "viem";
3
- import { createAccount } from "../utils/createAccount";
4
- import { createDummySigner } from "../utils/createDummySigner";
5
- // TODO: handle capabilities like permissions and paymaster here
1
+ import { deepHexlify, default7702GasEstimator, } from "@aa-sdk/core";
2
+ import { ChainNotFoundError, custom, fromHex, hashMessage, toHex, } from "viem";
3
+ import { createAccount } from "../utils/createAccount.js";
4
+ import { createDummySigner } from "../utils/createDummySigner.js";
5
+ import { createAuthorizationRequest, isDelegated } from "../utils/7702.js";
6
+ import { InvalidRequestError } from "ox/RpcResponse";
7
+ import { assertNever } from "../../utils.js";
8
+ import { assertValid7702AccountAddress } from "../utils/7702.js";
6
9
  export async function prepareCalls(client, params) {
7
10
  if (!client.chain) {
8
11
  throw new ChainNotFoundError();
9
12
  }
13
+ assertValid7702AccountAddress(params.from, params.capabilities?.eip7702Auth);
10
14
  // in local mode, we probably want some kind of caching for this
11
- const { counterfactualInfo } = await client.request({
15
+ const { counterfactualInfo, delegation } = await client.request({
12
16
  method: "wallet_requestAccount",
13
17
  params: [
14
- {
15
- accountAddress: params.from,
16
- includeCounterfactualInfo: true,
17
- },
18
+ params.capabilities?.eip7702Auth
19
+ ? {
20
+ signerAddress: params.from,
21
+ creationHint: {
22
+ accountType: "7702",
23
+ },
24
+ includeCounterfactualInfo: true,
25
+ }
26
+ : {
27
+ accountAddress: params.from,
28
+ includeCounterfactualInfo: true,
29
+ },
18
30
  ],
19
31
  });
20
- if (!counterfactualInfo) {
21
- throw new Error("No counterfactual info found.");
32
+ if (!counterfactualInfo && !delegation) {
33
+ throw new InvalidRequestError({
34
+ message: "No counterfactual info or delegated implementation address found.",
35
+ });
22
36
  }
23
37
  const account = await createAccount({
24
38
  chain: client.chain,
25
39
  transport: custom(client.transport),
26
- signer: createDummySigner(zeroAddress),
40
+ signer: createDummySigner(params.from),
27
41
  accountAddress: params.from,
28
42
  counterfactualInfo,
29
- capabilities: params.capabilities,
43
+ permissions: params.capabilities?.permissions,
44
+ delegation,
30
45
  });
46
+ const authorizationRequest = delegation &&
47
+ !(await isDelegated(client, {
48
+ address: account.address,
49
+ delegation,
50
+ }))
51
+ ? await createAuthorizationRequest(client, {
52
+ address: account.address,
53
+ delegation,
54
+ })
55
+ : undefined;
56
+ if (params.capabilities?.permissions && authorizationRequest) {
57
+ // The user shouldn't see this in most cases since we require
58
+ // the account to be delegated before creating the session.
59
+ throw new InvalidRequestError({
60
+ message: "When using a 7702 account with a session key, the account must be delegated before preparing calls.",
61
+ });
62
+ }
63
+ if (authorizationRequest) {
64
+ // @ts-expect-error - this is available but not typed as public
65
+ client.middleware.gasEstimator = default7702GasEstimator();
66
+ }
31
67
  // TODO: oops we don't actually support setting the policyId as an override here
32
68
  // if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly
33
69
  const builtUo = await client.buildUserOperation({
@@ -37,22 +73,44 @@ export async function prepareCalls(client, params) {
37
73
  value: x.value ? fromHex(x.value, "bigint") : undefined,
38
74
  })),
39
75
  account,
40
- overrides: params.capabilities?.gasParamsOverride,
76
+ overrides: {
77
+ ...params.capabilities?.gasParamsOverride,
78
+ nonceKey: params.capabilities?.nonceOverride?.nonceKey
79
+ ? fromHex(params.capabilities.nonceOverride.nonceKey, "bigint")
80
+ : undefined,
81
+ },
41
82
  });
42
- const uoRequest = deepHexlify(builtUo);
43
- const hash = account.getEntryPoint().getUserOperationHash(uoRequest);
44
- return {
45
- type: account.getEntryPoint().version === "0.7.0"
83
+ // The eip7702Auth field should never be included in the UO sig
84
+ // request. It's handled by a separate authorization request.
85
+ if ("eip7702Auth" in builtUo) {
86
+ builtUo.eip7702Auth = undefined;
87
+ }
88
+ const hexlifiedUo = deepHexlify(builtUo);
89
+ const ep = account.getEntryPoint();
90
+ const uoHash = ep.getUserOperationHash(hexlifiedUo);
91
+ const uoRequest = {
92
+ type: ep.version === "0.7.0"
46
93
  ? "user-operation-v070"
47
- : "user-operation-v060",
48
- data: uoRequest,
94
+ : ep.version === "0.6.0"
95
+ ? "user-operation-v060"
96
+ : assertNever(ep.version, "Unexpected entry point version"),
97
+ data: hexlifiedUo,
49
98
  chainId: toHex(client.chain.id),
50
99
  signatureRequest: {
51
100
  type: "personal_sign",
52
101
  data: {
53
- raw: hash,
102
+ raw: uoHash,
54
103
  },
104
+ rawPayload: hashMessage({
105
+ raw: uoHash,
106
+ }),
55
107
  },
56
108
  };
109
+ return authorizationRequest
110
+ ? {
111
+ type: "array",
112
+ data: [authorizationRequest, uoRequest],
113
+ }
114
+ : uoRequest;
57
115
  }
58
116
  //# sourceMappingURL=prepareCalls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAGZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,KAAK,EACL,WAAW,GAGZ,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAa/D,gEAAgE;AAChE,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAMC,EACD,MAA0B;IAE1B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,gEAA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AAO;QACL,IAAI,EACF,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;YACzC,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,qBAAqB;QAC3B,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,gBAAgB,EAAE;YAChB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE;gBACJ,GAAG,EAAE,IAAI;aACV;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n deepHexlify,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport {\n ChainNotFoundError,\n custom,\n fromHex,\n toHex,\n zeroAddress,\n type Chain,\n type Transport,\n} from \"viem\";\nimport type { wallet_prepareCalls } from \"../../rpc/request\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema\";\nimport { createAccount } from \"../utils/createAccount\";\nimport { createDummySigner } from \"../utils/createDummySigner\";\n\nexport type PrepareCallsParams = Omit<\n Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\n\nexport type PrepareCallsResult = Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"ReturnType\"]\n>;\n\n// TODO: handle capabilities like permissions and paymaster here\nexport async function prepareCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n // in local mode, we probably want some kind of caching for this\n const { counterfactualInfo } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.from,\n includeCounterfactualInfo: true,\n },\n ],\n });\n if (!counterfactualInfo) {\n throw new Error(\"No counterfactual info found.\");\n }\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(zeroAddress),\n accountAddress: params.from,\n counterfactualInfo,\n capabilities: params.capabilities,\n });\n\n // TODO: oops we don't actually support setting the policyId as an override here\n // if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly\n const builtUo = await client.buildUserOperation({\n uo: params.calls.map((x) => ({\n target: x.to,\n data: x.data ?? \"0x\",\n value: x.value ? fromHex(x.value, \"bigint\") : undefined,\n })),\n account,\n overrides: params.capabilities?.gasParamsOverride,\n });\n\n const uoRequest = deepHexlify(builtUo);\n\n const hash = account.getEntryPoint().getUserOperationHash(uoRequest);\n\n return {\n type:\n account.getEntryPoint().version === \"0.7.0\"\n ? \"user-operation-v070\"\n : \"user-operation-v060\",\n data: uoRequest,\n chainId: toHex(client.chain.id),\n signatureRequest: {\n type: \"personal_sign\",\n data: {\n raw: hash,\n },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,uBAAuB,GAGxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,WAAW,EACX,KAAK,GAGN,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAajE,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAMC,EACD,MAA0B;IAE1B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,C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G,WAAW,CAAC,OAAO,CAAC,CAAC;IAEzC,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAEnC,MAAM,MAAM,GAAG,EAAE,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAEpD,MAAM,SAAS,GAAG;QAChB,IAAI,EACF,EAAE,CAAC,OAAO,KAAK,OAAO;YACpB,CAAC,CAAE,qBAA+B;YAClC,CAAC,CAAC,EAAE,CAAC,OAAO,KAAK,OAAO;gBACtB,CAAC,CAAE,qBAA+B;gBAClC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,gCAAgC,CAAC;QACjE,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,gBAAgB,EAAE;YAChB,IAAI,EAAE,eAAwB;YAC9B,IAAI,EAAE;gBACJ,GAAG,EAAE,MAAM;aACZ;YACD,UAAU,EAAE,WAAW,CAAC;gBACtB,GAAG,EAAE,MAAM;aACZ,CAAC;SACH;KACF,CAAC;IAEF,OAAO,oBAAoB;QACzB,CAAC,CAAC;YACE,IAAI,EAAE,OAAgB;YACtB,IAAI,EAAE,CAAC,oBAAoB,EAAE,SAAS,CAAC;SACxC;QACH,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC","sourcesContent":["import {\n deepHexlify,\n default7702GasEstimator,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport {\n ChainNotFoundError,\n custom,\n fromHex,\n hashMessage,\n toHex,\n type Chain,\n type Transport,\n} from \"viem\";\nimport type {\n wallet_prepareCalls,\n WalletServerViemRpcSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport { createAccount } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\nimport { createAuthorizationRequest, isDelegated } from \"../utils/7702.js\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\nimport { assertNever } from \"../../utils.js\";\nimport { assertValid7702AccountAddress } from \"../utils/7702.js\";\n\nexport type PrepareCallsParams = Omit<\n Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\n\nexport type PrepareCallsResult = Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"ReturnType\"]\n>;\n\nexport async function prepareCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n assertValid7702AccountAddress(params.from, params.capabilities?.eip7702Auth);\n\n // in local mode, we probably want some kind of caching for this\n const { counterfactualInfo, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n params.capabilities?.eip7702Auth\n ? {\n signerAddress: params.from,\n creationHint: {\n accountType: \"7702\",\n },\n includeCounterfactualInfo: true,\n }\n : {\n accountAddress: params.from,\n includeCounterfactualInfo: true,\n },\n ],\n });\n\n if (!counterfactualInfo && !delegation) {\n throw new InvalidRequestError({\n message:\n \"No counterfactual info or delegated implementation address found.\",\n });\n }\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(params.from),\n accountAddress: params.from,\n counterfactualInfo,\n permissions: params.capabilities?.permissions,\n delegation,\n });\n\n const authorizationRequest =\n delegation &&\n !(await isDelegated(client, {\n address: account.address,\n delegation,\n }))\n ? await createAuthorizationRequest(client, {\n address: account.address,\n delegation,\n })\n : undefined;\n\n if (params.capabilities?.permissions && authorizationRequest) {\n // The user shouldn't see this in most cases since we require\n // the account to be delegated before creating the session.\n throw new InvalidRequestError({\n message:\n \"When using a 7702 account with a session key, the account must be delegated before preparing calls.\",\n });\n }\n\n if (authorizationRequest) {\n // @ts-expect-error - this is available but not typed as public\n client.middleware.gasEstimator = default7702GasEstimator();\n }\n\n // TODO: oops we don't actually support setting the policyId as an override here\n // if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly\n const builtUo = await client.buildUserOperation({\n uo: params.calls.map((x) => ({\n target: x.to,\n data: x.data ?? \"0x\",\n value: x.value ? fromHex(x.value, \"bigint\") : undefined,\n })),\n account,\n overrides: {\n ...params.capabilities?.gasParamsOverride,\n nonceKey: params.capabilities?.nonceOverride?.nonceKey\n ? fromHex(params.capabilities.nonceOverride.nonceKey, \"bigint\")\n : undefined,\n },\n });\n\n // The eip7702Auth field should never be included in the UO sig\n // request. It's handled by a separate authorization request.\n if (\"eip7702Auth\" in builtUo) {\n builtUo.eip7702Auth = undefined;\n }\n\n const hexlifiedUo = deepHexlify(builtUo);\n\n const ep = account.getEntryPoint();\n\n const uoHash = ep.getUserOperationHash(hexlifiedUo);\n\n const uoRequest = {\n type:\n ep.version === \"0.7.0\"\n ? (\"user-operation-v070\" as const)\n : ep.version === \"0.6.0\"\n ? (\"user-operation-v060\" as const)\n : assertNever(ep.version, \"Unexpected entry point version\"),\n data: hexlifiedUo,\n chainId: toHex(client.chain.id),\n signatureRequest: {\n type: \"personal_sign\" as const,\n data: {\n raw: uoHash,\n },\n rawPayload: hashMessage({\n raw: uoHash,\n }),\n },\n };\n\n return authorizationRequest\n ? {\n type: \"array\" as const,\n data: [authorizationRequest, uoRequest],\n }\n : uoRequest;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { Static } from "@sinclair/typebox";
2
+ import type { SmartAccountClient, SmartContractAccount } from "@aa-sdk/core";
3
+ import { type Chain, type Transport } from "viem";
4
+ import type { wallet_prepareSign, WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
5
+ export type PrepareSignParams = Static<(typeof wallet_prepareSign)["properties"]["Request"]["properties"]["params"]>[0];
6
+ export type PrepareSignResult = Static<(typeof wallet_prepareSign)["properties"]["ReturnType"]>;
7
+ export declare function prepareSign(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: PrepareSignParams): Promise<PrepareSignResult>;
@@ -0,0 +1,49 @@
1
+ import { ChainNotFoundError, custom, toHex, } from "viem";
2
+ import { TypeSignableMessage, jsonSafeTypedData, } from "@alchemy/wallet-api-types";
3
+ import { createAccount } from "../utils/createAccount.js";
4
+ import { createDummySigner } from "../utils/createDummySigner.js";
5
+ import { Value } from "@sinclair/typebox/value";
6
+ export async function prepareSign(client, params) {
7
+ if (!client.chain) {
8
+ throw new ChainNotFoundError();
9
+ }
10
+ const { counterfactualInfo, delegation } = await client.request({
11
+ method: "wallet_requestAccount",
12
+ params: [
13
+ {
14
+ accountAddress: params.from,
15
+ includeCounterfactualInfo: true,
16
+ },
17
+ ],
18
+ });
19
+ const account = await createAccount({
20
+ chain: client.chain,
21
+ transport: custom(client.transport),
22
+ signer: createDummySigner(params.from),
23
+ accountAddress: params.from,
24
+ counterfactualInfo,
25
+ permissions: params.capabilities?.permissions,
26
+ delegation,
27
+ });
28
+ const signatureRequest = await account.prepareSign(params.signatureRequest);
29
+ if (signatureRequest.type === "personal_sign") {
30
+ return {
31
+ chainId: toHex(client.chain.id),
32
+ signatureRequest: {
33
+ type: signatureRequest.type,
34
+ data: Value.Encode(TypeSignableMessage, signatureRequest.data),
35
+ },
36
+ };
37
+ }
38
+ else {
39
+ const typedData = signatureRequest.data;
40
+ return {
41
+ chainId: toHex(client.chain.id),
42
+ signatureRequest: {
43
+ type: signatureRequest.type,
44
+ data: jsonSafeTypedData(typedData),
45
+ },
46
+ };
47
+ }
48
+ }
49
+ //# sourceMappingURL=prepareSign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareSign.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareSign.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,KAAK,GAGN,MAAM,MAAM,CAAC;AAKd,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,2BAA2B,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CAAC;aAC/D;SACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC;QAExC,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,gBAAgB,EAAE;gBAChB,IAAI,EAAE,gBAAgB,CAAC,IAAI;gBAC3B,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC;aACnC;SACF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type {\n SignatureRequest,\n SmartAccountClient,\n SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport {\n ChainNotFoundError,\n custom,\n toHex,\n type Chain,\n type Transport,\n} from \"viem\";\nimport type {\n wallet_prepareSign,\n WalletServerViemRpcSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport {\n TypeSignableMessage,\n jsonSafeTypedData,\n} from \"@alchemy/wallet-api-types\";\nimport { createAccount } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\nimport { Value } from \"@sinclair/typebox/value\";\n\nexport type PrepareSignParams = Static<\n (typeof wallet_prepareSign)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\nexport type PrepareSignResult = Static<\n (typeof wallet_prepareSign)[\"properties\"][\"ReturnType\"]\n>;\n\nexport async function prepareSign(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: PrepareSignParams,\n): Promise<PrepareSignResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const { counterfactualInfo, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.from,\n includeCounterfactualInfo: true,\n },\n ],\n });\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(params.from),\n accountAddress: params.from,\n counterfactualInfo,\n permissions: params.capabilities?.permissions,\n delegation,\n });\n\n const signatureRequest = await account.prepareSign(\n params.signatureRequest as SignatureRequest,\n );\n\n if (signatureRequest.type === \"personal_sign\") {\n return {\n chainId: toHex(client.chain.id),\n signatureRequest: {\n type: signatureRequest.type,\n data: Value.Encode(TypeSignableMessage, signatureRequest.data),\n },\n };\n } else {\n const typedData = signatureRequest.data;\n\n return {\n chainId: toHex(client.chain.id),\n signatureRequest: {\n type: signatureRequest.type,\n data: jsonSafeTypedData(typedData),\n },\n };\n }\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
2
- import type { Static, StaticDecode } from "@sinclair/typebox";
3
2
  import { type Chain, type Transport } from "viem";
4
- import type { wallet_sendPreparedCalls } from "../../rpc/request";
5
- import type { WalletServerViemRpcSchema } from "../../rpc/schema";
6
- export type SendPreparedCallsParams = Omit<StaticDecode<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0], "chainId">;
3
+ import type { wallet_sendPreparedCalls, WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
4
+ import type { Static } from "@sinclair/typebox";
5
+ export type SendPreparedCallsParams = Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0];
7
6
  export type SendPreparedCallsResult = Static<(typeof wallet_sendPreparedCalls)["properties"]["ReturnType"]>;
8
7
  export declare function sendPreparedCalls(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;