permissionless 0.2.47 → 0.2.49
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 +14 -0
- package/_cjs/accounts/index.js +5 -1
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/kernel/to7702KernelSmartAccount.js +11 -0
- package/_cjs/accounts/kernel/to7702KernelSmartAccount.js.map +1 -0
- package/_cjs/accounts/kernel/toKernelSmartAccount.js +60 -17
- package/_cjs/accounts/kernel/toKernelSmartAccount.js.map +1 -1
- package/_cjs/accounts/simple/to7702SimpleSmartAccount.js +11 -0
- package/_cjs/accounts/simple/to7702SimpleSmartAccount.js.map +1 -0
- package/_cjs/accounts/simple/toSimpleSmartAccount.js +50 -18
- package/_cjs/accounts/simple/toSimpleSmartAccount.js.map +1 -1
- package/_cjs/actions/erc7579/installModule.js +2 -1
- package/_cjs/actions/erc7579/installModule.js.map +1 -1
- package/_cjs/actions/erc7579/installModules.js +2 -1
- package/_cjs/actions/erc7579/installModules.js.map +1 -1
- package/_esm/accounts/index.js +3 -1
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/kernel/to7702KernelSmartAccount.js +8 -0
- package/_esm/accounts/kernel/to7702KernelSmartAccount.js.map +1 -0
- package/_esm/accounts/kernel/toKernelSmartAccount.js +61 -22
- package/_esm/accounts/kernel/toKernelSmartAccount.js.map +1 -1
- package/_esm/accounts/simple/to7702SimpleSmartAccount.js +8 -0
- package/_esm/accounts/simple/to7702SimpleSmartAccount.js.map +1 -0
- package/_esm/accounts/simple/toSimpleSmartAccount.js +51 -20
- package/_esm/accounts/simple/toSimpleSmartAccount.js.map +1 -1
- package/_esm/actions/erc7579/installModule.js +2 -1
- package/_esm/actions/erc7579/installModule.js.map +1 -1
- package/_esm/actions/erc7579/installModules.js +2 -1
- package/_esm/actions/erc7579/installModules.js.map +1 -1
- package/_types/accounts/index.d.ts +3 -1
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/kernel/to7702KernelSmartAccount.d.ts +8 -0
- package/_types/accounts/kernel/to7702KernelSmartAccount.d.ts.map +1 -0
- package/_types/accounts/kernel/toKernelSmartAccount.d.ts +29 -9
- package/_types/accounts/kernel/toKernelSmartAccount.d.ts.map +1 -1
- package/_types/accounts/simple/to7702SimpleSmartAccount.d.ts +8 -0
- package/_types/accounts/simple/to7702SimpleSmartAccount.d.ts.map +1 -0
- package/_types/accounts/simple/toSimpleSmartAccount.d.ts +20 -7
- package/_types/accounts/simple/toSimpleSmartAccount.d.ts.map +1 -1
- package/_types/actions/erc7579/installModule.d.ts +2 -1
- package/_types/actions/erc7579/installModule.d.ts.map +1 -1
- package/_types/actions/erc7579/installModules.d.ts +2 -1
- package/_types/actions/erc7579/installModules.d.ts.map +1 -1
- package/accounts/index.ts +23 -1
- package/accounts/kernel/to7702KernelSmartAccount.ts +63 -0
- package/accounts/kernel/toKernelSmartAccount.ts +154 -63
- package/accounts/simple/to7702SimpleSmartAccount.ts +51 -0
- package/accounts/simple/toSimpleSmartAccount.ts +116 -46
- package/actions/erc7579/installModule.test.ts +44 -4
- package/actions/erc7579/installModule.ts +4 -1
- package/actions/erc7579/installModules.test.ts +41 -2
- package/actions/erc7579/installModules.ts +11 -1
- package/actions/erc7579/uninstallModule.test.ts +25 -3
- package/actions/smartAccount/sendTransaction.test.ts +79 -29
- package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +69 -257
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { zeroAddress } from "viem"
|
|
2
|
+
import { privateKeyToAccount } from "viem/accounts"
|
|
2
3
|
import { foundry } from "viem/chains"
|
|
3
4
|
import { describe, expect } from "vitest"
|
|
4
5
|
import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
|
|
@@ -8,13 +9,17 @@ import {
|
|
|
8
9
|
} from "../../../permissionless-test/src/utils"
|
|
9
10
|
import { sendTransaction } from "./sendTransaction"
|
|
10
11
|
|
|
12
|
+
const privateKey =
|
|
13
|
+
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"
|
|
14
|
+
|
|
11
15
|
describe.each(getCoreSmartAccounts())(
|
|
12
16
|
"sendTransaction $name",
|
|
13
17
|
({
|
|
14
18
|
getSmartAccountClient,
|
|
15
19
|
supportsEntryPointV06,
|
|
16
20
|
supportsEntryPointV07,
|
|
17
|
-
supportsEntryPointV08
|
|
21
|
+
supportsEntryPointV08,
|
|
22
|
+
isEip7702Compliant
|
|
18
23
|
}) => {
|
|
19
24
|
testWithRpc.skipIf(!supportsEntryPointV06)(
|
|
20
25
|
"sendTransaction_v06",
|
|
@@ -71,25 +76,36 @@ describe.each(getCoreSmartAccounts())(
|
|
|
71
76
|
async ({ rpc }) => {
|
|
72
77
|
const { anvilRpc } = rpc
|
|
73
78
|
|
|
79
|
+
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
80
|
+
|
|
74
81
|
const smartClient = await getSmartAccountClient({
|
|
75
82
|
entryPoint: {
|
|
76
83
|
version: "0.7"
|
|
77
84
|
},
|
|
78
|
-
privateKey
|
|
79
|
-
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // anvil private key
|
|
85
|
+
privateKey, // anvil private key
|
|
80
86
|
...rpc
|
|
81
87
|
})
|
|
82
88
|
|
|
89
|
+
const publicClient = getPublicClient(anvilRpc)
|
|
90
|
+
|
|
83
91
|
const transactionHash = await sendTransaction(smartClient, {
|
|
84
92
|
to: zeroAddress,
|
|
85
93
|
data: "0x",
|
|
86
|
-
value: 0n
|
|
94
|
+
value: 0n,
|
|
95
|
+
authorization: isEip7702Compliant
|
|
96
|
+
? await privateKeyAccount.signAuthorization({
|
|
97
|
+
address: (smartClient.account as any)
|
|
98
|
+
.implementation,
|
|
99
|
+
chainId: smartClient.chain.id,
|
|
100
|
+
nonce: await publicClient.getTransactionCount({
|
|
101
|
+
address: smartClient.account.address
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
: undefined
|
|
87
105
|
})
|
|
88
106
|
|
|
89
107
|
expect(transactionHash).toBeTruthy()
|
|
90
108
|
|
|
91
|
-
const publicClient = getPublicClient(anvilRpc)
|
|
92
|
-
|
|
93
109
|
const receipt = await publicClient.getTransactionReceipt({
|
|
94
110
|
hash: transactionHash
|
|
95
111
|
})
|
|
@@ -123,25 +139,37 @@ describe.each(getCoreSmartAccounts())(
|
|
|
123
139
|
async ({ rpc }) => {
|
|
124
140
|
const { anvilRpc } = rpc
|
|
125
141
|
|
|
142
|
+
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
143
|
+
|
|
126
144
|
const smartClient = await getSmartAccountClient({
|
|
127
145
|
entryPoint: {
|
|
128
146
|
version: "0.8"
|
|
129
147
|
},
|
|
130
|
-
privateKey
|
|
131
|
-
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // anvil private key
|
|
148
|
+
privateKey, // anvil private key
|
|
132
149
|
...rpc
|
|
133
150
|
})
|
|
134
151
|
|
|
152
|
+
const publicClient = getPublicClient(anvilRpc)
|
|
153
|
+
|
|
154
|
+
const authorization = isEip7702Compliant
|
|
155
|
+
? await privateKeyAccount.signAuthorization({
|
|
156
|
+
address: (smartClient.account as any).implementation,
|
|
157
|
+
chainId: smartClient.chain.id,
|
|
158
|
+
nonce: await publicClient.getTransactionCount({
|
|
159
|
+
address: smartClient.account.address
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
: undefined
|
|
163
|
+
|
|
135
164
|
const transactionHash = await sendTransaction(smartClient, {
|
|
136
165
|
to: zeroAddress,
|
|
137
166
|
data: "0x",
|
|
138
|
-
value: 0n
|
|
167
|
+
value: 0n,
|
|
168
|
+
authorization
|
|
139
169
|
})
|
|
140
170
|
|
|
141
171
|
expect(transactionHash).toBeTruthy()
|
|
142
172
|
|
|
143
|
-
const publicClient = getPublicClient(anvilRpc)
|
|
144
|
-
|
|
145
173
|
const receipt = await publicClient.getTransactionReceipt({
|
|
146
174
|
hash: transactionHash
|
|
147
175
|
})
|
|
@@ -180,8 +208,7 @@ describe.each(getCoreSmartAccounts())(
|
|
|
180
208
|
entryPoint: {
|
|
181
209
|
version: "0.6"
|
|
182
210
|
},
|
|
183
|
-
privateKey
|
|
184
|
-
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // anvil private key
|
|
211
|
+
privateKey, // anvil private key
|
|
185
212
|
...rpc
|
|
186
213
|
})
|
|
187
214
|
|
|
@@ -208,8 +235,7 @@ describe.each(getCoreSmartAccounts())(
|
|
|
208
235
|
entryPoint: {
|
|
209
236
|
version: "0.6"
|
|
210
237
|
},
|
|
211
|
-
privateKey
|
|
212
|
-
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // anvil private key
|
|
238
|
+
privateKey, // anvil private key
|
|
213
239
|
...rpc
|
|
214
240
|
})
|
|
215
241
|
|
|
@@ -240,25 +266,38 @@ describe.each(getCoreSmartAccounts())(
|
|
|
240
266
|
const { anvilRpc } = rpc
|
|
241
267
|
|
|
242
268
|
await (async () => {
|
|
269
|
+
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
270
|
+
|
|
243
271
|
const smartClient = await getSmartAccountClient({
|
|
244
272
|
entryPoint: {
|
|
245
273
|
version: "0.7"
|
|
246
274
|
},
|
|
247
|
-
privateKey
|
|
248
|
-
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // anvil private key
|
|
275
|
+
privateKey, // anvil private key
|
|
249
276
|
...rpc
|
|
250
277
|
})
|
|
251
278
|
|
|
279
|
+
const publicClient = getPublicClient(anvilRpc)
|
|
280
|
+
|
|
281
|
+
const authorization = isEip7702Compliant
|
|
282
|
+
? await privateKeyAccount.signAuthorization({
|
|
283
|
+
address: (smartClient.account as any)
|
|
284
|
+
.implementation,
|
|
285
|
+
chainId: smartClient.chain.id,
|
|
286
|
+
nonce: await publicClient.getTransactionCount({
|
|
287
|
+
address: smartClient.account.address
|
|
288
|
+
})
|
|
289
|
+
})
|
|
290
|
+
: undefined
|
|
291
|
+
|
|
252
292
|
const transactionHash = await sendTransaction(smartClient, {
|
|
253
293
|
to: zeroAddress,
|
|
254
294
|
data: "0x",
|
|
255
|
-
value: 0n
|
|
295
|
+
value: 0n,
|
|
296
|
+
authorization
|
|
256
297
|
})
|
|
257
298
|
|
|
258
299
|
expect(transactionHash).toBeTruthy()
|
|
259
300
|
|
|
260
|
-
const publicClient = getPublicClient(anvilRpc)
|
|
261
|
-
|
|
262
301
|
const receipt = await publicClient.getTransactionReceipt({
|
|
263
302
|
hash: transactionHash
|
|
264
303
|
})
|
|
@@ -272,8 +311,7 @@ describe.each(getCoreSmartAccounts())(
|
|
|
272
311
|
entryPoint: {
|
|
273
312
|
version: "0.7"
|
|
274
313
|
},
|
|
275
|
-
privateKey
|
|
276
|
-
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // anvil private key
|
|
314
|
+
privateKey, // anvil private key
|
|
277
315
|
...rpc
|
|
278
316
|
})
|
|
279
317
|
|
|
@@ -304,26 +342,39 @@ describe.each(getCoreSmartAccounts())(
|
|
|
304
342
|
async ({ rpc }) => {
|
|
305
343
|
const { anvilRpc } = rpc
|
|
306
344
|
|
|
345
|
+
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
346
|
+
|
|
307
347
|
await (async () => {
|
|
308
348
|
const smartClient = await getSmartAccountClient({
|
|
309
349
|
entryPoint: {
|
|
310
350
|
version: "0.8"
|
|
311
351
|
},
|
|
312
|
-
privateKey
|
|
313
|
-
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // anvil private key
|
|
352
|
+
privateKey, // anvil private key
|
|
314
353
|
...rpc
|
|
315
354
|
})
|
|
316
355
|
|
|
356
|
+
const publicClient = getPublicClient(anvilRpc)
|
|
357
|
+
|
|
358
|
+
const authorization = isEip7702Compliant
|
|
359
|
+
? await privateKeyAccount.signAuthorization({
|
|
360
|
+
address: (smartClient.account as any)
|
|
361
|
+
.implementation,
|
|
362
|
+
chainId: smartClient.chain.id,
|
|
363
|
+
nonce: await publicClient.getTransactionCount({
|
|
364
|
+
address: smartClient.account.address
|
|
365
|
+
})
|
|
366
|
+
})
|
|
367
|
+
: undefined
|
|
368
|
+
|
|
317
369
|
const transactionHash = await sendTransaction(smartClient, {
|
|
318
370
|
to: zeroAddress,
|
|
319
371
|
data: "0x",
|
|
320
|
-
value: 0n
|
|
372
|
+
value: 0n,
|
|
373
|
+
authorization
|
|
321
374
|
})
|
|
322
375
|
|
|
323
376
|
expect(transactionHash).toBeTruthy()
|
|
324
377
|
|
|
325
|
-
const publicClient = getPublicClient(anvilRpc)
|
|
326
|
-
|
|
327
378
|
const receipt = await publicClient.getTransactionReceipt({
|
|
328
379
|
hash: transactionHash
|
|
329
380
|
})
|
|
@@ -337,8 +388,7 @@ describe.each(getCoreSmartAccounts())(
|
|
|
337
388
|
entryPoint: {
|
|
338
389
|
version: "0.8"
|
|
339
390
|
},
|
|
340
|
-
privateKey
|
|
341
|
-
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // anvil private key
|
|
391
|
+
privateKey, // anvil private key
|
|
342
392
|
...rpc
|
|
343
393
|
})
|
|
344
394
|
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
entryPoint07Address,
|
|
5
5
|
entryPoint08Address
|
|
6
6
|
} from "viem/account-abstraction"
|
|
7
|
+
import { privateKeyToAccount } from "viem/accounts"
|
|
7
8
|
import { foundry } from "viem/chains"
|
|
8
9
|
import { describe, expect } from "vitest"
|
|
9
10
|
import {
|
|
@@ -20,6 +21,9 @@ import { createSmartAccountClient } from "../../../clients/createSmartAccountCli
|
|
|
20
21
|
import { createPimlicoClient } from "../../../clients/pimlico"
|
|
21
22
|
import { prepareUserOperationForErc20Paymaster } from "./prepareUserOperationForErc20Paymaster"
|
|
22
23
|
|
|
24
|
+
const privateKey =
|
|
25
|
+
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"
|
|
26
|
+
|
|
23
27
|
describe.each(getCoreSmartAccounts())(
|
|
24
28
|
"prepareUserOperationForErc20Paymaster $name",
|
|
25
29
|
({
|
|
@@ -27,6 +31,7 @@ describe.each(getCoreSmartAccounts())(
|
|
|
27
31
|
supportsEntryPointV06,
|
|
28
32
|
supportsEntryPointV07,
|
|
29
33
|
supportsEntryPointV08,
|
|
34
|
+
isEip7702Compliant,
|
|
30
35
|
name
|
|
31
36
|
}) => {
|
|
32
37
|
testWithRpc.skipIf(!supportsEntryPointV06 || name === "Kernel 0.2.1")(
|
|
@@ -39,6 +44,7 @@ describe.each(getCoreSmartAccounts())(
|
|
|
39
44
|
entryPoint: {
|
|
40
45
|
version: "0.6"
|
|
41
46
|
},
|
|
47
|
+
privateKey,
|
|
42
48
|
...rpc
|
|
43
49
|
})
|
|
44
50
|
).account
|
|
@@ -117,11 +123,14 @@ describe.each(getCoreSmartAccounts())(
|
|
|
117
123
|
async ({ rpc }) => {
|
|
118
124
|
const { anvilRpc } = rpc
|
|
119
125
|
|
|
126
|
+
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
127
|
+
|
|
120
128
|
const account = (
|
|
121
129
|
await getSmartAccountClient({
|
|
122
130
|
entryPoint: {
|
|
123
131
|
version: "0.7"
|
|
124
132
|
},
|
|
133
|
+
privateKey,
|
|
125
134
|
...rpc
|
|
126
135
|
})
|
|
127
136
|
).account
|
|
@@ -160,6 +169,17 @@ describe.each(getCoreSmartAccounts())(
|
|
|
160
169
|
anvilRpc
|
|
161
170
|
})
|
|
162
171
|
|
|
172
|
+
const authorization = isEip7702Compliant
|
|
173
|
+
? await privateKeyAccount.signAuthorization({
|
|
174
|
+
address: (smartAccountClient.account as any)
|
|
175
|
+
.implementation,
|
|
176
|
+
chainId: smartAccountClient.chain.id,
|
|
177
|
+
nonce: await publicClient.getTransactionCount({
|
|
178
|
+
address: smartAccountClient.account.address
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
: undefined
|
|
182
|
+
|
|
163
183
|
const opHash = await smartAccountClient.sendUserOperation({
|
|
164
184
|
calls: [
|
|
165
185
|
{
|
|
@@ -170,7 +190,8 @@ describe.each(getCoreSmartAccounts())(
|
|
|
170
190
|
],
|
|
171
191
|
paymasterContext: {
|
|
172
192
|
token: erc20Address
|
|
173
|
-
}
|
|
193
|
+
},
|
|
194
|
+
authorization
|
|
174
195
|
})
|
|
175
196
|
|
|
176
197
|
const receipt =
|
|
@@ -200,11 +221,14 @@ describe.each(getCoreSmartAccounts())(
|
|
|
200
221
|
async ({ rpc }) => {
|
|
201
222
|
const { anvilRpc } = rpc
|
|
202
223
|
|
|
224
|
+
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
225
|
+
|
|
203
226
|
const account = (
|
|
204
227
|
await getSmartAccountClient({
|
|
205
228
|
entryPoint: {
|
|
206
229
|
version: "0.8"
|
|
207
230
|
},
|
|
231
|
+
privateKey,
|
|
208
232
|
...rpc
|
|
209
233
|
})
|
|
210
234
|
).account
|
|
@@ -243,6 +267,17 @@ describe.each(getCoreSmartAccounts())(
|
|
|
243
267
|
anvilRpc
|
|
244
268
|
})
|
|
245
269
|
|
|
270
|
+
const authorization = isEip7702Compliant
|
|
271
|
+
? await privateKeyAccount.signAuthorization({
|
|
272
|
+
address: (smartAccountClient.account as any)
|
|
273
|
+
.implementation,
|
|
274
|
+
chainId: smartAccountClient.chain.id,
|
|
275
|
+
nonce: await publicClient.getTransactionCount({
|
|
276
|
+
address: smartAccountClient.account.address
|
|
277
|
+
})
|
|
278
|
+
})
|
|
279
|
+
: undefined
|
|
280
|
+
|
|
246
281
|
const opHash = await smartAccountClient.sendUserOperation({
|
|
247
282
|
calls: [
|
|
248
283
|
{
|
|
@@ -253,7 +288,8 @@ describe.each(getCoreSmartAccounts())(
|
|
|
253
288
|
],
|
|
254
289
|
paymasterContext: {
|
|
255
290
|
token: erc20Address
|
|
256
|
-
}
|
|
291
|
+
},
|
|
292
|
+
authorization
|
|
257
293
|
})
|
|
258
294
|
|
|
259
295
|
const receipt =
|
|
@@ -283,11 +319,14 @@ describe.each(getCoreSmartAccounts())(
|
|
|
283
319
|
async ({ rpc }) => {
|
|
284
320
|
const { anvilRpc } = rpc
|
|
285
321
|
|
|
322
|
+
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
323
|
+
|
|
286
324
|
const account = (
|
|
287
325
|
await getSmartAccountClient({
|
|
288
326
|
entryPoint: {
|
|
289
327
|
version: "0.7"
|
|
290
328
|
},
|
|
329
|
+
privateKey,
|
|
291
330
|
...rpc
|
|
292
331
|
})
|
|
293
332
|
).account
|
|
@@ -331,6 +370,17 @@ describe.each(getCoreSmartAccounts())(
|
|
|
331
370
|
anvilRpc
|
|
332
371
|
})
|
|
333
372
|
|
|
373
|
+
const authorization = isEip7702Compliant
|
|
374
|
+
? await privateKeyAccount.signAuthorization({
|
|
375
|
+
address: (smartAccountClient.account as any)
|
|
376
|
+
.implementation,
|
|
377
|
+
chainId: smartAccountClient.chain.id,
|
|
378
|
+
nonce: await publicClient.getTransactionCount({
|
|
379
|
+
address: smartAccountClient.account.address
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
: undefined
|
|
383
|
+
|
|
334
384
|
const opHash = await smartAccountClient.sendUserOperation({
|
|
335
385
|
calls: [
|
|
336
386
|
{
|
|
@@ -341,7 +391,8 @@ describe.each(getCoreSmartAccounts())(
|
|
|
341
391
|
],
|
|
342
392
|
paymasterContext: {
|
|
343
393
|
token: erc20Address
|
|
344
|
-
}
|
|
394
|
+
},
|
|
395
|
+
authorization
|
|
345
396
|
})
|
|
346
397
|
|
|
347
398
|
const receipt =
|
|
@@ -371,11 +422,14 @@ describe.each(getCoreSmartAccounts())(
|
|
|
371
422
|
async ({ rpc }) => {
|
|
372
423
|
const { anvilRpc } = rpc
|
|
373
424
|
|
|
425
|
+
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
426
|
+
|
|
374
427
|
const account = (
|
|
375
428
|
await getSmartAccountClient({
|
|
376
429
|
entryPoint: {
|
|
377
430
|
version: "0.8"
|
|
378
431
|
},
|
|
432
|
+
privateKey,
|
|
379
433
|
...rpc
|
|
380
434
|
})
|
|
381
435
|
).account
|
|
@@ -419,6 +473,17 @@ describe.each(getCoreSmartAccounts())(
|
|
|
419
473
|
anvilRpc
|
|
420
474
|
})
|
|
421
475
|
|
|
476
|
+
const authorization = isEip7702Compliant
|
|
477
|
+
? await privateKeyAccount.signAuthorization({
|
|
478
|
+
address: (smartAccountClient.account as any)
|
|
479
|
+
.implementation,
|
|
480
|
+
chainId: smartAccountClient.chain.id,
|
|
481
|
+
nonce: await publicClient.getTransactionCount({
|
|
482
|
+
address: smartAccountClient.account.address
|
|
483
|
+
})
|
|
484
|
+
})
|
|
485
|
+
: undefined
|
|
486
|
+
|
|
422
487
|
const opHash = await smartAccountClient.sendUserOperation({
|
|
423
488
|
calls: [
|
|
424
489
|
{
|
|
@@ -429,261 +494,8 @@ describe.each(getCoreSmartAccounts())(
|
|
|
429
494
|
],
|
|
430
495
|
paymasterContext: {
|
|
431
496
|
token: erc20Address
|
|
432
|
-
}
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
const receipt =
|
|
436
|
-
await smartAccountClient.waitForUserOperationReceipt({
|
|
437
|
-
hash: opHash
|
|
438
|
-
})
|
|
439
|
-
|
|
440
|
-
expect(receipt).toBeTruthy()
|
|
441
|
-
expect(receipt).toBeTruthy()
|
|
442
|
-
expect(receipt.success).toBeTruthy()
|
|
443
|
-
|
|
444
|
-
const FINAL_TOKEN_BALANCE = await tokenBalanceOf(
|
|
445
|
-
smartAccountClient.account.address,
|
|
446
|
-
rpc.anvilRpc
|
|
447
|
-
)
|
|
448
|
-
const FINAL_ETH_BALANCE = await publicClient.getBalance({
|
|
449
|
-
address: smartAccountClient.account.address
|
|
450
|
-
})
|
|
451
|
-
|
|
452
|
-
expect(FINAL_TOKEN_BALANCE).toBeLessThan(INITIAL_TOKEN_BALANCE) // Token balance should be deducted
|
|
453
|
-
expect(FINAL_ETH_BALANCE).toEqual(INTIAL_ETH_BALANCE) // There should be no ETH balance change
|
|
454
|
-
}
|
|
455
|
-
)
|
|
456
|
-
|
|
457
|
-
testWithRpc.skipIf(!supportsEntryPointV06 || name === "Kernel 0.2.1")(
|
|
458
|
-
"prepareUserOperationForErc20Paymaster_v06",
|
|
459
|
-
async ({ rpc }) => {
|
|
460
|
-
const { anvilRpc } = rpc
|
|
461
|
-
|
|
462
|
-
const account = (
|
|
463
|
-
await getSmartAccountClient({
|
|
464
|
-
entryPoint: {
|
|
465
|
-
version: "0.6"
|
|
466
|
-
},
|
|
467
|
-
...rpc
|
|
468
|
-
})
|
|
469
|
-
).account
|
|
470
|
-
|
|
471
|
-
const pimlicoClient = createPimlicoClient({
|
|
472
|
-
transport: http(rpc.paymasterRpc),
|
|
473
|
-
entryPoint: {
|
|
474
|
-
address: entryPoint06Address,
|
|
475
|
-
version: "0.6"
|
|
476
|
-
}
|
|
477
|
-
})
|
|
478
|
-
|
|
479
|
-
const publicClient = getPublicClient(anvilRpc)
|
|
480
|
-
|
|
481
|
-
const smartAccountClient = createSmartAccountClient({
|
|
482
|
-
// @ts-ignore
|
|
483
|
-
client: getPublicClient(anvilRpc),
|
|
484
|
-
account,
|
|
485
|
-
paymaster: pimlicoClient,
|
|
486
|
-
chain: foundry,
|
|
487
|
-
userOperation: {
|
|
488
|
-
prepareUserOperation:
|
|
489
|
-
prepareUserOperationForErc20Paymaster(pimlicoClient)
|
|
490
497
|
},
|
|
491
|
-
|
|
492
|
-
})
|
|
493
|
-
|
|
494
|
-
const INITIAL_TOKEN_BALANCE = parseEther("100")
|
|
495
|
-
const INTIAL_ETH_BALANCE = await publicClient.getBalance({
|
|
496
|
-
address: smartAccountClient.account.address
|
|
497
|
-
})
|
|
498
|
-
|
|
499
|
-
sudoMintTokens({
|
|
500
|
-
amount: INITIAL_TOKEN_BALANCE,
|
|
501
|
-
to: smartAccountClient.account.address,
|
|
502
|
-
anvilRpc
|
|
503
|
-
})
|
|
504
|
-
|
|
505
|
-
const opHash = await smartAccountClient.sendUserOperation({
|
|
506
|
-
callData: await smartAccountClient.account.encodeCalls([
|
|
507
|
-
{
|
|
508
|
-
to: zeroAddress,
|
|
509
|
-
data: "0x",
|
|
510
|
-
value: 0n
|
|
511
|
-
}
|
|
512
|
-
]),
|
|
513
|
-
paymasterContext: {
|
|
514
|
-
token: erc20Address
|
|
515
|
-
}
|
|
516
|
-
})
|
|
517
|
-
|
|
518
|
-
const receipt =
|
|
519
|
-
await smartAccountClient.waitForUserOperationReceipt({
|
|
520
|
-
hash: opHash
|
|
521
|
-
})
|
|
522
|
-
|
|
523
|
-
expect(receipt).toBeTruthy()
|
|
524
|
-
expect(receipt).toBeTruthy()
|
|
525
|
-
|
|
526
|
-
expect(receipt.success).toBeTruthy()
|
|
527
|
-
const FINAL_TOKEN_BALANCE = await tokenBalanceOf(
|
|
528
|
-
smartAccountClient.account.address,
|
|
529
|
-
rpc.anvilRpc
|
|
530
|
-
)
|
|
531
|
-
const FINAL_ETH_BALANCE = await publicClient.getBalance({
|
|
532
|
-
address: smartAccountClient.account.address
|
|
533
|
-
})
|
|
534
|
-
|
|
535
|
-
expect(FINAL_TOKEN_BALANCE).toBeLessThan(INITIAL_TOKEN_BALANCE) // Token balance should be deducted
|
|
536
|
-
expect(FINAL_ETH_BALANCE).toEqual(INTIAL_ETH_BALANCE) // There should be no ETH balance change
|
|
537
|
-
}
|
|
538
|
-
)
|
|
539
|
-
|
|
540
|
-
testWithRpc.skipIf(!supportsEntryPointV07)(
|
|
541
|
-
"prepareUserOperationForErc20Paymaster_v07",
|
|
542
|
-
async ({ rpc }) => {
|
|
543
|
-
const { anvilRpc } = rpc
|
|
544
|
-
|
|
545
|
-
const account = (
|
|
546
|
-
await getSmartAccountClient({
|
|
547
|
-
entryPoint: {
|
|
548
|
-
version: "0.7"
|
|
549
|
-
},
|
|
550
|
-
...rpc
|
|
551
|
-
})
|
|
552
|
-
).account
|
|
553
|
-
|
|
554
|
-
const publicClient = getPublicClient(anvilRpc)
|
|
555
|
-
|
|
556
|
-
const pimlicoClient = createPimlicoClient({
|
|
557
|
-
transport: http(rpc.paymasterRpc),
|
|
558
|
-
entryPoint: {
|
|
559
|
-
address: entryPoint07Address,
|
|
560
|
-
version: "0.7"
|
|
561
|
-
}
|
|
562
|
-
})
|
|
563
|
-
|
|
564
|
-
const smartAccountClient = createSmartAccountClient({
|
|
565
|
-
// @ts-ignore
|
|
566
|
-
client: getPublicClient(anvilRpc),
|
|
567
|
-
account,
|
|
568
|
-
paymaster: pimlicoClient,
|
|
569
|
-
chain: foundry,
|
|
570
|
-
userOperation: {
|
|
571
|
-
prepareUserOperation:
|
|
572
|
-
prepareUserOperationForErc20Paymaster(pimlicoClient)
|
|
573
|
-
},
|
|
574
|
-
bundlerTransport: http(rpc.altoRpc)
|
|
575
|
-
})
|
|
576
|
-
|
|
577
|
-
const INITIAL_TOKEN_BALANCE = parseEther("100")
|
|
578
|
-
const INTIAL_ETH_BALANCE = await publicClient.getBalance({
|
|
579
|
-
address: smartAccountClient.account.address
|
|
580
|
-
})
|
|
581
|
-
|
|
582
|
-
sudoMintTokens({
|
|
583
|
-
amount: INITIAL_TOKEN_BALANCE,
|
|
584
|
-
to: smartAccountClient.account.address,
|
|
585
|
-
anvilRpc
|
|
586
|
-
})
|
|
587
|
-
|
|
588
|
-
const opHash = await smartAccountClient.sendUserOperation({
|
|
589
|
-
callData: await smartAccountClient.account.encodeCalls([
|
|
590
|
-
{
|
|
591
|
-
to: zeroAddress,
|
|
592
|
-
data: "0x",
|
|
593
|
-
value: 0n
|
|
594
|
-
}
|
|
595
|
-
]),
|
|
596
|
-
paymasterContext: {
|
|
597
|
-
token: erc20Address
|
|
598
|
-
}
|
|
599
|
-
})
|
|
600
|
-
|
|
601
|
-
const receipt =
|
|
602
|
-
await smartAccountClient.waitForUserOperationReceipt({
|
|
603
|
-
hash: opHash
|
|
604
|
-
})
|
|
605
|
-
|
|
606
|
-
expect(receipt).toBeTruthy()
|
|
607
|
-
expect(receipt).toBeTruthy()
|
|
608
|
-
expect(receipt.success).toBeTruthy()
|
|
609
|
-
|
|
610
|
-
const FINAL_TOKEN_BALANCE = await tokenBalanceOf(
|
|
611
|
-
smartAccountClient.account.address,
|
|
612
|
-
rpc.anvilRpc
|
|
613
|
-
)
|
|
614
|
-
const FINAL_ETH_BALANCE = await publicClient.getBalance({
|
|
615
|
-
address: smartAccountClient.account.address
|
|
616
|
-
})
|
|
617
|
-
|
|
618
|
-
expect(FINAL_TOKEN_BALANCE).toBeLessThan(INITIAL_TOKEN_BALANCE) // Token balance should be deducted
|
|
619
|
-
expect(FINAL_ETH_BALANCE).toEqual(INTIAL_ETH_BALANCE) // There should be no ETH balance change
|
|
620
|
-
}
|
|
621
|
-
)
|
|
622
|
-
|
|
623
|
-
testWithRpc.skipIf(!supportsEntryPointV07)(
|
|
624
|
-
"prepareUserOperationForErc20Paymaster_v07 (balanceOverride enabled)",
|
|
625
|
-
async ({ rpc }) => {
|
|
626
|
-
const { anvilRpc } = rpc
|
|
627
|
-
|
|
628
|
-
const account = (
|
|
629
|
-
await getSmartAccountClient({
|
|
630
|
-
entryPoint: {
|
|
631
|
-
version: "0.7"
|
|
632
|
-
},
|
|
633
|
-
...rpc
|
|
634
|
-
})
|
|
635
|
-
).account
|
|
636
|
-
|
|
637
|
-
const publicClient = getPublicClient(anvilRpc)
|
|
638
|
-
|
|
639
|
-
const pimlicoClient = createPimlicoClient({
|
|
640
|
-
transport: http(rpc.paymasterRpc),
|
|
641
|
-
entryPoint: {
|
|
642
|
-
address: entryPoint07Address,
|
|
643
|
-
version: "0.7"
|
|
644
|
-
}
|
|
645
|
-
})
|
|
646
|
-
|
|
647
|
-
const smartAccountClient = createSmartAccountClient({
|
|
648
|
-
// @ts-ignore
|
|
649
|
-
client: getPublicClient(anvilRpc),
|
|
650
|
-
account,
|
|
651
|
-
paymaster: pimlicoClient,
|
|
652
|
-
chain: foundry,
|
|
653
|
-
userOperation: {
|
|
654
|
-
prepareUserOperation:
|
|
655
|
-
prepareUserOperationForErc20Paymaster(
|
|
656
|
-
pimlicoClient,
|
|
657
|
-
{
|
|
658
|
-
balanceOverride: true
|
|
659
|
-
}
|
|
660
|
-
)
|
|
661
|
-
},
|
|
662
|
-
bundlerTransport: http(rpc.altoRpc)
|
|
663
|
-
})
|
|
664
|
-
|
|
665
|
-
const INITIAL_TOKEN_BALANCE = parseEther("100")
|
|
666
|
-
const INTIAL_ETH_BALANCE = await publicClient.getBalance({
|
|
667
|
-
address: smartAccountClient.account.address
|
|
668
|
-
})
|
|
669
|
-
|
|
670
|
-
sudoMintTokens({
|
|
671
|
-
amount: INITIAL_TOKEN_BALANCE,
|
|
672
|
-
to: smartAccountClient.account.address,
|
|
673
|
-
anvilRpc
|
|
674
|
-
})
|
|
675
|
-
|
|
676
|
-
const opHash = await smartAccountClient.sendUserOperation({
|
|
677
|
-
callData: await smartAccountClient.account.encodeCalls([
|
|
678
|
-
{
|
|
679
|
-
to: zeroAddress,
|
|
680
|
-
data: "0x",
|
|
681
|
-
value: 0n
|
|
682
|
-
}
|
|
683
|
-
]),
|
|
684
|
-
paymasterContext: {
|
|
685
|
-
token: erc20Address
|
|
686
|
-
}
|
|
498
|
+
authorization
|
|
687
499
|
})
|
|
688
500
|
|
|
689
501
|
const receipt =
|