"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.eip1559 = void 0;
var tslib_1 = require("tslib");
var linea_1 = require("viem/linea");
var constants_1 = require("../../constants");
var utils_1 = require("../../utils");
function eip1559(provider, opts) {
    var _a, _b, _c, _d, _e;
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var _unsignedTx, priorityFeeMultiplier, unsignedTx, _f, baseFeePerGas, _priorityFeePerGas, priorityFeePerGas;
        return tslib_1.__generator(this, function (_g) {
            switch (_g.label) {
                case 0:
                    _unsignedTx = opts.unsignedTx, priorityFeeMultiplier = opts.priorityFeeMultiplier;
                    unsignedTx = _unsignedTx;
                    return [4, (0, linea_1.estimateGas)(provider, {
                            account: (_a = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.from) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS,
                            to: (_b = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.to) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS,
                            value: BigInt((_d = (_c = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.value) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : "0"),
                            data: (_e = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.data) !== null && _e !== void 0 ? _e : "0x",
                        })];
                case 1:
                    _f = _g.sent(), baseFeePerGas = _f.baseFeePerGas, _priorityFeePerGas = _f.priorityFeePerGas;
                    priorityFeePerGas = (_priorityFeePerGas * BigInt(priorityFeeMultiplier.toString())) / BigInt(utils_1.fixedPointAdjustment.toString());
                    return [2, {
                            maxFeePerGas: baseFeePerGas + priorityFeePerGas,
                            maxPriorityFeePerGas: priorityFeePerGas,
                        }];
            }
        });
    });
}
exports.eip1559 = eip1559;
//# sourceMappingURL=linea-viem.js.map