Changed ETH decimal values to have 8 places for sending (#12437)

* Changed ETH decimal values to have 8 places for sending

* Fixing unit tests

* Fixing test-lint
feature/default_network_editable
VSaric 3 years ago committed by GitHub
parent 6d786a7bbf
commit 65984291b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      ui/components/app/transaction-breakdown/transaction-breakdown.test.js
  2. 4
      ui/components/ui/currency-input/currency-input.component.js
  3. 12
      ui/components/ui/currency-input/currency-input.component.test.js
  4. 2
      ui/hooks/useUserPreferencedCurrency.js
  5. 4
      ui/hooks/useUserPreferencedCurrency.test.js

@ -51,7 +51,7 @@ describe('TransactionBreakdown', () => {
['Amount', '-0.01 ETH'],
['Gas Limit (units)', '46890'],
['Gas price', '2.467043803'],
['Total', '0.010116ETH'],
['Total', '0.01011568ETH'],
]);
});
});
@ -90,7 +90,7 @@ describe('TransactionBreakdown', () => {
['Priority Fee (GWEI)', '2.467043796'],
['Total Gas Fee', '0.000077ETH'],
['Max Fee Per Gas', '0.000000003ETH'],
['Total', '0.010077ETH'],
['Total', '0.01007712ETH'],
]);
});
});

@ -69,7 +69,7 @@ export default class CurrencyInput extends PureComponent {
: getValueFromWeiHex({
value: hexValue,
toCurrency: ETH,
numberOfDecimals: 6,
numberOfDecimals: 8,
});
return Number(decimalValueString) || 0;
@ -134,7 +134,7 @@ export default class CurrencyInput extends PureComponent {
if (this.shouldUseFiat()) {
// Display ETH
currency = nativeCurrency || ETH;
numberOfDecimals = 6;
numberOfDecimals = 8;
} else {
// Display Fiat
currency = currentCurrency;

@ -120,7 +120,7 @@ describe('CurrencyInput Component', () => {
expect(wrapper.find('.unit-input__suffix').text()).toStrictEqual('USD');
expect(wrapper.find('.unit-input__input').props().value).toStrictEqual(1);
expect(wrapper.find('.currency-display-component').text()).toStrictEqual(
'0.004328ETH',
'0.00432788ETH',
);
});
@ -159,14 +159,16 @@ describe('CurrencyInput Component', () => {
.find(CurrencyInput)
.at(0)
.instance();
expect(currencyInputInstance.state.decimalValue).toStrictEqual(0.004328);
expect(currencyInputInstance.state.decimalValue).toStrictEqual(
0.00432788,
);
expect(currencyInputInstance.state.hexValue).toStrictEqual(
'f602f2234d0ea',
);
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.004328,
0.00432788,
);
expect(
wrapper.find('.currency-input__conversion-component').text(),
@ -274,7 +276,7 @@ describe('CurrencyInput Component', () => {
expect(handleChangeSpy.callCount).toStrictEqual(1);
expect(handleChangeSpy.calledWith('f602f2234d0ea')).toStrictEqual(true);
expect(wrapper.find('.currency-display-component').text()).toStrictEqual(
'0.004328ETH',
'0.00432788ETH',
);
expect(currencyInputInstance.state.decimalValue).toStrictEqual(1);
expect(currencyInputInstance.state.hexValue).toStrictEqual(
@ -375,7 +377,7 @@ describe('CurrencyInput Component', () => {
const swap = wrapper.find('.currency-input__swap-component');
swap.simulate('click');
expect(wrapper.find('.currency-display-component').text()).toStrictEqual(
'0.004328ETH',
'0.00432788ETH',
);
});
});

@ -49,7 +49,7 @@ export function useUserPreferencedCurrency(type, opts = {}) {
) {
// Display ETH
currency = nativeCurrency || ETH;
numberOfDecimals = opts.numberOfDecimals || opts.ethNumberOfDecimals || 6;
numberOfDecimals = opts.numberOfDecimals || opts.ethNumberOfDecimals || 8;
} else if (
(type === SECONDARY && useNativeCurrencyAsPrimaryCurrency) ||
(type === PRIMARY && !useNativeCurrencyAsPrimaryCurrency)

@ -20,7 +20,7 @@ const tests = [
},
result: {
currency: 'ETH',
numberOfDecimals: 6,
numberOfDecimals: 8,
},
},
{
@ -82,7 +82,7 @@ const tests = [
},
result: {
currency: 'ETH',
numberOfDecimals: 6,
numberOfDecimals: 8,
},
},
{

Loading…
Cancel
Save