Skip to content

Commit 5494e69

Browse files
Add support for kernel + 7702 (#414)
1 parent 3fc7752 commit 5494e69

File tree

14 files changed

+539
-107
lines changed

14 files changed

+539
-107
lines changed

.changeset/silly-eyes-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"permissionless": patch
3+
---
4+
5+
Added to7702KernelSmartAccount

bun.lock

Lines changed: 177 additions & 19 deletions
Large diffs are not rendered by default.

bun.lockb

21.5 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@changesets/cli": "^2.26.2",
1717
"@permissionless/wagmi": "workspace:packages/wagmi",
1818
"@pimlico/mock-paymaster": "workspace:packages/mock-paymaster",
19-
"@pimlico/alto": "^0.0.18",
19+
"@pimlico/alto": "0.0.0-main.20250527T165035",
2020
"@size-limit/esbuild-why": "^9.0.0",
2121
"@size-limit/preset-small-lib": "^9.0.0",
2222
"@tanstack/react-query": "5.45.1",

packages/mock-paymaster/helpers/schema.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@ export const hexDataSchema = z
6060
.regex(hexDataPattern, { message: "not valid hex data" })
6161
.transform((val) => val.toLowerCase() as Hex)
6262

63+
const signedAuthorizationSchema = z.union([
64+
z.object({
65+
contractAddress: addressSchema,
66+
chainId: hexNumberSchema.transform((val) => Number(val)),
67+
nonce: hexNumberSchema.transform((val) => Number(val)),
68+
r: hexDataSchema.transform((val) => val as Hex),
69+
s: hexDataSchema.transform((val) => val as Hex),
70+
v: hexNumberSchema.optional(),
71+
yParity: hexNumberSchema.transform((val) => Number(val))
72+
}),
73+
z.object({
74+
address: addressSchema,
75+
chainId: hexNumberSchema.transform((val) => Number(val)),
76+
nonce: hexNumberSchema.transform((val) => Number(val)),
77+
r: hexDataSchema.transform((val) => val as Hex),
78+
s: hexDataSchema.transform((val) => val as Hex),
79+
v: hexNumberSchema.optional(),
80+
yParity: hexNumberSchema.transform((val) => Number(val))
81+
})
82+
])
83+
6384
const userOperationSchemaPaymasterV6 = z
6485
.object({
6586
sender: addressSchema,
@@ -80,7 +101,8 @@ const userOperationSchemaPaymasterV6 = z
80101
return "0x"
81102
}
82103
return val
83-
})
104+
}),
105+
eip7702Auth: signedAuthorizationSchema.optional().nullable()
84106
})
85107
.strict()
86108
.transform((val) => {
@@ -122,7 +144,8 @@ const userOperationSchemaPaymasterV7 = z
122144
return "0x"
123145
}
124146
return val
125-
})
147+
}),
148+
eip7702Auth: signedAuthorizationSchema.optional().nullable()
126149
})
127150
.strict()
128151
.transform((val) => {
@@ -173,7 +196,8 @@ const eip7677UserOperationSchemaV6 = z
173196
.optional()
174197
.transform((_) => {
175198
return "0x" as Hex
176-
})
199+
}),
200+
eip7702Auth: signedAuthorizationSchema.optional().nullable()
177201
})
178202
.strict()
179203
.transform((val) => {
@@ -219,7 +243,8 @@ const eip7677UserOperationSchemaV7 = z
219243
return "0x"
220244
}
221245
return val
222-
})
246+
}),
247+
eip7702Auth: signedAuthorizationSchema.optional().nullable()
223248
})
224249
.strict()
225250
.transform((val) => {

packages/permissionless-test/mock-aa-infra/alto/constants/accounts/kernel.ts

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

packages/permissionless-test/mock-aa-infra/alto/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,13 @@ export const setupContracts = async (rpc: string) => {
634634
data: "0x6e7dbabb000000000000000000000000E30c76Dc9eCF1c19F6Fec070674E1b4eFfE069FA0000000000000000000000000000000000000000000000000000000000000001"
635635
})
636636

637+
// register 0x2577507b78c2008Ff367261CB6285d44ba5eF2E9
638+
await sendTransaction(walletClient, {
639+
account: kernelFactoryOwner,
640+
to: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5" /* kernel factory v0.7 */,
641+
data: "0x6e7dbabb0000000000000000000000002577507b78c2008Ff367261CB6285d44ba5eF2E90000000000000000000000000000000000000000000000000000000000000001"
642+
})
643+
637644
await sendTransaction(walletClient, {
638645
account: kernelFactoryOwner,
639646
to: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5" /* kernel factory v0.7 */,
@@ -707,8 +714,8 @@ export const setupContracts = async (rpc: string) => {
707714
"0xbA45a2BFb8De3D24cA9D7F1B551E14dFF5d690Fd", // Kernel v0.3.1 WebAuthn Validator
708715
"0xD830D15D3dc0C269F3dBAa0F3e8626d33CFdaBe1", // Kernel v0.3.2 Account Logic
709716
"0x7a1dBAB750f12a90EB1B60D2Ae3aD17D4D81EfFe", // Kernel v0.3.2 Factory
710-
"0xE264dCCc54e4b6906c0D1Fee11D4326c06D33c80", // Kernel v0.3.3 Account Logic
711-
"0xE30c76Dc9eCF1c19F6Fec070674E1b4eFfE069FA", // Kernel v0.3.3 Factory
717+
"0xd6CEDDe84be40893d153Be9d467CD6aD37875b28", // Kernel v0.3.3 Account Logic
718+
"0x2577507b78c2008Ff367261CB6285d44ba5eF2E9", // Kernel v0.3.3 Factory
712719
"0x00004EC70002a32400f8ae005A26081065620D20", // LightAccountFactory v1.1.0
713720
"0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba", // LightAccount v1.1.0 implementation
714721
"0x0000000000400CdFef5E2714E63d8040b700BC24", // LightAccountFactory v2.0.0

packages/permissionless-test/src/testWithRpc.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ export const getInstances = async ({
2929
? anvil({
3030
chainId: foundry.id,
3131
port: anvilPort,
32+
hardfork: "Prague",
3233
forkUrl
3334
})
3435
: anvil({
3536
chainId: foundry.id,
37+
hardfork: "Prague",
3638
port: anvilPort
3739
})
3840

@@ -49,10 +51,10 @@ export const getInstances = async ({
4951
utilityPrivateKey: anvilPrivateKey
5052
})
5153

52-
// instance.on("stderr", (data) => {
54+
// altoInstance.on("stderr", (data) => {
5355
// console.error(data.toString())
5456
// })
55-
// instance.on("stdout", (data) => {
57+
// altoInstance.on("stdout", (data) => {
5658
// console.log(data.toString())
5759
// })
5860

packages/permissionless-test/src/utils.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import { foundry } from "viem/chains"
2424
import {
2525
type KernelVersion,
26+
to7702KernelSmartAccount,
2627
toKernelSmartAccount,
2728
toThirdwebSmartAccount
2829
} from "../../permissionless/accounts"
@@ -328,10 +329,12 @@ export const getKernelEcdsaClient = async <
328329
anvilRpc,
329330
version,
330331
privateKey,
331-
useMetaFactory
332+
useMetaFactory,
333+
eip7702 = false
332334
}: AAParamType<entryPointVersion> & {
333335
version?: KernelVersion<entryPointVersion>
334336
useMetaFactory?: boolean
337+
eip7702?: boolean
335338
}) => {
336339
const publicClient = getPublicClient(anvilRpc)
337340

@@ -342,6 +345,13 @@ export const getKernelEcdsaClient = async <
342345
throw new Error("Kernel ERC7579 is not supported for V06")
343346
}
344347

348+
if (eip7702) {
349+
return to7702KernelSmartAccount({
350+
client: publicClient,
351+
owner: privateKeyToAccount(privateKey ?? generatePrivateKey())
352+
})
353+
}
354+
345355
return toKernelSmartAccount({
346356
client: publicClient,
347357
entryPoint: {
@@ -449,6 +459,7 @@ export const getCoreSmartAccounts = (): Array<{
449459
supportsEntryPointV06: boolean
450460
supportsEntryPointV07: boolean
451461
supportsEntryPointV08: boolean
462+
isEip7702Compliant?: boolean
452463
isEip1271Compliant: boolean
453464
getSmartAccountClient: (
454465
conf: AAParamType<EntryPointVersion>
@@ -727,9 +738,37 @@ export const getCoreSmartAccounts = (): Array<{
727738
}),
728739
supportsEntryPointV06: false,
729740
supportsEntryPointV07: true,
730-
supportsEntryPointV08: false,
741+
supportsEntryPointV08: true,
731742
isEip1271Compliant: true
732743
},
744+
{
745+
name: "Kernel 7579 0.3.3 + EIP-7702",
746+
getSmartAccountClient: async (conf: AAParamType<EntryPointVersion>) =>
747+
getBundlerClient({
748+
account: await getKernelEcdsaClient({
749+
...(conf as AAParamType<"0.6" | "0.7">),
750+
version: "0.3.3" as KernelVersion<"0.6" | "0.7">,
751+
eip7702: true
752+
}),
753+
...conf
754+
}),
755+
getErc7579SmartAccountClient: async (
756+
conf: AAParamType<EntryPointVersion>
757+
) =>
758+
getSmartAccountClient({
759+
account: await getKernelEcdsaClient({
760+
...(conf as AAParamType<"0.6" | "0.7">),
761+
version: "0.3.3" as KernelVersion<"0.6" | "0.7">,
762+
eip7702: true
763+
}),
764+
...conf
765+
}),
766+
supportsEntryPointV06: false,
767+
supportsEntryPointV07: true,
768+
supportsEntryPointV08: false,
769+
isEip7702Compliant: true,
770+
isEip1271Compliant: false
771+
},
733772
{
734773
name: "Biconomy",
735774
getSmartAccountClient: async (conf: AAParamType<EntryPointVersion>) =>

packages/permissionless/accounts/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ import {
4242
toEcdsaKernelSmartAccount
4343
} from "./kernel/toEcdsaKernelSmartAccount.js"
4444

45+
import {
46+
type To7702KernelSmartAccountImplementation,
47+
type To7702KernelSmartAccountParameters,
48+
type To7702KernelSmartAccountReturnType,
49+
to7702KernelSmartAccount
50+
} from "./kernel/to7702KernelSmartAccount.js"
51+
4552
import {
4653
type KernelSmartAccountImplementation,
4754
type KernelVersion,
@@ -114,5 +121,9 @@ export {
114121
type ToEtherspotSmartAccountParameters,
115122
type EtherspotSmartAccountImplementation,
116123
type ToEtherspotSmartAccountReturnType,
117-
toEtherspotSmartAccount
124+
toEtherspotSmartAccount,
125+
type To7702KernelSmartAccountParameters,
126+
type To7702KernelSmartAccountImplementation,
127+
type To7702KernelSmartAccountReturnType,
128+
to7702KernelSmartAccount
118129
}

0 commit comments

Comments
 (0)