@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,102 @@
1
+ import type { SmartAccountSigner } from "@aa-sdk/core";
2
+ import type {
3
+ Hex,
4
+ JsonRpcAccount,
5
+ SignableMessage,
6
+ TypedDataDefinition,
7
+ } from "viem";
8
+ import type {
9
+ SendPreparedCallsParams,
10
+ SendPreparedCallsResult,
11
+ } from "../isomorphic/actions/sendPreparedCalls";
12
+ import type { InnerWalletApiClient } from "../types";
13
+ import {
14
+ createAccount,
15
+ type CreateAccountParams,
16
+ type CreateAccountResult,
17
+ } from "./actions/createAccount";
18
+ import {
19
+ listAccounts,
20
+ type ListAccountsParams,
21
+ type ListAccountsResult,
22
+ } from "./actions/listAccounts";
23
+ import {
24
+ prepareCalls,
25
+ type PrepareCallsParams,
26
+ type PrepareCallsResult,
27
+ } from "./actions/prepareCalls";
28
+ import {
29
+ requestAccount,
30
+ type RequestAccountParams,
31
+ type RequestAccountResult,
32
+ } from "./actions/requestAccount";
33
+ import {
34
+ getCallsStatus,
35
+ type GetCallsStatusParams,
36
+ type GetCallsStatusResult,
37
+ } from "./actions/getCallsStatus";
38
+ import {
39
+ signSignatureRequest,
40
+ type SignSignatureRequestParams,
41
+ type SignSignatureRequestResult,
42
+ } from "./actions/signSignatureRequest";
43
+ import { signMessage } from "./actions/signMessage";
44
+ import { signTypedData } from "./actions/signTypedData";
45
+ import {
46
+ grantPermissions,
47
+ type GrantPermissionsParams,
48
+ type GrantPermissionsResult,
49
+ } from "./actions/grantPermissions";
50
+ import { sendPreparedCalls } from "./actions/sendPreparedCalls";
51
+
52
+ export type SmartWalletActions<
53
+ TAccount extends JsonRpcAccount | undefined = JsonRpcAccount | undefined,
54
+ > = {
55
+ requestAccount: (
56
+ params?: RequestAccountParams<TAccount>,
57
+ ) => Promise<RequestAccountResult>;
58
+ prepareCalls: (
59
+ params: PrepareCallsParams<TAccount>,
60
+ ) => Promise<PrepareCallsResult>;
61
+ sendPreparedCalls: (
62
+ params: SendPreparedCallsParams,
63
+ ) => Promise<SendPreparedCallsResult>;
64
+ createAccount: (params: CreateAccountParams) => Promise<CreateAccountResult>;
65
+ listAccounts: (params: ListAccountsParams) => Promise<ListAccountsResult>;
66
+ getCallsStatus: (
67
+ params: GetCallsStatusParams,
68
+ ) => Promise<GetCallsStatusResult>;
69
+ signSignatureRequest: (
70
+ params: SignSignatureRequestParams,
71
+ ) => Promise<SignSignatureRequestResult>;
72
+ signMessage: (params: SignableMessage) => Promise<Hex>;
73
+ signTypedData: (params: TypedDataDefinition) => Promise<Hex>;
74
+ grantPermissions: (
75
+ params: GrantPermissionsParams,
76
+ ) => Promise<GrantPermissionsResult>;
77
+ };
78
+
79
+ export function smartWalletClientActions<
80
+ TAccount extends JsonRpcAccount | undefined = JsonRpcAccount | undefined,
81
+ >(
82
+ client: InnerWalletApiClient<TAccount>,
83
+ signer: SmartAccountSigner,
84
+ ): SmartWalletActions<TAccount>;
85
+
86
+ export function smartWalletClientActions(
87
+ client: InnerWalletApiClient,
88
+ signer: SmartAccountSigner,
89
+ ): SmartWalletActions {
90
+ return {
91
+ requestAccount: (params) => requestAccount(client, signer, params),
92
+ createAccount: (params) => createAccount(client, signer, params),
93
+ prepareCalls: (params) => prepareCalls(client, params),
94
+ listAccounts: (params) => listAccounts(client, params),
95
+ sendPreparedCalls: (params) => sendPreparedCalls(client, params),
96
+ getCallsStatus: (params) => getCallsStatus(client, params),
97
+ signSignatureRequest: (params) => signSignatureRequest(signer, params),
98
+ signMessage: (params) => signMessage(client, signer, params),
99
+ signTypedData: (params) => signTypedData(client, signer, params),
100
+ grantPermissions: (params) => grantPermissions(client, signer, params),
101
+ };
102
+ }
@@ -0,0 +1,93 @@
1
+ import { type SmartAccountSigner } from "@aa-sdk/core";
2
+ import { type AlchemyTransport } from "@account-kit/infra";
3
+ import {
4
+ type Address,
5
+ type Chain,
6
+ type IsUndefined,
7
+ type JsonRpcAccount,
8
+ type Prettify,
9
+ } from "viem";
10
+ import { createLocalClient } from "../local/client";
11
+ import { createRemoteClient } from "../remote/client";
12
+ import type { InnerWalletApiClient } from "../types";
13
+ import { smartWalletClientActions, type SmartWalletActions } from "./decorator";
14
+
15
+ export type SmartWalletClientParams<
16
+ TAccount extends JsonRpcAccount<Address> | undefined =
17
+ | JsonRpcAccount<Address>
18
+ | undefined,
19
+ > = Prettify<
20
+ {
21
+ transport: AlchemyTransport;
22
+ chain: Chain;
23
+ signer: SmartAccountSigner;
24
+ mode: "local" | "remote";
25
+ policyId?: string;
26
+ } & (IsUndefined<TAccount> extends true
27
+ ? {
28
+ account?: never;
29
+ }
30
+ : {
31
+ account: Address;
32
+ })
33
+ >;
34
+
35
+ export function createSmartWalletClient<
36
+ TAccount extends JsonRpcAccount<Address> | undefined =
37
+ | JsonRpcAccount<Address>
38
+ | undefined,
39
+ >(
40
+ params: SmartWalletClientParams<TAccount>,
41
+ ): InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;
42
+
43
+ export function createSmartWalletClient<
44
+ TAccount extends JsonRpcAccount<Address> = JsonRpcAccount<Address>,
45
+ >(
46
+ params: SmartWalletClientParams<TAccount>,
47
+ ): InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;
48
+
49
+ export function createSmartWalletClient(params: SmartWalletClientParams) {
50
+ const { transport, chain, policyId, mode, account, signer } = params;
51
+
52
+ const innerClient =
53
+ mode === "local"
54
+ ? createLocalClient({
55
+ transport,
56
+ chain,
57
+ policyId,
58
+ account,
59
+ })
60
+ : createRemoteClient({
61
+ transport,
62
+ chain,
63
+ policyId,
64
+ account,
65
+ });
66
+
67
+ // TODO: we need to do a few things here:
68
+ // 1. decorate the client with the wallet api actions
69
+ // 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
70
+ return innerClient.extend((client) =>
71
+ smartWalletClientActions(client, signer),
72
+ );
73
+ }
74
+
75
+ // Example usage:
76
+ // const clientWithoutAccount = createSmartWalletClient({
77
+ // transport: alchemy({ apiKey: "123" }),
78
+ // chain: baseSepolia,
79
+ // signer: createDummySigner(zeroAddress),
80
+ // mode: "local",
81
+ // });
82
+
83
+ // const account1 = await clientWithoutAccount.requestAccount();
84
+
85
+ // const clientWithAccount = createSmartWalletClient({
86
+ // transport: alchemy({ apiKey: "123" }),
87
+ // chain: baseSepolia,
88
+ // signer: createDummySigner(zeroAddress),
89
+ // mode: "local",
90
+ // account: zeroAddress,
91
+ // });
92
+
93
+ // const account2 = await clientWithAccount.requestAccount();
@@ -0,0 +1,32 @@
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 {
4
+ createSmartWalletClient,
5
+ type SmartWalletClientParams,
6
+ } from "../client";
7
+
8
+ export {
9
+ WalletServerRpcSchema,
10
+ type WalletServerRpcSchemaType,
11
+ type WalletServerViemRpcSchema,
12
+ } from "../rpc/schema";
13
+
14
+ // capabilities: TODO: should these actually just have the types exported?
15
+ export { Capabilities } from "../capabilities";
16
+ export { PaymasterCapability } from "../capabilities/paymaster";
17
+ export {
18
+ PermissionsArray,
19
+ PermissionsCapability,
20
+ PermissionsContext,
21
+ PermissionsData,
22
+ } from "../capabilities/permissions";
23
+
24
+ // client actions
25
+ export { createAccount } from "../client/actions/createAccount";
26
+ export { listAccounts } from "../client/actions/listAccounts";
27
+ export { prepareCalls } from "../client/actions/prepareCalls";
28
+ export { requestAccount } from "../client/actions/requestAccount";
29
+ export { getCallsStatus } from "../client/actions/getCallsStatus";
30
+ export { signSignatureRequest } from "../client/actions/signSignatureRequest";
31
+ export { signMessage } from "../client/actions/signMessage";
32
+ export { signTypedData } from "../client/actions/signTypedData";
@@ -0,0 +1,16 @@
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 type * from "../isomorphic/client";
9
+ export { createIsomorphicClient } from "../isomorphic/client";
10
+ export { createDummySigner } from "../isomorphic/utils/createDummySigner";
11
+ export * from "../rpc/request";
12
+ export * as RpcSchemas from "../rpc/request";
13
+ export * from "../rpc/schema";
14
+ export * from "../schemas";
15
+ export type * from "../types";
16
+ export * from "../utils";
@@ -0,0 +1,116 @@
1
+ import {
2
+ createSmartAccountClient,
3
+ type SmartAccountClient,
4
+ type SmartContractAccount,
5
+ } from "@aa-sdk/core";
6
+ import {
7
+ ChainNotFoundError,
8
+ type Chain,
9
+ type Transport,
10
+ custom,
11
+ hexToNumber,
12
+ type Hex,
13
+ toHex,
14
+ } from "viem";
15
+ import type { wallet_createSession } from "../../rpc/request";
16
+ import type { WalletServerViemRpcSchema } from "../../rpc/schema";
17
+ import type { Static } from "@sinclair/typebox";
18
+ import { isGlobalValidation } from "../../capabilities/permissions/mav2";
19
+ import {
20
+ deferralActions,
21
+ PermissionBuilder,
22
+ } from "@account-kit/smart-contracts/experimental";
23
+ import { createDummySigner } from "../utils/createDummySigner";
24
+ import { createAccount, isModularAccountV2 } from "../utils/createAccount";
25
+
26
+ export type CreateSessionParams = Omit<
27
+ Static<
28
+ (typeof wallet_createSession)["properties"]["Request"]["properties"]["params"]
29
+ >[0],
30
+ "chainId"
31
+ > & {
32
+ entityId?: Hex;
33
+ };
34
+
35
+ export type CreateSessionResult = Omit<
36
+ Static<(typeof wallet_createSession)["properties"]["ReturnType"]>,
37
+ "sessionId"
38
+ > & {
39
+ sessionId: Hex | null;
40
+ entityId: Hex;
41
+ fullPreSignatureDeferredActionDigest: Hex;
42
+ };
43
+
44
+ export async function createSession(
45
+ client: SmartAccountClient<
46
+ Transport,
47
+ Chain,
48
+ SmartContractAccount | undefined,
49
+ Record<string, unknown>,
50
+ WalletServerViemRpcSchema
51
+ >,
52
+ params: CreateSessionParams,
53
+ ): Promise<CreateSessionResult> {
54
+ if (!client.chain) {
55
+ throw new ChainNotFoundError();
56
+ }
57
+
58
+ const { counterfactualInfo } = await client.request({
59
+ method: "wallet_requestAccount",
60
+ params: [
61
+ {
62
+ includeCounterfactualInfo: true,
63
+ accountAddress: params.account,
64
+ },
65
+ ],
66
+ });
67
+ if (!counterfactualInfo) {
68
+ throw new Error("No counterfactual info found.");
69
+ }
70
+
71
+ const account = await createAccount({
72
+ chain: client.chain,
73
+ transport: custom(client.transport),
74
+ signer: createDummySigner(params.account),
75
+ accountAddress: params.account,
76
+ counterfactualInfo,
77
+ });
78
+
79
+ if (!isModularAccountV2(account)) {
80
+ throw new Error("Sessions are currently only supported by MAv2 accounts.");
81
+ }
82
+
83
+ const _client = createSmartAccountClient({
84
+ chain: client.chain,
85
+ transport: custom(client.transport),
86
+ account,
87
+ }).extend(deferralActions);
88
+
89
+ const { entityId, nonce } = await _client.getEntityIdAndNonce({
90
+ entityId: params.entityId ? hexToNumber(params.entityId) : undefined,
91
+ isGlobalValidation: isGlobalValidation(params),
92
+ });
93
+
94
+ const { typedData, fullPreSignatureDeferredActionDigest } =
95
+ await new PermissionBuilder({
96
+ client: _client,
97
+ key: params.key,
98
+ entityId,
99
+ nonce,
100
+ deadline: params.expiry,
101
+ })
102
+ .addPermissions({
103
+ permissions: params.permissions,
104
+ })
105
+ .compileDeferred();
106
+
107
+ return {
108
+ sessionId: null, // In remote mode, the server will set this later.
109
+ entityId: toHex(entityId),
110
+ signatureRequest: {
111
+ type: "eth_signTypedData_v4",
112
+ data: typedData,
113
+ },
114
+ fullPreSignatureDeferredActionDigest,
115
+ };
116
+ }
@@ -0,0 +1,98 @@
1
+ import {
2
+ type SmartAccountClient,
3
+ type SmartContractAccount,
4
+ } from "@aa-sdk/core";
5
+ import type { Static } from "@sinclair/typebox";
6
+ import {
7
+ ChainNotFoundError,
8
+ type Chain,
9
+ type Hex,
10
+ type TransactionReceipt,
11
+ type Transport,
12
+ isHex,
13
+ } from "viem";
14
+ import type { wallet_getCallsStatus } from "../../rpc/request";
15
+ import type { WalletServerViemRpcSchema } from "../../rpc/schema";
16
+ import { TypeCallId } from "../../schemas";
17
+ import { castToHex } from "../../utils";
18
+ import { Value } from "@sinclair/typebox/value";
19
+
20
+ export type GetCallsStatusParams = Static<
21
+ (typeof wallet_getCallsStatus)["properties"]["Request"]["properties"]["params"]
22
+ >[0];
23
+
24
+ export type GetCallsStatusResponse = Static<
25
+ (typeof wallet_getCallsStatus)["properties"]["ReturnType"]
26
+ >;
27
+
28
+ const ReceiptStatus: Record<TransactionReceipt["status"], Hex> = {
29
+ reverted: "0x0",
30
+ success: "0x1",
31
+ };
32
+
33
+ /** EIP-5792 call status codes */
34
+ export const CallStatusCode = {
35
+ /** Batch has been received by the wallet but has not completed execution onchain */
36
+ PENDING: 100,
37
+ /** Batch has been included onchain without reverts, receipts array contains info of all calls */
38
+ CONFIRMED: 200,
39
+ /** Batch has not been included onchain and wallet will not retry */
40
+ OFFCHAIN_FAILURE: 400,
41
+ /** Batch reverted *completely* and only changes related to gas charge may have been included onchain */
42
+ CHAIN_RULES_FAILURE: 500,
43
+ /** Batch reverted *partially* and some changes related to batch calls may have been included onchain */
44
+ PARTIAL_CHAIN_RULES_FAILURE: 600,
45
+ } as const;
46
+
47
+ export async function getCallsStatus(
48
+ client: SmartAccountClient<
49
+ Transport,
50
+ Chain,
51
+ SmartContractAccount | undefined,
52
+ Record<string, unknown>,
53
+ WalletServerViemRpcSchema
54
+ >,
55
+ callId: GetCallsStatusParams,
56
+ ): Promise<GetCallsStatusResponse> {
57
+ if (!client.chain) {
58
+ throw new ChainNotFoundError();
59
+ }
60
+
61
+ const { chainId, hash } = Value.Decode(TypeCallId, callId);
62
+
63
+ const result = await client.getUserOperationReceipt(hash);
64
+
65
+ return {
66
+ id: callId,
67
+ chainId,
68
+ atomic: true,
69
+ status: !result?.receipt
70
+ ? CallStatusCode.PENDING
71
+ : result.success
72
+ ? CallStatusCode.CONFIRMED
73
+ : CallStatusCode.CHAIN_RULES_FAILURE,
74
+ receipts: !result?.receipt ? undefined : [transformReceipt(result.receipt)],
75
+ };
76
+ }
77
+
78
+ function transformReceipt(
79
+ receipt: TransactionReceipt,
80
+ ): NonNullable<GetCallsStatusResponse["receipts"]>[number] {
81
+ return {
82
+ // viem's type for status is "success" | "reverted", but the actual value seems to already be 0x0 or 0x1
83
+ status: isHex(receipt.status)
84
+ ? receipt.status
85
+ : ReceiptStatus[receipt.status],
86
+ blockHash: receipt.blockHash,
87
+ // viem's type for blockNumber is bigint, but the actual value seems to already be a hex string
88
+ blockNumber: castToHex(receipt.blockNumber),
89
+ // viem's type for gasUsed is bigint, but the actual value seems to already be a hex string
90
+ gasUsed: castToHex(receipt.gasUsed),
91
+ transactionHash: receipt.transactionHash,
92
+ logs: receipt.logs.map((log) => ({
93
+ address: log.address,
94
+ data: log.data,
95
+ topics: log.topics,
96
+ })),
97
+ };
98
+ }
@@ -0,0 +1,99 @@
1
+ import {
2
+ deepHexlify,
3
+ type SmartAccountClient,
4
+ type SmartContractAccount,
5
+ } from "@aa-sdk/core";
6
+ import type { Static } from "@sinclair/typebox";
7
+ import {
8
+ custom,
9
+ fromHex,
10
+ zeroAddress,
11
+ type Chain,
12
+ type Transport,
13
+ ChainNotFoundError,
14
+ toHex,
15
+ } from "viem";
16
+ import type { wallet_prepareCalls } from "../../rpc/request";
17
+ import type { WalletServerViemRpcSchema } from "../../rpc/schema";
18
+ import { createAccount } from "../utils/createAccount";
19
+ import { createDummySigner } from "../utils/createDummySigner";
20
+
21
+ export type PrepareCallsParams = Omit<
22
+ Static<
23
+ (typeof wallet_prepareCalls)["properties"]["Request"]["properties"]["params"]
24
+ >[0],
25
+ "chainId"
26
+ >;
27
+
28
+ export type PrepareCallsResult = Static<
29
+ (typeof wallet_prepareCalls)["properties"]["ReturnType"]
30
+ >;
31
+
32
+ // TODO: handle capabilities like permissions and paymaster here
33
+ export async function prepareCalls(
34
+ client: SmartAccountClient<
35
+ Transport,
36
+ Chain,
37
+ SmartContractAccount | undefined,
38
+ Record<string, unknown>,
39
+ WalletServerViemRpcSchema
40
+ >,
41
+ params: PrepareCallsParams,
42
+ ): Promise<PrepareCallsResult> {
43
+ if (!client.chain) {
44
+ throw new ChainNotFoundError();
45
+ }
46
+
47
+ // in local mode, we probably want some kind of caching for this
48
+ const { counterfactualInfo } = await client.request({
49
+ method: "wallet_requestAccount",
50
+ params: [
51
+ {
52
+ accountAddress: params.from,
53
+ includeCounterfactualInfo: true,
54
+ },
55
+ ],
56
+ });
57
+ if (!counterfactualInfo) {
58
+ throw new Error("No counterfactual info found.");
59
+ }
60
+
61
+ const account = await createAccount({
62
+ chain: client.chain,
63
+ transport: custom(client.transport),
64
+ signer: createDummySigner(zeroAddress),
65
+ accountAddress: params.from,
66
+ counterfactualInfo,
67
+ capabilities: params.capabilities,
68
+ });
69
+
70
+ // TODO: oops we don't actually support setting the policyId as an override here
71
+ // if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly
72
+ const builtUo = await client.buildUserOperation({
73
+ uo: params.calls.map((x) => ({
74
+ target: x.to,
75
+ data: x.data ?? "0x",
76
+ value: x.value ? fromHex(x.value, "bigint") : undefined,
77
+ })),
78
+ account,
79
+ });
80
+
81
+ const uoRequest = deepHexlify(builtUo);
82
+
83
+ const hash = account.getEntryPoint().getUserOperationHash(uoRequest);
84
+
85
+ return {
86
+ type:
87
+ account.getEntryPoint().version === "0.7.0"
88
+ ? "user-operation-v070"
89
+ : "user-operation-v060",
90
+ data: uoRequest,
91
+ chainId: toHex(client.chain.id),
92
+ signatureRequest: {
93
+ type: "personal_sign",
94
+ data: {
95
+ raw: hash,
96
+ },
97
+ },
98
+ };
99
+ }
@@ -0,0 +1,95 @@
1
+ import {
2
+ getEntryPoint,
3
+ type SmartAccountClient,
4
+ type SmartContractAccount,
5
+ } from "@aa-sdk/core";
6
+ import {
7
+ ChainNotFoundError,
8
+ concat,
9
+ concatHex,
10
+ toHex,
11
+ type Chain,
12
+ type Hex,
13
+ type Transport,
14
+ } from "viem";
15
+ import { decodePermissionsContext } from "../../capabilities/permissions/mav2";
16
+ import type { wallet_sendPreparedCalls } from "../../rpc/request";
17
+ import type { WalletServerViemRpcSchema } from "../../rpc/schema";
18
+ import { Value } from "@sinclair/typebox/value";
19
+ import { TypeCallId } from "../../schemas";
20
+ import type { Static } from "@sinclair/typebox";
21
+
22
+ export type SendPreparedCallsParams = Omit<
23
+ Static<
24
+ (typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]
25
+ >[0],
26
+ "chainId"
27
+ >;
28
+
29
+ export type SendPreparedCallsResult = Static<
30
+ (typeof wallet_sendPreparedCalls)["properties"]["ReturnType"]
31
+ >;
32
+
33
+ // TODO: this only supports MAv2 right now, we need to fix this
34
+ export async function sendPreparedCalls(
35
+ client: SmartAccountClient<
36
+ Transport,
37
+ Chain,
38
+ SmartContractAccount | undefined,
39
+ Record<string, unknown>,
40
+ WalletServerViemRpcSchema
41
+ >,
42
+ params: SendPreparedCallsParams,
43
+ ): Promise<SendPreparedCallsResult> {
44
+ if (!client.chain) {
45
+ throw new ChainNotFoundError();
46
+ }
47
+
48
+ const deferredAction: Hex | undefined = (() => {
49
+ if (!params.capabilities?.permissions?.context) {
50
+ return;
51
+ }
52
+
53
+ const decodedContext = decodePermissionsContext(
54
+ params.capabilities.permissions.context,
55
+ );
56
+
57
+ if (decodedContext.contextVersion === "REMOTE_MODE_DEFERRED_ACTION") {
58
+ throw new Error(
59
+ "Remote mode deferred action not supported in isomorphic client",
60
+ );
61
+ }
62
+
63
+ return decodedContext.deferredAction;
64
+ })();
65
+
66
+ const entryPoint =
67
+ params.type === "user-operation-v060"
68
+ ? getEntryPoint(client.chain, { version: "0.6.0" })
69
+ : getEntryPoint(client.chain, { version: "0.7.0" });
70
+
71
+ const hash = await client.sendRawUserOperation(
72
+ {
73
+ ...params.data,
74
+ signature:
75
+ deferredAction != null
76
+ ? concatHex([
77
+ `0x${deferredAction.slice(68)}`, // Cuts off stuff preprended to the digest (nonce, etc. that we had previously).
78
+ "0xff",
79
+ "0x00",
80
+ params.signature.signature,
81
+ ])
82
+ : concat(["0xFF", "0x00", params.signature.signature]),
83
+ },
84
+ entryPoint.address,
85
+ );
86
+
87
+ const callId = Value.Encode(TypeCallId, {
88
+ chainId: toHex(client.chain.id),
89
+ hash,
90
+ });
91
+
92
+ return {
93
+ preparedCallIds: [callId],
94
+ };
95
+ }