diff --git a/.changeset/polite-cups-shout.md b/.changeset/polite-cups-shout.md new file mode 100644 index 00000000..7be7e82a --- /dev/null +++ b/.changeset/polite-cups-shout.md @@ -0,0 +1,5 @@ +--- +"permissionless": patch +--- + +Added useMetaFactory flag for toEcdsaKernelSmartAccount diff --git a/packages/permissionless-test/src/utils.ts b/packages/permissionless-test/src/utils.ts index bdd0b4a5..aaae353d 100644 --- a/packages/permissionless-test/src/utils.ts +++ b/packages/permissionless-test/src/utils.ts @@ -314,9 +314,11 @@ export const getKernelEcdsaClient = async < entryPoint, anvilRpc, version, - privateKey + privateKey, + useMetaFactory }: AAParamType & { version?: KernelVersion + useMetaFactory?: boolean }) => { const publicClient = getPublicClient(anvilRpc) @@ -336,6 +338,7 @@ export const getKernelEcdsaClient = async < : entryPoint07Address, version: entryPoint.version === "0.6" ? "0.6" : "0.7" }, + useMetaFactory, owners: [privateKeyToAccount(privateKey ?? generatePrivateKey())], version }) @@ -549,6 +552,36 @@ export const getCoreSmartAccounts = () => [ supportsEntryPointV07: false, isEip1271Compliant: true }, + { + name: "Kernel 7579 0.3.0-beta (non meta factory deployment)", + getSmartAccountClient: async ( + conf: AAParamType + ) => + getBundlerClient({ + account: await getKernelEcdsaClient({ + ...conf, + version: "0.3.0-beta" as KernelVersion, + useMetaFactory: false + }), + ...conf + }), + getErc7579SmartAccountClient: async < + entryPointVersion extends "0.6" | "0.7" + >( + conf: AAParamType + ) => + getSmartAccountClient({ + account: await getKernelEcdsaClient({ + ...conf, + version: "0.3.0-beta" as KernelVersion, + useMetaFactory: false + }), + ...conf + }), + supportsEntryPointV06: false, + supportsEntryPointV07: true, + isEip1271Compliant: true + }, { name: "Kernel 7579 0.3.0-beta", getSmartAccountClient: async ( @@ -577,6 +610,36 @@ export const getCoreSmartAccounts = () => [ supportsEntryPointV07: true, isEip1271Compliant: true }, + { + name: "Kernel 7579 0.3.1 (non meta factory deployment)", + getSmartAccountClient: async ( + conf: AAParamType + ) => + getBundlerClient({ + account: await getKernelEcdsaClient({ + ...conf, + version: "0.3.1" as KernelVersion, + useMetaFactory: false + }), + ...conf + }), + getErc7579SmartAccountClient: async < + entryPointVersion extends "0.6" | "0.7" + >( + conf: AAParamType + ) => + getSmartAccountClient({ + account: await getKernelEcdsaClient({ + ...conf, + version: "0.3.1" as KernelVersion, + useMetaFactory: false + }), + ...conf + }), + supportsEntryPointV06: false, + supportsEntryPointV07: true, + isEip1271Compliant: true + }, { name: "Kernel 7579 0.3.1", getSmartAccountClient: async ( diff --git a/packages/permissionless/accounts/kernel/abi/KernelV3FactoryAbi.ts b/packages/permissionless/accounts/kernel/abi/KernelV3FactoryAbi.ts new file mode 100644 index 00000000..7bb8f515 --- /dev/null +++ b/packages/permissionless/accounts/kernel/abi/KernelV3FactoryAbi.ts @@ -0,0 +1,12 @@ +export const KernelV3FactoryAbi = [ + { + type: "function", + name: "createAccount", + inputs: [ + { name: "data", type: "bytes", internalType: "bytes" }, + { name: "salt", type: "bytes32", internalType: "bytes32" } + ], + outputs: [{ name: "", type: "address", internalType: "address" }], + stateMutability: "payable" + } +] as const diff --git a/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts b/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts index 90de4289..5e3d86ec 100644 --- a/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts +++ b/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts @@ -41,6 +41,7 @@ import { KernelV3InitAbi, KernelV3_1AccountAbi } from "./abi/KernelV3AccountAbi.js" +import { KernelV3FactoryAbi } from "./abi/KernelV3FactoryAbi.js" import { KernelV3MetaFactoryDeployWithFactoryAbi } from "./abi/KernelV3MetaFactoryAbi.js" import { DUMMY_ECDSA_SIGNATURE, @@ -315,7 +316,8 @@ const getAccountInitCode = async ({ index, factoryAddress, accountLogicAddress, - validatorAddress + validatorAddress, + useMetaFactory }: { kernelVersion: KernelVersion entryPointVersion: entryPointVersion @@ -324,6 +326,7 @@ const getAccountInitCode = async ({ factoryAddress: Address accountLogicAddress: Address validatorAddress: Address + useMetaFactory: boolean }): Promise => { // Build the account initialization data const initializationData = getInitializationData({ @@ -343,6 +346,14 @@ const getAccountInitCode = async ({ }) } + if (!useMetaFactory) { + return encodeFunctionData({ + abi: KernelV3FactoryAbi, + functionName: "createAccount", + args: [initializationData, toHex(index, { size: 32 })] + }) + } + return encodeFunctionData({ abi: KernelV3MetaFactoryDeployWithFactoryAbi, functionName: "deployWithFactory", @@ -374,6 +385,7 @@ export type ToKernelSmartAccountParameters< accountLogicAddress?: Address validatorAddress?: Address nonceKey?: bigint + useMetaFactory?: boolean } export type KernelSmartAccountImplementation< @@ -431,7 +443,8 @@ export async function toKernelSmartAccount< validatorAddress: _validatorAddress, factoryAddress: _factoryAddress, metaFactoryAddress: _metaFactoryAddress, - accountLogicAddress: _accountLogicAddress + accountLogicAddress: _accountLogicAddress, + useMetaFactory = true } = parameters const isWebAuthn = owners[0].type === "webAuthn" @@ -484,7 +497,8 @@ export async function toKernelSmartAccount< index, factoryAddress, accountLogicAddress, - validatorAddress + validatorAddress, + useMetaFactory }) let accountAddress: Address | undefined = address @@ -502,7 +516,7 @@ export async function toKernelSmartAccount< const getFactoryArgs = async () => { return { factory: - entryPoint.version === "0.6" + entryPoint.version === "0.6" || useMetaFactory === false ? factoryAddress : metaFactoryAddress, factoryData: await generateInitCode()