@account-kit/wallet-client 0.0.1-alpha.1

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 (259) hide show
  1. package/dist/esm/abi/LightAccountFactoryAbi_V1_0_1.d.ts +55 -0
  2. package/dist/esm/abi/LightAccountFactoryAbi_V1_0_1.js +45 -0
  3. package/dist/esm/abi/LightAccountFactoryAbi_V1_0_1.js.map +1 -0
  4. package/dist/esm/abi/LightAccountFactoryAbi_V1_0_2.d.ts +55 -0
  5. package/dist/esm/abi/LightAccountFactoryAbi_V1_0_2.js +45 -0
  6. package/dist/esm/abi/LightAccountFactoryAbi_V1_0_2.js.map +1 -0
  7. package/dist/esm/abi/LightAccountFactoryAbi_V1_1_0.d.ts +55 -0
  8. package/dist/esm/abi/LightAccountFactoryAbi_V1_1_0.js +45 -0
  9. package/dist/esm/abi/LightAccountFactoryAbi_V1_1_0.js.map +1 -0
  10. package/dist/esm/abi/LightAccountFactoryAbi_V2_0_0.d.ts +256 -0
  11. package/dist/esm/abi/LightAccountFactoryAbi_V2_0_0.js +202 -0
  12. package/dist/esm/abi/LightAccountFactoryAbi_V2_0_0.js.map +1 -0
  13. package/dist/esm/abi/ModularAccountFactoryAbi_V2_0_0.d.ts +492 -0
  14. package/dist/esm/abi/ModularAccountFactoryAbi_V2_0_0.js +399 -0
  15. package/dist/esm/abi/ModularAccountFactoryAbi_V2_0_0.js.map +1 -0
  16. package/dist/esm/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.d.ts +286 -0
  17. package/dist/esm/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.js +225 -0
  18. package/dist/esm/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.js.map +1 -0
  19. package/dist/esm/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.d.ts +234 -0
  20. package/dist/esm/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.js +179 -0
  21. package/dist/esm/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.js.map +1 -0
  22. package/dist/esm/abi/MultisigModularAccountFactoryAbi_V1_0_0.d.ts +246 -0
  23. package/dist/esm/abi/MultisigModularAccountFactoryAbi_V1_0_0.js +182 -0
  24. package/dist/esm/abi/MultisigModularAccountFactoryAbi_V1_0_0.js.map +1 -0
  25. package/dist/esm/abi/index.d.ts +8 -0
  26. package/dist/esm/abi/index.js +9 -0
  27. package/dist/esm/abi/index.js.map +1 -0
  28. package/dist/esm/capabilities/index.d.ts +8 -0
  29. package/dist/esm/capabilities/index.js +8 -0
  30. package/dist/esm/capabilities/index.js.map +1 -0
  31. package/dist/esm/capabilities/paymaster.d.ts +3 -0
  32. package/dist/esm/capabilities/paymaster.js +5 -0
  33. package/dist/esm/capabilities/paymaster.js.map +1 -0
  34. package/dist/esm/capabilities/permissions/index.d.ts +98 -0
  35. package/dist/esm/capabilities/permissions/index.js +60 -0
  36. package/dist/esm/capabilities/permissions/index.js.map +1 -0
  37. package/dist/esm/capabilities/permissions/mav2.d.ts +36 -0
  38. package/dist/esm/capabilities/permissions/mav2.js +79 -0
  39. package/dist/esm/capabilities/permissions/mav2.js.map +1 -0
  40. package/dist/esm/client/actions/createAccount.d.ts +10 -0
  41. package/dist/esm/client/actions/createAccount.js +7 -0
  42. package/dist/esm/client/actions/createAccount.js.map +1 -0
  43. package/dist/esm/client/actions/getCallsStatus.d.ts +6 -0
  44. package/dist/esm/client/actions/getCallsStatus.js +7 -0
  45. package/dist/esm/client/actions/getCallsStatus.js.map +1 -0
  46. package/dist/esm/client/actions/grantPermissions.d.ts +13 -0
  47. package/dist/esm/client/actions/grantPermissions.js +11 -0
  48. package/dist/esm/client/actions/grantPermissions.js.map +1 -0
  49. package/dist/esm/client/actions/listAccounts.d.ts +6 -0
  50. package/dist/esm/client/actions/listAccounts.js +4 -0
  51. package/dist/esm/client/actions/listAccounts.js.map +1 -0
  52. package/dist/esm/client/actions/prepareCalls.d.ts +15 -0
  53. package/dist/esm/client/actions/prepareCalls.js +17 -0
  54. package/dist/esm/client/actions/prepareCalls.js.map +1 -0
  55. package/dist/esm/client/actions/requestAccount.d.ts +11 -0
  56. package/dist/esm/client/actions/requestAccount.js +28 -0
  57. package/dist/esm/client/actions/requestAccount.js.map +1 -0
  58. package/dist/esm/client/actions/sendPreparedCalls.d.ts +6 -0
  59. package/dist/esm/client/actions/sendPreparedCalls.js +8 -0
  60. package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -0
  61. package/dist/esm/client/actions/signMessage.d.ts +6 -0
  62. package/dist/esm/client/actions/signMessage.js +7 -0
  63. package/dist/esm/client/actions/signMessage.js.map +1 -0
  64. package/dist/esm/client/actions/signSignatureRequest.d.ts +10 -0
  65. package/dist/esm/client/actions/signSignatureRequest.js +15 -0
  66. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -0
  67. package/dist/esm/client/actions/signTypedData.d.ts +6 -0
  68. package/dist/esm/client/actions/signTypedData.js +7 -0
  69. package/dist/esm/client/actions/signTypedData.js.map +1 -0
  70. package/dist/esm/client/client.e2e-test.d.ts +1 -0
  71. package/dist/esm/client/client.e2e-test.js +238 -0
  72. package/dist/esm/client/client.e2e-test.js.map +1 -0
  73. package/dist/esm/client/decorator.d.ts +24 -0
  74. package/dist/esm/client/decorator.js +25 -0
  75. package/dist/esm/client/decorator.js.map +1 -0
  76. package/dist/esm/client/index.d.ts +18 -0
  77. package/dist/esm/client/index.js +43 -0
  78. package/dist/esm/client/index.js.map +1 -0
  79. package/dist/esm/exports/index.d.ts +13 -0
  80. package/dist/esm/exports/index.js +18 -0
  81. package/dist/esm/exports/index.js.map +1 -0
  82. package/dist/esm/exports/internal.d.ts +13 -0
  83. package/dist/esm/exports/internal.js +15 -0
  84. package/dist/esm/exports/internal.js.map +1 -0
  85. package/dist/esm/isomorphic/actions/createSession.d.ts +14 -0
  86. package/dist/esm/isomorphic/actions/createSession.js +63 -0
  87. package/dist/esm/isomorphic/actions/createSession.js.map +1 -0
  88. package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +21 -0
  89. package/dist/esm/isomorphic/actions/getCallsStatus.js +60 -0
  90. package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -0
  91. package/dist/esm/isomorphic/actions/prepareCalls.d.ts +8 -0
  92. package/dist/esm/isomorphic/actions/prepareCalls.js +57 -0
  93. package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -0
  94. package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +8 -0
  95. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +43 -0
  96. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -0
  97. package/dist/esm/isomorphic/client.d.ts +97 -0
  98. package/dist/esm/isomorphic/client.js +30 -0
  99. package/dist/esm/isomorphic/client.js.map +1 -0
  100. package/dist/esm/isomorphic/utils/createAccount.d.ts +22 -0
  101. package/dist/esm/isomorphic/utils/createAccount.js +32 -0
  102. package/dist/esm/isomorphic/utils/createAccount.js.map +1 -0
  103. package/dist/esm/isomorphic/utils/createDummySigner.d.ts +3 -0
  104. package/dist/esm/isomorphic/utils/createDummySigner.js +17 -0
  105. package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -0
  106. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +20 -0
  107. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +21 -0
  108. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -0
  109. package/dist/esm/local/client.d.ts +3 -0
  110. package/dist/esm/local/client.js +89 -0
  111. package/dist/esm/local/client.js.map +1 -0
  112. package/dist/esm/remote/client.d.ts +3 -0
  113. package/dist/esm/remote/client.js +42 -0
  114. package/dist/esm/remote/client.js.map +1 -0
  115. package/dist/esm/rpc/request.d.ts +329 -0
  116. package/dist/esm/rpc/request.js +194 -0
  117. package/dist/esm/rpc/request.js.map +1 -0
  118. package/dist/esm/rpc/schema.d.ts +319 -0
  119. package/dist/esm/rpc/schema.js +5 -0
  120. package/dist/esm/rpc/schema.js.map +1 -0
  121. package/dist/esm/schemas.d.ts +216 -0
  122. package/dist/esm/schemas.js +211 -0
  123. package/dist/esm/schemas.js.map +1 -0
  124. package/dist/esm/types.d.ts +27 -0
  125. package/dist/esm/types.js +2 -0
  126. package/dist/esm/types.js.map +1 -0
  127. package/dist/esm/utils.d.ts +4 -0
  128. package/dist/esm/utils.js +12 -0
  129. package/dist/esm/utils.js.map +1 -0
  130. package/dist/types/abi/LightAccountFactoryAbi_V1_0_1.d.ts +56 -0
  131. package/dist/types/abi/LightAccountFactoryAbi_V1_0_1.d.ts.map +1 -0
  132. package/dist/types/abi/LightAccountFactoryAbi_V1_0_2.d.ts +56 -0
  133. package/dist/types/abi/LightAccountFactoryAbi_V1_0_2.d.ts.map +1 -0
  134. package/dist/types/abi/LightAccountFactoryAbi_V1_1_0.d.ts +56 -0
  135. package/dist/types/abi/LightAccountFactoryAbi_V1_1_0.d.ts.map +1 -0
  136. package/dist/types/abi/LightAccountFactoryAbi_V2_0_0.d.ts +257 -0
  137. package/dist/types/abi/LightAccountFactoryAbi_V2_0_0.d.ts.map +1 -0
  138. package/dist/types/abi/ModularAccountFactoryAbi_V2_0_0.d.ts +493 -0
  139. package/dist/types/abi/ModularAccountFactoryAbi_V2_0_0.d.ts.map +1 -0
  140. package/dist/types/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.d.ts +287 -0
  141. package/dist/types/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.d.ts.map +1 -0
  142. package/dist/types/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.d.ts +235 -0
  143. package/dist/types/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.d.ts.map +1 -0
  144. package/dist/types/abi/MultisigModularAccountFactoryAbi_V1_0_0.d.ts +247 -0
  145. package/dist/types/abi/MultisigModularAccountFactoryAbi_V1_0_0.d.ts.map +1 -0
  146. package/dist/types/abi/index.d.ts +9 -0
  147. package/dist/types/abi/index.d.ts.map +1 -0
  148. package/dist/types/capabilities/index.d.ts +9 -0
  149. package/dist/types/capabilities/index.d.ts.map +1 -0
  150. package/dist/types/capabilities/paymaster.d.ts +4 -0
  151. package/dist/types/capabilities/paymaster.d.ts.map +1 -0
  152. package/dist/types/capabilities/permissions/index.d.ts +99 -0
  153. package/dist/types/capabilities/permissions/index.d.ts.map +1 -0
  154. package/dist/types/capabilities/permissions/mav2.d.ts +37 -0
  155. package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -0
  156. package/dist/types/client/actions/createAccount.d.ts +11 -0
  157. package/dist/types/client/actions/createAccount.d.ts.map +1 -0
  158. package/dist/types/client/actions/getCallsStatus.d.ts +7 -0
  159. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -0
  160. package/dist/types/client/actions/grantPermissions.d.ts +14 -0
  161. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -0
  162. package/dist/types/client/actions/listAccounts.d.ts +7 -0
  163. package/dist/types/client/actions/listAccounts.d.ts.map +1 -0
  164. package/dist/types/client/actions/prepareCalls.d.ts +16 -0
  165. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -0
  166. package/dist/types/client/actions/requestAccount.d.ts +12 -0
  167. package/dist/types/client/actions/requestAccount.d.ts.map +1 -0
  168. package/dist/types/client/actions/sendPreparedCalls.d.ts +7 -0
  169. package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -0
  170. package/dist/types/client/actions/signMessage.d.ts +7 -0
  171. package/dist/types/client/actions/signMessage.d.ts.map +1 -0
  172. package/dist/types/client/actions/signSignatureRequest.d.ts +11 -0
  173. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -0
  174. package/dist/types/client/actions/signTypedData.d.ts +7 -0
  175. package/dist/types/client/actions/signTypedData.d.ts.map +1 -0
  176. package/dist/types/client/client.e2e-test.d.ts +2 -0
  177. package/dist/types/client/client.e2e-test.d.ts.map +1 -0
  178. package/dist/types/client/decorator.d.ts +25 -0
  179. package/dist/types/client/decorator.d.ts.map +1 -0
  180. package/dist/types/client/index.d.ts +19 -0
  181. package/dist/types/client/index.d.ts.map +1 -0
  182. package/dist/types/exports/index.d.ts +14 -0
  183. package/dist/types/exports/index.d.ts.map +1 -0
  184. package/dist/types/exports/internal.d.ts +14 -0
  185. package/dist/types/exports/internal.d.ts.map +1 -0
  186. package/dist/types/isomorphic/actions/createSession.d.ts +15 -0
  187. package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -0
  188. package/dist/types/isomorphic/actions/getCallsStatus.d.ts +22 -0
  189. package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -0
  190. package/dist/types/isomorphic/actions/prepareCalls.d.ts +9 -0
  191. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -0
  192. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +9 -0
  193. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -0
  194. package/dist/types/isomorphic/client.d.ts +98 -0
  195. package/dist/types/isomorphic/client.d.ts.map +1 -0
  196. package/dist/types/isomorphic/utils/createAccount.d.ts +23 -0
  197. package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -0
  198. package/dist/types/isomorphic/utils/createDummySigner.d.ts +4 -0
  199. package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +1 -0
  200. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +21 -0
  201. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -0
  202. package/dist/types/local/client.d.ts +4 -0
  203. package/dist/types/local/client.d.ts.map +1 -0
  204. package/dist/types/remote/client.d.ts +4 -0
  205. package/dist/types/remote/client.d.ts.map +1 -0
  206. package/dist/types/rpc/request.d.ts +330 -0
  207. package/dist/types/rpc/request.d.ts.map +1 -0
  208. package/dist/types/rpc/schema.d.ts +320 -0
  209. package/dist/types/rpc/schema.d.ts.map +1 -0
  210. package/dist/types/schemas.d.ts +217 -0
  211. package/dist/types/schemas.d.ts.map +1 -0
  212. package/dist/types/types.d.ts +28 -0
  213. package/dist/types/types.d.ts.map +1 -0
  214. package/dist/types/utils.d.ts +5 -0
  215. package/dist/types/utils.d.ts.map +1 -0
  216. package/package.json +67 -0
  217. package/src/abi/LightAccountFactoryAbi_V1_0_1.ts +44 -0
  218. package/src/abi/LightAccountFactoryAbi_V1_0_2.ts +44 -0
  219. package/src/abi/LightAccountFactoryAbi_V1_1_0.ts +44 -0
  220. package/src/abi/LightAccountFactoryAbi_V2_0_0.ts +201 -0
  221. package/src/abi/ModularAccountFactoryAbi_V2_0_0.ts +398 -0
  222. package/src/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.ts +224 -0
  223. package/src/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.ts +178 -0
  224. package/src/abi/MultisigModularAccountFactoryAbi_V1_0_0.ts +181 -0
  225. package/src/abi/index.ts +8 -0
  226. package/src/capabilities/index.ts +11 -0
  227. package/src/capabilities/paymaster.ts +5 -0
  228. package/src/capabilities/permissions/index.ts +124 -0
  229. package/src/capabilities/permissions/mav2.ts +127 -0
  230. package/src/client/actions/createAccount.ts +28 -0
  231. package/src/client/actions/getCallsStatus.ts +29 -0
  232. package/src/client/actions/grantPermissions.ts +48 -0
  233. package/src/client/actions/listAccounts.ts +18 -0
  234. package/src/client/actions/prepareCalls.ts +55 -0
  235. package/src/client/actions/requestAccount.ts +71 -0
  236. package/src/client/actions/sendPreparedCalls.ts +23 -0
  237. package/src/client/actions/signMessage.ts +32 -0
  238. package/src/client/actions/signSignatureRequest.ts +34 -0
  239. package/src/client/actions/signTypedData.ts +32 -0
  240. package/src/client/client.e2e-test.ts +294 -0
  241. package/src/client/decorator.ts +102 -0
  242. package/src/client/index.ts +93 -0
  243. package/src/exports/index.ts +32 -0
  244. package/src/exports/internal.ts +16 -0
  245. package/src/isomorphic/actions/createSession.ts +116 -0
  246. package/src/isomorphic/actions/getCallsStatus.ts +98 -0
  247. package/src/isomorphic/actions/prepareCalls.ts +99 -0
  248. package/src/isomorphic/actions/sendPreparedCalls.ts +95 -0
  249. package/src/isomorphic/client.ts +81 -0
  250. package/src/isomorphic/utils/createAccount.ts +58 -0
  251. package/src/isomorphic/utils/createDummySigner.ts +26 -0
  252. package/src/isomorphic/utils/parsePermissionsContext.ts +33 -0
  253. package/src/local/client.ts +132 -0
  254. package/src/remote/client.ts +67 -0
  255. package/src/rpc/request.ts +258 -0
  256. package/src/rpc/schema.ts +40 -0
  257. package/src/schemas.ts +257 -0
  258. package/src/types.ts +60 -0
  259. package/src/utils.ts +13 -0
@@ -0,0 +1,43 @@
1
+ import {} from "@aa-sdk/core";
2
+ import {} from "@account-kit/infra";
3
+ import {} from "viem";
4
+ import { createLocalClient } from "../local/client";
5
+ import { createRemoteClient } from "../remote/client";
6
+ import { smartWalletClientActions } from "./decorator";
7
+ export function createSmartWalletClient(params) {
8
+ const { transport, chain, policyId, mode, account, signer } = params;
9
+ const innerClient = mode === "local"
10
+ ? createLocalClient({
11
+ transport,
12
+ chain,
13
+ policyId,
14
+ account,
15
+ })
16
+ : createRemoteClient({
17
+ transport,
18
+ chain,
19
+ policyId,
20
+ account,
21
+ });
22
+ // TODO: we need to do a few things here:
23
+ // 1. decorate the client with the wallet api actions
24
+ // 2. potentially we might want to make this client async and have it use `requestAccount` so that it can create a SCA client with an account attached to it
25
+ return innerClient.extend((client) => smartWalletClientActions(client, signer));
26
+ }
27
+ // Example usage:
28
+ // const clientWithoutAccount = createSmartWalletClient({
29
+ // transport: alchemy({ apiKey: "123" }),
30
+ // chain: baseSepolia,
31
+ // signer: createDummySigner(zeroAddress),
32
+ // mode: "local",
33
+ // });
34
+ // const account1 = await clientWithoutAccount.requestAccount();
35
+ // const clientWithAccount = createSmartWalletClient({
36
+ // transport: alchemy({ apiKey: "123" }),
37
+ // chain: baseSepolia,
38
+ // signer: createDummySigner(zeroAddress),
39
+ // mode: "local",
40
+ // account: zeroAddress,
41
+ // });
42
+ // const account2 = await clientWithAccount.requestAccount();
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,cAAc,CAAC;AACvD,OAAO,EAAyB,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAMN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,wBAAwB,EAA2B,MAAM,aAAa,CAAC;AAoChF,MAAM,UAAU,uBAAuB,CAAC,MAA+B;IACrE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAErE,MAAM,WAAW,GACf,IAAI,KAAK,OAAO;QACd,CAAC,CAAC,iBAAiB,CAAC;YAChB,SAAS;YACT,KAAK;YACL,QAAQ;YACR,OAAO;SACR,CAAC;QACJ,CAAC,CAAC,kBAAkB,CAAC;YACjB,SAAS;YACT,KAAK;YACL,QAAQ;YACR,OAAO;SACR,CAAC,CAAC;IAET,yCAAyC;IACzC,qDAAqD;IACrD,4JAA4J;IAC5J,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CACnC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,iBAAiB;AACjB,yDAAyD;AACzD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,mBAAmB;AACnB,MAAM;AAEN,gEAAgE;AAEhE,sDAAsD;AACtD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,mBAAmB;AACnB,0BAA0B;AAC1B,MAAM;AAEN,6DAA6D","sourcesContent":["import { type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type AlchemyTransport } from \"@account-kit/infra\";\nimport {\n type Address,\n type Chain,\n type IsUndefined,\n type JsonRpcAccount,\n type Prettify,\n} from \"viem\";\nimport { createLocalClient } from \"../local/client\";\nimport { createRemoteClient } from \"../remote/client\";\nimport type { InnerWalletApiClient } from \"../types\";\nimport { smartWalletClientActions, type SmartWalletActions } from \"./decorator\";\n\nexport type SmartWalletClientParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = Prettify<\n {\n transport: AlchemyTransport;\n chain: Chain;\n signer: SmartAccountSigner;\n mode: \"local\" | \"remote\";\n policyId?: string;\n } & (IsUndefined<TAccount> extends true\n ? {\n account?: never;\n }\n : {\n account: Address;\n })\n>;\n\nexport function createSmartWalletClient<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n params: SmartWalletClientParams<TAccount>,\n): InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;\n\nexport function createSmartWalletClient<\n TAccount extends JsonRpcAccount<Address> = JsonRpcAccount<Address>,\n>(\n params: SmartWalletClientParams<TAccount>,\n): InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;\n\nexport function createSmartWalletClient(params: SmartWalletClientParams) {\n const { transport, chain, policyId, mode, account, signer } = params;\n\n const innerClient =\n mode === \"local\"\n ? createLocalClient({\n transport,\n chain,\n policyId,\n account,\n })\n : createRemoteClient({\n transport,\n chain,\n policyId,\n account,\n });\n\n // TODO: we need to do a few things here:\n // 1. decorate the client with the wallet api actions\n // 2. potentially we might want to make this client async and have it use `requestAccount` so that it can create a SCA client with an account attached to it\n return innerClient.extend((client) =>\n smartWalletClientActions(client, signer),\n );\n}\n\n// Example usage:\n// const clientWithoutAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// mode: \"local\",\n// });\n\n// const account1 = await clientWithoutAccount.requestAccount();\n\n// const clientWithAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// mode: \"local\",\n// account: zeroAddress,\n// });\n\n// const account2 = await clientWithAccount.requestAccount();\n"]}
@@ -0,0 +1,13 @@
1
+ export { createSmartWalletClient, type SmartWalletClientParams, } from "../client";
2
+ export { WalletServerRpcSchema, type WalletServerRpcSchemaType, type WalletServerViemRpcSchema, } from "../rpc/schema";
3
+ export { Capabilities } from "../capabilities";
4
+ export { PaymasterCapability } from "../capabilities/paymaster";
5
+ export { PermissionsArray, PermissionsCapability, PermissionsContext, PermissionsData, } from "../capabilities/permissions";
6
+ export { createAccount } from "../client/actions/createAccount";
7
+ export { listAccounts } from "../client/actions/listAccounts";
8
+ export { prepareCalls } from "../client/actions/prepareCalls";
9
+ export { requestAccount } from "../client/actions/requestAccount";
10
+ export { getCallsStatus } from "../client/actions/getCallsStatus";
11
+ export { signSignatureRequest } from "../client/actions/signSignatureRequest";
12
+ export { signMessage } from "../client/actions/signMessage";
13
+ export { signTypedData } from "../client/actions/signTypedData";
@@ -0,0 +1,18 @@
1
+ // TODO: anything that we want to expose publicly should be exported from `index.ts` files in the subdirectories
2
+ // and we shouldn't export * for the sake of tree-shaking
3
+ export { createSmartWalletClient, } from "../client";
4
+ export { WalletServerRpcSchema, } from "../rpc/schema";
5
+ // capabilities: TODO: should these actually just have the types exported?
6
+ export { Capabilities } from "../capabilities";
7
+ export { PaymasterCapability } from "../capabilities/paymaster";
8
+ export { PermissionsArray, PermissionsCapability, PermissionsContext, PermissionsData, } from "../capabilities/permissions";
9
+ // client actions
10
+ export { createAccount } from "../client/actions/createAccount";
11
+ export { listAccounts } from "../client/actions/listAccounts";
12
+ export { prepareCalls } from "../client/actions/prepareCalls";
13
+ export { requestAccount } from "../client/actions/requestAccount";
14
+ export { getCallsStatus } from "../client/actions/getCallsStatus";
15
+ export { signSignatureRequest } from "../client/actions/signSignatureRequest";
16
+ export { signMessage } from "../client/actions/signMessage";
17
+ export { signTypedData } from "../client/actions/signTypedData";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,yDAAyD;AACzD,OAAO,EACL,uBAAuB,GAExB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,qBAAqB,GAGtB,MAAM,eAAe,CAAC;AAEvB,0EAA0E;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAChB,MAAM,6BAA6B,CAAC;AAErC,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["// TODO: anything that we want to expose publicly should be exported from `index.ts` files in the subdirectories\n// and we shouldn't export * for the sake of tree-shaking\nexport {\n createSmartWalletClient,\n type SmartWalletClientParams,\n} from \"../client\";\n\nexport {\n WalletServerRpcSchema,\n type WalletServerRpcSchemaType,\n type WalletServerViemRpcSchema,\n} from \"../rpc/schema\";\n\n// capabilities: TODO: should these actually just have the types exported?\nexport { Capabilities } from \"../capabilities\";\nexport { PaymasterCapability } from \"../capabilities/paymaster\";\nexport {\n PermissionsArray,\n PermissionsCapability,\n PermissionsContext,\n PermissionsData,\n} from \"../capabilities/permissions\";\n\n// client actions\nexport { createAccount } from \"../client/actions/createAccount\";\nexport { listAccounts } from \"../client/actions/listAccounts\";\nexport { prepareCalls } from \"../client/actions/prepareCalls\";\nexport { requestAccount } from \"../client/actions/requestAccount\";\nexport { getCallsStatus } from \"../client/actions/getCallsStatus\";\nexport { signSignatureRequest } from \"../client/actions/signSignatureRequest\";\nexport { signMessage } from \"../client/actions/signMessage\";\nexport { signTypedData } from \"../client/actions/signTypedData\";\n"]}
@@ -0,0 +1,13 @@
1
+ export * from "../capabilities";
2
+ export * from "../capabilities/paymaster";
3
+ export * from "../capabilities/permissions";
4
+ export * from "../capabilities/permissions/mav2";
5
+ export type * from "../isomorphic/client";
6
+ export { createIsomorphicClient } from "../isomorphic/client";
7
+ export { createDummySigner } from "../isomorphic/utils/createDummySigner";
8
+ export * from "../rpc/request";
9
+ export * as RpcSchemas from "../rpc/request";
10
+ export * from "../rpc/schema";
11
+ export * from "../schemas";
12
+ export type * from "../types";
13
+ export * from "../utils";
@@ -0,0 +1,15 @@
1
+ // exports from this file are meant to be imported by our packages in the monorepo
2
+ // we will expose this in the package.json as a named export like `this-pkg/internal`
3
+ // TODO: name `this-pkg`
4
+ export * from "../capabilities";
5
+ export * from "../capabilities/paymaster";
6
+ export * from "../capabilities/permissions";
7
+ export * from "../capabilities/permissions/mav2";
8
+ export { createIsomorphicClient } from "../isomorphic/client";
9
+ export { createDummySigner } from "../isomorphic/utils/createDummySigner";
10
+ export * from "../rpc/request";
11
+ export * as RpcSchemas from "../rpc/request";
12
+ export * from "../rpc/schema";
13
+ export * from "../schemas";
14
+ export * from "../utils";
15
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/exports/internal.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,qFAAqF;AACrF,wBAAwB;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,cAAc,gBAAgB,CAAC;AAC/B,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAE3B,cAAc,UAAU,CAAC","sourcesContent":["// exports from this file are meant to be imported by our packages in the monorepo\n// we will expose this in the package.json as a named export like `this-pkg/internal`\n// TODO: name `this-pkg`\nexport * from \"../capabilities\";\nexport * from \"../capabilities/paymaster\";\nexport * from \"../capabilities/permissions\";\nexport * from \"../capabilities/permissions/mav2\";\nexport type * from \"../isomorphic/client\";\nexport { createIsomorphicClient } from \"../isomorphic/client\";\nexport { createDummySigner } from \"../isomorphic/utils/createDummySigner\";\nexport * from \"../rpc/request\";\nexport * as RpcSchemas from \"../rpc/request\";\nexport * from \"../rpc/schema\";\nexport * from \"../schemas\";\nexport type * from \"../types\";\nexport * from \"../utils\";\n"]}
@@ -0,0 +1,14 @@
1
+ import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
2
+ import { type Chain, type Transport, type Hex } from "viem";
3
+ import type { wallet_createSession } from "../../rpc/request";
4
+ import type { WalletServerViemRpcSchema } from "../../rpc/schema";
5
+ import type { Static } from "@sinclair/typebox";
6
+ export type CreateSessionParams = Omit<Static<(typeof wallet_createSession)["properties"]["Request"]["properties"]["params"]>[0], "chainId"> & {
7
+ entityId?: Hex;
8
+ };
9
+ export type CreateSessionResult = Omit<Static<(typeof wallet_createSession)["properties"]["ReturnType"]>, "sessionId"> & {
10
+ sessionId: Hex | null;
11
+ entityId: Hex;
12
+ fullPreSignatureDeferredActionDigest: Hex;
13
+ };
14
+ export declare function createSession(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: CreateSessionParams): Promise<CreateSessionResult>;
@@ -0,0 +1,63 @@
1
+ import { createSmartAccountClient, } from "@aa-sdk/core";
2
+ import { ChainNotFoundError, custom, hexToNumber, toHex, } from "viem";
3
+ import { isGlobalValidation } from "../../capabilities/permissions/mav2";
4
+ import { deferralActions, PermissionBuilder, } from "@account-kit/smart-contracts/experimental";
5
+ import { createDummySigner } from "../utils/createDummySigner";
6
+ import { createAccount, isModularAccountV2 } from "../utils/createAccount";
7
+ export async function createSession(client, params) {
8
+ if (!client.chain) {
9
+ throw new ChainNotFoundError();
10
+ }
11
+ const { counterfactualInfo } = await client.request({
12
+ method: "wallet_requestAccount",
13
+ params: [
14
+ {
15
+ includeCounterfactualInfo: true,
16
+ accountAddress: params.account,
17
+ },
18
+ ],
19
+ });
20
+ if (!counterfactualInfo) {
21
+ throw new Error("No counterfactual info found.");
22
+ }
23
+ const account = await createAccount({
24
+ chain: client.chain,
25
+ transport: custom(client.transport),
26
+ signer: createDummySigner(params.account),
27
+ accountAddress: params.account,
28
+ counterfactualInfo,
29
+ });
30
+ if (!isModularAccountV2(account)) {
31
+ throw new Error("Sessions are currently only supported by MAv2 accounts.");
32
+ }
33
+ const _client = createSmartAccountClient({
34
+ chain: client.chain,
35
+ transport: custom(client.transport),
36
+ account,
37
+ }).extend(deferralActions);
38
+ const { entityId, nonce } = await _client.getEntityIdAndNonce({
39
+ entityId: params.entityId ? hexToNumber(params.entityId) : undefined,
40
+ isGlobalValidation: isGlobalValidation(params),
41
+ });
42
+ const { typedData, fullPreSignatureDeferredActionDigest } = await new PermissionBuilder({
43
+ client: _client,
44
+ key: params.key,
45
+ entityId,
46
+ nonce,
47
+ deadline: params.expiry,
48
+ })
49
+ .addPermissions({
50
+ permissions: params.permissions,
51
+ })
52
+ .compileDeferred();
53
+ return {
54
+ sessionId: null, // In remote mode, the server will set this later.
55
+ entityId: toHex(entityId),
56
+ signatureRequest: {
57
+ type: "eth_signTypedData_v4",
58
+ data: typedData,
59
+ },
60
+ fullPreSignatureDeferredActionDigest,
61
+ };
62
+ }
63
+ //# sourceMappingURL=createSession.js.map
@@ -0,0 +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,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAoB3E,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,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClD,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE;YACN;gBACE,yBAAyB,EAAE,IAAI;gBAC/B,cAAc,EAAE,MAAM,CAAC,OAAO;aAC/B;SACF;KACF,CAAC,CAAC;IACH,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC;QACzC,cAAc,EAAE,MAAM,CAAC,OAAO;QAC9B,kBAAkB;KACnB,CAAC,CAAC;IAEH,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,OAAO,GAAG,wBAAwB,CAAC;QACvC,KAAK,EAAE,MAAM,CAAC,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;KAChC,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\";\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,\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"]}
@@ -0,0 +1,21 @@
1
+ import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
2
+ import type { Static } from "@sinclair/typebox";
3
+ import { type Chain, type Transport } from "viem";
4
+ import type { wallet_getCallsStatus } from "../../rpc/request";
5
+ import type { WalletServerViemRpcSchema } from "../../rpc/schema";
6
+ export type GetCallsStatusParams = Static<(typeof wallet_getCallsStatus)["properties"]["Request"]["properties"]["params"]>[0];
7
+ 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
+ export declare function getCallsStatus(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, callId: GetCallsStatusParams): Promise<GetCallsStatusResponse>;
@@ -0,0 +1,60 @@
1
+ import {} from "@aa-sdk/core";
2
+ import { ChainNotFoundError, isHex, } from "viem";
3
+ import { TypeCallId } from "../../schemas";
4
+ import { castToHex } from "../../utils";
5
+ 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
+ };
23
+ export async function getCallsStatus(client, callId) {
24
+ if (!client.chain) {
25
+ throw new ChainNotFoundError();
26
+ }
27
+ const { chainId, hash } = Value.Decode(TypeCallId, callId);
28
+ const result = await client.getUserOperationReceipt(hash);
29
+ return {
30
+ id: callId,
31
+ chainId,
32
+ 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)],
39
+ };
40
+ }
41
+ function transformReceipt(receipt) {
42
+ return {
43
+ // viem's type for status is "success" | "reverted", but the actual value seems to already be 0x0 or 0x1
44
+ status: isHex(receipt.status)
45
+ ? receipt.status
46
+ : ReceiptStatus[receipt.status],
47
+ blockHash: receipt.blockHash,
48
+ // viem's type for blockNumber is bigint, but the actual value seems to already be a hex string
49
+ blockNumber: castToHex(receipt.blockNumber),
50
+ // viem's type for gasUsed is bigint, but the actual value seems to already be a hex string
51
+ gasUsed: castToHex(receipt.gasUsed),
52
+ transactionHash: receipt.transactionHash,
53
+ logs: receipt.logs.map((log) => ({
54
+ address: log.address,
55
+ data: log.data,
56
+ topics: log.topics,
57
+ })),
58
+ };
59
+ }
60
+ //# sourceMappingURL=getCallsStatus.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,8 @@
1
+ import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
2
+ import type { Static } from "@sinclair/typebox";
3
+ import { type Chain, type Transport } from "viem";
4
+ import type { wallet_prepareCalls } from "../../rpc/request";
5
+ import type { WalletServerViemRpcSchema } from "../../rpc/schema";
6
+ export type PrepareCallsParams = Omit<Static<(typeof wallet_prepareCalls)["properties"]["Request"]["properties"]["params"]>[0], "chainId">;
7
+ export type PrepareCallsResult = Static<(typeof wallet_prepareCalls)["properties"]["ReturnType"]>;
8
+ export declare function prepareCalls(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: PrepareCallsParams): Promise<PrepareCallsResult>;
@@ -0,0 +1,57 @@
1
+ import { deepHexlify, } from "@aa-sdk/core";
2
+ import { custom, fromHex, zeroAddress, ChainNotFoundError, toHex, } from "viem";
3
+ import { createAccount } from "../utils/createAccount";
4
+ import { createDummySigner } from "../utils/createDummySigner";
5
+ // TODO: handle capabilities like permissions and paymaster here
6
+ export async function prepareCalls(client, params) {
7
+ if (!client.chain) {
8
+ throw new ChainNotFoundError();
9
+ }
10
+ // in local mode, we probably want some kind of caching for this
11
+ const { counterfactualInfo } = await client.request({
12
+ method: "wallet_requestAccount",
13
+ params: [
14
+ {
15
+ accountAddress: params.from,
16
+ includeCounterfactualInfo: true,
17
+ },
18
+ ],
19
+ });
20
+ if (!counterfactualInfo) {
21
+ throw new Error("No counterfactual info found.");
22
+ }
23
+ const account = await createAccount({
24
+ chain: client.chain,
25
+ transport: custom(client.transport),
26
+ signer: createDummySigner(zeroAddress),
27
+ accountAddress: params.from,
28
+ counterfactualInfo,
29
+ capabilities: params.capabilities,
30
+ });
31
+ // TODO: oops we don't actually support setting the policyId as an override here
32
+ // if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly
33
+ const builtUo = await client.buildUserOperation({
34
+ uo: params.calls.map((x) => ({
35
+ target: x.to,
36
+ data: x.data ?? "0x",
37
+ value: x.value ? fromHex(x.value, "bigint") : undefined,
38
+ })),
39
+ account,
40
+ });
41
+ const uoRequest = deepHexlify(builtUo);
42
+ const hash = account.getEntryPoint().getUserOperationHash(uoRequest);
43
+ return {
44
+ type: account.getEntryPoint().version === "0.7.0"
45
+ ? "user-operation-v070"
46
+ : "user-operation-v060",
47
+ data: uoRequest,
48
+ chainId: toHex(client.chain.id),
49
+ signatureRequest: {
50
+ type: "personal_sign",
51
+ data: {
52
+ raw: hash,
53
+ },
54
+ },
55
+ };
56
+ }
57
+ //# sourceMappingURL=prepareCalls.js.map
@@ -0,0 +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,MAAM,EACN,OAAO,EACP,WAAW,EAGX,kBAAkB,EAClB,KAAK,GACN,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,gEAAgE;IAChE,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClD,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE;YACN;gBACE,cAAc,EAAE,MAAM,CAAC,IAAI;gBAC3B,yBAAyB,EAAE,IAAI;aAChC;SACF;KACF,CAAC,CAAC;IACH,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACtC,cAAc,EAAE,MAAM,CAAC,IAAI;QAC3B,kBAAkB;QAClB,YAAY,EAAE,MAAM,CAAC,YAAY;KAClC,CAAC,CAAC;IAEH,gFAAgF;IAChF,iIAAiI;IACjI,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC;QAC9C,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3B,MAAM,EAAE,CAAC,CAAC,EAAE;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI;YACpB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;SACxD,CAAC,CAAC;QACH,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAEvC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAErE,OAAO;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 custom,\n fromHex,\n zeroAddress,\n type Chain,\n type Transport,\n ChainNotFoundError,\n toHex,\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 });\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"]}
@@ -0,0 +1,8 @@
1
+ import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
2
+ import { type Chain, type Transport } from "viem";
3
+ import type { wallet_sendPreparedCalls } from "../../rpc/request";
4
+ import type { WalletServerViemRpcSchema } from "../../rpc/schema";
5
+ import type { Static } from "@sinclair/typebox";
6
+ export type SendPreparedCallsParams = Omit<Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0], "chainId">;
7
+ export type SendPreparedCallsResult = Static<(typeof wallet_sendPreparedCalls)["properties"]["ReturnType"]>;
8
+ export declare function sendPreparedCalls(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;
@@ -0,0 +1,43 @@
1
+ import { getEntryPoint, } from "@aa-sdk/core";
2
+ import { ChainNotFoundError, concat, concatHex, toHex, } from "viem";
3
+ import { decodePermissionsContext } from "../../capabilities/permissions/mav2";
4
+ import { Value } from "@sinclair/typebox/value";
5
+ import { TypeCallId } from "../../schemas";
6
+ // TODO: this only supports MAv2 right now, we need to fix this
7
+ export async function sendPreparedCalls(client, params) {
8
+ if (!client.chain) {
9
+ throw new ChainNotFoundError();
10
+ }
11
+ const deferredAction = (() => {
12
+ if (!params.capabilities?.permissions?.context) {
13
+ return;
14
+ }
15
+ const decodedContext = decodePermissionsContext(params.capabilities.permissions.context);
16
+ if (decodedContext.contextVersion === "REMOTE_MODE_DEFERRED_ACTION") {
17
+ throw new Error("Remote mode deferred action not supported in isomorphic client");
18
+ }
19
+ return decodedContext.deferredAction;
20
+ })();
21
+ const entryPoint = params.type === "user-operation-v060"
22
+ ? getEntryPoint(client.chain, { version: "0.6.0" })
23
+ : getEntryPoint(client.chain, { version: "0.7.0" });
24
+ const hash = await client.sendRawUserOperation({
25
+ ...params.data,
26
+ signature: deferredAction != null
27
+ ? concatHex([
28
+ `0x${deferredAction.slice(68)}`, // Cuts off stuff preprended to the digest (nonce, etc. that we had previously).
29
+ "0xff",
30
+ "0x00",
31
+ params.signature.signature,
32
+ ])
33
+ : concat(["0xFF", "0x00", params.signature.signature]),
34
+ }, entryPoint.address);
35
+ const callId = Value.Encode(TypeCallId, {
36
+ chainId: toHex(client.chain.id),
37
+ hash,
38
+ });
39
+ return {
40
+ preparedCallIds: [callId],
41
+ };
42
+ }
43
+ //# sourceMappingURL=sendPreparedCalls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAGd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAG/E,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAc3C,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAMC,EACD,MAA+B;IAE/B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,cAAc,GAAoB,CAAC,GAAG,EAAE;QAC5C,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;YAC/C,OAAO;QACT,CAAC;QAED,MAAM,cAAc,GAAG,wBAAwB,CAC7C,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CACxC,CAAC;QAEF,IAAI,cAAc,CAAC,cAAc,KAAK,6BAA6B,EAAE,CAAC;YACpE,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QAED,OAAO,cAAc,CAAC,cAAc,CAAC;IACvC,CAAC,CAAC,EAAE,CAAC;IAEL,MAAM,UAAU,GACd,MAAM,CAAC,IAAI,KAAK,qBAAqB;QACnC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QACnD,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAExD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAC5C;QACE,GAAG,MAAM,CAAC,IAAI;QACd,SAAS,EACP,cAAc,IAAI,IAAI;YACpB,CAAC,CAAC,SAAS,CAAC;gBACR,KAAK,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,gFAAgF;gBACjH,MAAM;gBACN,MAAM;gBACN,MAAM,CAAC,SAAS,CAAC,SAAS;aAC3B,CAAC;YACJ,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;KAC3D,EACD,UAAU,CAAC,OAAO,CACnB,CAAC;IAEF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE;QACtC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,IAAI;KACL,CAAC,CAAC;IAEH,OAAO;QACL,eAAe,EAAE,CAAC,MAAM,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import {\n getEntryPoint,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport {\n ChainNotFoundError,\n concat,\n concatHex,\n toHex,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { decodePermissionsContext } from \"../../capabilities/permissions/mav2\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport { TypeCallId } from \"../../schemas\";\nimport type { Static } from \"@sinclair/typebox\";\n\nexport type SendPreparedCallsParams = Omit<\n Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\n\nexport type SendPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"ReturnType\"]\n>;\n\n// TODO: this only supports MAv2 right now, we need to fix this\nexport async function sendPreparedCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const deferredAction: Hex | undefined = (() => {\n if (!params.capabilities?.permissions?.context) {\n return;\n }\n\n const decodedContext = decodePermissionsContext(\n params.capabilities.permissions.context,\n );\n\n if (decodedContext.contextVersion === \"REMOTE_MODE_DEFERRED_ACTION\") {\n throw new Error(\n \"Remote mode deferred action not supported in isomorphic client\",\n );\n }\n\n return decodedContext.deferredAction;\n })();\n\n const entryPoint =\n params.type === \"user-operation-v060\"\n ? getEntryPoint(client.chain, { version: \"0.6.0\" })\n : getEntryPoint(client.chain, { version: \"0.7.0\" });\n\n const hash = await client.sendRawUserOperation(\n {\n ...params.data,\n signature:\n deferredAction != null\n ? concatHex([\n `0x${deferredAction.slice(68)}`, // Cuts off stuff preprended to the digest (nonce, etc. that we had previously).\n \"0xff\",\n \"0x00\",\n params.signature.signature,\n ])\n : concat([\"0xFF\", \"0x00\", params.signature.signature]),\n },\n entryPoint.address,\n );\n\n const callId = Value.Encode(TypeCallId, {\n chainId: toHex(client.chain.id),\n hash,\n });\n\n return {\n preparedCallIds: [callId],\n };\n}\n"]}
@@ -0,0 +1,97 @@
1
+ import { type SmartAccountClient, type SmartAccountClientRpcSchema, type SmartContractAccount } from "@aa-sdk/core";
2
+ import { type Chain, type Transport } from "viem";
3
+ import type { WalletServerViemRpcSchema } from "../rpc/schema";
4
+ import { type PrepareCallsParams } from "./actions/prepareCalls";
5
+ import { type SendPreparedCallsParams } from "./actions/sendPreparedCalls";
6
+ import { type GetCallsStatusParams } from "./actions/getCallsStatus";
7
+ import { type CreateSessionParams } from "./actions/createSession";
8
+ type ClientParams = {
9
+ chain: Chain;
10
+ transport: Transport;
11
+ policyId?: string;
12
+ };
13
+ export declare function isomorphicClientActions(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>): {
14
+ prepareCalls: (params: PrepareCallsParams) => Promise<{
15
+ type: "user-operation-v060" | "user-operation-v070";
16
+ chainId: `0x${string}`;
17
+ data: {
18
+ sender: `0x${string}`;
19
+ nonce: `0x${string}`;
20
+ initCode: `0x${string}`;
21
+ callData: `0x${string}`;
22
+ callGasLimit: `0x${string}`;
23
+ verificationGasLimit: `0x${string}`;
24
+ preVerificationGas: `0x${string}`;
25
+ maxFeePerGas: `0x${string}`;
26
+ maxPriorityFeePerGas: `0x${string}`;
27
+ paymasterAndData: `0x${string}`;
28
+ } | {
29
+ factory?: `0x${string}` | undefined;
30
+ factoryData?: `0x${string}` | undefined;
31
+ paymaster?: `0x${string}` | undefined;
32
+ paymasterData?: `0x${string}` | undefined;
33
+ paymasterVerificationGasLimit?: `0x${string}` | undefined;
34
+ paymasterPostOpGasLimit?: `0x${string}` | undefined;
35
+ sender: `0x${string}`;
36
+ nonce: `0x${string}`;
37
+ callData: `0x${string}`;
38
+ callGasLimit: `0x${string}`;
39
+ verificationGasLimit: `0x${string}`;
40
+ preVerificationGas: `0x${string}`;
41
+ maxFeePerGas: `0x${string}`;
42
+ maxPriorityFeePerGas: `0x${string}`;
43
+ };
44
+ signatureRequest: {
45
+ type: "personal_sign";
46
+ data: string | {
47
+ raw: `0x${string}`;
48
+ };
49
+ } | {
50
+ type: "eth_signTypedData_v4";
51
+ data: {
52
+ domain?: {
53
+ salt?: `0x${string}` | undefined;
54
+ chainId?: number | undefined;
55
+ name?: string | undefined;
56
+ verifyingContract?: `0x${string}` | undefined;
57
+ version?: string | undefined;
58
+ } | undefined;
59
+ types: {
60
+ [x: string]: {
61
+ type: string;
62
+ name: string;
63
+ }[];
64
+ };
65
+ primaryType: string;
66
+ message: {
67
+ [x: string]: unknown;
68
+ };
69
+ };
70
+ };
71
+ }>;
72
+ sendPreparedCalls: (params: SendPreparedCallsParams) => Promise<{
73
+ preparedCallIds: `0x${string}`[];
74
+ }>;
75
+ getCallsStatus: (params: GetCallsStatusParams) => Promise<{
76
+ receipts?: {
77
+ status: `0x${string}`;
78
+ logs: {
79
+ data: `0x${string}`;
80
+ address: `0x${string}`;
81
+ topics: `0x${string}`[];
82
+ }[];
83
+ blockHash: `0x${string}`;
84
+ blockNumber: `0x${string}`;
85
+ gasUsed: `0x${string}`;
86
+ transactionHash: `0x${string}`;
87
+ }[] | undefined;
88
+ chainId: `0x${string}`;
89
+ id: `0x${string}`;
90
+ atomic: boolean;
91
+ status: 100 | 200 | 400 | 500 | 600;
92
+ }>;
93
+ createSession: (params: CreateSessionParams) => Promise<import("./actions/createSession").CreateSessionResult>;
94
+ };
95
+ export declare function createIsomorphicClient({ chain, transport, policyId, }: ClientParams): SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, ReturnType<typeof isomorphicClientActions>, WalletServerViemRpcSchema & SmartAccountClientRpcSchema>;
96
+ export type IsomorphicClient = ReturnType<typeof createIsomorphicClient>;
97
+ export {};
@@ -0,0 +1,30 @@
1
+ import { createSmartAccountClient, } from "@aa-sdk/core";
2
+ import { alchemyFeeEstimator, alchemyGasManagerMiddleware, } from "@account-kit/infra";
3
+ import {} from "viem";
4
+ import { prepareCalls } from "./actions/prepareCalls";
5
+ import { sendPreparedCalls, } from "./actions/sendPreparedCalls";
6
+ import { getCallsStatus, } from "./actions/getCallsStatus";
7
+ import { createSession, } from "./actions/createSession";
8
+ export function isomorphicClientActions(client) {
9
+ return {
10
+ prepareCalls: (params) => prepareCalls(client, params),
11
+ sendPreparedCalls: (params) => sendPreparedCalls(client, params),
12
+ getCallsStatus: (params) => getCallsStatus(client, params),
13
+ createSession: (params) => createSession(client, params),
14
+ };
15
+ }
16
+ // the isomorphic client likely won't be exposed directly. This client contains the business logic that can be run on the wallet server or on the client
17
+ // if the dev chooses to run the client in "local" mode.
18
+ export function createIsomorphicClient({ chain, transport, policyId, }) {
19
+ // This must be a smart account client since as of now we use it to build UOs under the hood
20
+ const client = createSmartAccountClient({
21
+ transport,
22
+ chain,
23
+ // TODO: we will want to enforce alchemy transport here probably
24
+ feeEstimator: alchemyFeeEstimator(transport),
25
+ // TODO: we need to use the other middleware that does gas estimation as well here
26
+ ...(policyId ? alchemyGasManagerMiddleware(policyId) : {}),
27
+ }).extend(isomorphicClientActions);
28
+ return client;
29
+ }
30
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/isomorphic/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAIzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,2BAA2B,GAE5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAA8B,MAAM,MAAM,CAAC;AAElD,OAAO,EAAE,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,iBAAiB,GAElB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,cAAc,GAEf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,aAAa,GAEd,MAAM,yBAAyB,CAAC;AASjC,MAAM,UAAU,uBAAuB,CACrC,MAMC;IAED,OAAO;QACL,YAAY,EAAE,CAAC,MAA0B,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;QAC1E,iBAAiB,EAAE,CAAC,MAA+B,EAAE,EAAE,CACrD,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;QACnC,cAAc,EAAE,CAAC,MAA4B,EAAE,EAAE,CAC/C,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC;QAChC,aAAa,EAAE,CAAC,MAA2B,EAAE,EAAE,CAC7C,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC;KAChC,CAAC;AACJ,CAAC;AAED,wJAAwJ;AACxJ,wDAAwD;AACxD,MAAM,UAAU,sBAAsB,CAAC,EACrC,KAAK,EACL,SAAS,EACT,QAAQ,GACK;IAOb,4FAA4F;IAC5F,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,SAAS;QACT,KAAK;QACL,gEAAgE;QAChE,YAAY,EAAE,mBAAmB,CAAC,SAA6B,CAAC;QAChE,kFAAkF;QAClF,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3D,CAAC,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAEnC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n type SmartAccountClient,\n type SmartAccountClientRpcSchema,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport {\n alchemyFeeEstimator,\n alchemyGasManagerMiddleware,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\nimport { type Chain, type Transport } from \"viem\";\nimport type { WalletServerViemRpcSchema } from \"../rpc/schema\";\nimport { prepareCalls, type PrepareCallsParams } from \"./actions/prepareCalls\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsParams,\n} from \"./actions/sendPreparedCalls\";\nimport {\n getCallsStatus,\n type GetCallsStatusParams,\n} from \"./actions/getCallsStatus\";\nimport {\n createSession,\n type CreateSessionParams,\n} from \"./actions/createSession\";\n\n// let's start with something that takes in as many params as possible, then we can eliminate them as we don't need them\ntype ClientParams = {\n chain: Chain;\n transport: Transport;\n policyId?: string;\n};\n\nexport function isomorphicClientActions(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n) {\n return {\n prepareCalls: (params: PrepareCallsParams) => prepareCalls(client, params),\n sendPreparedCalls: (params: SendPreparedCallsParams) =>\n sendPreparedCalls(client, params),\n getCallsStatus: (params: GetCallsStatusParams) =>\n getCallsStatus(client, params),\n createSession: (params: CreateSessionParams) =>\n createSession(client, params),\n };\n}\n\n// the isomorphic client likely won't be exposed directly. This client contains the business logic that can be run on the wallet server or on the client\n// if the dev chooses to run the client in \"local\" mode.\nexport function createIsomorphicClient({\n chain,\n transport,\n policyId,\n}: ClientParams): SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n ReturnType<typeof isomorphicClientActions>,\n WalletServerViemRpcSchema & SmartAccountClientRpcSchema\n> {\n // This must be a smart account client since as of now we use it to build UOs under the hood\n const client = createSmartAccountClient({\n transport,\n chain,\n // TODO: we will want to enforce alchemy transport here probably\n feeEstimator: alchemyFeeEstimator(transport as AlchemyTransport),\n // TODO: we need to use the other middleware that does gas estimation as well here\n ...(policyId ? alchemyGasManagerMiddleware(policyId) : {}),\n }).extend(isomorphicClientActions);\n\n return client;\n}\n\nexport type IsomorphicClient = ReturnType<typeof createIsomorphicClient>;\n"]}