@rarible/estimate-middleware
Advanced tools
Comparing version 0.9.10 to 0.9.13
@@ -8,2 +8,2 @@ import type { JsonRpcEngine, JsonRpcMiddleware } from "json-rpc-engine"; | ||
*/ | ||
export declare function createEstimateGasMiddleware(engine: JsonRpcEngine, force?: boolean, threshold?: number): JsonRpcMiddleware<string[], Block>; | ||
export declare function createEstimateGasMiddleware(engine: JsonRpcEngine, force?: boolean, threshold?: number, multiplier?: number): JsonRpcMiddleware<string[], Block>; |
@@ -13,6 +13,7 @@ "use strict"; | ||
*/ | ||
function createEstimateGasMiddleware(engine, force, threshold) { | ||
function createEstimateGasMiddleware(engine, force, threshold, multiplier) { | ||
var _this = this; | ||
if (force === void 0) { force = false; } | ||
if (threshold === void 0) { threshold = 1.03; } | ||
if (multiplier === void 0) { multiplier = 2; } | ||
return (0, json_rpc_engine_1.createAsyncMiddleware)(function (req, res, next) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { | ||
@@ -64,7 +65,10 @@ var params, gasLimitResponse, limitRaw, limitHex, multiplied, maxPriorityFeePerGasResponse, maxPriorityFeePerGasResponseRaw, blockResponse, baseFeeRaw, baseFee, maxPriorityFeePerGas, maxFeePerGasHex, error_1; | ||
blockResponse = _a.sent(); | ||
baseFeeRaw = extractbaseFeePerGas(blockResponse); | ||
baseFeeRaw = extractBaseFeePerGas(blockResponse); | ||
if (maxPriorityFeePerGasResponseRaw && baseFeeRaw) { | ||
baseFee = (0, bn_1.toBn)(extractHex(baseFeeRaw), 16).toFixed(0); | ||
if (params.gasPrice !== undefined) { | ||
delete params.gasPrice; | ||
} | ||
baseFee = (0, bn_1.toBn)(extractHex(baseFeeRaw), 16).multipliedBy(multiplier).toFixed(0); | ||
maxPriorityFeePerGas = extractHex(maxPriorityFeePerGasResponseRaw); | ||
maxFeePerGasHex = (0, bn_1.toBn)(maxPriorityFeePerGas, 16).plus(baseFee).minus(1).toString(16); | ||
maxFeePerGasHex = (0, bn_1.toBn)(maxPriorityFeePerGas, 16).plus(baseFee).toString(16); | ||
params["maxPriorityFeePerGas"] = maxPriorityFeePerGasResponseRaw; | ||
@@ -102,3 +106,3 @@ params["maxFeePerGas"] = withPrefix(maxFeePerGasHex); | ||
} | ||
function extractbaseFeePerGas(response) { | ||
function extractBaseFeePerGas(response) { | ||
if (isJSONRpcResponse(response)) { | ||
@@ -105,0 +109,0 @@ if (response.error) { |
{ | ||
"name": "@rarible/estimate-middleware", | ||
"version": "0.9.10", | ||
"version": "0.9.13", | ||
"keywords": [ | ||
@@ -39,3 +39,3 @@ "rarible", | ||
}, | ||
"gitHead": "d942b0e14cc928ff246d0baad5d578441175e719" | ||
"gitHead": "c418090181be16aca5a6d6227214a037a660e849" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34980
249