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

fix: properly handle 'estimate' for defaultTransactionGasLimit option on the CLI #3233

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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