permissionless
Version:
A utility library for working with ERC-4337
51 lines • 2.98 kB
TypeScript
import type { Account, Assign, Chain, JsonRpcAccount, OneOf, Transport, WalletClient } from "viem";
import { type Address, type Client, type LocalAccount } from "viem";
import { type SmartAccount, type SmartAccountImplementation, type WebAuthnAccount, entryPoint06Abi, entryPoint07Abi } from "viem/account-abstraction";
import { type EthereumProvider } from "../../utils/toOwner.js";
export type KernelVersion<entryPointVersion extends "0.6" | "0.7"> = entryPointVersion extends "0.6" ? "0.2.1" | "0.2.2" | "0.2.3" | "0.2.4" : "0.3.0-beta" | "0.3.1" | "0.3.2" | "0.3.3";
/**
* Default addresses map for different kernel smart account versions
*/
export declare const KERNEL_VERSION_TO_ADDRESSES_MAP: {
[key in KernelVersion<"0.6" | "0.7">]: {
ECDSA_VALIDATOR: Address;
WEB_AUTHN_VALIDATOR?: Address;
ACCOUNT_LOGIC: Address;
FACTORY_ADDRESS: Address;
META_FACTORY_ADDRESS?: Address;
};
};
export declare const getEcdsaRootIdentifierForKernelV3: (validatorAddress: Address) => `0x${string}`;
export type ToKernelSmartAccountParameters<entryPointVersion extends "0.6" | "0.7", kernelVersion extends KernelVersion<entryPointVersion>, owner extends OneOf<EthereumProvider | WalletClient<Transport, Chain | undefined, Account> | LocalAccount | WebAuthnAccount>> = {
client: Client<Transport, Chain | undefined, JsonRpcAccount | LocalAccount | undefined>;
owners: [owner];
entryPoint?: {
address: Address;
version: entryPointVersion;
};
address?: Address;
version?: kernelVersion;
index?: bigint;
factoryAddress?: Address;
metaFactoryAddress?: Address;
accountLogicAddress?: Address;
validatorAddress?: Address;
nonceKey?: bigint;
useMetaFactory?: boolean | "optional";
};
export type KernelSmartAccountImplementation<entryPointVersion extends "0.6" | "0.7" = "0.7"> = Assign<SmartAccountImplementation<entryPointVersion extends "0.6" ? typeof entryPoint06Abi : typeof entryPoint07Abi, entryPointVersion>, {
sign: NonNullable<SmartAccountImplementation["sign"]>;
}>;
export type ToKernelSmartAccountReturnType<entryPointVersion extends "0.6" | "0.7" = "0.7"> = SmartAccount<KernelSmartAccountImplementation<entryPointVersion>>;
/**
* Build a kernel smart account from a private key, that use the ECDSA or passkeys signer behind the scene
* @param client
* @param privateKey
* @param entryPoint
* @param index
* @param factoryAddress
* @param accountLogicAddress
* @param validatorAddress
*/
export declare function toKernelSmartAccount<entryPointVersion extends "0.6" | "0.7", kernelVersion extends KernelVersion<entryPointVersion>, owner extends OneOf<EthereumProvider | WalletClient<Transport, Chain | undefined, Account> | LocalAccount | WebAuthnAccount>>(parameters: ToKernelSmartAccountParameters<entryPointVersion, kernelVersion, owner>): Promise<ToKernelSmartAccountReturnType<entryPointVersion>>;
//# sourceMappingURL=toKernelSmartAccount.d.ts.map