UNPKG

@alchemy/aa-core

Version:

viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts

28 lines (26 loc) 963 B
import type { Address, Chain, Client, StateOverride, Transport } from "viem"; import type { BundlerRpcSchema } from "../../client/decorators/bundlerClient"; import type { EntryPointVersion } from "../../entrypoint/types"; import type { UserOperationEstimateGasResponse, UserOperationRequest, } from "../../types"; export const estimateUserOperationGas = async < TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>, TEntryPointVersion extends EntryPointVersion = EntryPointVersion >( client: TClient, args: { request: UserOperationRequest<TEntryPointVersion>; entryPoint: Address; stateOverride?: StateOverride; } ): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> => { return client.request({ method: "eth_estimateUserOperationGas", params: args.stateOverride != null ? [args.request, args.entryPoint, args.stateOverride] : [args.request, args.entryPoint], }); };