"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeCustomTransport = void 0;
var tslib_1 = require("tslib");
var viem_1 = require("viem");
var utils_1 = require("../../src/utils");
var makeCustomTransport = function (feeParams) {
    if (feeParams === void 0) { feeParams = {}; }
    var _a = feeParams.stdLastBaseFeePerGas, stdLastBaseFeePerGas = _a === void 0 ? (0, utils_1.parseUnits)("12", 9) : _a, _b = feeParams.stdMaxPriorityFeePerGas, stdMaxPriorityFeePerGas = _b === void 0 ? (0, utils_1.parseUnits)("1", 9) : _b;
    var stdMaxFeePerGas = stdLastBaseFeePerGas.add(stdMaxPriorityFeePerGas);
    var stdGasPrice = stdMaxFeePerGas;
    return (0, viem_1.custom)({
        request: function (_a) {
            return tslib_1.__awaiter(this, arguments, void 0, function (_b) {
                var _c, _d;
                var method = _b.method, params = _b.params;
                return tslib_1.__generator(this, function (_e) {
                    switch (method) {
                        case "eth_gasPrice":
                            return [2, BigInt(stdGasPrice.toString())];
                        case "eth_getBlockByNumber":
                            return [2, { baseFeePerGas: BigInt(stdLastBaseFeePerGas.toString()) }];
                        case "eth_maxPriorityFeePerGas":
                            return [2, BigInt(stdMaxPriorityFeePerGas.toString())];
                        case "linea_estimateGas":
                            return [2, {
                                    baseFeePerGas: BigInt(7),
                                    priorityFeePerGas: BigInt(stdMaxPriorityFeePerGas
                                        .mul(((_d = (_c = params[0]) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.slice(2).length) > 0 ? 2 : 1)
                                        .toString()),
                                    gasLimit: BigInt("0"),
                                }];
                        default:
                            throw new Error("Unsupported method: ".concat(method, "."));
                    }
                    return [2];
                });
            });
        },
    });
};
exports.makeCustomTransport = makeCustomTransport;
//# sourceMappingURL=transport.js.map