import { type EntryPointVersion, type GetAccountParameter, type OneOf, type SmartAccountSigner, type SmartContractAccount } from "@alchemy/aa-core"; import { type Address, type Chain } from "viem"; import type { LightAccountBase } from "./accounts/base"; /** * Light account types supported: LightAccount, MultiOwnerLightAccount * */ export type LightAccountType = keyof IAccountVersionRegistry; /** * Account version definition, which is the base type defining the LightAccountVersionDef interface * * @template {LightAccountType} TLightAccountType type * @template {GetLightAccountVersion} TLightAccountVersion version * @template {EntryPointVersion} TEntryPointVersion entryPointVersion */ export type AccountVersionDef = GetLightAccountVersion, TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = { type: TLightAccountType; version: TLightAccountVersion; entryPointVersion: TEntryPointVersion; address: Record; }; /** * Light account version type defs for tightly coupled types for smart accounts * */ export type LightAccountVersion = keyof IAccountVersionRegistry["LightAccount"] | keyof IAccountVersionRegistry["MultiOwnerLightAccount"]; /** * Get the light account versions available for the given light account type * * @template {LightAccountType} TLightAccountType */ export type GetLightAccountVersion = keyof IAccountVersionRegistry[TLightAccountType]; /** * Light account version definition type based on the light account type and version * * @template {LightAccountType} TLightAccountType * @template {GetLightAccountVersion} TLightAccountVersion */ export type LightAccountVersionDef = GetLightAccountVersion> = IAccountVersionRegistry[TLightAccountType][TLightAccountVersion]; /** * Light account version registry interface defining the supported light account versions * */ export interface IAccountVersionRegistry { LightAccount: { /** @deprecated This version does not support 1271 signature validation */ "v1.0.1": AccountVersionDef<"LightAccount", "v1.0.1", "0.6.0">; /** @deprecated This version has a known issue with 1271 validation */ "v1.0.2": AccountVersionDef<"LightAccount", "v1.0.2", "0.6.0">; "v1.1.0": AccountVersionDef<"LightAccount", "v1.1.0", "0.6.0">; /** * LightAccount v2 Changelog. * It is recommended to use v2.0.0 * https://alchemotion.notion.site/External-Light-Account-v2-Changelog-725b306ab1e04eb0a3e596521dd8f0bd */ "v2.0.0": AccountVersionDef<"LightAccount", "v2.0.0", "0.7.0">; }; MultiOwnerLightAccount: { /** * MultiOwnerLightAccount v2 Changelog * It is recommended to use v2.0.0 * https://alchemotion.notion.site/External-Light-Account-v2-Changelog-725b306ab1e04eb0a3e596521dd8f0bd */ "v2.0.0": AccountVersionDef<"MultiOwnerLightAccount", "v2.0.0", "0.7.0">; }; } /** * Get the light account version definitions available for the given light account type * * @template {LightAccountType} TLightAccountType * * @example * type T1 = GetLightAccountVersionsForType<"LightAccount">; * const t1: T1 = AccountVersionRegistry.LightAccount["v1.0.2"]; */ export type GetLightAccountVersionDefsForType = Extract; /** * Get the light account version definition for the given light account type and version * * @template {LightAccountType} TType * @template {GetLightAccountVersion} TLightAccountVersion */ export type GetLightAccountVersionDef> = IAccountVersionRegistry[TType][TLightAccountVersion]; /** * @example * type T = GetLightAccountVersionDefsForEntryPoint<"LightAccount", "0.6.0">; * const t_1: T = AccountVersionRegistry.LightAccount["v1.0.2"]; // compiles * const t_2: T = AccountVersionRegistry.LightAccount["v2.0.0"]; // errors */ export type GetLightAccountVersionDefsForEntryPoint = Extract, { entryPointVersion: TEntryPointVersion; }>; /** * Get the light account type for the given light account by inferring from its type definition * * @template {SmartContractAccount | undefined} TAccount * @template {SmartContractAccount} TAccountOverride */ export type GetLightAccountType = GetAccountParameter extends LightAccountBase ? OneOf : LightAccountType; /** * Get the light account version for the given light account by inferring from its type definition * * @template {LightAccountBase | undefined} TAccount * @template {LightAccountBase} TAccountOverride */ export type GetLightAccountVersionFromAccount = GetAccountParameter extends LightAccountBase ? OneOf : LightAccountVersion; /** * Get the entry point version supported for the given light account type and version * * @template {LightAccountType} TLightAccountType * @template {GetLightAccountVersion} TLightAccountVersion */ export type GetEntryPointForLightAccountVersion = GetLightAccountVersion> = GetLightAccountVersionDef extends AccountVersionDef ? TEntryPointVersion : EntryPointVersion; /** * Get the light account type for the given light account version by inferring from its type definition * * @template {LightAccountVersion} TLightAccountVersion */ export type GetLightAccountTypesForVersion = TLightAccountVersion extends GetLightAccountVersion ? TLightAccountType : LightAccountType; /** * Get default light account version for the given light account type * * @template {LightAccountType} TLightAccountType */ export type GetDefaultLightAccountVersion = TLightAccountType extends "MultiOwnerLightAccount" ? "v2.0.0" & LightAccountVersion : "v1.1.0" & LightAccountVersion; //# sourceMappingURL=types.d.ts.map