import { __awaiter, __generator } from "tslib";
import { custom } from "viem";
import { parseUnits } from "../../src/utils";
export var makeCustomTransport = function (feeParams) {
    if (feeParams === void 0) { feeParams = {}; }
    var _a = feeParams.stdLastBaseFeePerGas, stdLastBaseFeePerGas = _a === void 0 ? parseUnits("12", 9) : _a, _b = feeParams.stdMaxPriorityFeePerGas, stdMaxPriorityFeePerGas = _b === void 0 ? parseUnits("1", 9) : _b;
    var stdMaxFeePerGas = stdLastBaseFeePerGas.add(stdMaxPriorityFeePerGas);
    var stdGasPrice = stdMaxFeePerGas;
    return custom({
        // eslint-disable-next-line require-await
        request: function (_a) {
            return __awaiter(this, arguments, void 0, function (_b) {
                var _c, _d;
                var method = _b.method, params = _b.params;
                return __generator(this, function (_e) {
                    switch (method) {
                        case "eth_gasPrice":
                            return [2 /*return*/, BigInt(stdGasPrice.toString())];
                        case "eth_getBlockByNumber":
                            return [2 /*return*/, { baseFeePerGas: BigInt(stdLastBaseFeePerGas.toString()) }];
                        case "eth_maxPriorityFeePerGas":
                            return [2 /*return*/, BigInt(stdMaxPriorityFeePerGas.toString())];
                        case "linea_estimateGas":
                            // For testing purposes, double the priority fee if txnData is not the empty string "0x"
                            return [2 /*return*/, {
                                    // Linea base fee is always 7 wei
                                    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 /*return*/];
                });
            });
        },
    });
};
//# sourceMappingURL=transport.js.map