@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
26 lines • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultGasEstimator = void 0;
const index_js_1 = require("../../utils/index.js");
const userop_js_1 = require("../../utils/userop.js");
const defaultGasEstimator = (client) => async (struct, { account, overrides, feeOptions }) => {
const request = (0, index_js_1.deepHexlify)(await (0, index_js_1.resolveProperties)(struct));
const estimates = await client.estimateUserOperationGas(request, account.getEntryPoint().address, overrides?.stateOverride);
const callGasLimit = (0, userop_js_1.applyUserOpOverrideOrFeeOption)(estimates.callGasLimit, overrides?.callGasLimit, feeOptions?.callGasLimit);
const verificationGasLimit = (0, userop_js_1.applyUserOpOverrideOrFeeOption)(estimates.verificationGasLimit, overrides?.verificationGasLimit, feeOptions?.verificationGasLimit);
const preVerificationGas = (0, userop_js_1.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 = (0, userop_js_1.applyUserOpOverrideOrFeeOption)(estimates.paymasterVerificationGasLimit, overrides
?.paymasterVerificationGasLimit, feeOptions
?.paymasterVerificationGasLimit);
struct.paymasterVerificationGasLimit =
paymasterVerificationGasLimit;
}
return struct;
};
exports.defaultGasEstimator = defaultGasEstimator;
//# sourceMappingURL=gasEstimator.js.map