diff --git a/shared/constants/decimal.js b/shared/constants/decimal.js
deleted file mode 100644
index cc6090a84..000000000
--- a/shared/constants/decimal.js
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * MAX_DECIMAL represensts the maximum number of decimal values allow for the input,
- * the limitation in javascript retstricts us to keep it as 15 and below.
- */
-export const MAX_DECIMAL = 15;
diff --git a/ui/components/app/currency-input/currency-input.js b/ui/components/app/currency-input/currency-input.js
index a87393d4a..5e899dcde 100644
--- a/ui/components/app/currency-input/currency-input.js
+++ b/ui/components/app/currency-input/currency-input.js
@@ -14,7 +14,6 @@ import {
getNativeCurrency,
} from '../../../ducks/metamask/metamask';
import { getCurrentCurrency, getShouldShowFiat } from '../../../selectors';
-import { MAX_DECIMAL } from '../../../../shared/constants/decimal';
/**
* Component that allows user to enter currency values as a number, and props receive a converted
@@ -26,14 +25,12 @@ import { MAX_DECIMAL } from '../../../../shared/constants/decimal';
* @param options0.featureSecondary
* @param options0.onChange
* @param options0.onPreferenceToggle
- * @param options0.primaryNumberOfDecimals
*/
export default function CurrencyInput({
hexValue,
featureSecondary,
onChange,
onPreferenceToggle,
- primaryNumberOfDecimals = 8,
}) {
const t = useContext(I18nContext);
@@ -67,10 +64,7 @@ export default function CurrencyInput({
: getValueFromWeiHex({
value: hexValue,
toCurrency: ETH,
- numberOfDecimals:
- primaryNumberOfDecimals <= MAX_DECIMAL
- ? primaryNumberOfDecimals
- : MAX_DECIMAL,
+ numberOfDecimals: 8,
});
return Number(decimalValueString) || 0;
@@ -133,10 +127,7 @@ export default function CurrencyInput({
if (shouldUseFiat()) {
// Display ETH
currency = preferredCurrency || ETH;
- numberOfDecimals =
- primaryNumberOfDecimals <= MAX_DECIMAL
- ? primaryNumberOfDecimals
- : MAX_DECIMAL;
+ numberOfDecimals = 8;
} else {
// Display Fiat
currency = secondaryCurrency;
@@ -152,6 +143,7 @@ export default function CurrencyInput({
/>
);
};
+
return (
{
@@ -146,11 +145,7 @@ describe('CurrencyInput Component', () => {
const wrapper = mount(
-
+
,
{
context: { t: (str) => `${str}_t` },
@@ -162,7 +157,7 @@ describe('CurrencyInput Component', () => {
expect(wrapper.find('.unit-input__suffix')).toHaveLength(1);
expect(wrapper.find('.unit-input__suffix').text()).toStrictEqual('ETH');
expect(wrapper.find('.unit-input__input').props().value).toStrictEqual(
- 0.004327880204276,
+ 0.00432788,
);
expect(
wrapper.find('.currency-input__conversion-component').text(),
@@ -198,11 +193,7 @@ describe('CurrencyInput Component', () => {
const store = configureMockStore()(mockStore);
const wrapper = mount(
-
+
,
);
@@ -211,7 +202,7 @@ describe('CurrencyInput Component', () => {
expect(handleBlurSpy.callCount).toStrictEqual(0);
const input = wrapper.find('input');
- expect(input.props().value).toStrictEqual(0.004327880204276);
+ expect(input.props().value).toStrictEqual(0.00432788);
input.simulate('change', { target: { value: 1 } });
expect(handleChangeSpy.callCount).toStrictEqual(2);
diff --git a/ui/components/ui/token-input/token-input.component.js b/ui/components/ui/token-input/token-input.component.js
index 401d4385b..3b8d2eefb 100644
--- a/ui/components/ui/token-input/token-input.component.js
+++ b/ui/components/ui/token-input/token-input.component.js
@@ -11,7 +11,6 @@ import {
import { ETH } from '../../../helpers/constants/common';
import { addHexPrefix } from '../../../../app/scripts/lib/util';
-import { MAX_DECIMAL } from '../../../../shared/constants/decimal';
/**
* Component that allows user to enter token values as a number, and props receive a converted
@@ -35,7 +34,6 @@ export default class TokenInput extends PureComponent {
symbol: PropTypes.string,
}).isRequired,
tokenExchangeRates: PropTypes.object,
- primaryNumberOfDecimals: PropTypes.number,
};
constructor(props) {
@@ -110,7 +108,6 @@ export default class TokenInput extends PureComponent {
currentCurrency,
hideConversion,
token,
- primaryNumberOfDecimals = 8,
} = this.props;
const { decimalValue } = this.state;
@@ -132,10 +129,7 @@ export default class TokenInput extends PureComponent {
} else {
// Display ETH
currency = ETH;
- numberOfDecimals =
- primaryNumberOfDecimals <= MAX_DECIMAL
- ? primaryNumberOfDecimals
- : MAX_DECIMAL;
+ numberOfDecimals = 6;
}
const decimalEthValue = decimalValue * tokenExchangeRate || 0;
diff --git a/ui/components/ui/unit-input/unit-input.component.js b/ui/components/ui/unit-input/unit-input.component.js
index b496a914f..10e14b12f 100644
--- a/ui/components/ui/unit-input/unit-input.component.js
+++ b/ui/components/ui/unit-input/unit-input.component.js
@@ -1,9 +1,6 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
-import { MAX_DECIMAL } from '../../../../shared/constants/decimal';
-
-const DECIMAL_REGEX = /\.(\d*)/u;
function removeLeadingZeroes(str) {
return str.replace(/^0*(?=\d)/u, '');
@@ -65,11 +62,6 @@ export default class UnitInput extends PureComponent {
handleChange = (event) => {
const { value: userInput } = event.target;
- const match = DECIMAL_REGEX.exec(userInput);
- if (match?.[1]?.length > MAX_DECIMAL) {
- return;
- }
-
let value = userInput;
if (userInput.length && userInput.length > 1) {
diff --git a/ui/pages/send/send-content/send-amount-row/send-amount-row.component.js b/ui/pages/send/send-content/send-amount-row/send-amount-row.component.js
index 9cd3eed09..711437e46 100644
--- a/ui/pages/send/send-content/send-amount-row/send-amount-row.component.js
+++ b/ui/pages/send/send-content/send-amount-row/send-amount-row.component.js
@@ -4,7 +4,6 @@ import SendRowWrapper from '../send-row-wrapper';
import UserPreferencedCurrencyInput from '../../../../components/app/user-preferenced-currency-input';
import UserPreferencedTokenInput from '../../../../components/app/user-preferenced-token-input';
import { ASSET_TYPES } from '../../../../ducks/send';
-import { MAX_DECIMAL } from '../../../../../shared/constants/decimal';
import AmountMaxButton from './amount-max-button';
export default class SendAmountRow extends Component {
@@ -32,14 +31,12 @@ export default class SendAmountRow extends Component {
onChange={this.handleChange}
token={asset.details}
value={amount}
- primaryNumberOfDecimals={asset.decimals}
/>
) : (
);
}