@account-kit/wallet-client 0.1.0-alpha.11 → 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 (141) 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 +1 -1
  14. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  15. package/dist/esm/client/client.e2e-test.js +171 -349
  16. package/dist/esm/client/client.e2e-test.js.map +1 -1
  17. package/dist/esm/client/index.d.ts +1 -4
  18. package/dist/esm/client/index.js +13 -18
  19. package/dist/esm/client/index.js.map +1 -1
  20. package/dist/esm/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +1 -5
  21. package/dist/esm/{isomorphic/utils/createAccount.js → internal/account.js} +8 -32
  22. package/dist/esm/internal/account.js.map +1 -0
  23. package/dist/esm/types.d.ts +2 -8
  24. package/dist/esm/types.js.map +1 -1
  25. package/dist/types/client/actions/getCallsStatus.d.ts +4 -3
  26. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  27. package/dist/types/client/actions/grantPermissions.d.ts +5 -4
  28. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  29. package/dist/types/client/actions/prepareCalls.d.ts +4 -3
  30. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  31. package/dist/types/client/actions/prepareSign.d.ts +4 -3
  32. package/dist/types/client/actions/prepareSign.d.ts.map +1 -1
  33. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  34. package/dist/types/client/index.d.ts +1 -4
  35. package/dist/types/client/index.d.ts.map +1 -1
  36. package/dist/types/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +2 -6
  37. package/dist/types/internal/account.d.ts.map +1 -0
  38. package/dist/types/types.d.ts +2 -8
  39. package/dist/types/types.d.ts.map +1 -1
  40. package/package.json +3 -8
  41. package/src/client/actions/getCallsStatus.ts +8 -6
  42. package/src/client/actions/grantPermissions.ts +41 -10
  43. package/src/client/actions/prepareCalls.ts +11 -6
  44. package/src/client/actions/prepareSign.ts +9 -6
  45. package/src/client/actions/requestAccount.ts +1 -1
  46. package/src/client/client.e2e-test.ts +208 -442
  47. package/src/client/index.ts +22 -23
  48. package/src/{isomorphic/utils/createAccount.ts → internal/account.ts} +9 -49
  49. package/src/types.ts +4 -15
  50. package/dist/esm/exports/internal.d.ts +0 -4
  51. package/dist/esm/exports/internal.js +0 -3
  52. package/dist/esm/exports/internal.js.map +0 -1
  53. package/dist/esm/isomorphic/actions/createSession.d.ts +0 -13
  54. package/dist/esm/isomorphic/actions/createSession.js +0 -94
  55. package/dist/esm/isomorphic/actions/createSession.js.map +0 -1
  56. package/dist/esm/isomorphic/actions/formatSign.d.ts +0 -8
  57. package/dist/esm/isomorphic/actions/formatSign.js +0 -42
  58. package/dist/esm/isomorphic/actions/formatSign.js.map +0 -1
  59. package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +0 -7
  60. package/dist/esm/isomorphic/actions/getCallsStatus.js +0 -71
  61. package/dist/esm/isomorphic/actions/getCallsStatus.js.map +0 -1
  62. package/dist/esm/isomorphic/actions/prepareCalls.d.ts +0 -7
  63. package/dist/esm/isomorphic/actions/prepareCalls.js +0 -116
  64. package/dist/esm/isomorphic/actions/prepareCalls.js.map +0 -1
  65. package/dist/esm/isomorphic/actions/prepareSign.d.ts +0 -7
  66. package/dist/esm/isomorphic/actions/prepareSign.js +0 -49
  67. package/dist/esm/isomorphic/actions/prepareSign.js.map +0 -1
  68. package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +0 -7
  69. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +0 -183
  70. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +0 -1
  71. package/dist/esm/isomorphic/client.d.ts +0 -275
  72. package/dist/esm/isomorphic/client.js +0 -41
  73. package/dist/esm/isomorphic/client.js.map +0 -1
  74. package/dist/esm/isomorphic/utils/7702.d.ts +0 -19
  75. package/dist/esm/isomorphic/utils/7702.js +0 -70
  76. package/dist/esm/isomorphic/utils/7702.js.map +0 -1
  77. package/dist/esm/isomorphic/utils/createAccount.js.map +0 -1
  78. package/dist/esm/isomorphic/utils/createDummySigner.d.ts +0 -3
  79. package/dist/esm/isomorphic/utils/createDummySigner.js +0 -17
  80. package/dist/esm/isomorphic/utils/createDummySigner.js.map +0 -1
  81. package/dist/esm/isomorphic/utils/decodeSignature.d.ts +0 -3
  82. package/dist/esm/isomorphic/utils/decodeSignature.js +0 -15
  83. package/dist/esm/isomorphic/utils/decodeSignature.js.map +0 -1
  84. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +0 -21
  85. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +0 -34
  86. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +0 -1
  87. package/dist/esm/isomorphic/utils/supportsFeature.d.ts +0 -4
  88. package/dist/esm/isomorphic/utils/supportsFeature.js +0 -21
  89. package/dist/esm/isomorphic/utils/supportsFeature.js.map +0 -1
  90. package/dist/esm/local/client.d.ts +0 -3
  91. package/dist/esm/local/client.js +0 -97
  92. package/dist/esm/local/client.js.map +0 -1
  93. package/dist/esm/remote/client.d.ts +0 -9
  94. package/dist/esm/remote/client.js +0 -41
  95. package/dist/esm/remote/client.js.map +0 -1
  96. package/dist/types/exports/internal.d.ts +0 -5
  97. package/dist/types/exports/internal.d.ts.map +0 -1
  98. package/dist/types/isomorphic/actions/createSession.d.ts +0 -14
  99. package/dist/types/isomorphic/actions/createSession.d.ts.map +0 -1
  100. package/dist/types/isomorphic/actions/formatSign.d.ts +0 -9
  101. package/dist/types/isomorphic/actions/formatSign.d.ts.map +0 -1
  102. package/dist/types/isomorphic/actions/getCallsStatus.d.ts +0 -8
  103. package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +0 -1
  104. package/dist/types/isomorphic/actions/prepareCalls.d.ts +0 -8
  105. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +0 -1
  106. package/dist/types/isomorphic/actions/prepareSign.d.ts +0 -8
  107. package/dist/types/isomorphic/actions/prepareSign.d.ts.map +0 -1
  108. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +0 -8
  109. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +0 -1
  110. package/dist/types/isomorphic/client.d.ts +0 -276
  111. package/dist/types/isomorphic/client.d.ts.map +0 -1
  112. package/dist/types/isomorphic/utils/7702.d.ts +0 -20
  113. package/dist/types/isomorphic/utils/7702.d.ts.map +0 -1
  114. package/dist/types/isomorphic/utils/createAccount.d.ts.map +0 -1
  115. package/dist/types/isomorphic/utils/createDummySigner.d.ts +0 -4
  116. package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +0 -1
  117. package/dist/types/isomorphic/utils/decodeSignature.d.ts +0 -4
  118. package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +0 -1
  119. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +0 -22
  120. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +0 -1
  121. package/dist/types/isomorphic/utils/supportsFeature.d.ts +0 -5
  122. package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +0 -1
  123. package/dist/types/local/client.d.ts +0 -4
  124. package/dist/types/local/client.d.ts.map +0 -1
  125. package/dist/types/remote/client.d.ts +0 -10
  126. package/dist/types/remote/client.d.ts.map +0 -1
  127. package/src/exports/internal.ts +0 -8
  128. package/src/isomorphic/actions/createSession.ts +0 -163
  129. package/src/isomorphic/actions/formatSign.ts +0 -76
  130. package/src/isomorphic/actions/getCallsStatus.ts +0 -112
  131. package/src/isomorphic/actions/prepareCalls.ts +0 -172
  132. package/src/isomorphic/actions/prepareSign.ts +0 -88
  133. package/src/isomorphic/actions/sendPreparedCalls.ts +0 -271
  134. package/src/isomorphic/client.ts +0 -102
  135. package/src/isomorphic/utils/7702.ts +0 -135
  136. package/src/isomorphic/utils/createDummySigner.ts +0 -27
  137. package/src/isomorphic/utils/decodeSignature.ts +0 -21
  138. package/src/isomorphic/utils/parsePermissionsContext.ts +0 -51
  139. package/src/isomorphic/utils/supportsFeature.ts +0 -34
  140. package/src/local/client.ts +0 -136
  141. package/src/remote/client.ts +0 -67
@@ -15,507 +15,273 @@ describe("Client E2E Tests", () => {
15
15
  apiKey: process.env.TEST_ALCHEMY_API_KEY!,
16
16
  },
17
17
  );
18
- describe("Local Mode Tests", () => {
19
- const signer = LocalAccountSigner.privateKeyToAccountSigner(
20
- "0xbaca22d9b6846ec09a4da378ffa07e2f14ce7d65675d135911b6fd281416bb03",
21
- );
22
-
23
- const client = createSmartWalletClient({
24
- transport,
25
- chain: arbitrumSepolia,
26
- mode: "local",
27
- signer,
28
- });
29
-
30
- const publicClient = createPublicClient({
31
- chain: arbitrumSepolia,
32
- transport,
33
- });
34
18
 
35
- it("should successfully get a counterfactual address", async () => {
36
- const account = await client.requestAccount();
37
- expect(account.address).toMatchInlineSnapshot(
38
- `"0xa46944b7a39c35d931D514ACAc3ac77c226a81ff"`,
39
- );
40
- });
19
+ const signer = LocalAccountSigner.privateKeyToAccountSigner(
20
+ "0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d",
21
+ );
41
22
 
42
- it("should successfully request account with different salt", async () => {
43
- const account = await client.requestAccount({
44
- id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
45
- creationHint: { salt: "0x1" },
46
- });
23
+ const client = createSmartWalletClient({
24
+ transport,
25
+ chain: arbitrumSepolia,
26
+ signer,
27
+ });
47
28
 
48
- expect(account.address).toMatchInlineSnapshot(
49
- `"0xA692f0E5AfAD20F771443D89C635146C6A592f06"`,
50
- );
51
- });
29
+ const publicClient = createPublicClient({
30
+ chain: arbitrumSepolia,
31
+ transport,
32
+ });
52
33
 
53
- it("should not cache account if different inputs provided", async () => {
54
- const account = await client.requestAccount();
55
- const account2 = await client.requestAccount({
56
- id: "52ab44be-b03e-47ed-ad65-43014ea5fbfc",
57
- creationHint: { salt: "0x2" },
58
- });
34
+ it("should successfully get a counterfactual address", async () => {
35
+ const account = await client.requestAccount();
36
+ expect(account.address).toMatchInlineSnapshot(
37
+ `"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`,
38
+ );
39
+ });
59
40
 
60
- expect(account.address).not.toEqual(account2.address);
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" },
61
45
  });
62
46
 
63
- it("can correctly sign a message", async () => {
64
- const account = await client.requestAccount();
65
- const message = "hello world";
66
- const signature = await client.signMessage({ message });
67
- const isValid = await publicClient.verifyMessage({
68
- address: account.address,
69
- message,
70
- signature,
71
- });
72
- expect(isValid).toBeTrue();
73
- });
47
+ expect(account.address).toMatchInlineSnapshot(
48
+ `"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`,
49
+ );
50
+ });
74
51
 
75
- it("can correctly sign typed data", async () => {
76
- const account = await client.requestAccount();
77
- const signature = await client.signTypedData(givenTypedData);
78
- const isValid = await publicClient.verifyTypedData({
79
- ...givenTypedData,
80
- signature,
81
- address: account.address,
82
- });
83
- expect(isValid).toBeTrue();
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" },
84
57
  });
85
58
 
86
- it("can correctly sign a message with a different account", async () => {
87
- const account = await client.requestAccount({
88
- id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
89
- creationHint: { salt: "0x1" },
90
- });
91
- const message = "hello world";
59
+ expect(account.address).not.toEqual(account2.address);
60
+ });
92
61
 
93
- const signature = await client.signMessage({
94
- message,
95
- account: account.address,
96
- });
97
- const isValid = await publicClient.verifyMessage({
98
- address: account.address,
99
- message,
100
- signature,
101
- });
102
- expect(isValid).toBeTrue();
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,
103
70
  });
71
+ expect(isValid).toBeTrue();
72
+ });
104
73
 
105
- it("can correctly sign typed data with a different account", async () => {
106
- const account = await client.requestAccount({
107
- id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
108
- creationHint: { salt: "0x1" },
109
- });
110
-
111
- const signature = await client.signTypedData({
112
- ...givenTypedData,
113
- account: account.address,
114
- });
115
- const isValid = await publicClient.verifyTypedData({
116
- ...givenTypedData,
117
- signature,
118
- address: account.address,
119
- });
120
- expect(isValid).toBeTrue();
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,
121
81
  });
122
-
123
- it(
124
- "should successfully send a UO with paymaster using 7702",
125
- async () => {
126
- const _signer = LocalAccountSigner.privateKeyToAccountSigner(
127
- "0x49daf21e92c997093e9ffdf7e7ddbf8970e9eadc5d4847d0f690db25d5128e1f",
128
- );
129
-
130
- const _client = createSmartWalletClient({
131
- transport,
132
- chain: arbitrumSepolia,
133
- mode: "local",
134
- signer: _signer,
135
- });
136
-
137
- const account = await _client.requestAccount({
138
- creationHint: {
139
- accountType: "7702",
140
- },
141
- });
142
-
143
- const preparedCalls = await _client.prepareCalls({
144
- calls: [{ to: zeroAddress, value: "0x0" }],
145
- from: account.address,
146
- capabilities: {
147
- paymasterService: {
148
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
149
- },
150
- },
151
- });
152
-
153
- const signedCalls = await _client.signPreparedCalls(preparedCalls);
154
-
155
- const result = await _client.sendPreparedCalls(signedCalls);
156
-
157
- expect(result.preparedCallIds).toBeArrayOfSize(1);
158
-
159
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
160
- },
161
- {
162
- timeout: 45_000,
163
- },
164
- );
165
-
166
- it(
167
- "should successfully send a UO with paymaster",
168
- async () => {
169
- const account = await client.requestAccount();
170
- const preparedCalls = await client.prepareCalls({
171
- calls: [{ to: zeroAddress, value: "0x0" }],
172
- from: account.address,
173
- capabilities: {
174
- paymasterService: {
175
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
176
- },
177
- },
178
- });
179
-
180
- const signedCalls = await client.signPreparedCalls(preparedCalls);
181
-
182
- const result = await client.sendPreparedCalls(signedCalls);
183
-
184
- expect(result.preparedCallIds).toBeArrayOfSize(1);
185
-
186
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
187
- },
188
- {
189
- timeout: 45_000,
190
- },
191
- );
192
-
193
- it(
194
- "should successfully create a session with grantPermissions and send a UO",
195
- async () => {
196
- const account = await client.requestAccount();
197
-
198
- const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
199
-
200
- const permissions = await client.grantPermissions({
201
- account: account.address,
202
- expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
203
- key: {
204
- publicKey: await sessionKey.getAddress(),
205
- type: "secp256k1",
206
- },
207
- permissions: [{ type: "root" }],
208
- });
209
-
210
- const sessionKeyClient = createSmartWalletClient({
211
- transport,
212
- chain: arbitrumSepolia,
213
- mode: "local",
214
- signer: sessionKey,
215
- });
216
-
217
- const preparedCalls = await sessionKeyClient.prepareCalls({
218
- calls: [{ to: zeroAddress, value: "0x0" }],
219
- from: account.address,
220
- capabilities: {
221
- paymasterService: {
222
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
223
- },
224
- permissions,
225
- },
226
- });
227
-
228
- const signedCalls =
229
- await sessionKeyClient.signPreparedCalls(preparedCalls);
230
-
231
- const result = await sessionKeyClient.sendPreparedCalls({
232
- ...signedCalls,
233
- capabilities: {
234
- permissions,
235
- },
236
- });
237
-
238
- expect(result.preparedCallIds).toBeArrayOfSize(1);
239
-
240
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
241
- },
242
- {
243
- timeout: 45_000,
244
- },
245
- );
82
+ expect(isValid).toBeTrue();
246
83
  });
247
84
 
248
- describe("Remote Mode Tests", () => {
249
- const signer = LocalAccountSigner.privateKeyToAccountSigner(
250
- "0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d",
251
- );
252
-
253
- const client = createSmartWalletClient({
254
- transport,
255
- chain: arbitrumSepolia,
256
- mode: "remote",
257
- signer,
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" },
258
89
  });
259
90
 
260
- const publicClient = createPublicClient({
261
- chain: arbitrumSepolia,
262
- transport,
91
+ const message = "hello world";
92
+ const signature = await client.signMessage({
93
+ message,
94
+ account: account.address,
263
95
  });
264
-
265
- it("should successfully get a counterfactual address", async () => {
266
- const account = await client.requestAccount();
267
- expect(account.address).toMatchInlineSnapshot(
268
- `"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`,
269
- );
96
+ const isValid = await publicClient.verifyMessage({
97
+ address: account.address,
98
+ message: "hello world",
99
+ signature,
270
100
  });
101
+ expect(isValid).toBeTrue();
102
+ });
271
103
 
272
- it("should successfully request account with different salt", async () => {
273
- const account = await client.requestAccount({
274
- id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
275
- creationHint: { salt: "0x1" },
276
- });
277
-
278
- expect(account.address).toMatchInlineSnapshot(
279
- `"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`,
280
- );
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" },
281
108
  });
282
109
 
283
- it("should not cache account if different inputs provided", async () => {
284
- const account = await client.requestAccount();
285
- const account2 = await client.requestAccount({
286
- id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
287
- creationHint: { salt: "0x2" },
288
- });
289
-
290
- expect(account.address).not.toEqual(account2.address);
110
+ const signature = await client.signTypedData({
111
+ ...givenTypedData,
112
+ account: account.address,
291
113
  });
292
114
 
293
- it("can correctly sign a message", async () => {
294
- const account = await client.requestAccount();
295
- const message = "hello world";
296
- const signature = await client.signMessage({ message });
297
- const isValid = await publicClient.verifyMessage({
298
- address: account.address,
299
- message: "hello world",
300
- signature,
301
- });
302
- expect(isValid).toBeTrue();
115
+ const isValid = await publicClient.verifyTypedData({
116
+ ...givenTypedData,
117
+ signature,
118
+ address: account.address,
303
119
  });
120
+ expect(isValid).toBeTrue();
121
+ });
304
122
 
305
- it("can correctly sign typed data", async () => {
123
+ it(
124
+ "should successfully send a UO with paymaster",
125
+ async () => {
306
126
  const account = await client.requestAccount();
307
- const signature = await client.signTypedData(givenTypedData);
308
- const isValid = await publicClient.verifyTypedData({
309
- ...givenTypedData,
310
- signature,
311
- address: account.address,
127
+ const preparedCalls = await client.prepareCalls({
128
+ calls: [{ to: zeroAddress, value: "0x0" }],
129
+ from: account.address,
130
+ capabilities: {
131
+ paymasterService: {
132
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
133
+ },
134
+ },
312
135
  });
313
- expect(isValid).toBeTrue();
314
- });
315
136
 
316
- it("can correctly sign a message with a different account", async () => {
317
- const account = await client.requestAccount({
318
- id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
319
- creationHint: { salt: "0x1" },
320
- });
137
+ const signedCalls = await client.signPreparedCalls(preparedCalls);
321
138
 
322
- const message = "hello world";
323
- const signature = await client.signMessage({
324
- message,
325
- account: account.address,
326
- });
327
- const isValid = await publicClient.verifyMessage({
328
- address: account.address,
329
- message: "hello world",
330
- signature,
331
- });
332
- expect(isValid).toBeTrue();
333
- });
139
+ const result = await client.sendPreparedCalls(signedCalls);
334
140
 
335
- it("can correctly sign typed data with a different account", async () => {
336
- const account = await client.requestAccount({
337
- id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
338
- creationHint: { salt: "0x1" },
339
- });
141
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
340
142
 
341
- const signature = await client.signTypedData({
342
- ...givenTypedData,
343
- account: account.address,
344
- });
345
-
346
- const isValid = await publicClient.verifyTypedData({
347
- ...givenTypedData,
348
- signature,
349
- address: account.address,
350
- });
351
- expect(isValid).toBeTrue();
352
- });
143
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
144
+ },
145
+ {
146
+ timeout: 45_000,
147
+ },
148
+ );
353
149
 
354
- it(
355
- "should successfully send a UO with paymaster",
356
- async () => {
357
- const account = await client.requestAccount();
358
- const preparedCalls = await client.prepareCalls({
359
- calls: [{ to: zeroAddress, value: "0x0" }],
360
- from: account.address,
361
- capabilities: {
362
- paymasterService: {
363
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
364
- },
150
+ it(
151
+ "should successfully drop and replace a UO with repeat calls",
152
+ async () => {
153
+ const account = await client.requestAccount();
154
+ const preparedCalls = await client.prepareCalls({
155
+ calls: [{ to: zeroAddress, value: "0x0" }],
156
+ from: account.address,
157
+ capabilities: {
158
+ paymasterService: {
159
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
365
160
  },
366
- });
367
-
368
- const signedCalls = await client.signPreparedCalls(preparedCalls);
161
+ },
162
+ });
369
163
 
370
- const result = await client.sendPreparedCalls(signedCalls);
164
+ const signedCalls = await client.signPreparedCalls(preparedCalls);
165
+ const result = await client.sendPreparedCalls(signedCalls);
371
166
 
372
- expect(result.preparedCallIds).toBeArrayOfSize(1);
167
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
373
168
 
374
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
375
- },
376
- {
377
- timeout: 45_000,
378
- },
379
- );
169
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
380
170
 
381
- it(
382
- "should successfully drop and replace a UO with repeat calls",
383
- async () => {
384
- const account = await client.requestAccount();
385
- const preparedCalls = await client.prepareCalls({
386
- calls: [{ to: zeroAddress, value: "0x0" }],
387
- from: account.address,
388
- capabilities: {
389
- paymasterService: {
390
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
391
- },
171
+ const prepareCalls2 = await client.prepareCalls({
172
+ calls: [{ to: zeroAddress, value: "0x0" }],
173
+ from: account.address,
174
+ capabilities: {
175
+ paymasterService: {
176
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
392
177
  },
393
- });
178
+ },
179
+ });
180
+ const signedCalls2 = await client.signPreparedCalls(prepareCalls2);
181
+ const result2 = await client.sendPreparedCalls(signedCalls2);
394
182
 
395
- const signedCalls = await client.signPreparedCalls(preparedCalls);
396
- const result = await client.sendPreparedCalls(signedCalls);
183
+ expect(result2.preparedCallIds).toBeArrayOfSize(1);
397
184
 
398
- expect(result.preparedCallIds).toBeArrayOfSize(1);
185
+ await waitForUserOpSuccess(client, result2.preparedCallIds[0]);
186
+ },
187
+ {
188
+ timeout: 90_000,
189
+ },
190
+ );
399
191
 
400
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
192
+ it(
193
+ "should successfully send a UO with paymaster using 7702",
194
+ async () => {
195
+ const _signer = LocalAccountSigner.privateKeyToAccountSigner(
196
+ "0x00d35c6d307b5cddeb70aeed96ee27a551fee58bf1a43858477e6c11f9172ba8",
197
+ );
401
198
 
402
- const prepareCalls2 = await client.prepareCalls({
403
- calls: [{ to: zeroAddress, value: "0x0" }],
404
- from: account.address,
405
- capabilities: {
406
- paymasterService: {
407
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
408
- },
409
- },
410
- });
411
- const signedCalls2 = await client.signPreparedCalls(prepareCalls2);
412
- const result2 = await client.sendPreparedCalls(signedCalls2);
199
+ const _client = createSmartWalletClient({
200
+ transport,
201
+ chain: arbitrumSepolia,
202
+ signer: _signer,
203
+ });
413
204
 
414
- expect(result2.preparedCallIds).toBeArrayOfSize(1);
205
+ const account = await _client.requestAccount({
206
+ creationHint: {
207
+ accountType: "7702",
208
+ },
209
+ });
210
+ expect(account.address).toBe(await _signer.getAddress());
211
+
212
+ const preparedCalls = await _client.prepareCalls({
213
+ calls: [{ to: zeroAddress, value: "0x0" }],
214
+ from: account.address,
215
+ capabilities: {
216
+ paymasterService: {
217
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
218
+ },
219
+ },
220
+ });
415
221
 
416
- await waitForUserOpSuccess(client, result2.preparedCallIds[0]);
417
- },
418
- {
419
- timeout: 90_000,
420
- },
421
- );
222
+ const signedCalls = await _client.signPreparedCalls(preparedCalls);
422
223
 
423
- it(
424
- "should successfully send a UO with paymaster using 7702",
425
- async () => {
426
- const _signer = LocalAccountSigner.privateKeyToAccountSigner(
427
- "0x00d35c6d307b5cddeb70aeed96ee27a551fee58bf1a43858477e6c11f9172ba8",
428
- );
429
-
430
- const _client = createSmartWalletClient({
431
- transport,
432
- chain: arbitrumSepolia,
433
- mode: "remote",
434
- signer: _signer,
435
- });
436
-
437
- const account = await _client.requestAccount({
438
- creationHint: {
439
- accountType: "7702",
440
- },
441
- });
442
- expect(account.address).toBe(await _signer.getAddress());
443
-
444
- const preparedCalls = await _client.prepareCalls({
445
- calls: [{ to: zeroAddress, value: "0x0" }],
446
- from: account.address,
447
- capabilities: {
448
- paymasterService: {
449
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
450
- },
451
- },
452
- });
224
+ const result = await _client.sendPreparedCalls(signedCalls);
453
225
 
454
- const signedCalls = await _client.signPreparedCalls(preparedCalls);
226
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
455
227
 
456
- const result = await _client.sendPreparedCalls(signedCalls);
228
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
229
+ },
230
+ { timeout: 45_000 },
231
+ );
457
232
 
458
- expect(result.preparedCallIds).toBeArrayOfSize(1);
233
+ it(
234
+ "should successfully create a session with grantPermissions and send a UO",
235
+ async () => {
236
+ const account = await client.requestAccount();
459
237
 
460
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
461
- },
462
- { timeout: 45_000 },
463
- );
238
+ const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
464
239
 
465
- it(
466
- "should successfully create a session with grantPermissions and send a UO",
467
- async () => {
468
- const account = await client.requestAccount();
240
+ const permissions = await client.grantPermissions({
241
+ account: account.address,
242
+ expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
243
+ key: {
244
+ publicKey: await sessionKey.getAddress(),
245
+ type: "secp256k1",
246
+ },
247
+ permissions: [{ type: "root" }],
248
+ });
469
249
 
470
- const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
250
+ const sessionKeyClient = createSmartWalletClient({
251
+ transport,
252
+ chain: arbitrumSepolia,
253
+ signer: sessionKey,
254
+ });
471
255
 
472
- const permissions = await client.grantPermissions({
473
- account: account.address,
474
- expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
475
- key: {
476
- publicKey: await sessionKey.getAddress(),
477
- type: "secp256k1",
256
+ const preparedCalls = await sessionKeyClient.prepareCalls({
257
+ calls: [{ to: zeroAddress, value: "0x0" }],
258
+ from: account.address,
259
+ capabilities: {
260
+ paymasterService: {
261
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
478
262
  },
479
- permissions: [{ type: "root" }],
480
- });
481
-
482
- const sessionKeyClient = createSmartWalletClient({
483
- transport,
484
- chain: arbitrumSepolia,
485
- mode: "remote",
486
- signer: sessionKey,
487
- });
488
-
489
- const preparedCalls = await sessionKeyClient.prepareCalls({
490
- calls: [{ to: zeroAddress, value: "0x0" }],
491
- from: account.address,
492
- capabilities: {
493
- paymasterService: {
494
- policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
495
- },
496
- permissions,
497
- },
498
- });
263
+ permissions,
264
+ },
265
+ });
499
266
 
500
- const signedCalls =
501
- await sessionKeyClient.signPreparedCalls(preparedCalls);
267
+ const signedCalls =
268
+ await sessionKeyClient.signPreparedCalls(preparedCalls);
502
269
 
503
- const result = await sessionKeyClient.sendPreparedCalls({
504
- ...signedCalls,
505
- capabilities: {
506
- permissions,
507
- },
508
- });
270
+ const result = await sessionKeyClient.sendPreparedCalls({
271
+ ...signedCalls,
272
+ capabilities: {
273
+ permissions,
274
+ },
275
+ });
509
276
 
510
- expect(result.preparedCallIds).toBeArrayOfSize(1);
277
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
511
278
 
512
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
513
- },
514
- {
515
- timeout: 45_000,
516
- },
517
- );
518
- });
279
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
280
+ },
281
+ {
282
+ timeout: 45_000,
283
+ },
284
+ );
519
285
 
520
286
  const givenTypedData = {
521
287
  types: {