import { AccountId } from 'caip'; import { PublicClient } from 'viem'; import type { AccountClientInterface, AccountStatus } from '../client'; import { type AccountConfig } from './config'; import type { EmptyVaultResult } from '../../types'; import { BundlerConfig } from '../../bundler'; import type { VaultEncryptionKeyWithMetadata } from '../../cryptography'; import { PersistedAccount } from '../../state'; import { LibQCStorage } from '../../storage'; import { Activity, EvmAddress, Asset, BalanceResult, GasCostEstimate, GetActivityFilters, TransactionValue, type WithdrawalRecord } from '../../types'; /** * EVM account client implementing AccountClientInterface * * Provides EVM-specific operations: getConfig, getTransferGasCostEstimate, * plus all AccountClientInterface methods (getBalance, getActivities, etc.) * * Instances are created via `LibQC.getAccount()` or `LibQC.createAccount()` for EVM chains. * * @example * ```typescript * const account = await vault.getAccount(accountId); * * // Check balance * const balance = await account.getBalance(asset); * ``` */ export declare class EvmAccountClient implements AccountClientInterface { private account; private storage; private encryptionKey; private publicClient; private bundlerConfig; /** * Creates a new AccountClient instance * * Note: This constructor is internal and should not be called directly. * Use `LibQC.getAccount()` or `LibQC.createAccount()` instead. * * @param account - Persisted account data * @param storage - Storage implementation for persisting state * @param encryptionKey - Key for decrypting vault state * @param publicClient - Viem public client for blockchain reads * @param bundlerConfig - Configuration for the ERC-4337 bundler * * @internal */ constructor(account: PersistedAccount, storage: LibQCStorage, encryptionKey: VaultEncryptionKeyWithMetadata, publicClient: PublicClient, bundlerConfig: BundlerConfig); /** * Public getter for the ID of the account * * @returns The account ID */ getId(): AccountId; /** * Gets the token balance for the account * * For ERC-20 tokens the on-chain `decimals()` value is read from the * contract and compared against the entity decimals in assets.json. * If they disagree an {@link OnChainDecimalsMismatchError} is thrown * so that misconfigured asset metadata is surfaced immediately * rather than silently producing wrong balances. * * @param asset An asset (token or native) to fetch the balance for * @returns Balance result with balance, decimals, and symbol * @throws {AssetEntityNotFoundError} If the asset has no entity on this chain * @throws {NonErc20TokenBalanceError} If the asset is not an ERC-20 token * @throws {OnChainDecimalsMismatchError} If on-chain decimals differ from entity config */ getBalance(asset: Asset): Promise; /** * Gets the balances of an array of assets for the account * * Omitting the assets fetches the native token balances * * @param assets An optional array of assets (tokens or native) to fetch the balances for * @returns The balance results of the assets for the account */ getBalances(assets: Asset[]): Promise; /** * Gets the config for the account * * @returns The config for the account */ getConfig(): Promise; /** * Get activity for an account * * @param filters Optional activity filters * @returns Activity for the account */ getActivities(filters?: GetActivityFilters): Promise; /** * Get the estimated gas cost for a transfer * * Omitting the asset assumes the transfer will use the chain's native token * * @param amount The amount of the transfer * @param to The destination address or domain name * @param asset An optional asset (ERC-20 token or native) * @returns A gas cost estimate * @throws AssetEntityNotFoundError if the asset is not supported on the chain */ getTransferGasCostEstimate(amount: TransactionValue, to: EvmAddress, asset?: Asset): Promise; /** * Sends a transfer from this account * * Handles both native token transfers and ERC-20 token transfers. * Omitting the asset sends the chain's native token. * * @param amount The amount to transfer * @param to The destination address * @param asset An optional asset (ERC-20 token); omit for native token * @returns A transaction activity representing the transfer */ private sendTransfer; /** * Withdraws all supported assets from this account to a destination address * * Sends ERC-20 balances first, then the native asset last (after re-checking * the live balance to account for gas consumed by ERC-20 transfers). * * @param destinationAddress The destination address to receive all assets * @returns Summary of the completed empty-vault flow * @throws {InvalidDestinationAddressError} If the destination address is invalid * @throws {NoWithdrawableAssetsError} If no supported assets have a positive balance * @throws {InsufficientNativeBalanceForGasError} If the native balance exists but is entirely consumed by gas and no ERC-20s were transferred */ emptyVault(destinationAddress: string): Promise; /** * Reconciles a withdrawal record against on-chain state (ENG-1791). * * EVM `emptyVault` waits for userop receipts and persists records with * status='sent', so reconciliation only needs to verify that the source * account holds no remaining withdrawable balance to advance to 'withdrawn'. * * @internal Used by `LibQC.refreshWithdrawalLifecycle`. */ reconcileWithdrawalRecord(record: WithdrawalRecord): Promise; /** * Lists all assets that have been added, filtered by the account's chain * * Only returns assets that have at least one entity on the account's chain * * @returns An array of added assets that are available on the account's chain */ listAssets(): Promise; /** * Checks if the public key is exposed * * If the account is not deployed, the public key is not exposed * * @returns Whether the public key is exposed */ isPubKeyExposed(): Promise; /** * Gets the safety status of the account * * @returns The safety status of the account */ getStatus(): Promise; /** * Gets the persisted EVM address from the account * * @returns The persisted EVM address */ private getPersistedAddressFromAccount; /** * Extracts the token address from an asset * * If the asset is native on this chain, returns undefined. * If the asset is an ERC-20 token, returns the token contract address. * * @param asset The asset to extract the token address from * @returns The token address or undefined for native assets * @throws AssetEntityNotFoundError if the asset is not supported on the chain * @throws UnsupportedAssetTypeError if the asset type is not supported (not native or ERC-20) */ private extractTokenAddress; } /** @deprecated Use EvmAccountClient. Default export for backward compatibility. */ export default EvmAccountClient;