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 requires parameters in string format
|
||||||
getGasFeeTimeEstimate(
|
getGasFeeTimeEstimate(
|
||||||
new BigNumber(priority).toString(10),
|
new BigNumber(priority, 10).toString(10),
|
||||||
new BigNumber(fee).toString(10),
|
new BigNumber(fee, 10).toString(10),
|
||||||
).then((result) => {
|
).then((result) => {
|
||||||
if (maxFeePerGas === fee && maxPriorityFeePerGas === priority) {
|
if (maxFeePerGas === fee && maxPriorityFeePerGas === priority) {
|
||||||
setCustomEstimatedTime(result);
|
setCustomEstimatedTime(result);
|
||||||
|
@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
|
|||||||
import Typography from '../typography/typography';
|
import Typography from '../typography/typography';
|
||||||
import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system';
|
import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system';
|
||||||
|
|
||||||
|
const DECIMAL_REGEX = /\.(\d*)/u;
|
||||||
|
|
||||||
export default function NumericInput({
|
export default function NumericInput({
|
||||||
detailText = '',
|
detailText = '',
|
||||||
value = 0,
|
value = 0,
|
||||||
@ -26,7 +28,10 @@ export default function NumericInput({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onChange={(e) => {
|
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"
|
min="0"
|
||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user