Skip to content

Commit

Permalink
Merge pull request #340 from pimlicolabs/passkeys
Browse files Browse the repository at this point in the history
Add passkeys support to kernel
  • Loading branch information
plusminushalf authored Dec 7, 2024
2 parents f0b3c68 + c4e394f commit 2ec3ac1
Show file tree
Hide file tree
Showing 30 changed files with 1,154 additions and 596 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-deers-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Added toKernelSmartAccount with passkeys support
5 changes: 5 additions & 0 deletions .changeset/chilly-starfishes-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Depricated toEcdsaKernelSmartAccount
3 changes: 3 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:

- name: Build
run: bun run build:permissionless
- name: Create .env file
run: |
echo "VITE_FORK_RPC_URL=${{ secrets.VITE_FORK_RPC_URL }}" > .env.test
- name: Run tests & coverage
run: bun run test:ci
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"get-port": "^7.0.0",
"tsc-alias": "^1.8.8",
"vitest": "^2.1.5",
"viem": "2.21.22",
"viem": "2.21.54",
"wagmi": "^2.12.8",
"@permissionless/wagmi": "workspace:packages/wagmi",
"@types/react": "^18.3.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/permissionless-test/mock-aa-infra/alto/constants.ts

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/permissionless-test/mock-aa-infra/alto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
KERNEL_V07_V3_1_ACCOUNT_V3_LOGIC_CREATECALL,
KERNEL_V07_V3_1_ECDSA_VALIDATOR_V3_CREATECALL,
KERNEL_V07_V3_1_FACTORY_CREATECALL,
KERNEL_V07_V3_1_WEB_AUTHN_VALIDATOR_CREATECALL,
LIGHT_ACCOUNT_FACTORY_V110_CREATECALL,
LIGHT_ACCOUNT_FACTORY_V200_CREATECALL,
NEXUS_ACCOUNT_BOOTSTRAPPER_CREATECALL,
Expand Down Expand Up @@ -255,6 +256,12 @@ export const setupContracts = async (rpc: string) => {
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: KERNEL_V07_V3_1_WEB_AUTHN_VALIDATOR_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: LIGHT_ACCOUNT_FACTORY_V110_CREATECALL,
Expand Down Expand Up @@ -621,6 +628,7 @@ export const setupContracts = async (rpc: string) => {
"0x845ADb2C711129d4f3966735eD98a9F09fC4cE57", // Kernel v0.3.1 ECDSA Valdiator
"0xBAC849bB641841b44E965fB01A4Bf5F074f84b4D", // Kernel v0.3.1 Account Logic
"0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419", // Kernel v0.3.1 Factory
"0xbA45a2BFb8De3D24cA9D7F1B551E14dFF5d690Fd", // Kernel v0.3.1 WebAuthn Validator
"0x00004EC70002a32400f8ae005A26081065620D20", // LightAccountFactory v1.1.0
"0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba", // LightAccount v1.1.0 implementation
"0x0000000000400CdFef5E2714E63d8040b700BC24", // LightAccountFactory v2.0.0
Expand Down
26 changes: 19 additions & 7 deletions packages/permissionless-test/src/testWithRpc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import getPort from "get-port"
import { alto, anvil } from "prool/instances"
import { createTestClient, parseEther } from "viem"
import { http } from "viem"
import {
entryPoint06Address,
entryPoint07Address
} from "viem/account-abstraction"
import { privateKeyToAccount } from "viem/accounts"
import { foundry } from "viem/chains"
import { test } from "vitest"
import {
Expand All @@ -12,7 +15,7 @@ import {
} from "../mock-aa-infra/alto"
import { paymaster } from "../mock-aa-infra/mock-paymaster"

export const getAltoInstance = async ({
export const getInstances = async ({
anvilPort,
altoPort,
paymasterPort
Expand All @@ -23,12 +26,17 @@ export const getAltoInstance = async ({
const anvilPrivateKey =
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

const forkUrl = (import.meta as any).env.VITE_FORK_RPC_URL as
| string
| undefined

const anvilInstance = anvil({
chainId: foundry.id,
port: anvilPort
port: anvilPort,
forkUrl
})

const instance = alto({
const altoInstance = alto({
entrypoints: [entryPoint06Address, entryPoint07Address],
rpcUrl: anvilRpc,
executorPrivateKeys: [anvilPrivateKey],
Expand All @@ -49,12 +57,16 @@ export const getAltoInstance = async ({
port: paymasterPort,
altoRpc
})

await anvilInstance.start()
await setupContracts(anvilRpc)
await instance.start()
await altoInstance.start()
await paymasterInstance.start()

return [anvilInstance, instance, paymasterInstance]
if (!forkUrl) {
await setupContracts(anvilRpc)
}

return [anvilInstance, altoInstance, paymasterInstance]
}

let ports: number[] = []
Expand Down Expand Up @@ -85,7 +97,7 @@ export const testWithRpc = test.extend<{
const altoRpc = `http://localhost:${altoPort}`
const paymasterRpc = `http://localhost:${paymasterPort}`

const instances = await getAltoInstance({
const instances = await getInstances({
anvilPort,
altoPort,
paymasterPort
Expand Down
10 changes: 5 additions & 5 deletions packages/permissionless-test/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
privateKeyToAccount
} from "viem/accounts"
import { foundry } from "viem/chains"
import { toThirdwebSmartAccount } from "../../permissionless/accounts"
import { toBiconomySmartAccount } from "../../permissionless/accounts/biconomy/toBiconomySmartAccount"
import {
type KernelVersion,
toEcdsaKernelSmartAccount
} from "../../permissionless/accounts/kernel/toEcdsaKernelSmartAccount"
toKernelSmartAccount,
toThirdwebSmartAccount
} from "../../permissionless/accounts"
import { toBiconomySmartAccount } from "../../permissionless/accounts/biconomy/toBiconomySmartAccount"
import {
type LightAccountVersion,
toLightSmartAccount
Expand Down Expand Up @@ -318,7 +318,7 @@ export const getKernelEcdsaClient = async <
throw new Error("ERC7579 is not supported for V06")
}

return toEcdsaKernelSmartAccount({
return toKernelSmartAccount({
client: publicClient,
entryPoint: {
address:
Expand Down
17 changes: 14 additions & 3 deletions packages/permissionless/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ import {

import {
type EcdsaKernelSmartAccountImplementation,
type KernelVersion,
type ToEcdsaKernelSmartAccountParameters,
type ToEcdsaKernelSmartAccountReturnType,
toEcdsaKernelSmartAccount
} from "./kernel/toEcdsaKernelSmartAccount.js"

import {
type KernelSmartAccountImplementation,
type KernelVersion,
type ToKernelSmartAccountParameters,
type ToKernelSmartAccountReturnType,
toKernelSmartAccount
} from "./kernel/toKernelSmartAccount.js"

import {
type BiconomySmartAccountImplementation,
type ToBiconomySmartAccountParameters,
Expand Down Expand Up @@ -74,13 +81,17 @@ export {
type ToSafeSmartAccountParameters,
type SafeSmartAccountImplementation,
type ToSafeSmartAccountReturnType,
type SafeVersion,
toSafeSmartAccount,
type ToEcdsaKernelSmartAccountParameters,
type EcdsaKernelSmartAccountImplementation,
type ToEcdsaKernelSmartAccountReturnType,
type SafeVersion,
type KernelVersion,
toEcdsaKernelSmartAccount,
type KernelSmartAccountImplementation,
type ToKernelSmartAccountReturnType,
type ToKernelSmartAccountParameters,
type KernelVersion,
toKernelSmartAccount,
type NexusSmartAccountImplementation,
type ToNexusSmartAccountParameters,
type ToNexusSmartAccountReturnType,
Expand Down
Loading

0 comments on commit 2ec3ac1

Please sign in to comment.