@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
21 lines • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultFeeEstimator = void 0;
const index_js_1 = require("../../utils/index.js");
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 = (0, index_js_1.applyUserOpOverrideOrFeeOption)(maxPriorityFeePerGas, overrides?.maxPriorityFeePerGas, feeOptions?.maxPriorityFeePerGas);
let maxFeePerGas = feeData.maxFeePerGas -
feeData.maxPriorityFeePerGas +
BigInt(maxPriorityFeePerGas);
maxFeePerGas = (0, index_js_1.applyUserOpOverrideOrFeeOption)(maxFeePerGas, overrides?.maxFeePerGas, feeOptions?.maxFeePerGas);
struct.maxFeePerGas = maxFeePerGas;
struct.maxPriorityFeePerGas = maxPriorityFeePerGas;
return struct;
};
exports.defaultFeeEstimator = defaultFeeEstimator;
//# sourceMappingURL=feeEstimator.js.map