mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Adding base to BigNumber constructor to round off value (#12140)
* Adding base to BigNumber constructor to round off value * Numeric inputs to not allow more than 14 decimal places
This commit is contained in:
parent
02a4da9ad2
commit
adb56d8d16
@ -71,8 +71,8 @@ export default function GasTiming({
|
||||
) {
|
||||
// getGasFeeTimeEstimate requires parameters in string format
|
||||
getGasFeeTimeEstimate(
|
||||
new BigNumber(priority).toString(10),
|
||||
new BigNumber(fee).toString(10),
|
||||
new BigNumber(priority, 10).toString(10),
|
||||
new BigNumber(fee, 10).toString(10),
|
||||
).then((result) => {
|
||||
if (maxFeePerGas === fee && maxPriorityFeePerGas === priority) {
|
||||
setCustomEstimatedTime(result);
|
||||
|
@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
|
||||
import Typography from '../typography/typography';
|
||||
import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system';
|
||||
|
||||
const DECIMAL_REGEX = /\.(\d*)/u;
|
||||
|
||||
export default function NumericInput({
|
||||
detailText = '',
|
||||
value = 0,
|
||||
@ -26,7 +28,10 @@ export default function NumericInput({
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
onChange?.(parseFloat(e.target.value || 0, 10));
|
||||
const newValue = e.target.value;
|
||||
const match = DECIMAL_REGEX.exec(newValue);
|
||||
if (match?.[1]?.length >= 15) return;
|
||||
onChange?.(parseFloat(newValue || 0, 10));
|
||||
}}
|
||||
min="0"
|
||||
autoFocus={autoFocus}
|
||||
|
Loading…
Reference in New Issue
Block a user