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.
- package/CHANGELOG.md +12 -0
- package/_cjs/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/etherspot/toEtherspotSmartAccount.js.map +1 -1
- package/_cjs/accounts/kernel/toKernelSmartAccount.js.map +1 -1
- package/_cjs/accounts/light/toLightSmartAccount.js.map +1 -1
- package/_cjs/accounts/nexus/toNexusSmartAccount.js.map +1 -1
- package/_cjs/accounts/safe/toSafeSmartAccount.js +1 -1
- package/_cjs/accounts/safe/toSafeSmartAccount.js.map +1 -1
- package/_cjs/accounts/simple/toSimpleSmartAccount.js +208 -178
- package/_cjs/accounts/simple/toSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/thirdweb/toThirdwebSmartAccount.js.map +1 -1
- package/_cjs/accounts/trust/toTrustSmartAccount.js.map +1 -1
- package/_cjs/clients/decorators/pimlico.js.map +1 -1
- package/_cjs/clients/pimlico.js.map +1 -1
- package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
- package/_cjs/utils/getEstimationCallData.js +13 -0
- package/_cjs/utils/getEstimationCallData.js.map +1 -1
- package/_cjs/utils/getRequiredPrefund.js.map +1 -1
- package/_esm/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/etherspot/toEtherspotSmartAccount.js.map +1 -1
- package/_esm/accounts/kernel/toKernelSmartAccount.js.map +1 -1
- package/_esm/accounts/light/toLightSmartAccount.js.map +1 -1
- package/_esm/accounts/nexus/toNexusSmartAccount.js.map +1 -1
- package/_esm/accounts/safe/toSafeSmartAccount.js +1 -1
- package/_esm/accounts/safe/toSafeSmartAccount.js.map +1 -1
- package/_esm/accounts/simple/toSimpleSmartAccount.js +211 -179
- package/_esm/accounts/simple/toSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/thirdweb/toThirdwebSmartAccount.js.map +1 -1
- package/_esm/accounts/trust/toTrustSmartAccount.js.map +1 -1
- package/_esm/clients/decorators/pimlico.js.map +1 -1
- package/_esm/clients/pimlico.js.map +1 -1
- package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
- package/_esm/utils/getEstimationCallData.js +13 -0
- package/_esm/utils/getEstimationCallData.js.map +1 -1
- package/_esm/utils/getRequiredPrefund.js.map +1 -1
- package/_types/accounts/biconomy/toBiconomySmartAccount.d.ts +2 -2
- package/_types/accounts/biconomy/toBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/etherspot/toEtherspotSmartAccount.d.ts +2 -2
- package/_types/accounts/etherspot/toEtherspotSmartAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/toKernelSmartAccount.d.ts +2 -2
- package/_types/accounts/kernel/toKernelSmartAccount.d.ts.map +1 -1
- package/_types/accounts/light/toLightSmartAccount.d.ts +2 -2
- package/_types/accounts/light/toLightSmartAccount.d.ts.map +1 -1
- package/_types/accounts/nexus/toNexusSmartAccount.d.ts +2 -2
- package/_types/accounts/nexus/toNexusSmartAccount.d.ts.map +1 -1
- package/_types/accounts/safe/toSafeSmartAccount.d.ts +2 -2
- package/_types/accounts/safe/toSafeSmartAccount.d.ts.map +1 -1
- package/_types/accounts/simple/toSimpleSmartAccount.d.ts +2303 -7
- package/_types/accounts/simple/toSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/thirdweb/toThirdwebSmartAccount.d.ts +2 -2
- package/_types/accounts/thirdweb/toThirdwebSmartAccount.d.ts.map +1 -1
- package/_types/accounts/trust/toTrustSmartAccount.d.ts +2 -2
- package/_types/accounts/trust/toTrustSmartAccount.d.ts.map +1 -1
- package/_types/actions/pimlico/sponsorUserOperation.d.ts +4 -4
- package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
- package/_types/clients/decorators/pimlico.d.ts +3 -2
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/clients/pimlico.d.ts +4 -4
- package/_types/clients/pimlico.d.ts.map +1 -1
- package/_types/types/pimlico.d.ts +3 -3
- package/_types/types/pimlico.d.ts.map +1 -1
- package/_types/utils/getEstimationCallData.d.ts +3 -3
- package/_types/utils/getEstimationCallData.d.ts.map +1 -1
- package/_types/utils/getRequiredPrefund.d.ts +3 -3
- package/_types/utils/getRequiredPrefund.d.ts.map +1 -1
- package/accounts/biconomy/toBiconomySmartAccount.ts +6 -1
- package/accounts/decodeCalls.test.ts +161 -0
- package/accounts/etherspot/toEtherspotSmartAccount.ts +6 -1
- package/accounts/kernel/toKernelSmartAccount.ts +6 -1
- package/accounts/light/toLightSmartAccount.ts +6 -1
- package/accounts/nexus/toNexusSmartAccount.ts +6 -1
- package/accounts/safe/toSafeSmartAccount.ts +7 -2
- package/accounts/simple/toSimpleSmartAccount.ts +243 -197
- package/accounts/thirdweb/toThirdwebSmartAccount.ts +6 -1
- package/accounts/trust/toTrustSmartAccount.ts +6 -1
- package/actions/pimlico/getTokenQuotes.test.ts +55 -1
- package/actions/pimlico/getUserOperationGasPrice.test.ts +50 -0
- package/actions/pimlico/getUserOperationStatus.test.ts +62 -0
- package/actions/pimlico/sponsorUserOperation.test.ts +51 -0
- package/actions/pimlico/sponsorUserOperation.ts +4 -4
- package/actions/pimlico/validateSponsorshipPolicies.test.ts +98 -2
- package/actions/public/getAccountNonce.test.ts +27 -0
- package/actions/public/getSenderAddress.test.ts +37 -1
- package/actions/smartAccount/sendTransaction.test.ts +121 -1
- package/actions/smartAccount/signMessage.test.ts +59 -0
- package/actions/smartAccount/signTypedData.test.ts +54 -0
- package/clients/decorators/pimlico.ts +3 -2
- package/clients/pimlico.ts +4 -3
- package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +208 -43
- package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +1 -1
- package/package.json +2 -2
- package/types/pimlico.ts +12 -2
- package/utils/getEstimationCallData.ts +25 -7
- 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
|
|
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:
|
|
97
|
+
entryPointVersion: EntryPointVersion,
|
|
90
98
|
factoryAddress?: Address
|
|
91
99
|
): Address => {
|
|
92
100
|
if (factoryAddress) return factoryAddress
|
|
93
101
|
|
|
94
|
-
|
|
95
|
-
|
|
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
|
|
124
|
+
entryPointVersion extends EntryPointVersion = "0.7"
|
|
102
125
|
> = Assign<
|
|
103
126
|
SmartAccountImplementation<
|
|
104
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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.
|
|
214
|
+
if (entryPoint.version === "0.8") {
|
|
196
215
|
return encodeFunctionData({
|
|
197
|
-
abi:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
data:
|
|
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
|
-
|
|
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
|
|
368
|
-
|
|
369
|
-
|
|
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 <
|
|
298
|
+
for (let i = 0; i < destinations.length; i++) {
|
|
374
299
|
calls.push({
|
|
375
|
-
to:
|
|
376
|
-
|
|
377
|
-
|
|
300
|
+
to: destinations[i],
|
|
301
|
+
data: datas[i],
|
|
302
|
+
value: values[i]
|
|
378
303
|
})
|
|
379
304
|
}
|
|
380
305
|
|
|
381
306
|
return calls
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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
|
})
|