Skip to content

Add support for kernel + 7702 #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/full-peas-open.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Added authorisation support for installModule and installModules
2 changes: 1 addition & 1 deletion packages/permissionless-test/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ export const getCoreSmartAccounts = (): Array<{
supportsEntryPointV06: false,
supportsEntryPointV07: true,
supportsEntryPointV08: false,
isEip7702Compliant: true,
isEip7702Compliant: false,
isEip1271Compliant: false
},
{
Expand Down
48 changes: 44 additions & 4 deletions packages/permissionless/actions/erc7579/installModule.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
import { encodeAbiParameters, encodePacked, isHash, zeroAddress } from "viem"
import { privateKeyToAccount } from "viem/accounts"
import { describe, expect } from "vitest"
import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
import { getCoreSmartAccounts } from "../../../permissionless-test/src/utils"
import {
getCoreSmartAccounts,
getPublicClient
} from "../../../permissionless-test/src/utils"
import { erc7579Actions } from "../erc7579"
import { installModule } from "./installModule"

describe.each(getCoreSmartAccounts())(
"installModule $name",
({ getErc7579SmartAccountClient, name }) => {
({ getErc7579SmartAccountClient, name, isEip7702Compliant }) => {
testWithRpc.skipIf(!getErc7579SmartAccountClient)(
"installModule",
async ({ rpc }) => {
if (!getErc7579SmartAccountClient) {
throw new Error("getErc7579SmartAccountClient not defined")
}

const privateKey =
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"

const privateKeyAccount = privateKeyToAccount(privateKey)

const smartClientWithoutExtend =
await getErc7579SmartAccountClient({
entryPoint: {
version: "0.7"
},
privateKey,
...rpc
})

const publicClient = getPublicClient(rpc.anvilRpc)

const smartClient = smartClientWithoutExtend.extend(
erc7579Actions()
)
Expand All @@ -47,7 +59,17 @@ describe.each(getCoreSmartAccounts())(
)
]
)
: moduleData
: moduleData,
authorization: isEip7702Compliant
? await privateKeyAccount.signAuthorization({
address: (smartClient.account as any)
.implementation,
chainId: smartClient.chain.id,
nonce: await publicClient.getTransactionCount({
address: smartClient.account.address
})
})
: undefined
})

expect(isHash(opHash)).toBe(true)
Expand Down Expand Up @@ -88,14 +110,22 @@ describe.each(getCoreSmartAccounts())(
throw new Error("getErc7579SmartAccountClient not defined")
}

const privateKey =
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"

const privateKeyAccount = privateKeyToAccount(privateKey)

const smartClientWithoutExtend =
await getErc7579SmartAccountClient({
entryPoint: {
version: "0.7"
},
privateKey,
...rpc
})

const publicClient = getPublicClient(rpc.anvilRpc)

const smartClient = smartClientWithoutExtend.extend(
erc7579Actions()
)
Expand All @@ -112,7 +142,17 @@ describe.each(getCoreSmartAccounts())(
value: 0n,
data: "0x"
}
]
],
authorization: isEip7702Compliant
? await privateKeyAccount.signAuthorization({
address: (smartClient.account as any)
.implementation,
chainId: smartClient.chain.id,
nonce: await publicClient.getTransactionCount({
address: smartClient.account.address
})
})
: undefined
})

await smartClient.waitForUserOperationReceipt({
Expand Down
5 changes: 4 additions & 1 deletion packages/permissionless/actions/erc7579/installModule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Address, Client, Hex, OneOf } from "viem"
import type { Address, Client, Hex, OneOf, SignedAuthorization } from "viem"
import {
type GetSmartAccountParameter,
type PaymasterActions,
Expand All @@ -13,6 +13,7 @@ import type { ModuleType } from "./supportsModule.js"
export type InstallModuleParameters<
TSmartAccount extends SmartAccount | undefined
> = GetSmartAccountParameter<TSmartAccount> & {
authorization?: SignedAuthorization<number> | undefined
type: ModuleType
address: Address
maxFeePerGas?: bigint
Expand Down Expand Up @@ -63,6 +64,7 @@ export function installModule<TSmartAccount extends SmartAccount | undefined>(
type,
calls,
paymaster,
authorization,
paymasterContext
} = parameters

Expand Down Expand Up @@ -91,6 +93,7 @@ export function installModule<TSmartAccount extends SmartAccount | undefined>(
maxFeePerGas,
maxPriorityFeePerGas,
nonce,
authorization,
account
})
}
43 changes: 41 additions & 2 deletions packages/permissionless/actions/erc7579/installModules.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
import { encodeAbiParameters, encodePacked, isHash, zeroAddress } from "viem"
import { privateKeyToAccount } from "viem/accounts"
import { describe, expect } from "vitest"
import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
import { getCoreSmartAccounts } from "../../../permissionless-test/src/utils"
import {
getCoreSmartAccounts,
getPublicClient
} from "../../../permissionless-test/src/utils"
import { erc7579Actions } from "../erc7579"
import { installModules } from "./installModules"

describe.each(getCoreSmartAccounts())(
"installModules $name",
({ getErc7579SmartAccountClient, name }) => {
({ getErc7579SmartAccountClient, name, isEip7702Compliant }) => {
testWithRpc.skipIf(!getErc7579SmartAccountClient)(
"installModules",
async ({ rpc }) => {
if (!getErc7579SmartAccountClient) {
throw new Error("getErc7579SmartAccountClient not defined")
}

const privateKey =
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"

const privateKeyAccount = privateKeyToAccount(privateKey)

const smartClientWithoutExtend =
await getErc7579SmartAccountClient({
entryPoint: {
version: "0.7"
},
privateKey,
...rpc
})

const publicClient = getPublicClient(rpc.anvilRpc)

const smartClient = smartClientWithoutExtend.extend(
erc7579Actions()
)
Expand All @@ -41,6 +53,16 @@ describe.each(getCoreSmartAccounts())(
data: "0x"
}
],
authorization: isEip7702Compliant
? await privateKeyAccount.signAuthorization({
address: (smartClient.account as any)
.implementation,
chainId: smartClient.chain.id,
nonce: await publicClient.getTransactionCount({
address: smartClient.account.address
})
})
: undefined,
modules: [
{
type: "executor",
Expand Down Expand Up @@ -102,19 +124,36 @@ describe.each(getCoreSmartAccounts())(
throw new Error("getErc7579SmartAccountClient not defined")
}

const privateKey =
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"

const privateKeyAccount = privateKeyToAccount(privateKey)

const smartClientWithoutExtend =
await getErc7579SmartAccountClient({
entryPoint: {
version: "0.7"
},
privateKey,
...rpc
})
const publicClient = getPublicClient(rpc.anvilRpc)

const smartClient = smartClientWithoutExtend.extend(
erc7579Actions()
)

const userOpHash = await smartClient.sendUserOperation({
authorization: isEip7702Compliant
? await privateKeyAccount.signAuthorization({
address: (smartClient.account as any)
.implementation,
chainId: smartClient.chain.id,
nonce: await publicClient.getTransactionCount({
address: smartClient.account.address
})
})
: undefined,
calls: [
{
to: smartClient.account.address,
Expand Down
12 changes: 11 additions & 1 deletion packages/permissionless/actions/erc7579/installModules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import type { Address, Chain, Client, Hex, Transport } from "viem"
import type {
Address,
Chain,
Client,
Hex,
SignedAuthorization,
Transport
} from "viem"
import {
type PaymasterActions,
type SmartAccount,
Expand All @@ -14,6 +21,7 @@ import {
export type InstallModulesParameters<
TSmartAccount extends SmartAccount | undefined
> = EncodeInstallModuleParameters<TSmartAccount> & {
authorization?: SignedAuthorization<number> | undefined
maxFeePerGas?: bigint
maxPriorityFeePerGas?: bigint
nonce?: bigint
Expand Down Expand Up @@ -54,6 +62,7 @@ export async function installModules<
modules,
paymaster,
paymasterContext,
authorization,
calls
} = parameters

Expand All @@ -80,6 +89,7 @@ export async function installModules<
paymasterContext,
maxFeePerGas,
maxPriorityFeePerGas,
authorization,
nonce,
account: account
})
Expand Down
28 changes: 25 additions & 3 deletions packages/permissionless/actions/erc7579/uninstallModule.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
import { encodeAbiParameters, encodePacked, isHash, zeroAddress } from "viem"
import { privateKeyToAccount } from "viem/accounts"
import { describe, expect } from "vitest"
import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
import { getCoreSmartAccounts } from "../../../permissionless-test/src/utils"
import {
getCoreSmartAccounts,
getPublicClient
} from "../../../permissionless-test/src/utils"
import { erc7579Actions } from "../erc7579"
import { uninstallModule } from "./uninstallModule"

describe.each(getCoreSmartAccounts())(
"uninstallModule $name",
({ getErc7579SmartAccountClient, name }) => {
({ getErc7579SmartAccountClient, name, isEip7702Compliant }) => {
testWithRpc.skipIf(!getErc7579SmartAccountClient)(
"uninstallModule",
async ({ rpc }) => {
if (!getErc7579SmartAccountClient) {
throw new Error("getErc7579SmartAccountClient not defined")
}

const privateKey =
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"

const privateKeyAccount = privateKeyToAccount(privateKey)

const smartClientWithoutExtend =
await getErc7579SmartAccountClient({
entryPoint: {
version: "0.7"
},
privateKey,
...rpc
})

const publicClient = getPublicClient(rpc.anvilRpc)

const smartClient = smartClientWithoutExtend.extend(
erc7579Actions()
)
Expand All @@ -46,7 +58,17 @@ describe.each(getCoreSmartAccounts())(
)
]
)
: moduleData
: moduleData,
authorization: isEip7702Compliant
? await privateKeyAccount.signAuthorization({
address: (smartClient.account as any)
.implementation,
chainId: smartClient.chain.id,
nonce: await publicClient.getTransactionCount({
address: smartClient.account.address
})
})
: undefined
})

await smartClient.waitForUserOperationReceipt({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ describe.each(getCoreSmartAccounts())(
async ({ rpc }) => {
const { anvilRpc } = rpc

const privateKeyAccount = privateKeyToAccount(
const privateKey =
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"
)

const privateKeyAccount = privateKeyToAccount(privateKey)

const smartClient = await getSmartAccountClient({
entryPoint: {
version: "0.7"
},
privateKey:
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356", // anvil private key
privateKey, // anvil private key
...rpc
})

Expand Down
Loading