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

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 (146) hide show
  1. package/dist/esm/client/actions/getCallsStatus.d.ts +4 -3
  2. package/dist/esm/client/actions/getCallsStatus.js +1 -0
  3. package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
  4. package/dist/esm/client/actions/grantPermissions.d.ts +5 -4
  5. package/dist/esm/client/actions/grantPermissions.js +21 -5
  6. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  7. package/dist/esm/client/actions/prepareCalls.d.ts +4 -3
  8. package/dist/esm/client/actions/prepareCalls.js +1 -0
  9. package/dist/esm/client/actions/prepareCalls.js.map +1 -1
  10. package/dist/esm/client/actions/prepareSign.d.ts +4 -3
  11. package/dist/esm/client/actions/prepareSign.js +1 -0
  12. package/dist/esm/client/actions/prepareSign.js.map +1 -1
  13. package/dist/esm/client/actions/requestAccount.js +3 -3
  14. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  15. package/dist/esm/client/actions/signSignatureRequest.d.ts +3 -3
  16. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  17. package/dist/esm/client/client.e2e-test.js +190 -329
  18. package/dist/esm/client/client.e2e-test.js.map +1 -1
  19. package/dist/esm/client/index.d.ts +1 -4
  20. package/dist/esm/client/index.js +13 -18
  21. package/dist/esm/client/index.js.map +1 -1
  22. package/dist/esm/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +3 -7
  23. package/dist/esm/{isomorphic/utils/createAccount.js → internal/account.js} +9 -33
  24. package/dist/esm/internal/account.js.map +1 -0
  25. package/dist/esm/types.d.ts +2 -8
  26. package/dist/esm/types.js.map +1 -1
  27. package/dist/types/client/actions/getCallsStatus.d.ts +4 -3
  28. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  29. package/dist/types/client/actions/grantPermissions.d.ts +5 -4
  30. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  31. package/dist/types/client/actions/prepareCalls.d.ts +4 -3
  32. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  33. package/dist/types/client/actions/prepareSign.d.ts +4 -3
  34. package/dist/types/client/actions/prepareSign.d.ts.map +1 -1
  35. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  36. package/dist/types/client/actions/signSignatureRequest.d.ts +3 -3
  37. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  38. package/dist/types/client/index.d.ts +1 -4
  39. package/dist/types/client/index.d.ts.map +1 -1
  40. package/dist/types/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +4 -8
  41. package/dist/types/internal/account.d.ts.map +1 -0
  42. package/dist/types/types.d.ts +2 -8
  43. package/dist/types/types.d.ts.map +1 -1
  44. package/package.json +3 -8
  45. package/src/client/actions/getCallsStatus.ts +8 -6
  46. package/src/client/actions/grantPermissions.ts +41 -10
  47. package/src/client/actions/prepareCalls.ts +11 -6
  48. package/src/client/actions/prepareSign.ts +9 -6
  49. package/src/client/actions/requestAccount.ts +3 -3
  50. package/src/client/actions/signSignatureRequest.ts +8 -8
  51. package/src/client/client.e2e-test.ts +143 -298
  52. package/src/client/index.ts +22 -23
  53. package/src/{isomorphic/utils/createAccount.ts → internal/account.ts} +11 -51
  54. package/src/types.ts +4 -15
  55. package/dist/esm/exports/internal.d.ts +0 -4
  56. package/dist/esm/exports/internal.js +0 -3
  57. package/dist/esm/exports/internal.js.map +0 -1
  58. package/dist/esm/isomorphic/actions/createSession.d.ts +0 -13
  59. package/dist/esm/isomorphic/actions/createSession.js +0 -94
  60. package/dist/esm/isomorphic/actions/createSession.js.map +0 -1
  61. package/dist/esm/isomorphic/actions/formatSign.d.ts +0 -8
  62. package/dist/esm/isomorphic/actions/formatSign.js +0 -42
  63. package/dist/esm/isomorphic/actions/formatSign.js.map +0 -1
  64. package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +0 -7
  65. package/dist/esm/isomorphic/actions/getCallsStatus.js +0 -71
  66. package/dist/esm/isomorphic/actions/getCallsStatus.js.map +0 -1
  67. package/dist/esm/isomorphic/actions/prepareCalls.d.ts +0 -7
  68. package/dist/esm/isomorphic/actions/prepareCalls.js +0 -116
  69. package/dist/esm/isomorphic/actions/prepareCalls.js.map +0 -1
  70. package/dist/esm/isomorphic/actions/prepareSign.d.ts +0 -7
  71. package/dist/esm/isomorphic/actions/prepareSign.js +0 -49
  72. package/dist/esm/isomorphic/actions/prepareSign.js.map +0 -1
  73. package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +0 -7
  74. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +0 -156
  75. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +0 -1
  76. package/dist/esm/isomorphic/client.d.ts +0 -275
  77. package/dist/esm/isomorphic/client.js +0 -41
  78. package/dist/esm/isomorphic/client.js.map +0 -1
  79. package/dist/esm/isomorphic/utils/7702.d.ts +0 -19
  80. package/dist/esm/isomorphic/utils/7702.js +0 -70
  81. package/dist/esm/isomorphic/utils/7702.js.map +0 -1
  82. package/dist/esm/isomorphic/utils/createAccount.js.map +0 -1
  83. package/dist/esm/isomorphic/utils/createDummySigner.d.ts +0 -3
  84. package/dist/esm/isomorphic/utils/createDummySigner.js +0 -17
  85. package/dist/esm/isomorphic/utils/createDummySigner.js.map +0 -1
  86. package/dist/esm/isomorphic/utils/decodeSignature.d.ts +0 -3
  87. package/dist/esm/isomorphic/utils/decodeSignature.js +0 -15
  88. package/dist/esm/isomorphic/utils/decodeSignature.js.map +0 -1
  89. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +0 -21
  90. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +0 -34
  91. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +0 -1
  92. package/dist/esm/isomorphic/utils/supportsFeature.d.ts +0 -4
  93. package/dist/esm/isomorphic/utils/supportsFeature.js +0 -21
  94. package/dist/esm/isomorphic/utils/supportsFeature.js.map +0 -1
  95. package/dist/esm/local/client.d.ts +0 -3
  96. package/dist/esm/local/client.js +0 -97
  97. package/dist/esm/local/client.js.map +0 -1
  98. package/dist/esm/remote/client.d.ts +0 -9
  99. package/dist/esm/remote/client.js +0 -41
  100. package/dist/esm/remote/client.js.map +0 -1
  101. package/dist/types/exports/internal.d.ts +0 -5
  102. package/dist/types/exports/internal.d.ts.map +0 -1
  103. package/dist/types/isomorphic/actions/createSession.d.ts +0 -14
  104. package/dist/types/isomorphic/actions/createSession.d.ts.map +0 -1
  105. package/dist/types/isomorphic/actions/formatSign.d.ts +0 -9
  106. package/dist/types/isomorphic/actions/formatSign.d.ts.map +0 -1
  107. package/dist/types/isomorphic/actions/getCallsStatus.d.ts +0 -8
  108. package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +0 -1
  109. package/dist/types/isomorphic/actions/prepareCalls.d.ts +0 -8
  110. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +0 -1
  111. package/dist/types/isomorphic/actions/prepareSign.d.ts +0 -8
  112. package/dist/types/isomorphic/actions/prepareSign.d.ts.map +0 -1
  113. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +0 -8
  114. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +0 -1
  115. package/dist/types/isomorphic/client.d.ts +0 -276
  116. package/dist/types/isomorphic/client.d.ts.map +0 -1
  117. package/dist/types/isomorphic/utils/7702.d.ts +0 -20
  118. package/dist/types/isomorphic/utils/7702.d.ts.map +0 -1
  119. package/dist/types/isomorphic/utils/createAccount.d.ts.map +0 -1
  120. package/dist/types/isomorphic/utils/createDummySigner.d.ts +0 -4
  121. package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +0 -1
  122. package/dist/types/isomorphic/utils/decodeSignature.d.ts +0 -4
  123. package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +0 -1
  124. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +0 -22
  125. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +0 -1
  126. package/dist/types/isomorphic/utils/supportsFeature.d.ts +0 -5
  127. package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +0 -1
  128. package/dist/types/local/client.d.ts +0 -4
  129. package/dist/types/local/client.d.ts.map +0 -1
  130. package/dist/types/remote/client.d.ts +0 -10
  131. package/dist/types/remote/client.d.ts.map +0 -1
  132. package/src/exports/internal.ts +0 -8
  133. package/src/isomorphic/actions/createSession.ts +0 -163
  134. package/src/isomorphic/actions/formatSign.ts +0 -76
  135. package/src/isomorphic/actions/getCallsStatus.ts +0 -112
  136. package/src/isomorphic/actions/prepareCalls.ts +0 -172
  137. package/src/isomorphic/actions/prepareSign.ts +0 -91
  138. package/src/isomorphic/actions/sendPreparedCalls.ts +0 -234
  139. package/src/isomorphic/client.ts +0 -102
  140. package/src/isomorphic/utils/7702.ts +0 -135
  141. package/src/isomorphic/utils/createDummySigner.ts +0 -27
  142. package/src/isomorphic/utils/decodeSignature.ts +0 -21
  143. package/src/isomorphic/utils/parsePermissionsContext.ts +0 -51
  144. package/src/isomorphic/utils/supportsFeature.ts +0 -34
  145. package/src/local/client.ts +0 -136
  146. package/src/remote/client.ts +0 -67
@@ -1,8 +1,9 @@
1
1
  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
- import { createPublicClient, zeroAddress, type Address } from "viem";
5
- import { createSmartWalletClient } from "./index.js";
4
+ import { createPublicClient, zeroAddress, type Address, type Hex } from "viem";
5
+ import { createSmartWalletClient, type SmartWalletClient } from "./index.js";
6
+ import { sleep } from "bun";
6
7
 
7
8
  describe("Client E2E Tests", () => {
8
9
  const transport = alchemy(
@@ -14,319 +15,114 @@ describe("Client E2E Tests", () => {
14
15
  apiKey: process.env.TEST_ALCHEMY_API_KEY!,
15
16
  },
16
17
  );
17
- describe("Local Mode Tests", () => {
18
- const signer = LocalAccountSigner.privateKeyToAccountSigner(
19
- "0xbaca22d9b6846ec09a4da378ffa07e2f14ce7d65675d135911b6fd281416bb03",
20
- );
21
-
22
- const client = createSmartWalletClient({
23
- transport,
24
- chain: arbitrumSepolia,
25
- mode: "local",
26
- signer,
27
- });
28
-
29
- const publicClient = createPublicClient({
30
- chain: arbitrumSepolia,
31
- transport,
32
- });
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
-
41
- it("should successfully request account with different salt", async () => {
42
- const account = await client.requestAccount({
43
- id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
44
- creationHint: { salt: "0x1" },
45
- });
46
-
47
- expect(account.address).toMatchInlineSnapshot(
48
- `"0xA692f0E5AfAD20F771443D89C635146C6A592f06"`,
49
- );
50
- });
51
-
52
- it("should not cache account if different inputs provided", async () => {
53
- const account = await client.requestAccount();
54
- const account2 = await client.requestAccount({
55
- id: "52ab44be-b03e-47ed-ad65-43014ea5fbfc",
56
- creationHint: { salt: "0x2" },
57
- });
58
-
59
- expect(account.address).not.toEqual(account2.address);
60
- });
61
-
62
- it("can correctly sign a message", async () => {
63
- const account = await client.requestAccount();
64
- const message = "hello world";
65
- const signature = await client.signMessage({ message });
66
- const isValid = await publicClient.verifyMessage({
67
- address: account.address,
68
- message,
69
- signature,
70
- });
71
- expect(isValid).toBeTrue();
72
- });
73
18
 
74
- it("can correctly sign typed data", async () => {
75
- const account = await client.requestAccount();
76
- const signature = await client.signTypedData(givenTypedData);
77
- const isValid = await publicClient.verifyTypedData({
78
- ...givenTypedData,
79
- signature,
80
- address: account.address,
81
- });
82
- expect(isValid).toBeTrue();
83
- });
84
-
85
- it("can correctly sign a message with a different account", async () => {
86
- const account = await client.requestAccount({
87
- id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
88
- creationHint: { salt: "0x1" },
89
- });
90
- const message = "hello world";
91
-
92
- const signature = await client.signMessage({
93
- message,
94
- account: account.address,
95
- });
96
- const isValid = await publicClient.verifyMessage({
97
- address: account.address,
98
- message,
99
- signature,
100
- });
101
- expect(isValid).toBeTrue();
102
- });
103
-
104
- it("can correctly sign typed data with a different account", async () => {
105
- const account = await client.requestAccount({
106
- id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
107
- creationHint: { salt: "0x1" },
108
- });
109
-
110
- const signature = await client.signTypedData({
111
- ...givenTypedData,
112
- account: account.address,
113
- });
114
- const isValid = await publicClient.verifyTypedData({
115
- ...givenTypedData,
116
- signature,
117
- address: account.address,
118
- });
119
- expect(isValid).toBeTrue();
120
- });
121
-
122
- it("should successfully send a UO with paymaster using 7702", async () => {
123
- const _signer = LocalAccountSigner.privateKeyToAccountSigner(
124
- "0x49daf21e92c997093e9ffdf7e7ddbf8970e9eadc5d4847d0f690db25d5128e1f",
125
- );
126
-
127
- const _client = createSmartWalletClient({
128
- transport,
129
- chain: arbitrumSepolia,
130
- mode: "local",
131
- signer: _signer,
132
- });
133
-
134
- const account = await _client.requestAccount({
135
- creationHint: {
136
- accountType: "7702",
137
- },
138
- });
19
+ const signer = LocalAccountSigner.privateKeyToAccountSigner(
20
+ "0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d",
21
+ );
139
22
 
140
- const preparedCalls = await _client.prepareCalls({
141
- calls: [{ to: zeroAddress, value: "0x0" }],
142
- from: account.address,
143
- capabilities: {
144
- paymasterService: {
145
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
146
- },
147
- },
148
- });
23
+ const client = createSmartWalletClient({
24
+ transport,
25
+ chain: arbitrumSepolia,
26
+ signer,
27
+ });
149
28
 
150
- const signedCalls = await _client.signPreparedCalls(preparedCalls);
29
+ const publicClient = createPublicClient({
30
+ chain: arbitrumSepolia,
31
+ transport,
32
+ });
151
33
 
152
- const result = await _client.sendPreparedCalls(signedCalls);
34
+ it("should successfully get a counterfactual address", async () => {
35
+ const account = await client.requestAccount();
36
+ expect(account.address).toMatchInlineSnapshot(
37
+ `"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`,
38
+ );
39
+ });
153
40
 
154
- expect(result.preparedCallIds).toBeArrayOfSize(1);
41
+ it("should successfully request account with different salt", async () => {
42
+ const account = await client.requestAccount({
43
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
44
+ creationHint: { salt: "0x1" },
155
45
  });
156
46
 
157
- it("should successfully send a UO with paymaster", async () => {
158
- const account = await client.requestAccount();
159
- const preparedCalls = await client.prepareCalls({
160
- calls: [{ to: zeroAddress, value: "0x0" }],
161
- from: account.address,
162
- capabilities: {
163
- paymasterService: {
164
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
165
- },
166
- },
167
- });
168
-
169
- const signedCalls = await client.signPreparedCalls(preparedCalls);
170
-
171
- const result = await client.sendPreparedCalls(signedCalls);
47
+ expect(account.address).toMatchInlineSnapshot(
48
+ `"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`,
49
+ );
50
+ });
172
51
 
173
- expect(result.preparedCallIds).toBeArrayOfSize(1);
52
+ it("should not cache account if different inputs provided", async () => {
53
+ const account = await client.requestAccount();
54
+ const account2 = await client.requestAccount({
55
+ id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
56
+ creationHint: { salt: "0x2" },
174
57
  });
175
58
 
176
- it("should successfully create a session with grantPermissions and send a UO", async () => {
177
- const account = await client.requestAccount();
178
-
179
- const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
180
-
181
- const permissions = await client.grantPermissions({
182
- account: account.address,
183
- expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
184
- key: {
185
- publicKey: await sessionKey.getAddress(),
186
- type: "secp256k1",
187
- },
188
- permissions: [{ type: "root" }],
189
- });
190
-
191
- const sessionKeyClient = createSmartWalletClient({
192
- transport,
193
- chain: arbitrumSepolia,
194
- mode: "local",
195
- signer: sessionKey,
196
- });
197
-
198
- const preparedCalls = await sessionKeyClient.prepareCalls({
199
- calls: [{ to: zeroAddress, value: "0x0" }],
200
- from: account.address,
201
- capabilities: {
202
- paymasterService: {
203
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
204
- },
205
- permissions,
206
- },
207
- });
208
-
209
- const signedCalls =
210
- await sessionKeyClient.signPreparedCalls(preparedCalls);
211
-
212
- const result = await sessionKeyClient.sendPreparedCalls({
213
- ...signedCalls,
214
- capabilities: {
215
- permissions,
216
- },
217
- });
218
-
219
- expect(result.preparedCallIds).toBeArrayOfSize(1);
220
- });
59
+ expect(account.address).not.toEqual(account2.address);
221
60
  });
222
61
 
223
- describe("Remote Mode Tests", () => {
224
- const signer = LocalAccountSigner.privateKeyToAccountSigner(
225
- "0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d",
226
- );
227
-
228
- const client = createSmartWalletClient({
229
- transport,
230
- chain: arbitrumSepolia,
231
- mode: "remote",
232
- signer,
233
- });
234
-
235
- const publicClient = createPublicClient({
236
- chain: arbitrumSepolia,
237
- transport,
62
+ it("can correctly sign a message", async () => {
63
+ const account = await client.requestAccount();
64
+ const message = "hello world";
65
+ const signature = await client.signMessage({ message });
66
+ const isValid = await publicClient.verifyMessage({
67
+ address: account.address,
68
+ message: "hello world",
69
+ signature,
238
70
  });
71
+ expect(isValid).toBeTrue();
72
+ });
239
73
 
240
- it("should successfully get a counterfactual address", async () => {
241
- const account = await client.requestAccount();
242
- expect(account.address).toMatchInlineSnapshot(
243
- `"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`,
244
- );
74
+ it("can correctly sign typed data", async () => {
75
+ const account = await client.requestAccount();
76
+ const signature = await client.signTypedData(givenTypedData);
77
+ const isValid = await publicClient.verifyTypedData({
78
+ ...givenTypedData,
79
+ signature,
80
+ address: account.address,
245
81
  });
82
+ expect(isValid).toBeTrue();
83
+ });
246
84
 
247
- it("should successfully request account with different salt", async () => {
248
- const account = await client.requestAccount({
249
- id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
250
- creationHint: { salt: "0x1" },
251
- });
252
-
253
- expect(account.address).toMatchInlineSnapshot(
254
- `"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`,
255
- );
85
+ it("can correctly sign a message with a different account", async () => {
86
+ const account = await client.requestAccount({
87
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
88
+ creationHint: { salt: "0x1" },
256
89
  });
257
90
 
258
- it("should not cache account if different inputs provided", async () => {
259
- const account = await client.requestAccount();
260
- const account2 = await client.requestAccount({
261
- id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
262
- creationHint: { salt: "0x2" },
263
- });
264
-
265
- expect(account.address).not.toEqual(account2.address);
91
+ const message = "hello world";
92
+ const signature = await client.signMessage({
93
+ message,
94
+ account: account.address,
266
95
  });
267
-
268
- it("can correctly sign a message", async () => {
269
- const account = await client.requestAccount();
270
- const message = "hello world";
271
- const signature = await client.signMessage({ message });
272
- const isValid = await publicClient.verifyMessage({
273
- address: account.address,
274
- message: "hello world",
275
- signature,
276
- });
277
- expect(isValid).toBeTrue();
96
+ const isValid = await publicClient.verifyMessage({
97
+ address: account.address,
98
+ message: "hello world",
99
+ signature,
278
100
  });
101
+ expect(isValid).toBeTrue();
102
+ });
279
103
 
280
- it("can correctly sign typed data", async () => {
281
- const account = await client.requestAccount();
282
- const signature = await client.signTypedData(givenTypedData);
283
- const isValid = await publicClient.verifyTypedData({
284
- ...givenTypedData,
285
- signature,
286
- address: account.address,
287
- });
288
- expect(isValid).toBeTrue();
104
+ it("can correctly sign typed data with a different account", async () => {
105
+ const account = await client.requestAccount({
106
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
107
+ creationHint: { salt: "0x1" },
289
108
  });
290
109
 
291
- it("can correctly sign a message with a different account", async () => {
292
- const account = await client.requestAccount({
293
- id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
294
- creationHint: { salt: "0x1" },
295
- });
296
-
297
- const message = "hello world";
298
- const signature = await client.signMessage({
299
- message,
300
- account: account.address,
301
- });
302
- const isValid = await publicClient.verifyMessage({
303
- address: account.address,
304
- message: "hello world",
305
- signature,
306
- });
307
- expect(isValid).toBeTrue();
110
+ const signature = await client.signTypedData({
111
+ ...givenTypedData,
112
+ account: account.address,
308
113
  });
309
114
 
310
- it("can correctly sign typed data with a different account", async () => {
311
- const account = await client.requestAccount({
312
- id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
313
- creationHint: { salt: "0x1" },
314
- });
315
-
316
- const signature = await client.signTypedData({
317
- ...givenTypedData,
318
- account: account.address,
319
- });
320
-
321
- const isValid = await publicClient.verifyTypedData({
322
- ...givenTypedData,
323
- signature,
324
- address: account.address,
325
- });
326
- expect(isValid).toBeTrue();
115
+ const isValid = await publicClient.verifyTypedData({
116
+ ...givenTypedData,
117
+ signature,
118
+ address: account.address,
327
119
  });
120
+ expect(isValid).toBeTrue();
121
+ });
328
122
 
329
- it("should successfully send a UO with paymaster", async () => {
123
+ it(
124
+ "should successfully send a UO with paymaster",
125
+ async () => {
330
126
  const account = await client.requestAccount();
331
127
  const preparedCalls = await client.prepareCalls({
332
128
  calls: [{ to: zeroAddress, value: "0x0" }],
@@ -343,9 +139,17 @@ describe("Client E2E Tests", () => {
343
139
  const result = await client.sendPreparedCalls(signedCalls);
344
140
 
345
141
  expect(result.preparedCallIds).toBeArrayOfSize(1);
346
- });
347
142
 
348
- it("should successfully drop and replace a UO with repeat calls", async () => {
143
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
144
+ },
145
+ {
146
+ timeout: 45_000,
147
+ },
148
+ );
149
+
150
+ it(
151
+ "should successfully drop and replace a UO with repeat calls",
152
+ async () => {
349
153
  const account = await client.requestAccount();
350
154
  const preparedCalls = await client.prepareCalls({
351
155
  calls: [{ to: zeroAddress, value: "0x0" }],
@@ -362,6 +166,8 @@ describe("Client E2E Tests", () => {
362
166
 
363
167
  expect(result.preparedCallIds).toBeArrayOfSize(1);
364
168
 
169
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
170
+
365
171
  const prepareCalls2 = await client.prepareCalls({
366
172
  calls: [{ to: zeroAddress, value: "0x0" }],
367
173
  from: account.address,
@@ -375,9 +181,17 @@ describe("Client E2E Tests", () => {
375
181
  const result2 = await client.sendPreparedCalls(signedCalls2);
376
182
 
377
183
  expect(result2.preparedCallIds).toBeArrayOfSize(1);
378
- });
379
184
 
380
- it("should successfully send a UO with paymaster using 7702", async () => {
185
+ await waitForUserOpSuccess(client, result2.preparedCallIds[0]);
186
+ },
187
+ {
188
+ timeout: 90_000,
189
+ },
190
+ );
191
+
192
+ it(
193
+ "should successfully send a UO with paymaster using 7702",
194
+ async () => {
381
195
  const _signer = LocalAccountSigner.privateKeyToAccountSigner(
382
196
  "0x00d35c6d307b5cddeb70aeed96ee27a551fee58bf1a43858477e6c11f9172ba8",
383
197
  );
@@ -385,7 +199,6 @@ describe("Client E2E Tests", () => {
385
199
  const _client = createSmartWalletClient({
386
200
  transport,
387
201
  chain: arbitrumSepolia,
388
- mode: "remote",
389
202
  signer: _signer,
390
203
  });
391
204
 
@@ -411,9 +224,15 @@ describe("Client E2E Tests", () => {
411
224
  const result = await _client.sendPreparedCalls(signedCalls);
412
225
 
413
226
  expect(result.preparedCallIds).toBeArrayOfSize(1);
414
- });
415
227
 
416
- it("should successfully create a session with grantPermissions and send a UO", async () => {
228
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
229
+ },
230
+ { timeout: 45_000 },
231
+ );
232
+
233
+ it(
234
+ "should successfully create a session with grantPermissions and send a UO",
235
+ async () => {
417
236
  const account = await client.requestAccount();
418
237
 
419
238
  const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
@@ -431,7 +250,6 @@ describe("Client E2E Tests", () => {
431
250
  const sessionKeyClient = createSmartWalletClient({
432
251
  transport,
433
252
  chain: arbitrumSepolia,
434
- mode: "remote",
435
253
  signer: sessionKey,
436
254
  });
437
255
 
@@ -457,8 +275,13 @@ describe("Client E2E Tests", () => {
457
275
  });
458
276
 
459
277
  expect(result.preparedCallIds).toBeArrayOfSize(1);
460
- });
461
- });
278
+
279
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
280
+ },
281
+ {
282
+ timeout: 45_000,
283
+ },
284
+ );
462
285
 
463
286
  const givenTypedData = {
464
287
  types: {
@@ -493,3 +316,25 @@ describe("Client E2E Tests", () => {
493
316
  },
494
317
  } as const;
495
318
  });
319
+
320
+ const waitForUserOpSuccess = async (
321
+ client: SmartWalletClient,
322
+ preparedCallId: Hex,
323
+ ) => {
324
+ const maxTimeoutMs = 1000 * 30;
325
+ const deadline = Date.now() + maxTimeoutMs;
326
+ while (Date.now() < deadline) {
327
+ const status = (await client.getCallsStatus(preparedCallId)).status;
328
+ if (status === 200) {
329
+ // Success.
330
+ return;
331
+ }
332
+ if (status !== 100) {
333
+ // Error.
334
+ throw new Error(`Get call status failed with status ${status}.`);
335
+ }
336
+ // Pending.
337
+ await sleep(5000);
338
+ }
339
+ throw new Error("Timed out waiting for successful call status.");
340
+ };
@@ -1,13 +1,20 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import type { AlchemyTransport } from "@account-kit/infra";
3
- import type { Address, Chain, Prettify } from "viem";
4
- import { createLocalClient } from "../local/client.js";
5
- import { createRemoteClient } from "../remote/client.js";
3
+ import {
4
+ type Address,
5
+ type Chain,
6
+ type Prettify,
7
+ createClient,
8
+ custom,
9
+ } from "viem";
6
10
  import type { InnerWalletApiClient } from "../types.ts";
7
11
  import {
8
12
  smartWalletClientActions,
9
13
  type SmartWalletActions,
10
14
  } from "./decorator.js";
15
+ import { Provider } from "ox";
16
+ import { WalletServerRpcSchema } from "@alchemy/wallet-api-types/rpc";
17
+ import { internalStateDecorator } from "../internal/decorator.js";
11
18
 
12
19
  export type SmartWalletClientParams<
13
20
  TAccount extends Address | undefined = Address | undefined,
@@ -15,7 +22,6 @@ export type SmartWalletClientParams<
15
22
  transport: AlchemyTransport;
16
23
  chain: Chain;
17
24
  signer: SmartAccountSigner;
18
- mode: "local" | "remote";
19
25
  policyId?: string;
20
26
  account?: TAccount | Address | undefined;
21
27
  }>;
@@ -31,7 +37,6 @@ export type SmartWalletClient<
31
37
  * @param {AlchemyTransport} params.transport - The Alchemy transport to use
32
38
  * @param {Chain} params.chain - The chain to use
33
39
  * @param {SmartAccountSigner} params.signer - The signer to use for the smart account
34
- * @param {"local" | "remote"} params.mode - The client's mode (local or remote).
35
40
  * @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)
36
41
  * @param {Address} [params.account] - The smart account address to use (optional)
37
42
  * @returns {SmartWalletClient} - A viem-compatible client
@@ -49,7 +54,6 @@ export type SmartWalletClient<
49
54
  * const client = createSmartWalletClient({
50
55
  * transport,
51
56
  * chain: arbitrumSepolia,
52
- * mode: "remote",
53
57
  * signer,
54
58
  * });
55
59
  */
@@ -60,22 +64,19 @@ export function createSmartWalletClient<
60
64
  export function createSmartWalletClient(
61
65
  params: SmartWalletClientParams,
62
66
  ): SmartWalletClient {
63
- const { transport, chain, policyId, mode, account, signer } = params;
67
+ const { transport, chain, policyId, account, signer } = params;
64
68
 
65
- const innerClient =
66
- mode === "local"
67
- ? createLocalClient({
68
- transport,
69
- chain,
70
- policyId,
71
- account,
72
- })
73
- : createRemoteClient({
74
- transport,
75
- chain,
76
- policyId,
77
- account,
78
- });
69
+ const innerClient = createClient({
70
+ transport: (opts) =>
71
+ custom(Provider.from(transport(opts), { schema: WalletServerRpcSchema }))(
72
+ opts,
73
+ ),
74
+ chain,
75
+ account,
76
+ }).extend(() => ({
77
+ policyId,
78
+ internal: internalStateDecorator(),
79
+ }));
79
80
 
80
81
  // TODO: we need to do a few things here:
81
82
  // 1. decorate the client with the wallet api actions
@@ -90,7 +91,6 @@ export function createSmartWalletClient(
90
91
  // transport: alchemy({ apiKey: "123" }),
91
92
  // chain: baseSepolia,
92
93
  // signer: createDummySigner(zeroAddress),
93
- // mode: "local",
94
94
  // });
95
95
 
96
96
  // const account1 = await clientWithoutAccount.requestAccount();
@@ -99,7 +99,6 @@ export function createSmartWalletClient(
99
99
  // transport: alchemy({ apiKey: "123" }),
100
100
  // chain: baseSepolia,
101
101
  // signer: createDummySigner(zeroAddress),
102
- // mode: "local",
103
102
  // account: zeroAddress,
104
103
  // });
105
104