"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.eip1559 = eip1559;
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) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var _unsignedTx, priorityFeeMultiplier, unsignedTx, _a, baseFeePerGas, _priorityFeePerGas, priorityFeePerGas;
        var _b, _c, _d, _e, _f;
        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: (_b = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.from) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS,
                            to: (_c = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.to) !== null && _c !== void 0 ? _c : constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS,
                            value: BigInt((_e = (_d = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.value) === null || _d === void 0 ? void 0 : _d.toString()) !== null && _e !== void 0 ? _e : "0"),
                            data: (_f = unsignedTx === null || unsignedTx === void 0 ? void 0 : unsignedTx.data) !== null && _f !== void 0 ? _f : "0x",
                        })];
                case 1:
                    _a = _g.sent(), baseFeePerGas = _a.baseFeePerGas, _priorityFeePerGas = _a.priorityFeePerGas;
                    priorityFeePerGas = (_priorityFeePerGas * BigInt(priorityFeeMultiplier.toString())) / BigInt(utils_1.fixedPointAdjustment.toString());
                    return [2, {
                            maxFeePerGas: baseFeePerGas + priorityFeePerGas,
                            maxPriorityFeePerGas: priorityFeePerGas,
                        }];
            }
        });
    });
}
//# sourceMappingURL=linea-viem.js.map