Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix: Properly handle 'estimate' for defaultTransactionGasLimit opti…
Browse files Browse the repository at this point in the history
…on on the CLI #3233
  • Loading branch information
tenthirtyone authored Jun 24, 2022
1 parent 279ab6d commit 75a5a26
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/chains/ethereum/options/src/miner-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -259,7 +271,7 @@ export const MinerOptions: Definitions<MinerConfig> = {
'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,
Expand Down

0 comments on commit 75a5a26

Please sign in to comment.