permissionless 0.1.34 → 0.1.36

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 (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/_cjs/actions/erc7579/supportsExecutionMode.js +4 -4
  3. package/_cjs/actions/erc7579/supportsExecutionMode.js.map +1 -1
  4. package/_cjs/experimental/eip7677/actions/getPaymasterStubData.js +6 -2
  5. package/_cjs/experimental/eip7677/actions/getPaymasterStubData.js.map +1 -1
  6. package/_cjs/utils/encode7579CallData.js +1 -1
  7. package/_cjs/utils/encode7579CallData.js.map +1 -1
  8. package/_esm/actions/erc7579/supportsExecutionMode.js +4 -4
  9. package/_esm/actions/erc7579/supportsExecutionMode.js.map +1 -1
  10. package/_esm/experimental/eip7677/actions/getPaymasterStubData.js +6 -2
  11. package/_esm/experimental/eip7677/actions/getPaymasterStubData.js.map +1 -1
  12. package/_esm/utils/encode7579CallData.js +1 -1
  13. package/_esm/utils/encode7579CallData.js.map +1 -1
  14. package/_types/actions/erc7579/supportsExecutionMode.d.ts +3 -3
  15. package/_types/actions/erc7579/supportsExecutionMode.d.ts.map +1 -1
  16. package/_types/experimental/eip7677/actions/getPaymasterStubData.d.ts +10 -0
  17. package/_types/experimental/eip7677/actions/getPaymasterStubData.d.ts.map +1 -1
  18. package/_types/experimental/eip7677/types/paymaster.d.ts +10 -0
  19. package/_types/experimental/eip7677/types/paymaster.d.ts.map +1 -1
  20. package/actions/erc7579/supportsExecutionMode.test.ts +53 -0
  21. package/actions/erc7579/supportsExecutionMode.ts +7 -7
  22. package/actions/smartAccount/prepareUserOperationRequest.test.ts +371 -2
  23. package/actions/smartAccount.test.ts +198 -0
  24. package/clients/createBundlerClient.test.ts +26 -0
  25. package/clients/createSmartAccountClient.test.ts +55 -0
  26. package/clients/decorators/smartAccount.test.ts +55 -0
  27. package/experimental/eip7677/actions/getPaymasterStubData.test.ts +6 -0
  28. package/experimental/eip7677/actions/getPaymasterStubData.ts +10 -2
  29. package/experimental/eip7677/types/paymaster.ts +4 -0
  30. package/package.json +1 -1
  31. package/utils/deepHexlify.test.ts +57 -0
  32. package/utils/encode7579CallData.test.ts +68 -0
  33. package/utils/encode7579CallData.ts +1 -1
  34. package/utils/getAddressFromInitCodeOrPaymasterAndData.test.ts +31 -0
  35. package/utils/getEntryPointVersion.test.ts +52 -0
  36. package/utils/getPackedUserOperation.test.ts +204 -0
  37. package/utils/getRequiredPrefund.test.ts +71 -0
@@ -2,11 +2,15 @@ import { type Chain, type Client, type Transport, zeroAddress } from "viem"
2
2
  import { generatePrivateKey } from "viem/accounts"
3
3
  import { describe, expect } from "vitest"
4
4
  import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
5
- import { getCoreSmartAccounts } from "../../../permissionless-test/src/utils"
5
+ import {
6
+ getCoreSmartAccounts,
7
+ getPimlicoBundlerClient,
8
+ getPimlicoPaymasterClient
9
+ } from "../../../permissionless-test/src/utils"
6
10
  import type { SmartAccount } from "../../accounts"
7
- import type { SmartAccountClient } from "../../clients/createSmartAccountClient"
8
11
  import type { EntryPoint } from "../../types/entrypoint"
9
12
  import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from "../../utils"
13
+ import { pimlicoPaymasterActions } from "../pimlico"
10
14
  import { prepareUserOperationRequest } from "./prepareUserOperationRequest"
11
15
 
12
16
  describe.each(getCoreSmartAccounts())(
@@ -81,6 +85,189 @@ describe.each(getCoreSmartAccounts())(
81
85
  }
82
86
  )
83
87
 
88
+ testWithRpc.skipIf(!supportsEntryPointV06)(
89
+ "prepareUserOperationRequest_v06",
90
+ async ({ rpc }) => {
91
+ const { anvilRpc, altoRpc, paymasterRpc } = rpc
92
+
93
+ const smartClient = await getSmartAccountClient({
94
+ entryPoint: ENTRYPOINT_ADDRESS_V06,
95
+ privateKey: generatePrivateKey(),
96
+ altoRpc: altoRpc,
97
+ anvilRpc: anvilRpc
98
+ })
99
+
100
+ const pimlicoBundlerClient = getPimlicoBundlerClient({
101
+ entryPoint: ENTRYPOINT_ADDRESS_V06,
102
+ altoRpc: altoRpc
103
+ })
104
+
105
+ const pimlicoPaymasterActions = getPimlicoPaymasterClient({
106
+ entryPoint: ENTRYPOINT_ADDRESS_V06,
107
+ paymasterRpc: paymasterRpc
108
+ })
109
+
110
+ const userOperation = await prepareUserOperationRequest(
111
+ smartClient as Client<
112
+ Transport,
113
+ Chain,
114
+ SmartAccount<EntryPoint>
115
+ >,
116
+ {
117
+ userOperation: {
118
+ callData: await smartClient.account.encodeCallData({
119
+ to: zeroAddress,
120
+ data: "0x",
121
+ value: 0n
122
+ })
123
+ },
124
+ middleware: {
125
+ gasPrice: async () =>
126
+ (
127
+ await pimlicoBundlerClient.getUserOperationGasPrice()
128
+ ).fast,
129
+ sponsorUserOperation:
130
+ pimlicoPaymasterActions.sponsorUserOperation
131
+ }
132
+ }
133
+ )
134
+
135
+ expect(userOperation).toBeTruthy()
136
+ expect(userOperation.sender).toBe(smartClient.account.address)
137
+ expect(userOperation.nonce).toBe(
138
+ await smartClient.account.getNonce()
139
+ )
140
+ expect(userOperation.initCode).toBe(
141
+ await smartClient.account.getInitCode()
142
+ )
143
+ expect(userOperation.callData).toBe(
144
+ await smartClient.account.encodeCallData({
145
+ to: zeroAddress,
146
+ data: "0x",
147
+ value: 0n
148
+ })
149
+ )
150
+ expect(userOperation.callGasLimit).toBeTruthy()
151
+ expect(userOperation.verificationGasLimit).toBeTruthy()
152
+ expect(userOperation.maxFeePerGas).toBeTruthy()
153
+ expect(userOperation.maxPriorityFeePerGas).toBeTruthy()
154
+ expect(userOperation.paymasterAndData).toBeTruthy()
155
+ expect(userOperation.signature).toBe(
156
+ // @ts-ignore: since tests return all smart account client, some of them don't support V06.
157
+ // The TS error is because in that case, getDummySignature would not accept the userOperation of type UserOperation<V07>
158
+ await smartClient.account.getDummySignature(userOperation)
159
+ )
160
+
161
+ expect(userOperation.factory).toBe(undefined)
162
+ expect(userOperation.factoryData).toBe(undefined)
163
+ expect(userOperation.paymaster).toBe(undefined)
164
+ expect(userOperation.paymasterVerificationGasLimit).toBe(
165
+ undefined
166
+ )
167
+ expect(userOperation.paymasterPostOpGasLimit).toBe(undefined)
168
+ expect(userOperation.paymasterData).toBe(undefined)
169
+ }
170
+ )
171
+
172
+ testWithRpc.skipIf(!supportsEntryPointV06)(
173
+ "prepareUserOperationRequest_v06",
174
+ async ({ rpc }) => {
175
+ const { anvilRpc, altoRpc, paymasterRpc } = rpc
176
+
177
+ const smartClient = await getSmartAccountClient({
178
+ entryPoint: ENTRYPOINT_ADDRESS_V06,
179
+ privateKey: generatePrivateKey(),
180
+ altoRpc: altoRpc,
181
+ anvilRpc: anvilRpc
182
+ })
183
+
184
+ const pimlicoBundlerClient = getPimlicoBundlerClient({
185
+ entryPoint: ENTRYPOINT_ADDRESS_V06,
186
+ altoRpc: altoRpc
187
+ })
188
+ const pimlicoPaymasterActions = getPimlicoPaymasterClient({
189
+ entryPoint: ENTRYPOINT_ADDRESS_V06,
190
+ paymasterRpc: paymasterRpc
191
+ })
192
+
193
+ const userOperation = await prepareUserOperationRequest(
194
+ smartClient as Client<
195
+ Transport,
196
+ Chain,
197
+ SmartAccount<EntryPoint>
198
+ >,
199
+ {
200
+ userOperation: {
201
+ callData: await smartClient.account.encodeCallData({
202
+ to: zeroAddress,
203
+ data: "0x",
204
+ value: 0n
205
+ })
206
+ },
207
+ middleware: async <T>(args: {
208
+ userOperation: T
209
+ entryPoint: EntryPoint
210
+ }) => {
211
+ const gasPrice = (
212
+ await pimlicoBundlerClient.getUserOperationGasPrice()
213
+ ).fast
214
+
215
+ return {
216
+ ...args.userOperation,
217
+ maxFeePerGas: gasPrice.maxFeePerGas,
218
+ maxPriorityFeePerGas:
219
+ gasPrice.maxPriorityFeePerGas,
220
+ ...(await pimlicoPaymasterActions.sponsorUserOperation(
221
+ {
222
+ userOperation: {
223
+ ...args.userOperation,
224
+ maxFeePerGas: gasPrice.maxFeePerGas,
225
+ maxPriorityFeePerGas:
226
+ gasPrice.maxPriorityFeePerGas
227
+ }
228
+ }
229
+ ))
230
+ } as T
231
+ }
232
+ }
233
+ )
234
+
235
+ expect(userOperation).toBeTruthy()
236
+ expect(userOperation.sender).toBe(smartClient.account.address)
237
+ expect(userOperation.nonce).toBe(
238
+ await smartClient.account.getNonce()
239
+ )
240
+ expect(userOperation.initCode).toBe(
241
+ await smartClient.account.getInitCode()
242
+ )
243
+ expect(userOperation.callData).toBe(
244
+ await smartClient.account.encodeCallData({
245
+ to: zeroAddress,
246
+ data: "0x",
247
+ value: 0n
248
+ })
249
+ )
250
+ expect(userOperation.callGasLimit).toBeTruthy()
251
+ expect(userOperation.verificationGasLimit).toBeTruthy()
252
+ expect(userOperation.maxFeePerGas).toBeTruthy()
253
+ expect(userOperation.maxPriorityFeePerGas).toBeTruthy()
254
+ expect(userOperation.paymasterAndData).toBeTruthy()
255
+ expect(userOperation.signature).toBe(
256
+ // @ts-ignore: since tests return all smart account client, some of them don't support V06.
257
+ // The TS error is because in that case, getDummySignature would not accept the userOperation of type UserOperation<V07>
258
+ await smartClient.account.getDummySignature(userOperation)
259
+ )
260
+
261
+ expect(userOperation.factory).toBe(undefined)
262
+ expect(userOperation.factoryData).toBe(undefined)
263
+ expect(userOperation.paymaster).toBe(undefined)
264
+ expect(userOperation.paymasterVerificationGasLimit).toBe(
265
+ undefined
266
+ )
267
+ expect(userOperation.paymasterPostOpGasLimit).toBe(undefined)
268
+ expect(userOperation.paymasterData).toBe(undefined)
269
+ }
270
+ )
84
271
  testWithRpc.skipIf(!supportsEntryPointV07)(
85
272
  "prepareUserOperationRequest_v07",
86
273
  async ({ rpc }) => {
@@ -147,5 +334,187 @@ describe.each(getCoreSmartAccounts())(
147
334
  expect(userOperation.initCode).toBe(undefined)
148
335
  }
149
336
  )
337
+
338
+ testWithRpc.skipIf(!supportsEntryPointV07)(
339
+ "prepareUserOperationRequest_v07",
340
+ async ({ rpc }) => {
341
+ const { anvilRpc, altoRpc, paymasterRpc } = rpc
342
+
343
+ const smartClient = await getSmartAccountClient({
344
+ entryPoint: ENTRYPOINT_ADDRESS_V07,
345
+ privateKey: generatePrivateKey(),
346
+ altoRpc: altoRpc,
347
+ anvilRpc: anvilRpc
348
+ })
349
+
350
+ const pimlicoBundlerClient = getPimlicoBundlerClient({
351
+ entryPoint: ENTRYPOINT_ADDRESS_V07,
352
+ altoRpc: altoRpc
353
+ })
354
+
355
+ const pimlicoPaymasterActions = getPimlicoPaymasterClient({
356
+ entryPoint: ENTRYPOINT_ADDRESS_V07,
357
+ paymasterRpc: paymasterRpc
358
+ })
359
+
360
+ const userOperation = await prepareUserOperationRequest(
361
+ smartClient as Client<
362
+ Transport,
363
+ Chain,
364
+ SmartAccount<EntryPoint>
365
+ >,
366
+ {
367
+ userOperation: {
368
+ callData: await smartClient.account.encodeCallData({
369
+ to: zeroAddress,
370
+ data: "0x",
371
+ value: 0n
372
+ })
373
+ },
374
+ middleware: {
375
+ gasPrice: async () =>
376
+ (
377
+ await pimlicoBundlerClient.getUserOperationGasPrice()
378
+ ).fast,
379
+ sponsorUserOperation:
380
+ pimlicoPaymasterActions.sponsorUserOperation
381
+ }
382
+ }
383
+ )
384
+
385
+ expect(userOperation).toBeTruthy()
386
+ expect(userOperation.sender).toBe(smartClient.account.address)
387
+ expect(userOperation.nonce).toBe(
388
+ await smartClient.account.getNonce()
389
+ )
390
+ expect(userOperation.factory).toBe(
391
+ await smartClient.account.getFactory()
392
+ )
393
+ expect(userOperation.factoryData).toBe(
394
+ await smartClient.account.getFactoryData()
395
+ )
396
+ expect(userOperation.callData).toBe(
397
+ await smartClient.account.encodeCallData({
398
+ to: zeroAddress,
399
+ data: "0x",
400
+ value: 0n
401
+ })
402
+ )
403
+ expect(userOperation.callGasLimit).toBeTruthy()
404
+ expect(userOperation.verificationGasLimit).toBeTruthy()
405
+ expect(userOperation.maxFeePerGas).toBeTruthy()
406
+ expect(userOperation.maxPriorityFeePerGas).toBeTruthy()
407
+ expect(userOperation.paymaster).toBeTruthy()
408
+ expect(userOperation.paymasterVerificationGasLimit).toBeTruthy()
409
+ expect(userOperation.signature).toBe(
410
+ // @ts-ignore: since tests return all smart account client, some of them don't support V07.
411
+ // The TS error is because in that case, getDummySignature would not accept the userOperation of type UserOperation<V07>
412
+ await smartClient.account.getDummySignature(userOperation)
413
+ )
414
+ expect(userOperation.paymasterPostOpGasLimit).toBe(1n)
415
+ expect(userOperation.paymasterData).toBeTruthy()
416
+ expect(userOperation.paymasterAndData).toBe(undefined)
417
+ expect(userOperation.initCode).toBe(undefined)
418
+ }
419
+ )
420
+
421
+ testWithRpc.skipIf(!supportsEntryPointV07)(
422
+ "prepareUserOperationRequest_v07",
423
+ async ({ rpc }) => {
424
+ const { anvilRpc, altoRpc, paymasterRpc } = rpc
425
+
426
+ const smartClient = await getSmartAccountClient({
427
+ entryPoint: ENTRYPOINT_ADDRESS_V07,
428
+ privateKey: generatePrivateKey(),
429
+ altoRpc: altoRpc,
430
+ anvilRpc: anvilRpc
431
+ })
432
+
433
+ const pimlicoBundlerClient = getPimlicoBundlerClient({
434
+ entryPoint: ENTRYPOINT_ADDRESS_V07,
435
+ altoRpc: altoRpc
436
+ })
437
+ const pimlicoPaymasterActions = getPimlicoPaymasterClient({
438
+ entryPoint: ENTRYPOINT_ADDRESS_V07,
439
+ paymasterRpc: paymasterRpc
440
+ })
441
+
442
+ const userOperation = await prepareUserOperationRequest(
443
+ smartClient as Client<
444
+ Transport,
445
+ Chain,
446
+ SmartAccount<EntryPoint>
447
+ >,
448
+ {
449
+ userOperation: {
450
+ callData: await smartClient.account.encodeCallData({
451
+ to: zeroAddress,
452
+ data: "0x",
453
+ value: 0n
454
+ })
455
+ },
456
+ middleware: async <T>(args: {
457
+ userOperation: T
458
+ entryPoint: EntryPoint
459
+ }) => {
460
+ const gasPrice = (
461
+ await pimlicoBundlerClient.getUserOperationGasPrice()
462
+ ).fast
463
+
464
+ return {
465
+ ...args.userOperation,
466
+ maxFeePerGas: gasPrice.maxFeePerGas,
467
+ maxPriorityFeePerGas:
468
+ gasPrice.maxPriorityFeePerGas,
469
+ ...(await pimlicoPaymasterActions.sponsorUserOperation(
470
+ {
471
+ userOperation: {
472
+ ...args.userOperation,
473
+ maxFeePerGas: gasPrice.maxFeePerGas,
474
+ maxPriorityFeePerGas:
475
+ gasPrice.maxPriorityFeePerGas
476
+ }
477
+ }
478
+ ))
479
+ } as T
480
+ }
481
+ }
482
+ )
483
+
484
+ expect(userOperation).toBeTruthy()
485
+ expect(userOperation.sender).toBe(smartClient.account.address)
486
+ expect(userOperation.nonce).toBe(
487
+ await smartClient.account.getNonce()
488
+ )
489
+ expect(userOperation.factory).toBe(
490
+ await smartClient.account.getFactory()
491
+ )
492
+ expect(userOperation.factoryData).toBe(
493
+ await smartClient.account.getFactoryData()
494
+ )
495
+ expect(userOperation.callData).toBe(
496
+ await smartClient.account.encodeCallData({
497
+ to: zeroAddress,
498
+ data: "0x",
499
+ value: 0n
500
+ })
501
+ )
502
+ expect(userOperation.callGasLimit).toBeTruthy()
503
+ expect(userOperation.verificationGasLimit).toBeTruthy()
504
+ expect(userOperation.maxFeePerGas).toBeTruthy()
505
+ expect(userOperation.maxPriorityFeePerGas).toBeTruthy()
506
+ expect(userOperation.paymaster).toBeTruthy()
507
+ expect(userOperation.paymasterVerificationGasLimit).toBeTruthy()
508
+ expect(userOperation.signature).toBe(
509
+ // @ts-ignore: since tests return all smart account client, some of them don't support V07.
510
+ // The TS error is because in that case, getDummySignature would not accept the userOperation of type UserOperation<V07>
511
+ await smartClient.account.getDummySignature(userOperation)
512
+ )
513
+ expect(userOperation.paymasterPostOpGasLimit).toBe(1n)
514
+ expect(userOperation.paymasterData).toBeTruthy()
515
+ expect(userOperation.paymasterAndData).toBe(undefined)
516
+ expect(userOperation.initCode).toBe(undefined)
517
+ }
518
+ )
150
519
  }
151
520
  )
@@ -0,0 +1,198 @@
1
+ import type {
2
+ Abi,
3
+ Account,
4
+ Address,
5
+ Chain,
6
+ Client,
7
+ Hash,
8
+ Hex,
9
+ SignTypedDataParameters,
10
+ Transport,
11
+ TypedData
12
+ } from "viem"
13
+ import type { SignMessageParameters } from "viem"
14
+ import { describe, expectTypeOf, test } from "vitest"
15
+ import type { SmartAccount } from "../accounts"
16
+ import type { BundlerRpcSchema } from "../types/bundler"
17
+ import type {
18
+ ENTRYPOINT_ADDRESS_V06_TYPE,
19
+ EntryPoint
20
+ } from "../types/entrypoint"
21
+ import {
22
+ type DeployContractParametersWithPaymaster,
23
+ type PrepareUserOperationRequestParameters,
24
+ type PrepareUserOperationRequestReturnType,
25
+ type SendTransactionWithPaymasterParameters,
26
+ type SendTransactionsWithPaymasterParameters,
27
+ type SendUserOperationParameters,
28
+ type WriteContractWithPaymasterParameters,
29
+ deployContract,
30
+ prepareUserOperationRequest,
31
+ sendTransaction,
32
+ sendTransactions,
33
+ sendUserOperation,
34
+ signMessage,
35
+ signTypedData,
36
+ writeContract
37
+ } from "./smartAccount"
38
+
39
+ describe("index", () => {
40
+ test("sendUserOperation", () => {
41
+ expectTypeOf(deployContract).toBeFunction()
42
+ expectTypeOf(deployContract)
43
+ .parameter(0)
44
+ .toMatchTypeOf<
45
+ Client<
46
+ Transport,
47
+ Chain | undefined,
48
+ Account | undefined,
49
+ BundlerRpcSchema<EntryPoint>
50
+ >
51
+ >()
52
+ expectTypeOf(deployContract)
53
+ .parameter(1)
54
+ .toMatchTypeOf<DeployContractParametersWithPaymaster<EntryPoint>>()
55
+ expectTypeOf(deployContract).returns.toMatchTypeOf<Promise<Hash>>()
56
+ })
57
+ test("prepareUserOperationRequest", () => {
58
+ expectTypeOf(prepareUserOperationRequest).toBeFunction()
59
+ expectTypeOf(prepareUserOperationRequest)
60
+ .parameter(0)
61
+ .toMatchTypeOf<
62
+ Client<
63
+ Transport,
64
+ Chain | undefined,
65
+ Account | undefined,
66
+ BundlerRpcSchema<EntryPoint>
67
+ >
68
+ >()
69
+ expectTypeOf(prepareUserOperationRequest)
70
+ .parameter(1)
71
+ .toMatchTypeOf<PrepareUserOperationRequestParameters<EntryPoint>>()
72
+ expectTypeOf(prepareUserOperationRequest).returns.toMatchTypeOf<
73
+ Promise<PrepareUserOperationRequestReturnType<EntryPoint>>
74
+ >()
75
+ })
76
+ test("sendTransaction", () => {
77
+ expectTypeOf(sendTransaction).toBeFunction()
78
+ expectTypeOf(sendTransaction)
79
+ .parameter(0)
80
+ .toMatchTypeOf<
81
+ Client<
82
+ Transport,
83
+ Chain | undefined,
84
+ Account | undefined,
85
+ BundlerRpcSchema<EntryPoint>
86
+ >
87
+ >()
88
+ expectTypeOf(sendTransaction)
89
+ .parameter(1)
90
+ .toMatchTypeOf<SendTransactionWithPaymasterParameters<EntryPoint>>()
91
+ expectTypeOf(sendTransaction).returns.toMatchTypeOf<Promise<Hex>>()
92
+ })
93
+ test("sendTransactions", () => {
94
+ expectTypeOf(sendTransactions).toBeFunction()
95
+ expectTypeOf(sendTransactions)
96
+ .parameter(0)
97
+ .toMatchTypeOf<
98
+ Client<
99
+ Transport,
100
+ Chain | undefined,
101
+ Account | undefined,
102
+ BundlerRpcSchema<EntryPoint>
103
+ >
104
+ >()
105
+ expectTypeOf(sendTransactions)
106
+ .parameter(1)
107
+ .toMatchTypeOf<
108
+ SendTransactionsWithPaymasterParameters<EntryPoint>
109
+ >()
110
+ expectTypeOf(sendTransactions).returns.toMatchTypeOf<Promise<Hex>>()
111
+ })
112
+ test("writeContract", () => {
113
+ expectTypeOf(writeContract).toBeFunction()
114
+ expectTypeOf(writeContract)
115
+ .parameter(0)
116
+ .toMatchTypeOf<
117
+ Client<
118
+ Transport,
119
+ Chain | undefined,
120
+ Account | undefined,
121
+ BundlerRpcSchema<EntryPoint>
122
+ >
123
+ >()
124
+ expectTypeOf(
125
+ writeContract<
126
+ ENTRYPOINT_ADDRESS_V06_TYPE,
127
+ Chain,
128
+ SmartAccount<ENTRYPOINT_ADDRESS_V06_TYPE>,
129
+ Abi
130
+ >
131
+ )
132
+ .parameter(1)
133
+ .toMatchTypeOf<
134
+ WriteContractWithPaymasterParameters<
135
+ ENTRYPOINT_ADDRESS_V06_TYPE,
136
+ Chain,
137
+ SmartAccount<ENTRYPOINT_ADDRESS_V06_TYPE>,
138
+ Abi
139
+ >
140
+ >()
141
+ expectTypeOf(writeContract).returns.toMatchTypeOf<Promise<Hex>>()
142
+ })
143
+ test("sendUserOperation", () => {
144
+ expectTypeOf(sendUserOperation).toBeFunction()
145
+ expectTypeOf(sendUserOperation)
146
+ .parameter(0)
147
+ .toMatchTypeOf<
148
+ Client<
149
+ Transport,
150
+ Chain | undefined,
151
+ Account | undefined,
152
+ BundlerRpcSchema<EntryPoint>
153
+ >
154
+ >()
155
+ expectTypeOf(sendUserOperation)
156
+ .parameter(1)
157
+ .toMatchTypeOf<SendUserOperationParameters<EntryPoint>>()
158
+ expectTypeOf(sendUserOperation).returns.toMatchTypeOf<Promise<Hex>>()
159
+ })
160
+ test("signMessage", () => {
161
+ expectTypeOf(signMessage).toBeFunction()
162
+ expectTypeOf(signMessage)
163
+ .parameter(0)
164
+ .toMatchTypeOf<
165
+ Client<
166
+ Transport,
167
+ Chain | undefined,
168
+ Account | undefined,
169
+ BundlerRpcSchema<EntryPoint>
170
+ >
171
+ >()
172
+ expectTypeOf(signMessage)
173
+ .parameter(1)
174
+ .toMatchTypeOf<SignMessageParameters<SmartAccount<EntryPoint>>>()
175
+ expectTypeOf(signMessage).returns.toMatchTypeOf<Promise<Hex>>()
176
+ })
177
+ test("signTypedData", () => {
178
+ expectTypeOf(signTypedData).toBeFunction()
179
+ expectTypeOf(signTypedData)
180
+ .parameter(0)
181
+ .toMatchTypeOf<
182
+ Client<
183
+ Transport,
184
+ Chain | undefined,
185
+ Account | undefined,
186
+ BundlerRpcSchema<EntryPoint>
187
+ >
188
+ >()
189
+ expectTypeOf(
190
+ signTypedData<EntryPoint, TypedData, string, undefined, undefined>
191
+ )
192
+ .parameter(1)
193
+ .toMatchTypeOf<
194
+ SignTypedDataParameters<TypedData, string, undefined>
195
+ >()
196
+ expectTypeOf(signTypedData).returns.toMatchTypeOf<Promise<Hex>>()
197
+ })
198
+ })
@@ -0,0 +1,26 @@
1
+ import { http } from "viem"
2
+ import { describe, expect } from "vitest"
3
+ import { testWithRpc } from "../../permissionless-test/src/testWithRpc"
4
+ import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from "../utils"
5
+ import { createBundlerClient } from "./createBundlerClient"
6
+
7
+ describe("createBundlerClient", () => {
8
+ testWithRpc("createBundlerClient_V06", async ({ rpc }) => {
9
+ const bundlerClientV06 = createBundlerClient({
10
+ transport: http(rpc.altoRpc),
11
+ entryPoint: ENTRYPOINT_ADDRESS_V06
12
+ })
13
+
14
+ const entryPoints = await bundlerClientV06.supportedEntryPoints()
15
+ expect(entryPoints).contain(ENTRYPOINT_ADDRESS_V06)
16
+ })
17
+
18
+ testWithRpc("createBundlerClient_V07", async ({ rpc }) => {
19
+ const bundlerClientV07 = createBundlerClient({
20
+ transport: http(rpc.altoRpc),
21
+ entryPoint: ENTRYPOINT_ADDRESS_V07
22
+ })
23
+ const entryPoints = await bundlerClientV07.supportedEntryPoints()
24
+ expect(entryPoints).contain(ENTRYPOINT_ADDRESS_V07)
25
+ })
26
+ })
@@ -0,0 +1,55 @@
1
+ import { http } from "viem"
2
+ import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"
3
+ import { foundry } from "viem/chains"
4
+ import { describe, expect } from "vitest"
5
+ import { testWithRpc } from "../../permissionless-test/src/testWithRpc"
6
+ import { getPublicClient } from "../../permissionless-test/src/utils"
7
+ import { signerToSimpleSmartAccount } from "../accounts"
8
+ import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from "../utils"
9
+ import { createSmartAccountClient } from "./createSmartAccountClient"
10
+
11
+ describe("createSmartAccountClient", () => {
12
+ testWithRpc("createSmartAccountClient_V06", async ({ rpc }) => {
13
+ const publicClient = getPublicClient(rpc.anvilRpc)
14
+
15
+ const simpleSmartAccount = await signerToSimpleSmartAccount(
16
+ publicClient,
17
+ {
18
+ entryPoint: ENTRYPOINT_ADDRESS_V06,
19
+ signer: privateKeyToAccount(generatePrivateKey())
20
+ }
21
+ )
22
+
23
+ const smartAccountClient = createSmartAccountClient({
24
+ chain: foundry,
25
+ account: simpleSmartAccount,
26
+ bundlerTransport: http(rpc.altoRpc)
27
+ })
28
+
29
+ expect(smartAccountClient.account.address).toBe(
30
+ simpleSmartAccount.address
31
+ )
32
+ })
33
+
34
+ testWithRpc("createSmartAccountClient_V07", async ({ rpc }) => {
35
+ const publicClient = getPublicClient(rpc.anvilRpc)
36
+
37
+ const simpleSmartAccount = await signerToSimpleSmartAccount(
38
+ publicClient,
39
+ {
40
+ entryPoint: ENTRYPOINT_ADDRESS_V07,
41
+ signer: privateKeyToAccount(generatePrivateKey())
42
+ }
43
+ )
44
+
45
+ const smartAccountClient = createSmartAccountClient({
46
+ chain: foundry,
47
+ account: simpleSmartAccount,
48
+ bundlerTransport: http(rpc.altoRpc)
49
+ })
50
+
51
+ expect(smartAccountClient.account.address).toBe(
52
+ simpleSmartAccount.address
53
+ )
54
+ })
55
+ })