@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
22 lines • 1.52 kB
JavaScript
import { deepHexlify, resolveProperties } from "../../utils/index.js";
import { applyUserOpOverrideOrFeeOption } from "../../utils/userop.js";
export const defaultGasEstimator = (client) => async (struct, { account, overrides, feeOptions }) => {
const request = deepHexlify(await resolveProperties(struct));
const estimates = await client.estimateUserOperationGas(request, account.getEntryPoint().address, overrides?.stateOverride);
const callGasLimit = applyUserOpOverrideOrFeeOption(estimates.callGasLimit, overrides?.callGasLimit, feeOptions?.callGasLimit);
const verificationGasLimit = applyUserOpOverrideOrFeeOption(estimates.verificationGasLimit, overrides?.verificationGasLimit, feeOptions?.verificationGasLimit);
const preVerificationGas = applyUserOpOverrideOrFeeOption(estimates.preVerificationGas, overrides?.preVerificationGas, feeOptions?.preVerificationGas);
struct.callGasLimit = callGasLimit;
struct.verificationGasLimit = verificationGasLimit;
struct.preVerificationGas = preVerificationGas;
const entryPoint = account.getEntryPoint();
if (entryPoint.version === "0.7.0") {
const paymasterVerificationGasLimit = applyUserOpOverrideOrFeeOption(estimates.paymasterVerificationGasLimit, overrides
?.paymasterVerificationGasLimit, feeOptions
?.paymasterVerificationGasLimit);
struct.paymasterVerificationGasLimit =
paymasterVerificationGasLimit;
}
return struct;
};
//# sourceMappingURL=gasEstimator.js.map