mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #12830 from MetaMask/Version-v10.6.3
Version v10.6.3 RC
This commit is contained in:
commit
036edda11d
@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [10.6.3]
|
||||
### Fixed
|
||||
- [##12822](https://github.com/MetaMask/metamask-extension/pull/#12822): Fix `replaceChildren` and `function.prototype.apply` errors that could make the app unusable on older browsers due to a bug in our logo component.
|
||||
- [#61e0526d5](https://github.com/MetaMask/metamask-extension/pull/61e0526d5): Fix requesting of swaps quotes for token pairs that have highly precise exchange rates.
|
||||
- [##12773](https://github.com/MetaMask/metamask-extension/pull/#12773): Prevent token input in send flow from adding arbitary trailing decimal values to input
|
||||
|
||||
## [10.6.2]
|
||||
### Fixed
|
||||
- [#12770](https://github.com/MetaMask/metamask-extension/pull/12770): Fixed display of best quote in swaps quotes modal
|
||||
@ -2603,7 +2609,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Uncategorized
|
||||
- Added the ability to restore accounts from seed words.
|
||||
|
||||
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.6.2...HEAD
|
||||
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.6.3...HEAD
|
||||
[10.6.3]: https://github.com/MetaMask/metamask-extension/compare/v10.6.2...v10.6.3
|
||||
[10.6.2]: https://github.com/MetaMask/metamask-extension/compare/v10.6.1...v10.6.2
|
||||
[10.6.1]: https://github.com/MetaMask/metamask-extension/compare/v10.6.0...v10.6.1
|
||||
[10.6.0]: https://github.com/MetaMask/metamask-extension/compare/v10.5.2...v10.6.0
|
||||
|
@ -746,7 +746,7 @@ export default class SwapsController {
|
||||
const conversionRateForSorting = tokenConversionRate || 1;
|
||||
|
||||
const ethValueOfTokens = decimalAdjustedDestinationAmount.times(
|
||||
conversionRateForSorting,
|
||||
conversionRateForSorting.toString(10),
|
||||
10,
|
||||
);
|
||||
|
||||
@ -768,7 +768,7 @@ export default class SwapsController {
|
||||
quote.ethValueOfTokens = ethValueOfTokens.toString(10);
|
||||
quote.overallValueOfQuote = overallValueOfQuoteForSorting.toString(10);
|
||||
quote.metaMaskFeeInEth = metaMaskFeeInTokens
|
||||
.times(conversionRateForCalculations)
|
||||
.times(conversionRateForCalculations.toString(10))
|
||||
.toString(10);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "metamask-crx",
|
||||
"version": "10.6.2",
|
||||
"version": "10.6.3",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -111,7 +111,7 @@
|
||||
"@metamask/eth-token-tracker": "^3.0.1",
|
||||
"@metamask/etherscan-link": "^2.1.0",
|
||||
"@metamask/jazzicon": "^2.0.0",
|
||||
"@metamask/logo": "^3.1.0",
|
||||
"@metamask/logo": "^3.1.1",
|
||||
"@metamask/obs-store": "^5.0.0",
|
||||
"@metamask/post-message-stream": "^4.0.0",
|
||||
"@metamask/providers": "^8.1.1",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import BigNumber from 'bignumber.js';
|
||||
import UnitInput from '../unit-input';
|
||||
import CurrencyDisplay from '../currency-display';
|
||||
import { getWeiHexFromDecimalValue } from '../../../helpers/utils/conversions.util';
|
||||
@ -7,6 +8,7 @@ import {
|
||||
conversionUtil,
|
||||
multiplyCurrencies,
|
||||
} from '../../../../shared/modules/conversion.utils';
|
||||
|
||||
import { ETH } from '../../../helpers/constants/common';
|
||||
import { addHexPrefix } from '../../../../app/scripts/lib/util';
|
||||
|
||||
@ -75,12 +77,13 @@ export default class TokenInput extends PureComponent {
|
||||
return Number(decimalValueString) ? decimalValueString : '';
|
||||
}
|
||||
|
||||
handleChange = (decimalValue) => {
|
||||
handleChange = (decimalValue, applyDecimals = false) => {
|
||||
const { token: { decimals } = {}, onChange } = this.props;
|
||||
|
||||
let newDecimalValue = decimalValue;
|
||||
if (decimals) {
|
||||
newDecimalValue = parseFloat(decimalValue).toFixed(decimals);
|
||||
|
||||
if (decimals && decimalValue && applyDecimals) {
|
||||
newDecimalValue = new BigNumber(decimalValue, 10).toFixed(decimals);
|
||||
}
|
||||
|
||||
const multiplier = Math.pow(10, Number(decimals || 0));
|
||||
@ -94,6 +97,10 @@ export default class TokenInput extends PureComponent {
|
||||
onChange(hexValue);
|
||||
};
|
||||
|
||||
handleBlur = (decimalValue) => {
|
||||
this.handleChange(decimalValue, true);
|
||||
};
|
||||
|
||||
renderConversionComponent() {
|
||||
const {
|
||||
tokenExchangeRates,
|
||||
@ -155,6 +162,7 @@ export default class TokenInput extends PureComponent {
|
||||
{...restProps}
|
||||
suffix={token.symbol}
|
||||
onChange={this.handleChange}
|
||||
onBlur={this.handleBlur}
|
||||
value={decimalValue}
|
||||
>
|
||||
{this.renderConversionComponent()}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { shallow, mount } from 'enzyme';
|
||||
import sinon from 'sinon';
|
||||
import { Provider } from 'react-redux';
|
||||
import configureMockStore from 'redux-mock-store';
|
||||
import UnitInput from '../unit-input';
|
||||
@ -207,12 +206,10 @@ describe('TokenInput Component', () => {
|
||||
});
|
||||
|
||||
describe('handling actions', () => {
|
||||
const handleChangeSpy = sinon.spy();
|
||||
const handleBlurSpy = sinon.spy();
|
||||
const handleChangeSpy = jest.fn();
|
||||
|
||||
afterEach(() => {
|
||||
handleChangeSpy.resetHistory();
|
||||
handleBlurSpy.resetHistory();
|
||||
handleChangeSpy.mockClear();
|
||||
});
|
||||
|
||||
it('should call onChange on input changes with the hex value for ETH', () => {
|
||||
@ -238,8 +235,7 @@ describe('TokenInput Component', () => {
|
||||
);
|
||||
|
||||
expect(wrapper).toHaveLength(1);
|
||||
expect(handleChangeSpy.callCount).toStrictEqual(0);
|
||||
expect(handleBlurSpy.callCount).toStrictEqual(0);
|
||||
expect(handleChangeSpy.mock.calls).toHaveLength(0);
|
||||
|
||||
const tokenInputInstance = wrapper.find(TokenInput).at(0).instance();
|
||||
expect(tokenInputInstance.state.decimalValue).toStrictEqual(0);
|
||||
@ -250,13 +246,13 @@ describe('TokenInput Component', () => {
|
||||
const input = wrapper.find('input');
|
||||
expect(input.props().value).toStrictEqual(0);
|
||||
|
||||
input.simulate('change', { target: { value: 1 } });
|
||||
expect(handleChangeSpy.callCount).toStrictEqual(1);
|
||||
expect(handleChangeSpy.calledWith('2710')).toStrictEqual(true);
|
||||
input.simulate('change', { target: { value: '1' } });
|
||||
expect(handleChangeSpy.mock.calls).toHaveLength(1);
|
||||
expect(handleChangeSpy.mock.calls[0][0]).toStrictEqual('2710');
|
||||
expect(wrapper.find('.currency-display-component').text()).toStrictEqual(
|
||||
'2ETH',
|
||||
);
|
||||
expect(tokenInputInstance.state.decimalValue).toStrictEqual(1);
|
||||
expect(tokenInputInstance.state.decimalValue).toStrictEqual('1');
|
||||
expect(tokenInputInstance.state.hexValue).toStrictEqual('2710');
|
||||
});
|
||||
|
||||
@ -285,8 +281,7 @@ describe('TokenInput Component', () => {
|
||||
);
|
||||
|
||||
expect(wrapper).toHaveLength(1);
|
||||
expect(handleChangeSpy.callCount).toStrictEqual(0);
|
||||
expect(handleBlurSpy.callCount).toStrictEqual(0);
|
||||
expect(handleChangeSpy.mock.calls).toHaveLength(0);
|
||||
|
||||
const tokenInputInstance = wrapper.find(TokenInput).at(0).instance();
|
||||
expect(tokenInputInstance.state.decimalValue).toStrictEqual(0);
|
||||
@ -297,13 +292,13 @@ describe('TokenInput Component', () => {
|
||||
const input = wrapper.find('input');
|
||||
expect(input.props().value).toStrictEqual(0);
|
||||
|
||||
input.simulate('change', { target: { value: 1 } });
|
||||
expect(handleChangeSpy.callCount).toStrictEqual(1);
|
||||
expect(handleChangeSpy.calledWith('2710')).toStrictEqual(true);
|
||||
input.simulate('change', { target: { value: '1' } });
|
||||
expect(handleChangeSpy.mock.calls).toHaveLength(1);
|
||||
expect(handleChangeSpy.mock.calls[0][0]).toStrictEqual('2710');
|
||||
expect(wrapper.find('.currency-display-component').text()).toStrictEqual(
|
||||
'$462.12USD',
|
||||
);
|
||||
expect(tokenInputInstance.state.decimalValue).toStrictEqual(1);
|
||||
expect(tokenInputInstance.state.decimalValue).toStrictEqual('1');
|
||||
expect(tokenInputInstance.state.hexValue).toStrictEqual('2710');
|
||||
});
|
||||
|
||||
@ -345,4 +340,84 @@ describe('TokenInput Component', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Token Input Decimals Check', () => {
|
||||
const handleChangeSpy = jest.fn();
|
||||
|
||||
afterEach(() => {
|
||||
handleChangeSpy.mockClear();
|
||||
});
|
||||
|
||||
it('should render incorrect hex onChange when input decimals is more than token decimals', () => {
|
||||
const mockStore = {
|
||||
metamask: {
|
||||
currentCurrency: 'usd',
|
||||
conversionRate: 231.06,
|
||||
},
|
||||
};
|
||||
const store = configureMockStore()(mockStore);
|
||||
const wrapper = mount(
|
||||
<Provider store={store}>
|
||||
<TokenInput
|
||||
onChange={handleChangeSpy}
|
||||
token={{
|
||||
address: '0x1',
|
||||
decimals: 4,
|
||||
symbol: 'ABC',
|
||||
}}
|
||||
tokenExchangeRates={{ '0x1': 2 }}
|
||||
showFiat
|
||||
currentCurrency="usd"
|
||||
/>
|
||||
</Provider>,
|
||||
);
|
||||
|
||||
expect(wrapper).toHaveLength(1);
|
||||
expect(handleChangeSpy.mock.calls).toHaveLength(0);
|
||||
|
||||
const input = wrapper.find('input');
|
||||
expect(input.props().value).toStrictEqual(0);
|
||||
|
||||
input.simulate('change', { target: { value: '1.11111' } });
|
||||
expect(handleChangeSpy.mock.calls).toHaveLength(1);
|
||||
|
||||
expect(handleChangeSpy.mock.calls[0][0]).toStrictEqual(
|
||||
'2b67.1999999999999999999a',
|
||||
);
|
||||
});
|
||||
|
||||
it('should render correct hex onChange when input decimals is more than token decimals by omitting excess fractional part on blur', () => {
|
||||
const mockStore = {
|
||||
metamask: {
|
||||
currentCurrency: 'usd',
|
||||
conversionRate: 231.06,
|
||||
},
|
||||
};
|
||||
const store = configureMockStore()(mockStore);
|
||||
|
||||
const wrapper = mount(
|
||||
<Provider store={store}>
|
||||
<TokenInput
|
||||
onChange={handleChangeSpy}
|
||||
token={{
|
||||
address: '0x1',
|
||||
decimals: 4,
|
||||
symbol: 'ABC',
|
||||
}}
|
||||
tokenExchangeRates={{ '0x1': 2 }}
|
||||
showFiat
|
||||
currentCurrency="usd"
|
||||
/>
|
||||
</Provider>,
|
||||
);
|
||||
expect(wrapper).toHaveLength(1);
|
||||
|
||||
const input = wrapper.find('input');
|
||||
|
||||
input.simulate('blur', { target: { value: '1.11111' } });
|
||||
|
||||
expect(handleChangeSpy.mock.calls).toHaveLength(1);
|
||||
expect(handleChangeSpy.mock.calls[0][0]).toStrictEqual('2b67');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -17,6 +17,7 @@ export default class UnitInput extends PureComponent {
|
||||
actionComponent: PropTypes.node,
|
||||
error: PropTypes.bool,
|
||||
onChange: PropTypes.func,
|
||||
onBlur: PropTypes.func,
|
||||
placeholder: PropTypes.string,
|
||||
suffix: PropTypes.string,
|
||||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
@ -55,6 +56,8 @@ export default class UnitInput extends PureComponent {
|
||||
if (value === '') {
|
||||
this.setState({ value: '0' });
|
||||
}
|
||||
|
||||
this.props.onBlur && this.props.onBlur(value);
|
||||
};
|
||||
|
||||
handleChange = (event) => {
|
||||
|
@ -3999,10 +3999,10 @@
|
||||
color "^0.11.3"
|
||||
mersenne-twister "^1.1.0"
|
||||
|
||||
"@metamask/logo@^3.1.0":
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@metamask/logo/-/logo-3.1.0.tgz#6b7b9b90b6d846583558de855511d34796735855"
|
||||
integrity sha512-W0FBwIaG1pC4Vk/ZdUJYv7PDjnAbQJro3yhEXN7WXEdz8kyVcxFb6dj0Dpe6ytaveYiqIL6+iDDWMevzU2MpVw==
|
||||
"@metamask/logo@^3.1.1":
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@metamask/logo/-/logo-3.1.1.tgz#0a40bcfc462a70aa2110efc737767ca7ba188fa3"
|
||||
integrity sha512-8/ObOWyBtwbe3/r9QbXMs+aKK2EgcYp2NiF4fm1xIO/c3aBMN5wBc2zUnl1lpHU71l70/OH5cxHbyDYoEgdMoA==
|
||||
dependencies:
|
||||
gl-mat4 "1.1.4"
|
||||
gl-vec3 "1.0.3"
|
||||
|
Loading…
Reference in New Issue
Block a user