From 75a5a26b6a9ab2ffec86cc2b3368681f5b909412 Mon Sep 17 00:00:00 2001 From: tenthirtyone Date: Fri, 24 Jun 2022 12:23:36 -0500 Subject: [PATCH] fix: Properly handle 'estimate' for `defaultTransactionGasLimit` option on the CLI #3233 --- src/chains/ethereum/options/src/miner-options.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/chains/ethereum/options/src/miner-options.ts b/src/chains/ethereum/options/src/miner-options.ts index 0f36586ec8..670cb0dff5 100644 --- a/src/chains/ethereum/options/src/miner-options.ts +++ b/src/chains/ethereum/options/src/miner-options.ts @@ -195,6 +195,18 @@ const toBigIntOrString = (str: string) => { return BigInt(str); } }; +/** + * Handles defaultTransactionGasLimit special case of 'estimate' for tx value. + * + * @param str - the string literal 'estimate' or string that that represents a bigint, number, or hexadecimal value. + */ +const estimateOrToBigIntOrString = (str: string) => { + if (str === "estimate") { + return str; + } else { + return toBigIntOrString(str); + } +}; /** * Attempts to convert strings that don't start with `0x` to a number @@ -259,7 +271,7 @@ export const MinerOptions: Definitions = { 'Sets the default transaction gas limit in WEI. Set to "estimate" to use an estimate (slows down transaction execution by 40%+).', default: () => Quantity.from(90_000), cliType: "string", - cliCoerce: toBigIntOrString + cliCoerce: estimateOrToBigIntOrString }, difficulty: { normalize: Quantity.from,