UNPKG

@zerodev/sdk

Version:

A utility library for working with ERC-4337

67 lines 4 kB
import { type Address, type Assign, type EncodeDeployDataParameters, type Hex, type SignableMessage } from "viem"; import { type EntryPointVersion, type SmartAccount, type SmartAccountImplementation } from "viem/account-abstraction"; import type { SignAuthorizationReturnType } from "viem/accounts"; import type { CallType, EntryPointType, GetEntryPointAbi, GetKernelVersion, KernelPluginManager, KernelPluginManagerParams, PluginMigrationData } from "../../types/kernel.js"; import type { Signer } from "../../types/utils.js"; type SignMessageParameters = { message: SignableMessage; useReplayableSignature?: boolean; }; export type KernelSmartAccountImplementation<entryPointVersion extends EntryPointVersion = "0.7"> = Assign<SmartAccountImplementation<GetEntryPointAbi<entryPointVersion>, entryPointVersion>, { sign: NonNullable<SmartAccountImplementation["sign"]>; encodeCalls: (calls: Parameters<SmartAccountImplementation["encodeCalls"]>[0], callType?: CallType | undefined) => Promise<Hex>; kernelVersion: GetKernelVersion<entryPointVersion>; kernelPluginManager: KernelPluginManager<entryPointVersion>; factoryAddress: Address; accountImplementationAddress: Address; generateInitCode: () => Promise<Hex>; encodeModuleInstallCallData: () => Promise<Hex>; encodeDeployCallData: ({ abi, args, bytecode }: EncodeDeployDataParameters) => Promise<Hex>; signMessage: (parameters: SignMessageParameters) => Promise<Hex>; eip7702Authorization?: (() => Promise<SignAuthorizationReturnType | undefined>) | undefined; }>; export type CreateKernelAccountReturnType<entryPointVersion extends EntryPointVersion = "0.7"> = SmartAccount<KernelSmartAccountImplementation<entryPointVersion>>; export type CreateKernelAccountParameters<entryPointVersion extends EntryPointVersion, KernelVerion extends GetKernelVersion<entryPointVersion>> = { entryPoint: EntryPointType<entryPointVersion>; index?: bigint; factoryAddress?: Address; accountImplementationAddress?: Address; metaFactoryAddress?: Address; address?: Address; kernelVersion: GetKernelVersion<entryPointVersion>; initConfig?: KernelVerion extends "0.3.1" ? Hex[] : never; useMetaFactory?: boolean; pluginMigrations?: PluginMigrationData[]; } & ({ eip7702Auth?: SignAuthorizationReturnType | undefined; eip7702Account: Signer; plugins?: Omit<KernelPluginManagerParams<entryPointVersion>, "entryPoint" | "kernelVersion"> | KernelPluginManager<entryPointVersion> | undefined; } | { eip7702Auth?: SignAuthorizationReturnType | undefined; eip7702Account?: Signer | undefined; plugins: Omit<KernelPluginManagerParams<entryPointVersion>, "entryPoint" | "kernelVersion"> | KernelPluginManager<entryPointVersion>; }); /** * Default addresses for kernel smart account */ export declare const KERNEL_ADDRESSES: { ACCOUNT_LOGIC_V0_6: Address; ACCOUNT_LOGIC_V0_7: Address; FACTORY_ADDRESS_V0_6: Address; FACTORY_ADDRESS_V0_7: Address; FACTORY_STAKER: Address; }; /** * Build a kernel smart account from a private key, that use the ECDSA signer behind the scene * @param client * @param privateKey * @param entryPoint * @param index * @param factoryAddress * @param accountImplementationAddress * @param ecdsaValidatorAddress * @param address */ export declare function createKernelAccount<entryPointVersion extends EntryPointVersion, KernelVersion extends GetKernelVersion<entryPointVersion>>(client: KernelSmartAccountImplementation["client"], { plugins, entryPoint, index, factoryAddress: _factoryAddress, accountImplementationAddress: _accountImplementationAddress, metaFactoryAddress: _metaFactoryAddress, address, kernelVersion, initConfig, useMetaFactory: _useMetaFactory, eip7702Auth, eip7702Account, pluginMigrations }: CreateKernelAccountParameters<entryPointVersion, KernelVersion>): Promise<CreateKernelAccountReturnType<entryPointVersion>>; export {}; //# sourceMappingURL=createKernelAccount.d.ts.map