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

17 lines 1 kB
import { applyUserOpOverrideOrFeeOption } from "../../utils/index.js"; export const defaultFeeEstimator = (client) => async (struct, { overrides, feeOptions }) => { const feeData = await client.estimateFeesPerGas(); if (!feeData.maxFeePerGas || feeData.maxPriorityFeePerGas == null) { throw new Error("feeData is missing maxFeePerGas or maxPriorityFeePerGas"); } let maxPriorityFeePerGas = await client.estimateMaxPriorityFeePerGas(); maxPriorityFeePerGas = applyUserOpOverrideOrFeeOption(maxPriorityFeePerGas, overrides?.maxPriorityFeePerGas, feeOptions?.maxPriorityFeePerGas); let maxFeePerGas = feeData.maxFeePerGas - feeData.maxPriorityFeePerGas + BigInt(maxPriorityFeePerGas); maxFeePerGas = applyUserOpOverrideOrFeeOption(maxFeePerGas, overrides?.maxFeePerGas, feeOptions?.maxFeePerGas); struct.maxFeePerGas = maxFeePerGas; struct.maxPriorityFeePerGas = maxPriorityFeePerGas; return struct; }; //# sourceMappingURL=feeEstimator.js.map