import { type Address, type Chain, type CustomSource, type Hex, type LocalAccount, type PublicClient, type SignableMessage, type Transport, type TypedData, type TypedDataDefinition } from "viem"; import type { EntryPointDef, EntryPointRegistryBase, EntryPointVersion } from "../entrypoint/types.js"; import type { SmartAccountSigner } from "../signer/types.js"; import type { NullAddress } from "../types.js"; import type { IsUndefined, Never } from "../utils/types.js"; export type AccountOp = { target: Address; value?: bigint; data: Hex | "0x"; }; export declare enum DeploymentState { UNDEFINED = "0x0", NOT_DEPLOYED = "0x1", DEPLOYED = "0x2" } export type SignatureRequest = { type: "personal_sign"; data: SignableMessage; } | { type: "eth_signTypedData_v4"; data: TypedDataDefinition; }; export type SigningMethods = { prepareSign: (request: SignatureRequest) => Promise; formatSign: (signature: Hex) => Promise; }; export type GetEntryPointFromAccount = GetAccountParameter extends SmartContractAccount ? TEntryPointVersion : EntryPointVersion; export type GetAccountParameter = IsUndefined extends true ? { account: TAccountOverride; } : { account?: TAccountOverride; }; export type UpgradeToAndCallParams = { upgradeToAddress: Address; upgradeToInitData: Hex; }; export type SmartContractAccountWithSigner = SmartContractAccount & { getSigner: () => TSigner; }; /** * Determines if the given SmartContractAccount has a signer associated with it. * * @example * ```ts * import { toSmartContractAccount } from "@aa-sdk/core"; * * const account = await toSmartContractAccount(...); * * console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer * ``` * * @param {SmartContractAccount} account The account to check. * @returns {boolean} true if the account has a signer, otherwise false. */ export declare const isSmartAccountWithSigner: (account: SmartContractAccount) => account is SmartContractAccountWithSigner; export type SmartContractAccount = LocalAccount & { source: Name; getDummySignature: () => Hex | Promise; encodeExecute: (tx: AccountOp) => Promise; encodeBatchExecute: (txs: AccountOp[]) => Promise; signUserOperationHash: (uoHash: Hex) => Promise; signMessageWith6492: (params: { message: SignableMessage; }) => Promise; signTypedDataWith6492: , primaryType extends keyof typedData | "EIP712Domain" = keyof typedData>(typedDataDefinition: TypedDataDefinition) => Promise; encodeUpgradeToAndCall: (params: UpgradeToAndCallParams) => Promise; getAccountNonce(nonceKey?: bigint): Promise; getInitCode: () => Promise; isAccountDeployed: () => Promise; getFactoryAddress: () => Promise
; getFactoryData: () => Promise; getEntryPoint: () => EntryPointDef; getImplementationAddress: () => Promise; } & SigningMethods; export interface AccountEntryPointRegistry extends EntryPointRegistryBase> { "0.6.0": SmartContractAccount; "0.7.0": SmartContractAccount; } export type ToSmartContractAccountParams = { source: Name; transport: TTransport; chain: TChain; entryPoint: EntryPointDef; accountAddress?: Address; getAccountInitCode: () => Promise; getDummySignature: () => Hex | Promise; encodeExecute: (tx: AccountOp) => Promise; encodeBatchExecute?: (txs: AccountOp[]) => Promise; getNonce?: (nonceKey?: bigint) => Promise; signUserOperationHash?: (uoHash: Hex) => Promise; encodeUpgradeToAndCall?: (params: UpgradeToAndCallParams) => Promise; getImplementationAddress?: () => Promise; } & Omit & (SigningMethods | Never); /** * Parses the factory address and factory calldata from the provided account initialization code (initCode). * * @example * ```ts * import { parseFactoryAddressFromAccountInitCode } from "@aa-sdk/core"; * * const [address, calldata] = parseFactoryAddressFromAccountInitCode("0xAddressCalldata"); * ``` * * @param {Hex} initCode The initialization code from which to parse the factory address and calldata * @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata */ export declare const parseFactoryAddressFromAccountInitCode: (initCode: Hex) => [Address, Hex]; export type GetAccountAddressParams = { client: PublicClient; entryPoint: EntryPointDef; accountAddress?: Address; getAccountInitCode: () => Promise; }; /** * Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code. * * @example * ```ts * import { getEntryPoint, getAccountAddress } from "@aa-sdk/core"; * * const accountAddress = await getAccountAddress({ * client, * entryPoint: getEntryPoint(chain), * getAccountInitCode: async () => "0x{factoryAddress}{factoryCallData}", * }); * ``` * * @param {GetAccountAddressParams} params The configuration object * @param {PublicClient} params.client A public client instance to interact with the blockchain * @param {EntryPointDef} params.entryPoint The entry point definition which includes the address and ABI * @param {Address} params.accountAddress Optional existing account address * @param {() => Promise} params.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account * @returns {Promise
} A promise that resolves to the account address */ export declare const getAccountAddress: ({ client, entryPoint, accountAddress, getAccountInitCode, }: GetAccountAddressParams) => Promise<`0x${string}`>; export declare function toSmartContractAccount({ transport, chain, entryPoint, source, accountAddress, getAccountInitCode, getNonce, signMessage, signTypedData, encodeBatchExecute, encodeExecute, getDummySignature, signUserOperationHash, encodeUpgradeToAndCall, }: ToSmartContractAccountParams): Promise>;