@account-kit/wallet-client 0.1.0-alpha.4 → 0.1.0-alpha.6

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 (186) hide show
  1. package/dist/esm/capabilities/eip7702Auth.d.ts +4 -0
  2. package/dist/esm/capabilities/eip7702Auth.js +18 -0
  3. package/dist/esm/capabilities/eip7702Auth.js.map +1 -0
  4. package/dist/esm/capabilities/index.d.ts +4 -0
  5. package/dist/esm/capabilities/index.js +2 -0
  6. package/dist/esm/capabilities/index.js.map +1 -1
  7. package/dist/esm/capabilities/overrides.js +8 -8
  8. package/dist/esm/capabilities/overrides.js.map +1 -1
  9. package/dist/esm/capabilities/permissions/index.d.ts +2 -2
  10. package/dist/esm/capabilities/permissions/index.js +6 -3
  11. package/dist/esm/capabilities/permissions/index.js.map +1 -1
  12. package/dist/esm/capabilities/permissions/mav2.js +1 -0
  13. package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
  14. package/dist/esm/client/actions/getCallsStatus.d.ts +1 -2
  15. package/dist/esm/client/actions/getCallsStatus.js +19 -0
  16. package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
  17. package/dist/esm/client/actions/grantPermissions.d.ts +10 -65
  18. package/dist/esm/client/actions/grantPermissions.js +63 -4
  19. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  20. package/dist/esm/client/actions/prepareCalls.d.ts +4 -4
  21. package/dist/esm/client/actions/prepareCalls.js +38 -5
  22. package/dist/esm/client/actions/prepareCalls.js.map +1 -1
  23. package/dist/esm/client/actions/requestAccount.d.ts +3 -4
  24. package/dist/esm/client/actions/requestAccount.js +18 -1
  25. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  26. package/dist/esm/client/actions/sendPreparedCalls.d.ts +6 -14
  27. package/dist/esm/client/actions/sendPreparedCalls.js +11 -12
  28. package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
  29. package/dist/esm/client/actions/signMessage.d.ts +3 -3
  30. package/dist/esm/client/actions/signMessage.js +18 -0
  31. package/dist/esm/client/actions/signMessage.js.map +1 -1
  32. package/dist/esm/client/actions/signPreparedCalls.d.ts +14 -0
  33. package/dist/esm/client/actions/signPreparedCalls.js +53 -0
  34. package/dist/esm/client/actions/signPreparedCalls.js.map +1 -0
  35. package/dist/esm/client/actions/signSignatureRequest.d.ts +9 -8
  36. package/dist/esm/client/actions/signSignatureRequest.js +69 -31
  37. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  38. package/dist/esm/client/actions/signTypedData.d.ts +2 -2
  39. package/dist/esm/client/actions/signTypedData.js +31 -0
  40. package/dist/esm/client/actions/signTypedData.js.map +1 -1
  41. package/dist/esm/client/client.e2e-test.js +47 -44
  42. package/dist/esm/client/client.e2e-test.js.map +1 -1
  43. package/dist/esm/client/decorator.d.ts +7 -5
  44. package/dist/esm/client/decorator.js +3 -1
  45. package/dist/esm/client/decorator.js.map +1 -1
  46. package/dist/esm/client/index.d.ts +35 -10
  47. package/dist/esm/client/index.js +0 -29
  48. package/dist/esm/client/index.js.map +1 -1
  49. package/dist/esm/exports/index.d.ts +2 -1
  50. package/dist/esm/exports/index.js +2 -1
  51. package/dist/esm/exports/index.js.map +1 -1
  52. package/dist/esm/isomorphic/actions/createSession.js +15 -18
  53. package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
  54. package/dist/esm/isomorphic/actions/getCallsStatus.js +62 -9
  55. package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
  56. package/dist/esm/isomorphic/actions/prepareCalls.js +39 -26
  57. package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
  58. package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +3 -3
  59. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +77 -37
  60. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
  61. package/dist/esm/isomorphic/client.d.ts +139 -13
  62. package/dist/esm/isomorphic/utils/7702.d.ts +13 -6
  63. package/dist/esm/isomorphic/utils/7702.js +48 -13
  64. package/dist/esm/isomorphic/utils/7702.js.map +1 -1
  65. package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -2
  66. package/dist/esm/isomorphic/utils/createAccount.js +4 -3
  67. package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
  68. package/dist/esm/isomorphic/utils/decodeSignature.d.ts +3 -0
  69. package/dist/esm/isomorphic/utils/decodeSignature.js +13 -0
  70. package/dist/esm/isomorphic/utils/decodeSignature.js.map +1 -0
  71. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +2 -2
  72. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +8 -7
  73. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
  74. package/dist/esm/local/client.d.ts +2 -2
  75. package/dist/esm/local/client.js +2 -3
  76. package/dist/esm/local/client.js.map +1 -1
  77. package/dist/esm/remote/client.d.ts +8 -2
  78. package/dist/esm/remote/client.js +3 -13
  79. package/dist/esm/remote/client.js.map +1 -1
  80. package/dist/esm/rpc/examples.d.ts +3 -3
  81. package/dist/esm/rpc/examples.js +3 -3
  82. package/dist/esm/rpc/examples.js.map +1 -1
  83. package/dist/esm/rpc/request.d.ts +362 -44
  84. package/dist/esm/rpc/request.js +26 -56
  85. package/dist/esm/rpc/request.js.map +1 -1
  86. package/dist/esm/rpc/schema.d.ts +325 -49
  87. package/dist/esm/rpc/schema.js.map +1 -1
  88. package/dist/esm/schemas.d.ts +454 -14
  89. package/dist/esm/schemas.js +168 -53
  90. package/dist/esm/schemas.js.map +1 -1
  91. package/dist/esm/types.d.ts +10 -10
  92. package/dist/esm/types.js.map +1 -1
  93. package/dist/types/capabilities/eip7702Auth.d.ts +5 -0
  94. package/dist/types/capabilities/eip7702Auth.d.ts.map +1 -0
  95. package/dist/types/capabilities/index.d.ts +4 -0
  96. package/dist/types/capabilities/index.d.ts.map +1 -1
  97. package/dist/types/capabilities/permissions/index.d.ts +2 -2
  98. package/dist/types/capabilities/permissions/index.d.ts.map +1 -1
  99. package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -1
  100. package/dist/types/client/actions/getCallsStatus.d.ts +1 -2
  101. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  102. package/dist/types/client/actions/grantPermissions.d.ts +10 -65
  103. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  104. package/dist/types/client/actions/prepareCalls.d.ts +4 -4
  105. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  106. package/dist/types/client/actions/requestAccount.d.ts +3 -4
  107. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  108. package/dist/types/client/actions/sendPreparedCalls.d.ts +6 -14
  109. package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
  110. package/dist/types/client/actions/signMessage.d.ts +3 -3
  111. package/dist/types/client/actions/signMessage.d.ts.map +1 -1
  112. package/dist/types/client/actions/signPreparedCalls.d.ts +15 -0
  113. package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -0
  114. package/dist/types/client/actions/signSignatureRequest.d.ts +9 -8
  115. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  116. package/dist/types/client/actions/signTypedData.d.ts +2 -2
  117. package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
  118. package/dist/types/client/decorator.d.ts +7 -5
  119. package/dist/types/client/decorator.d.ts.map +1 -1
  120. package/dist/types/client/index.d.ts +35 -10
  121. package/dist/types/client/index.d.ts.map +1 -1
  122. package/dist/types/exports/index.d.ts +2 -1
  123. package/dist/types/exports/index.d.ts.map +1 -1
  124. package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
  125. package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -1
  126. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
  127. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +3 -3
  128. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
  129. package/dist/types/isomorphic/client.d.ts +139 -13
  130. package/dist/types/isomorphic/client.d.ts.map +1 -1
  131. package/dist/types/isomorphic/utils/7702.d.ts +13 -6
  132. package/dist/types/isomorphic/utils/7702.d.ts.map +1 -1
  133. package/dist/types/isomorphic/utils/createAccount.d.ts +2 -2
  134. package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
  135. package/dist/types/isomorphic/utils/decodeSignature.d.ts +4 -0
  136. package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +1 -0
  137. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +2 -2
  138. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
  139. package/dist/types/local/client.d.ts +2 -2
  140. package/dist/types/local/client.d.ts.map +1 -1
  141. package/dist/types/remote/client.d.ts +8 -2
  142. package/dist/types/remote/client.d.ts.map +1 -1
  143. package/dist/types/rpc/examples.d.ts +3 -3
  144. package/dist/types/rpc/examples.d.ts.map +1 -1
  145. package/dist/types/rpc/request.d.ts +362 -44
  146. package/dist/types/rpc/request.d.ts.map +1 -1
  147. package/dist/types/rpc/schema.d.ts +325 -49
  148. package/dist/types/rpc/schema.d.ts.map +1 -1
  149. package/dist/types/schemas.d.ts +454 -14
  150. package/dist/types/schemas.d.ts.map +1 -1
  151. package/dist/types/types.d.ts +10 -10
  152. package/dist/types/types.d.ts.map +1 -1
  153. package/package.json +2 -2
  154. package/src/capabilities/eip7702Auth.ts +26 -0
  155. package/src/capabilities/index.ts +2 -0
  156. package/src/capabilities/overrides.ts +8 -8
  157. package/src/capabilities/permissions/index.ts +8 -3
  158. package/src/capabilities/permissions/mav2.ts +1 -0
  159. package/src/client/actions/getCallsStatus.ts +0 -10
  160. package/src/client/actions/grantPermissions.ts +16 -84
  161. package/src/client/actions/prepareCalls.ts +18 -23
  162. package/src/client/actions/requestAccount.ts +9 -26
  163. package/src/client/actions/sendPreparedCalls.ts +17 -17
  164. package/src/client/actions/signMessage.ts +2 -17
  165. package/src/client/actions/signPreparedCalls.ts +71 -0
  166. package/src/client/actions/signSignatureRequest.ts +51 -47
  167. package/src/client/actions/signTypedData.ts +1 -16
  168. package/src/client/client.e2e-test.ts +54 -57
  169. package/src/client/decorator.ts +19 -15
  170. package/src/client/index.ts +16 -39
  171. package/src/exports/index.ts +2 -1
  172. package/src/isomorphic/actions/createSession.ts +17 -20
  173. package/src/isomorphic/actions/getCallsStatus.ts +82 -10
  174. package/src/isomorphic/actions/prepareCalls.ts +43 -27
  175. package/src/isomorphic/actions/sendPreparedCalls.ts +105 -55
  176. package/src/isomorphic/utils/7702.ts +79 -21
  177. package/src/isomorphic/utils/createAccount.ts +5 -5
  178. package/src/isomorphic/utils/decodeSignature.ts +18 -0
  179. package/src/isomorphic/utils/parsePermissionsContext.ts +9 -9
  180. package/src/local/client.ts +5 -11
  181. package/src/remote/client.ts +7 -22
  182. package/src/rpc/examples.ts +3 -4
  183. package/src/rpc/request.ts +41 -64
  184. package/src/rpc/schema.ts +2 -2
  185. package/src/schemas.ts +232 -54
  186. package/src/types.ts +9 -21
@@ -1,28 +1,37 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import type { Static } from "@sinclair/typebox";
3
- import { type Hex, toHex } from "viem";
4
- import { TypeSignatureRequest } from "../../schemas.js";
3
+ import { type Hex, hexToNumber, serializeSignature } from "viem";
5
4
  import { assertNever } from "../../utils.js";
6
- import type { Eip7702ExtendedFields } from "@aa-sdk/core";
5
+ import {
6
+ TypeAuthorizationSignatureRequest,
7
+ TypePersonalSignSignatureRequest,
8
+ TypeTypedDataSignatureRequest,
9
+ } from "../../schemas.js";
10
+ import { TypeEip7702UnsignedAuth } from "../../schemas.js";
11
+ import { vToYParity } from "ox/Signature";
7
12
 
8
- export type SignSignatureRequestParams = Static<typeof TypeSignatureRequest>;
13
+ export type SignSignatureRequestParams =
14
+ | Static<typeof TypePersonalSignSignatureRequest>
15
+ | Static<typeof TypeTypedDataSignatureRequest>
16
+ | (Static<typeof TypeAuthorizationSignatureRequest> & {
17
+ data: Static<typeof TypeEip7702UnsignedAuth>;
18
+ });
9
19
 
10
20
  export type SignSignatureRequestResult = {
11
- type: "ecdsa";
12
- signature: Hex;
13
- signedAuthorization?: Eip7702ExtendedFields["eip7702Auth"];
21
+ type: "secp256k1";
22
+ data: Hex;
14
23
  };
15
24
 
16
25
  /**
17
26
  * Signs a signature request using the provided signer.
18
- * This method handles different types of signature requests including personal_sign and eth_signTypedData_v4.
27
+ * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
19
28
  *
20
29
  * @param {SmartAccountSigner} signer - The signer to use for signing the request
21
30
  * @param {SignSignatureRequestParams} params - The signature request parameters
22
31
  * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
23
32
  * @param {any} params.data - The data to sign, format depends on the signature type
24
33
  * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
25
- * @returns {string} result.type - The signature type (currently only 'ecdsa' is supported)
34
+ * @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)
26
35
  * @returns {Hex} result.signature - The hex-encoded signature
27
36
  * @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
28
37
  *
@@ -45,49 +54,44 @@ export type SignSignatureRequestResult = {
45
54
  * }
46
55
  * });
47
56
  */
48
- export function signSignatureRequest(
49
- signer: SmartAccountSigner,
50
- params: SignSignatureRequestParams,
51
- ): Promise<SignSignatureRequestResult>;
52
57
 
53
58
  export async function signSignatureRequest(
54
59
  signer: SmartAccountSigner,
55
60
  params: SignSignatureRequestParams,
56
61
  ): Promise<SignSignatureRequestResult> {
57
- const signature =
58
- params.type === "personal_sign"
59
- ? await signer.signMessage(params.data)
60
- : params.type === "eth_signTypedData_v4"
61
- ? await signer.signTypedData(params.data)
62
- : assertNever(params, "Unexpected signature request type");
63
-
64
- if (!params.authorizationRequest) {
65
- return {
66
- type: "ecdsa" as const,
67
- signature,
68
- };
69
- }
62
+ switch (params.type) {
63
+ case "personal_sign": {
64
+ return {
65
+ type: "secp256k1",
66
+ data: await signer.signMessage(params.data),
67
+ };
68
+ }
69
+ case "eth_signTypedData_v4": {
70
+ return {
71
+ type: "secp256k1",
72
+ data: await signer.signTypedData(params.data),
73
+ };
74
+ }
75
+ case "eip7702Auth": {
76
+ if (!signer.signAuthorization) {
77
+ throw new Error("Signer does not implement signAuthorization");
78
+ }
79
+ const { r, s, v, yParity } = await signer.signAuthorization({
80
+ ...params.data,
81
+ chainId: hexToNumber(params.data.chainId),
82
+ nonce: hexToNumber(params.data.nonce),
83
+ });
70
84
 
71
- if (!signer.signAuthorization) {
72
- throw new Error("Signer does not implement signAuthorization");
85
+ return {
86
+ type: "secp256k1",
87
+ data: serializeSignature({
88
+ r,
89
+ s,
90
+ yParity: yParity ?? vToYParity(Number(v)),
91
+ }),
92
+ };
93
+ }
94
+ default:
95
+ return assertNever(params, `Unexpected signature request type.`);
73
96
  }
74
-
75
- const authSig = await signer.signAuthorization(params.authorizationRequest);
76
- const { r, s } = authSig;
77
- const yParity = toHex(authSig.yParity ?? authSig.v - 27n);
78
-
79
- const signedAuthorization = {
80
- chainId: toHex(params.authorizationRequest.chainId),
81
- nonce: toHex(params.authorizationRequest.nonce),
82
- address: params.authorizationRequest.address,
83
- r,
84
- s,
85
- yParity,
86
- };
87
-
88
- return {
89
- type: "ecdsa" as const,
90
- signature,
91
- signedAuthorization,
92
- };
93
97
  }
@@ -1,10 +1,5 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
- import {
3
- type Address,
4
- type Hex,
5
- type JsonRpcAccount,
6
- type TypedDataDefinition,
7
- } from "viem";
2
+ import { type Address, type Hex, type TypedDataDefinition } from "viem";
8
3
  import type { InnerWalletApiClient } from "../../types.ts";
9
4
  import { requestAccount } from "./requestAccount.js";
10
5
 
@@ -45,16 +40,6 @@ export type SignTypedDataResult = Hex;
45
40
  * }
46
41
  * });
47
42
  */
48
- export async function signTypedData<
49
- TAccount extends JsonRpcAccount<Address> | undefined =
50
- | JsonRpcAccount<Address>
51
- | undefined,
52
- >(
53
- client: InnerWalletApiClient<TAccount>,
54
- signer: SmartAccountSigner,
55
- params: SignTypedDataParams,
56
- ): Promise<SignTypedDataResult>;
57
-
58
43
  export async function signTypedData(
59
44
  client: InnerWalletApiClient,
60
45
  signer: SmartAccountSigner,
@@ -2,7 +2,6 @@ import { LocalAccountSigner } from "@aa-sdk/core";
2
2
  import { alchemy, arbitrumSepolia } from "@account-kit/infra";
3
3
  import { describe, expect, it } from "bun:test";
4
4
  import { createPublicClient, zeroAddress, type Address } from "viem";
5
- import { signSignatureRequest } from "./actions/signSignatureRequest.js";
6
5
  import { createSmartWalletClient } from "./index.js";
7
6
 
8
7
  describe("Client E2E Tests", () => {
@@ -17,7 +16,7 @@ describe("Client E2E Tests", () => {
17
16
  );
18
17
  describe("Local Mode Tests", () => {
19
18
  const signer = LocalAccountSigner.privateKeyToAccountSigner(
20
- "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff81",
19
+ "0xbaca22d9b6846ec09a4da378ffa07e2f14ce7d65675d135911b6fd281416bb03",
21
20
  );
22
21
 
23
22
  const client = createSmartWalletClient({
@@ -32,34 +31,34 @@ describe("Client E2E Tests", () => {
32
31
  transport,
33
32
  });
34
33
 
34
+ it("should successfully get a counterfactual address", async () => {
35
+ const account = await client.requestAccount();
36
+ expect(account.address).toMatchInlineSnapshot(
37
+ `"0xa46944b7a39c35d931D514ACAc3ac77c226a81ff"`,
38
+ );
39
+ });
40
+
35
41
  it("should successfully request account with different salt", async () => {
36
42
  const account = await client.requestAccount({
37
- id: "2d00c64e-2e55-4925-832e-e288dbf1139e",
43
+ id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
38
44
  creationHint: { salt: "0x1" },
39
45
  });
40
46
 
41
47
  expect(account.address).toMatchInlineSnapshot(
42
- `"0x569bCECaC47Ef9706c4b2370f2891bccd4cdE30c"`,
48
+ `"0xA692f0E5AfAD20F771443D89C635146C6A592f06"`,
43
49
  );
44
50
  });
45
51
 
46
52
  it("should not cache account if different inputs provided", async () => {
47
53
  const account = await client.requestAccount();
48
54
  const account2 = await client.requestAccount({
49
- id: "2d00c64e-2e55-4925-832e-e288dbf1139e",
50
- creationHint: { salt: "0x1" },
55
+ id: "52ab44be-b03e-47ed-ad65-43014ea5fbfc",
56
+ creationHint: { salt: "0x2" },
51
57
  });
52
58
 
53
59
  expect(account.address).not.toEqual(account2.address);
54
60
  });
55
61
 
56
- it("should successfully get a counterfactual address", async () => {
57
- const account = await client.requestAccount();
58
- expect(account.address).toMatchInlineSnapshot(
59
- `"0x26809de7733F9CcB5c0c61210a4f78d6F1daFc58"`,
60
- );
61
- });
62
-
63
62
  it("can correctly sign a message", async () => {
64
63
  const account = await client.requestAccount();
65
64
  const message = "hello world";
@@ -85,7 +84,7 @@ describe("Client E2E Tests", () => {
85
84
 
86
85
  it("can correctly sign a message with a different account", async () => {
87
86
  const account = await client.requestAccount({
88
- id: "2d00c64e-2e55-4925-832e-e288dbf1139e",
87
+ id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
89
88
  creationHint: { salt: "0x1" },
90
89
  });
91
90
  const message = "hello world";
@@ -104,7 +103,7 @@ describe("Client E2E Tests", () => {
104
103
 
105
104
  it("can correctly sign typed data with a different account", async () => {
106
105
  const account = await client.requestAccount({
107
- id: "2d00c64e-2e55-4925-832e-e288dbf1139e",
106
+ id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
108
107
  creationHint: { salt: "0x1" },
109
108
  });
110
109
 
@@ -122,7 +121,7 @@ describe("Client E2E Tests", () => {
122
121
 
123
122
  it("should successfully send a UO with paymaster", async () => {
124
123
  const account = await client.requestAccount();
125
- const preparedCall = await client.prepareCalls({
124
+ const preparedCalls = await client.prepareCalls({
126
125
  calls: [{ to: zeroAddress, value: "0x0" }],
127
126
  from: account.address,
128
127
  capabilities: {
@@ -132,14 +131,9 @@ describe("Client E2E Tests", () => {
132
131
  },
133
132
  });
134
133
 
135
- const signature = await client.signSignatureRequest(
136
- preparedCall.signatureRequest,
137
- );
134
+ const signedCalls = await client.signPreparedCalls(preparedCalls);
138
135
 
139
- const result = await client.sendPreparedCalls({
140
- ...preparedCall,
141
- signature,
142
- });
136
+ const result = await client.sendPreparedCalls(signedCalls);
143
137
 
144
138
  expect(result.preparedCallIds).toBeArrayOfSize(1);
145
139
  });
@@ -151,7 +145,7 @@ describe("Client E2E Tests", () => {
151
145
 
152
146
  const permissions = await client.grantPermissions({
153
147
  account: account.address,
154
- expiry: Math.floor(Date.now() / 1000) + 60 * 60,
148
+ expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
155
149
  key: {
156
150
  publicKey: await sessionKey.getAddress(),
157
151
  type: "secp256k1",
@@ -159,7 +153,14 @@ describe("Client E2E Tests", () => {
159
153
  permissions: [{ type: "root" }],
160
154
  });
161
155
 
162
- const preparedCall = await client.prepareCalls({
156
+ const sessionKeyClient = createSmartWalletClient({
157
+ transport,
158
+ chain: arbitrumSepolia,
159
+ mode: "local",
160
+ signer: sessionKey,
161
+ });
162
+
163
+ const preparedCalls = await sessionKeyClient.prepareCalls({
163
164
  calls: [{ to: zeroAddress, value: "0x0" }],
164
165
  from: account.address,
165
166
  capabilities: {
@@ -170,14 +171,11 @@ describe("Client E2E Tests", () => {
170
171
  },
171
172
  });
172
173
 
173
- const signature = await signSignatureRequest(
174
- sessionKey,
175
- preparedCall.signatureRequest,
176
- );
174
+ const signedCalls =
175
+ await sessionKeyClient.signPreparedCalls(preparedCalls);
177
176
 
178
- const result = await client.sendPreparedCalls({
179
- ...preparedCall,
180
- signature,
177
+ const result = await sessionKeyClient.sendPreparedCalls({
178
+ ...signedCalls,
181
179
  capabilities: {
182
180
  permissions,
183
181
  },
@@ -189,7 +187,7 @@ describe("Client E2E Tests", () => {
189
187
 
190
188
  describe("Remote Mode Tests", () => {
191
189
  const signer = LocalAccountSigner.privateKeyToAccountSigner(
192
- "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
190
+ "0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d",
193
191
  );
194
192
 
195
193
  const client = createSmartWalletClient({
@@ -207,26 +205,26 @@ describe("Client E2E Tests", () => {
207
205
  it("should successfully get a counterfactual address", async () => {
208
206
  const account = await client.requestAccount();
209
207
  expect(account.address).toMatchInlineSnapshot(
210
- `"0x65b5DE0251f553B2208762a4724303E750294D96"`,
208
+ `"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`,
211
209
  );
212
210
  });
213
211
 
214
212
  it("should successfully request account with different salt", async () => {
215
213
  const account = await client.requestAccount({
216
- id: "8670d2d8-2781-49e9-a75c-1eb980271ca9",
214
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
217
215
  creationHint: { salt: "0x1" },
218
216
  });
219
217
 
220
218
  expect(account.address).toMatchInlineSnapshot(
221
- `"0xC9B8271E44f14be83CecfDE1dDb325e9fa15e9Ff"`,
219
+ `"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`,
222
220
  );
223
221
  });
224
222
 
225
223
  it("should not cache account if different inputs provided", async () => {
226
224
  const account = await client.requestAccount();
227
225
  const account2 = await client.requestAccount({
228
- id: "8670d2d8-2781-49e9-a75c-1eb980271ca9",
229
- creationHint: { salt: "0x1" },
226
+ id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
227
+ creationHint: { salt: "0x2" },
230
228
  });
231
229
 
232
230
  expect(account.address).not.toEqual(account2.address);
@@ -257,7 +255,7 @@ describe("Client E2E Tests", () => {
257
255
 
258
256
  it("can correctly sign a message with a different account", async () => {
259
257
  const account = await client.requestAccount({
260
- id: "8670d2d8-2781-49e9-a75c-1eb980271ca9",
258
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
261
259
  creationHint: { salt: "0x1" },
262
260
  });
263
261
 
@@ -276,7 +274,7 @@ describe("Client E2E Tests", () => {
276
274
 
277
275
  it("can correctly sign typed data with a different account", async () => {
278
276
  const account = await client.requestAccount({
279
- id: "8670d2d8-2781-49e9-a75c-1eb980271ca9",
277
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
280
278
  creationHint: { salt: "0x1" },
281
279
  });
282
280
 
@@ -295,7 +293,7 @@ describe("Client E2E Tests", () => {
295
293
 
296
294
  it("should successfully send a UO with paymaster", async () => {
297
295
  const account = await client.requestAccount();
298
- const preparedCall = await client.prepareCalls({
296
+ const preparedCalls = await client.prepareCalls({
299
297
  calls: [{ to: zeroAddress, value: "0x0" }],
300
298
  from: account.address,
301
299
  capabilities: {
@@ -305,14 +303,9 @@ describe("Client E2E Tests", () => {
305
303
  },
306
304
  });
307
305
 
308
- const signature = await client.signSignatureRequest(
309
- preparedCall.signatureRequest,
310
- );
306
+ const signedCalls = await client.signPreparedCalls(preparedCalls);
311
307
 
312
- const result = await client.sendPreparedCalls({
313
- ...preparedCall,
314
- signature,
315
- });
308
+ const result = await client.sendPreparedCalls(signedCalls);
316
309
 
317
310
  expect(result.preparedCallIds).toBeArrayOfSize(1);
318
311
  });
@@ -324,7 +317,7 @@ describe("Client E2E Tests", () => {
324
317
 
325
318
  const permissions = await client.grantPermissions({
326
319
  account: account.address,
327
- expiry: Math.floor(Date.now() / 1000) + 60 * 60,
320
+ expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
328
321
  key: {
329
322
  publicKey: await sessionKey.getAddress(),
330
323
  type: "secp256k1",
@@ -332,7 +325,14 @@ describe("Client E2E Tests", () => {
332
325
  permissions: [{ type: "root" }],
333
326
  });
334
327
 
335
- const preparedCall = await client.prepareCalls({
328
+ const sessionKeyClient = createSmartWalletClient({
329
+ transport,
330
+ chain: arbitrumSepolia,
331
+ mode: "remote",
332
+ signer: sessionKey,
333
+ });
334
+
335
+ const preparedCalls = await sessionKeyClient.prepareCalls({
336
336
  calls: [{ to: zeroAddress, value: "0x0" }],
337
337
  from: account.address,
338
338
  capabilities: {
@@ -343,14 +343,11 @@ describe("Client E2E Tests", () => {
343
343
  },
344
344
  });
345
345
 
346
- const signature = await signSignatureRequest(
347
- sessionKey,
348
- preparedCall.signatureRequest,
349
- );
346
+ const signedCalls =
347
+ await sessionKeyClient.signPreparedCalls(preparedCalls);
350
348
 
351
- const result = await client.sendPreparedCalls({
352
- ...preparedCall,
353
- signature,
349
+ const result = await sessionKeyClient.sendPreparedCalls({
350
+ ...signedCalls,
354
351
  capabilities: {
355
352
  permissions,
356
353
  },
@@ -1,9 +1,5 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
- import type { Hex, JsonRpcAccount } from "viem";
3
- import type {
4
- SendPreparedCallsParams,
5
- SendPreparedCallsResult,
6
- } from "../isomorphic/actions/sendPreparedCalls.ts";
2
+ import type { Address, Hex } from "viem";
7
3
  import type { InnerWalletApiClient } from "../types.ts";
8
4
  import {
9
5
  createAccount,
@@ -35,7 +31,11 @@ import {
35
31
  type RequestAccountParams,
36
32
  type RequestAccountResult,
37
33
  } from "./actions/requestAccount.js";
38
- import { sendPreparedCalls } from "./actions/sendPreparedCalls.js";
34
+ import {
35
+ sendPreparedCalls,
36
+ type SendPreparedCallsParams,
37
+ type SendPreparedCallsResult,
38
+ } from "./actions/sendPreparedCalls.js";
39
39
  import { signMessage, type SignMessageParams } from "./actions/signMessage.js";
40
40
  import {
41
41
  signSignatureRequest,
@@ -46,12 +46,17 @@ import {
46
46
  signTypedData,
47
47
  type SignTypedDataParams,
48
48
  } from "./actions/signTypedData.js";
49
+ import {
50
+ signPreparedCalls,
51
+ type SignPreparedCallsParams,
52
+ type SignPreparedCallsResult,
53
+ } from "./actions/signPreparedCalls.js";
49
54
 
50
55
  export type SmartWalletActions<
51
- TAccount extends JsonRpcAccount | undefined = JsonRpcAccount | undefined,
56
+ TAccount extends Address | undefined = Address | undefined,
52
57
  > = {
53
58
  requestAccount: (
54
- params?: RequestAccountParams<TAccount>,
59
+ params?: RequestAccountParams,
55
60
  ) => Promise<RequestAccountResult>;
56
61
  prepareCalls: (
57
62
  params: PrepareCallsParams<TAccount>,
@@ -67,6 +72,9 @@ export type SmartWalletActions<
67
72
  signSignatureRequest: (
68
73
  params: SignSignatureRequestParams,
69
74
  ) => Promise<SignSignatureRequestResult>;
75
+ signPreparedCalls: (
76
+ params: SignPreparedCallsParams,
77
+ ) => Promise<SignPreparedCallsResult>;
70
78
  signMessage: (params: SignMessageParams) => Promise<Hex>;
71
79
  signTypedData: (params: SignTypedDataParams) => Promise<Hex>;
72
80
  grantPermissions: (
@@ -75,16 +83,11 @@ export type SmartWalletActions<
75
83
  };
76
84
 
77
85
  export function smartWalletClientActions<
78
- TAccount extends JsonRpcAccount | undefined = JsonRpcAccount | undefined,
86
+ TAccount extends Address | undefined = Address | undefined,
79
87
  >(
80
- client: InnerWalletApiClient<TAccount>,
81
- signer: SmartAccountSigner,
82
- ): SmartWalletActions<TAccount>;
83
-
84
- export function smartWalletClientActions(
85
88
  client: InnerWalletApiClient,
86
89
  signer: SmartAccountSigner,
87
- ): SmartWalletActions {
90
+ ): SmartWalletActions<TAccount> {
88
91
  return {
89
92
  requestAccount: (params) => requestAccount(client, signer, params),
90
93
  createAccount: (params) => createAccount(client, signer, params),
@@ -93,6 +96,7 @@ export function smartWalletClientActions(
93
96
  sendPreparedCalls: (params) => sendPreparedCalls(client, params),
94
97
  getCallsStatus: (params) => getCallsStatus(client, params),
95
98
  signSignatureRequest: (params) => signSignatureRequest(signer, params),
99
+ signPreparedCalls: (params) => signPreparedCalls(signer, params),
96
100
  signMessage: (params) => signMessage(client, signer, params),
97
101
  signTypedData: (params) => signTypedData(client, signer, params),
98
102
  grantPermissions: (params) => grantPermissions(client, signer, params),
@@ -1,12 +1,6 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import type { AlchemyTransport } from "@account-kit/infra";
3
- import type {
4
- Address,
5
- Chain,
6
- IsUndefined,
7
- JsonRpcAccount,
8
- Prettify,
9
- } from "viem";
3
+ import type { Address, Chain, Prettify } from "viem";
10
4
  import { createLocalClient } from "../local/client.js";
11
5
  import { createRemoteClient } from "../remote/client.js";
12
6
  import type { InnerWalletApiClient } from "../types.ts";
@@ -16,40 +10,19 @@ import {
16
10
  } from "./decorator.js";
17
11
 
18
12
  export type SmartWalletClientParams<
19
- TAccount extends JsonRpcAccount<Address> | undefined =
20
- | JsonRpcAccount<Address>
21
- | undefined,
22
- > = Prettify<
23
- {
24
- transport: AlchemyTransport;
25
- chain: Chain;
26
- signer: SmartAccountSigner;
27
- mode: "local" | "remote";
28
- policyId?: string;
29
- } & (IsUndefined<TAccount> extends true
30
- ? {
31
- account?: never;
32
- }
33
- : {
34
- account: Address;
35
- })
36
- >;
13
+ TAccount extends Address | undefined = Address | undefined,
14
+ > = Prettify<{
15
+ transport: AlchemyTransport;
16
+ chain: Chain;
17
+ signer: SmartAccountSigner;
18
+ mode: "local" | "remote";
19
+ policyId?: string;
20
+ account?: TAccount | Address | undefined;
21
+ }>;
37
22
 
38
23
  export type SmartWalletClient<
39
- TAccount extends JsonRpcAccount<Address> | undefined =
40
- | JsonRpcAccount<Address>
41
- | undefined,
42
- > = InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;
43
-
44
- export function createSmartWalletClient<
45
- TAccount extends JsonRpcAccount<Address> | undefined =
46
- | JsonRpcAccount<Address>
47
- | undefined,
48
- >(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;
49
-
50
- export function createSmartWalletClient<
51
- TAccount extends JsonRpcAccount<Address> = JsonRpcAccount<Address>,
52
- >(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;
24
+ TAccount extends Address | undefined = Address | undefined,
25
+ > = InnerWalletApiClient & SmartWalletActions<TAccount>;
53
26
 
54
27
  /**
55
28
  * Creates a smart wallet client that can be used to interact with a smart account.
@@ -80,6 +53,10 @@ export function createSmartWalletClient<
80
53
  * signer,
81
54
  * });
82
55
  */
56
+ export function createSmartWalletClient<
57
+ TAccount extends Address | undefined = undefined,
58
+ >(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;
59
+
83
60
  export function createSmartWalletClient(
84
61
  params: SmartWalletClientParams,
85
62
  ): SmartWalletClient {
@@ -29,6 +29,7 @@ export { grantPermissions } from "../client/actions/grantPermissions.js";
29
29
  export { listAccounts } from "../client/actions/listAccounts.js";
30
30
  export { prepareCalls } from "../client/actions/prepareCalls.js";
31
31
  export { requestAccount } from "../client/actions/requestAccount.js";
32
- export { signMessage } from "../client/actions/signMessage.js";
33
32
  export { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
33
+ export { signPreparedCalls } from "../client/actions/signPreparedCalls.js";
34
+ export { signMessage } from "../client/actions/signMessage.js";
34
35
  export { signTypedData } from "../client/actions/signTypedData.js";
@@ -24,7 +24,6 @@ import type { wallet_createSession } from "../../rpc/request.js";
24
24
  import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
25
25
  import { createAccount, isModularAccountV2 } from "../utils/createAccount.js";
26
26
  import { createDummySigner } from "../utils/createDummySigner.js";
27
- import { createAuthorization } from "../utils/7702.js";
28
27
  import { InvalidRequestError } from "ox/RpcResponse";
29
28
 
30
29
  export type CreateSessionParams = Omit<
@@ -68,10 +67,17 @@ export async function createSession(
68
67
  },
69
68
  ],
70
69
  });
71
- if (!counterfactualInfo && !delegation) {
70
+
71
+ if (delegation) {
72
72
  throw new InvalidRequestError({
73
73
  message:
74
- "No counterfactual info or delegated implementation address found.",
74
+ "'wallet_createSession' does not currently support 7702 accounts.",
75
+ });
76
+ }
77
+
78
+ if (!counterfactualInfo) {
79
+ throw new InvalidRequestError({
80
+ message: "No counterfactual info found.",
75
81
  });
76
82
  }
77
83
 
@@ -104,10 +110,14 @@ export async function createSession(
104
110
  const { typedData, fullPreSignatureDeferredActionDigest } =
105
111
  await new PermissionBuilder({
106
112
  client: _client,
107
- key: params.key,
113
+ key: {
114
+ ...params.key,
115
+ // Alias 'ecdsa' to 'secp256k1'
116
+ type: params.key.type === "ecdsa" ? "secp256k1" : params.key.type,
117
+ },
108
118
  entityId,
109
119
  nonce,
110
- deadline: params.expiry,
120
+ deadline: params.expirySec,
111
121
  })
112
122
  .addPermissions({
113
123
  permissions: params.permissions.map((permission) =>
@@ -116,25 +126,12 @@ export async function createSession(
116
126
  })
117
127
  .compileDeferred();
118
128
 
119
- // If using 7702, we need an Authorization (unless it's already authorized).
120
- const authorizationRequest = delegation
121
- ? await createAuthorization(client, {
122
- address: account.address,
123
- delegation,
124
- })
125
- : undefined;
126
-
127
- const signatureRequest = {
128
- type: "eth_signTypedData_v4" as const,
129
- data: typedData,
130
- };
131
-
132
129
  return {
133
130
  sessionId: null, // In remote mode, the server will set this later.
134
131
  entityId: toHex(entityId),
135
132
  signatureRequest: {
136
- ...signatureRequest,
137
- ...(authorizationRequest ? { authorizationRequest } : {}),
133
+ type: "eth_signTypedData_v4" as const,
134
+ data: typedData,
138
135
  },
139
136
  fullPreSignatureDeferredActionDigest,
140
137
  };