permissionless 0.2.45 → 0.2.47

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 (94) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/_cjs/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
  3. package/_cjs/accounts/etherspot/toEtherspotSmartAccount.js.map +1 -1
  4. package/_cjs/accounts/kernel/toKernelSmartAccount.js.map +1 -1
  5. package/_cjs/accounts/light/toLightSmartAccount.js.map +1 -1
  6. package/_cjs/accounts/nexus/toNexusSmartAccount.js.map +1 -1
  7. package/_cjs/accounts/safe/toSafeSmartAccount.js +1 -1
  8. package/_cjs/accounts/safe/toSafeSmartAccount.js.map +1 -1
  9. package/_cjs/accounts/simple/toSimpleSmartAccount.js +208 -178
  10. package/_cjs/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  11. package/_cjs/accounts/thirdweb/toThirdwebSmartAccount.js.map +1 -1
  12. package/_cjs/accounts/trust/toTrustSmartAccount.js.map +1 -1
  13. package/_cjs/clients/decorators/pimlico.js.map +1 -1
  14. package/_cjs/clients/pimlico.js.map +1 -1
  15. package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
  16. package/_cjs/utils/getEstimationCallData.js +13 -0
  17. package/_cjs/utils/getEstimationCallData.js.map +1 -1
  18. package/_cjs/utils/getRequiredPrefund.js.map +1 -1
  19. package/_esm/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
  20. package/_esm/accounts/etherspot/toEtherspotSmartAccount.js.map +1 -1
  21. package/_esm/accounts/kernel/toKernelSmartAccount.js.map +1 -1
  22. package/_esm/accounts/light/toLightSmartAccount.js.map +1 -1
  23. package/_esm/accounts/nexus/toNexusSmartAccount.js.map +1 -1
  24. package/_esm/accounts/safe/toSafeSmartAccount.js +1 -1
  25. package/_esm/accounts/safe/toSafeSmartAccount.js.map +1 -1
  26. package/_esm/accounts/simple/toSimpleSmartAccount.js +211 -179
  27. package/_esm/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  28. package/_esm/accounts/thirdweb/toThirdwebSmartAccount.js.map +1 -1
  29. package/_esm/accounts/trust/toTrustSmartAccount.js.map +1 -1
  30. package/_esm/clients/decorators/pimlico.js.map +1 -1
  31. package/_esm/clients/pimlico.js.map +1 -1
  32. package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
  33. package/_esm/utils/getEstimationCallData.js +13 -0
  34. package/_esm/utils/getEstimationCallData.js.map +1 -1
  35. package/_esm/utils/getRequiredPrefund.js.map +1 -1
  36. package/_types/accounts/biconomy/toBiconomySmartAccount.d.ts +2 -2
  37. package/_types/accounts/biconomy/toBiconomySmartAccount.d.ts.map +1 -1
  38. package/_types/accounts/etherspot/toEtherspotSmartAccount.d.ts +2 -2
  39. package/_types/accounts/etherspot/toEtherspotSmartAccount.d.ts.map +1 -1
  40. package/_types/accounts/kernel/toKernelSmartAccount.d.ts +2 -2
  41. package/_types/accounts/kernel/toKernelSmartAccount.d.ts.map +1 -1
  42. package/_types/accounts/light/toLightSmartAccount.d.ts +2 -2
  43. package/_types/accounts/light/toLightSmartAccount.d.ts.map +1 -1
  44. package/_types/accounts/nexus/toNexusSmartAccount.d.ts +2 -2
  45. package/_types/accounts/nexus/toNexusSmartAccount.d.ts.map +1 -1
  46. package/_types/accounts/safe/toSafeSmartAccount.d.ts +2 -2
  47. package/_types/accounts/safe/toSafeSmartAccount.d.ts.map +1 -1
  48. package/_types/accounts/simple/toSimpleSmartAccount.d.ts +2303 -7
  49. package/_types/accounts/simple/toSimpleSmartAccount.d.ts.map +1 -1
  50. package/_types/accounts/thirdweb/toThirdwebSmartAccount.d.ts +2 -2
  51. package/_types/accounts/thirdweb/toThirdwebSmartAccount.d.ts.map +1 -1
  52. package/_types/accounts/trust/toTrustSmartAccount.d.ts +2 -2
  53. package/_types/accounts/trust/toTrustSmartAccount.d.ts.map +1 -1
  54. package/_types/actions/pimlico/sponsorUserOperation.d.ts +4 -4
  55. package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
  56. package/_types/clients/decorators/pimlico.d.ts +3 -2
  57. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  58. package/_types/clients/pimlico.d.ts +4 -4
  59. package/_types/clients/pimlico.d.ts.map +1 -1
  60. package/_types/types/pimlico.d.ts +3 -3
  61. package/_types/types/pimlico.d.ts.map +1 -1
  62. package/_types/utils/getEstimationCallData.d.ts +3 -3
  63. package/_types/utils/getEstimationCallData.d.ts.map +1 -1
  64. package/_types/utils/getRequiredPrefund.d.ts +3 -3
  65. package/_types/utils/getRequiredPrefund.d.ts.map +1 -1
  66. package/accounts/biconomy/toBiconomySmartAccount.ts +6 -1
  67. package/accounts/decodeCalls.test.ts +161 -0
  68. package/accounts/etherspot/toEtherspotSmartAccount.ts +6 -1
  69. package/accounts/kernel/toKernelSmartAccount.ts +6 -1
  70. package/accounts/light/toLightSmartAccount.ts +6 -1
  71. package/accounts/nexus/toNexusSmartAccount.ts +6 -1
  72. package/accounts/safe/toSafeSmartAccount.ts +7 -2
  73. package/accounts/simple/toSimpleSmartAccount.ts +243 -197
  74. package/accounts/thirdweb/toThirdwebSmartAccount.ts +6 -1
  75. package/accounts/trust/toTrustSmartAccount.ts +6 -1
  76. package/actions/pimlico/getTokenQuotes.test.ts +55 -1
  77. package/actions/pimlico/getUserOperationGasPrice.test.ts +50 -0
  78. package/actions/pimlico/getUserOperationStatus.test.ts +62 -0
  79. package/actions/pimlico/sponsorUserOperation.test.ts +51 -0
  80. package/actions/pimlico/sponsorUserOperation.ts +4 -4
  81. package/actions/pimlico/validateSponsorshipPolicies.test.ts +98 -2
  82. package/actions/public/getAccountNonce.test.ts +27 -0
  83. package/actions/public/getSenderAddress.test.ts +37 -1
  84. package/actions/smartAccount/sendTransaction.test.ts +121 -1
  85. package/actions/smartAccount/signMessage.test.ts +59 -0
  86. package/actions/smartAccount/signTypedData.test.ts +54 -0
  87. package/clients/decorators/pimlico.ts +3 -2
  88. package/clients/pimlico.ts +4 -3
  89. package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +208 -43
  90. package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +1 -1
  91. package/package.json +2 -2
  92. package/types/pimlico.ts +12 -2
  93. package/utils/getEstimationCallData.ts +25 -7
  94. package/utils/getRequiredPrefund.ts +6 -4
@@ -5,6 +5,7 @@ import {
5
5
  type Chain,
6
6
  type Client,
7
7
  type Hex,
8
+ type JsonRpcAccount,
8
9
  type LocalAccount,
9
10
  type OneOf,
10
11
  type Transport,
@@ -13,13 +14,16 @@ import {
13
14
  encodeFunctionData
14
15
  } from "viem"
15
16
  import {
17
+ type EntryPointVersion,
16
18
  type SmartAccount,
17
19
  type SmartAccountImplementation,
18
20
  type UserOperation,
19
21
  entryPoint06Abi,
20
22
  entryPoint07Abi,
21
23
  entryPoint07Address,
24
+ entryPoint08Abi,
22
25
  getUserOperationHash,
26
+ getUserOperationTypedData,
23
27
  toSmartAccount
24
28
  } from "viem/account-abstraction"
25
29
  import { getChainId, signMessage } from "viem/actions"
@@ -67,9 +71,13 @@ const getAccountInitCode = async (
67
71
  }
68
72
 
69
73
  export type ToSimpleSmartAccountParameters<
70
- entryPointVersion extends "0.6" | "0.7"
74
+ entryPointVersion extends EntryPointVersion
71
75
  > = {
72
- client: Client
76
+ client: Client<
77
+ Transport,
78
+ Chain | undefined,
79
+ JsonRpcAccount | LocalAccount | undefined
80
+ >
73
81
  owner: OneOf<
74
82
  | EthereumProvider
75
83
  | WalletClient<Transport, Chain | undefined, Account>
@@ -86,36 +94,44 @@ export type ToSimpleSmartAccountParameters<
86
94
  }
87
95
 
88
96
  const getFactoryAddress = (
89
- entryPointVersion: "0.6" | "0.7",
97
+ entryPointVersion: EntryPointVersion,
90
98
  factoryAddress?: Address
91
99
  ): Address => {
92
100
  if (factoryAddress) return factoryAddress
93
101
 
94
- if (entryPointVersion === "0.6") {
95
- return "0x9406Cc6185a346906296840746125a0E44976454"
102
+ switch (entryPointVersion) {
103
+ case "0.8":
104
+ return "0x13E9ed32155810FDbd067D4522C492D6f68E5944"
105
+ case "0.7":
106
+ return "0x91E60e0613810449d098b0b5Ec8b51A0FE8c8985"
107
+ default:
108
+ return "0x9406Cc6185a346906296840746125a0E44976454"
109
+ }
110
+ }
111
+
112
+ const getEntryPointAbi = (entryPointVersion: EntryPointVersion) => {
113
+ switch (entryPointVersion) {
114
+ case "0.8":
115
+ return entryPoint08Abi
116
+ case "0.7":
117
+ return entryPoint07Abi
118
+ default:
119
+ return entryPoint06Abi
96
120
  }
97
- return "0x91E60e0613810449d098b0b5Ec8b51A0FE8c8985"
98
121
  }
99
122
 
100
123
  export type SimpleSmartAccountImplementation<
101
- entryPointVersion extends "0.6" | "0.7" = "0.7"
124
+ entryPointVersion extends EntryPointVersion = "0.7"
102
125
  > = Assign<
103
126
  SmartAccountImplementation<
104
- entryPointVersion extends "0.6"
105
- ? typeof entryPoint06Abi
106
- : typeof entryPoint07Abi,
127
+ ReturnType<typeof getEntryPointAbi>,
107
128
  entryPointVersion
108
- // {
109
- // // entryPoint === ENTRYPOINT_ADDRESS_V06 ? "0.2.2" : "0.3.0-beta"
110
- // abi: entryPointVersion extends "0.6" ? typeof BiconomyAbi
111
- // factory: { abi: typeof FactoryAbi; address: Address }
112
- // }
113
129
  >,
114
130
  { sign: NonNullable<SmartAccountImplementation["sign"]> }
115
131
  >
116
132
 
117
133
  export type ToSimpleSmartAccountReturnType<
118
- entryPointVersion extends "0.6" | "0.7" = "0.7"
134
+ entryPointVersion extends EntryPointVersion = "0.7"
119
135
  > = SmartAccount<SimpleSmartAccountImplementation<entryPointVersion>>
120
136
 
121
137
  /**
@@ -124,7 +140,7 @@ export type ToSimpleSmartAccountReturnType<
124
140
  * @returns A Private Key Simple Account.
125
141
  */
126
142
  export async function toSimpleSmartAccount<
127
- entryPointVersion extends "0.6" | "0.7"
143
+ entryPointVersion extends EntryPointVersion
128
144
  >(
129
145
  parameters: ToSimpleSmartAccountParameters<entryPointVersion>
130
146
  ): Promise<ToSimpleSmartAccountReturnType<entryPointVersion>> {
@@ -139,14 +155,17 @@ export async function toSimpleSmartAccount<
139
155
 
140
156
  const localOwner = await toOwner({ owner })
141
157
 
142
- const entryPoint = {
143
- address: parameters.entryPoint?.address ?? entryPoint07Address,
144
- abi:
145
- (parameters.entryPoint?.version ?? "0.7") === "0.6"
146
- ? entryPoint06Abi
147
- : entryPoint07Abi,
148
- version: parameters.entryPoint?.version ?? "0.7"
149
- } as const
158
+ const entryPoint = parameters.entryPoint
159
+ ? {
160
+ address: parameters.entryPoint.address,
161
+ abi: getEntryPointAbi(parameters.entryPoint.version),
162
+ version: parameters.entryPoint.version
163
+ }
164
+ : ({
165
+ address: entryPoint07Address,
166
+ abi: getEntryPointAbi("0.7"),
167
+ version: "0.7"
168
+ } as const)
150
169
 
151
170
  const factoryAddress = getFactoryAddress(
152
171
  entryPoint.version,
@@ -192,65 +211,37 @@ export async function toSimpleSmartAccount<
192
211
  },
193
212
  async encodeCalls(calls) {
194
213
  if (calls.length > 1) {
195
- if (entryPoint.version === "0.6") {
214
+ if (entryPoint.version === "0.8") {
196
215
  return encodeFunctionData({
197
- abi: [
198
- {
199
- inputs: [
200
- {
201
- internalType: "address[]",
202
- name: "dest",
203
- type: "address[]"
204
- },
205
- {
206
- internalType: "bytes[]",
207
- name: "func",
208
- type: "bytes[]"
209
- }
210
- ],
211
- name: "executeBatch",
212
- outputs: [],
213
- stateMutability: "nonpayable",
214
- type: "function"
215
- }
216
- ],
216
+ abi: executeBatch08Abi,
217
+ functionName: "executeBatch",
218
+ args: [
219
+ calls.map((a) => ({
220
+ target: a.to,
221
+ value: a.value ?? 0n,
222
+ data: a.data ?? "0x"
223
+ }))
224
+ ]
225
+ })
226
+ }
227
+
228
+ if (entryPoint.version === "0.7") {
229
+ return encodeFunctionData({
230
+ abi: executeBatch07Abi,
217
231
  functionName: "executeBatch",
218
232
  args: [
219
233
  calls.map((a) => a.to),
234
+ calls.map((a) => a.value ?? 0n),
220
235
  calls.map((a) => a.data ?? "0x")
221
236
  ]
222
237
  })
223
238
  }
239
+
224
240
  return encodeFunctionData({
225
- abi: [
226
- {
227
- inputs: [
228
- {
229
- internalType: "address[]",
230
- name: "dest",
231
- type: "address[]"
232
- },
233
- {
234
- internalType: "uint256[]",
235
- name: "value",
236
- type: "uint256[]"
237
- },
238
- {
239
- internalType: "bytes[]",
240
- name: "func",
241
- type: "bytes[]"
242
- }
243
- ],
244
- name: "executeBatch",
245
- outputs: [],
246
- stateMutability: "nonpayable",
247
- type: "function"
248
- }
249
- ],
241
+ abi: executeBatch06Abi,
250
242
  functionName: "executeBatch",
251
243
  args: [
252
244
  calls.map((a) => a.to),
253
- calls.map((a) => a.value ?? 0n),
254
245
  calls.map((a) => a.data ?? "0x")
255
246
  ]
256
247
  })
@@ -262,160 +253,93 @@ export async function toSimpleSmartAccount<
262
253
  throw new Error("No calls to encode")
263
254
  }
264
255
 
256
+ // 0.6, 0.7 and 0.8 all use the same for "execute"
265
257
  return encodeFunctionData({
266
- abi: [
267
- {
268
- inputs: [
269
- {
270
- internalType: "address",
271
- name: "dest",
272
- type: "address"
273
- },
274
- {
275
- internalType: "uint256",
276
- name: "value",
277
- type: "uint256"
278
- },
279
- {
280
- internalType: "bytes",
281
- name: "func",
282
- type: "bytes"
283
- }
284
- ],
285
- name: "execute",
286
- outputs: [],
287
- stateMutability: "nonpayable",
288
- type: "function"
289
- }
290
- ],
258
+ abi: executeSingleAbi,
291
259
  functionName: "execute",
292
260
  args: [call.to, call.value ?? 0n, call.data ?? "0x"]
293
261
  })
294
262
  },
295
263
  decodeCalls: async (callData) => {
296
264
  try {
297
- const decodedV6 = decodeFunctionData({
298
- abi: [
299
- {
300
- inputs: [
301
- {
302
- internalType: "address[]",
303
- name: "dest",
304
- type: "address[]"
305
- },
306
- {
307
- internalType: "bytes[]",
308
- name: "func",
309
- type: "bytes[]"
310
- }
311
- ],
312
- name: "executeBatch",
313
- outputs: [],
314
- stateMutability: "nonpayable",
315
- type: "function"
316
- }
317
- ],
318
- data: callData
319
- })
320
-
321
265
  const calls: {
322
266
  to: Address
323
267
  data: Hex
324
268
  value?: bigint
325
269
  }[] = []
326
270
 
327
- for (let i = 0; i < decodedV6.args.length; i++) {
328
- calls.push({
329
- to: decodedV6.args[0][i],
330
- data: decodedV6.args[1][i],
331
- value: 0n
271
+ if (entryPoint.version === "0.8") {
272
+ const decodedV8 = decodeFunctionData({
273
+ abi: executeBatch08Abi,
274
+ data: callData
332
275
  })
276
+
277
+ for (const call of decodedV8.args[0]) {
278
+ calls.push({
279
+ to: call.target,
280
+ data: call.data,
281
+ value: call.value
282
+ })
283
+ }
284
+
285
+ return calls
333
286
  }
334
287
 
335
- return calls
336
- } catch (_) {
337
- try {
288
+ if (entryPoint.version === "0.7") {
338
289
  const decodedV7 = decodeFunctionData({
339
- abi: [
340
- {
341
- inputs: [
342
- {
343
- internalType: "address[]",
344
- name: "dest",
345
- type: "address[]"
346
- },
347
- {
348
- internalType: "uint256[]",
349
- name: "value",
350
- type: "uint256[]"
351
- },
352
- {
353
- internalType: "bytes[]",
354
- name: "func",
355
- type: "bytes[]"
356
- }
357
- ],
358
- name: "executeBatch",
359
- outputs: [],
360
- stateMutability: "nonpayable",
361
- type: "function"
362
- }
363
- ],
290
+ abi: executeBatch07Abi,
364
291
  data: callData
365
292
  })
366
293
 
367
- const calls: {
368
- to: Address
369
- data: Hex
370
- value?: bigint
371
- }[] = []
294
+ const destinations = decodedV7.args[0]
295
+ const values = decodedV7.args[1]
296
+ const datas = decodedV7.args[2]
372
297
 
373
- for (let i = 0; i < decodedV7.args[0].length; i++) {
298
+ for (let i = 0; i < destinations.length; i++) {
374
299
  calls.push({
375
- to: decodedV7.args[0][i],
376
- value: decodedV7.args[1][i],
377
- data: decodedV7.args[2][i]
300
+ to: destinations[i],
301
+ data: datas[i],
302
+ value: values[i]
378
303
  })
379
304
  }
380
305
 
381
306
  return calls
382
- } catch (_) {
383
- const decodedSingle = decodeFunctionData({
384
- abi: [
385
- {
386
- inputs: [
387
- {
388
- internalType: "address",
389
- name: "dest",
390
- type: "address"
391
- },
392
- {
393
- internalType: "uint256",
394
- name: "value",
395
- type: "uint256"
396
- },
397
- {
398
- internalType: "bytes",
399
- name: "func",
400
- type: "bytes"
401
- }
402
- ],
403
- name: "execute",
404
- outputs: [],
405
- stateMutability: "nonpayable",
406
- type: "function"
407
- }
408
- ],
307
+ }
308
+
309
+ if (entryPoint.version === "0.6") {
310
+ const decodedV6 = decodeFunctionData({
311
+ abi: executeBatch06Abi,
409
312
  data: callData
410
313
  })
411
- return [
412
- {
413
- to: decodedSingle.args[0],
414
- value: decodedSingle.args[1],
415
- data: decodedSingle.args[2]
416
- }
417
- ]
314
+
315
+ const destinations = decodedV6.args[0]
316
+ const datas = decodedV6.args[1]
317
+
318
+ for (let i = 0; i < destinations.length; i++) {
319
+ calls.push({
320
+ to: destinations[i],
321
+ data: datas[i],
322
+ value: 0n
323
+ })
324
+ }
325
+
326
+ return calls
418
327
  }
328
+
329
+ return calls
330
+ } catch (_) {
331
+ const decodedSingle = decodeFunctionData({
332
+ abi: executeSingleAbi,
333
+ data: callData
334
+ })
335
+
336
+ return [
337
+ {
338
+ to: decodedSingle.args[0],
339
+ value: decodedSingle.args[1],
340
+ data: decodedSingle.args[2]
341
+ }
342
+ ]
419
343
  }
420
344
  },
421
345
  async getNonce(args) {
@@ -440,6 +364,22 @@ export async function toSimpleSmartAccount<
440
364
  async signUserOperation(parameters) {
441
365
  const { chainId = await getMemoizedChainId(), ...userOperation } =
442
366
  parameters
367
+
368
+ // 0.8 Signs using typed data
369
+ if (entryPoint.version === "0.8") {
370
+ const typedData = getUserOperationTypedData({
371
+ chainId,
372
+ entryPointAddress: entryPoint.address,
373
+ userOperation: {
374
+ ...userOperation,
375
+ sender:
376
+ userOperation.sender ?? (await this.getAddress()),
377
+ signature: "0x"
378
+ }
379
+ })
380
+ return await localOwner.signTypedData(typedData)
381
+ }
382
+
443
383
  return signMessage(client, {
444
384
  account: localOwner,
445
385
  message: {
@@ -460,3 +400,109 @@ export async function toSimpleSmartAccount<
460
400
  }
461
401
  }) as Promise<ToSimpleSmartAccountReturnType<entryPointVersion>>
462
402
  }
403
+
404
+ const executeSingleAbi = [
405
+ {
406
+ inputs: [
407
+ {
408
+ internalType: "address",
409
+ name: "dest",
410
+ type: "address"
411
+ },
412
+ {
413
+ internalType: "uint256",
414
+ name: "value",
415
+ type: "uint256"
416
+ },
417
+ {
418
+ internalType: "bytes",
419
+ name: "func",
420
+ type: "bytes"
421
+ }
422
+ ],
423
+ name: "execute",
424
+ outputs: [],
425
+ stateMutability: "nonpayable",
426
+ type: "function"
427
+ }
428
+ ] as const
429
+
430
+ const executeBatch06Abi = [
431
+ {
432
+ inputs: [
433
+ {
434
+ internalType: "address[]",
435
+ name: "dest",
436
+ type: "address[]"
437
+ },
438
+ {
439
+ internalType: "bytes[]",
440
+ name: "func",
441
+ type: "bytes[]"
442
+ }
443
+ ],
444
+ name: "executeBatch",
445
+ outputs: [],
446
+ stateMutability: "nonpayable",
447
+ type: "function"
448
+ }
449
+ ] as const
450
+
451
+ const executeBatch07Abi = [
452
+ {
453
+ inputs: [
454
+ {
455
+ internalType: "address[]",
456
+ name: "dest",
457
+ type: "address[]"
458
+ },
459
+ {
460
+ internalType: "uint256[]",
461
+ name: "value",
462
+ type: "uint256[]"
463
+ },
464
+ {
465
+ internalType: "bytes[]",
466
+ name: "func",
467
+ type: "bytes[]"
468
+ }
469
+ ],
470
+ name: "executeBatch",
471
+ outputs: [],
472
+ stateMutability: "nonpayable",
473
+ type: "function"
474
+ }
475
+ ] as const
476
+
477
+ const executeBatch08Abi = [
478
+ {
479
+ type: "function",
480
+ name: "executeBatch",
481
+ inputs: [
482
+ {
483
+ name: "calls",
484
+ type: "tuple[]",
485
+ internalType: "struct BaseAccount.Call[]",
486
+ components: [
487
+ {
488
+ name: "target",
489
+ type: "address",
490
+ internalType: "address"
491
+ },
492
+ {
493
+ name: "value",
494
+ type: "uint256",
495
+ internalType: "uint256"
496
+ },
497
+ {
498
+ name: "data",
499
+ type: "bytes",
500
+ internalType: "bytes"
501
+ }
502
+ ]
503
+ }
504
+ ],
505
+ outputs: [],
506
+ stateMutability: "nonpayable"
507
+ }
508
+ ] as const
@@ -4,6 +4,7 @@ import type {
4
4
  Assign,
5
5
  Chain,
6
6
  Client,
7
+ JsonRpcAccount,
7
8
  LocalAccount,
8
9
  OneOf,
9
10
  Transport,
@@ -53,7 +54,11 @@ export const THIRDWEB_ADDRESSES = {
53
54
  export type ToThirdwebSmartAccountParameters<
54
55
  entryPointVersion extends "0.6" | "0.7" = "0.7"
55
56
  > = {
56
- client: Client
57
+ client: Client<
58
+ Transport,
59
+ Chain | undefined,
60
+ JsonRpcAccount | LocalAccount | undefined
61
+ >
57
62
  owner: OneOf<
58
63
  | EthereumProvider
59
64
  | WalletClient<Transport, Chain | undefined, Account>
@@ -5,6 +5,7 @@ import {
5
5
  type Chain,
6
6
  type Client,
7
7
  type Hex,
8
+ type JsonRpcAccount,
8
9
  type LocalAccount,
9
10
  type OneOf,
10
11
  type Transport,
@@ -67,7 +68,11 @@ export const TRUST_ADDRESSES: {
67
68
  }
68
69
 
69
70
  export type ToTrustSmartAccountParameters = {
70
- client: Client
71
+ client: Client<
72
+ Transport,
73
+ Chain | undefined,
74
+ JsonRpcAccount | LocalAccount | undefined
75
+ >
71
76
  owner: OneOf<
72
77
  | EthereumProvider
73
78
  | WalletClient<Transport, Chain | undefined, Account>
@@ -7,7 +7,34 @@ import { getPimlicoClient } from "../../../permissionless-test/src/utils"
7
7
  import { getTokenQuotes } from "./getTokenQuotes"
8
8
 
9
9
  describe("getTokenQuotes", () => {
10
- testWithRpc("getTokenQuotes", async ({ rpc }) => {
10
+ testWithRpc("getTokenQuotes v0.6", async ({ rpc }) => {
11
+ const pimlicoBundlerClient = getPimlicoClient({
12
+ entryPointVersion: "0.6",
13
+ altoRpc: rpc.paymasterRpc
14
+ })
15
+
16
+ const token = getAddress("0xffffffffffffffffffffffffffffffffffffffff")
17
+
18
+ const quotes = await getTokenQuotes(pimlicoBundlerClient, {
19
+ tokens: [token],
20
+ entryPointAddress: entryPoint07Address,
21
+ chain: foundry
22
+ })
23
+
24
+ expect(quotes).toBeTruthy()
25
+ expect(Array.isArray(quotes)).toBe(true)
26
+ expect(quotes[0].token).toBeTruthy()
27
+ expect(isAddress(quotes[0].token))
28
+ expect(quotes[0].token).toEqual(token)
29
+ expect(quotes[0].paymaster).toBeTruthy()
30
+ expect(isAddress(quotes[0].paymaster))
31
+ expect(quotes[0].exchangeRate).toBeTruthy()
32
+ expect(quotes[0].exchangeRate).toBeGreaterThan(0n)
33
+ expect(quotes[0].postOpGas).toBeTruthy()
34
+ expect(quotes[0].postOpGas).toBeGreaterThan(0n)
35
+ })
36
+
37
+ testWithRpc("getTokenQuotes v0.7", async ({ rpc }) => {
11
38
  const pimlicoBundlerClient = getPimlicoClient({
12
39
  entryPointVersion: "0.7",
13
40
  altoRpc: rpc.paymasterRpc
@@ -33,4 +60,31 @@ describe("getTokenQuotes", () => {
33
60
  expect(quotes[0].postOpGas).toBeTruthy()
34
61
  expect(quotes[0].postOpGas).toBeGreaterThan(0n)
35
62
  })
63
+
64
+ testWithRpc("getTokenQuotes v0.8", async ({ rpc }) => {
65
+ const pimlicoBundlerClient = getPimlicoClient({
66
+ entryPointVersion: "0.8",
67
+ altoRpc: rpc.paymasterRpc
68
+ })
69
+
70
+ const token = getAddress("0xffffffffffffffffffffffffffffffffffffffff")
71
+
72
+ const quotes = await getTokenQuotes(pimlicoBundlerClient, {
73
+ tokens: [token],
74
+ entryPointAddress: entryPoint07Address,
75
+ chain: foundry
76
+ })
77
+
78
+ expect(quotes).toBeTruthy()
79
+ expect(Array.isArray(quotes)).toBe(true)
80
+ expect(quotes[0].token).toBeTruthy()
81
+ expect(isAddress(quotes[0].token))
82
+ expect(quotes[0].token).toEqual(token)
83
+ expect(quotes[0].paymaster).toBeTruthy()
84
+ expect(isAddress(quotes[0].paymaster))
85
+ expect(quotes[0].exchangeRate).toBeTruthy()
86
+ expect(quotes[0].exchangeRate).toBeGreaterThan(0n)
87
+ expect(quotes[0].postOpGas).toBeTruthy()
88
+ expect(quotes[0].postOpGas).toBeGreaterThan(0n)
89
+ })
36
90
  })