Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- fix(swaps): set default slippage when source or destination token is not stablecoin ([#14730](https://github.com/MetaMask/metamask-mobile/pull/14730))
- fix(bridge): fix transaction history for EVM and Solana bridge transactions ([#14759](https://github.com/MetaMask/metamask-mobile/pull/14759))
- fix(bridge): change networks properly when user switches between source and destination tokens ([#14812](https://github.com/MetaMask/metamask-mobile/pull/14812))
- fix(bridge): fix(bridge): update quote details card toggle to handle same chain swaps and improve slippage button layout ([#15153](https://github.com/MetaMask/metamask-mobile/pull/15153))
- fix(confirmations): fix the send crash when user puts unexpected address into recipient input([#15308](https://github.com/MetaMask/metamask-mobile/pull/15308))

## [7.45.2]

### Fixed

- fix: 15108 create a wrapper for toChecksumAddress to prevent app crash ([#15202](https://github.com/MetaMask/metamask-mobile/pull/15202))
- chore(runway): cherry-pick fix: base-x audit issue ([#15216](https://github.com/MetaMask/metamask-mobile/pull/15216))

## [7.45.1]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SendTo Component should render 1`] = `
exports[`SendTo Component render matches snapshot 1`] = `
<RNCSafeAreaView
edges={
[
Expand Down
14 changes: 11 additions & 3 deletions app/components/Views/confirmations/legacy/SendFlow/SendTo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
const { toAccount } = this.state;
const { addressBook, globalChainId, internalAccounts } = this.props;
const networkAddressBook = addressBook[globalChainId] || {};
const checksummedAddress = safeToChecksumAddress(toAccount);
const checksummedAddress = this.safeChecksumAddress(toAccount);
return !!(
networkAddressBook[checksummedAddress] ||
internalAccounts.find((account) =>
Expand Down Expand Up @@ -381,7 +381,7 @@

const networkAddressBook = addressBook[globalChainId] || {};

const checksummedAddress = safeToChecksumAddress(toAccount);
const checksummedAddress = this.safeChecksumAddress(toAccount);
const matchingAccount = internalAccounts.find((account) =>
toLowerCaseEquals(account.address, checksummedAddress),
);
Expand Down Expand Up @@ -481,6 +481,14 @@
this.setState({ showAmbiguousAcountWarning: false });
};

safeChecksumAddress = (address) => {
try {
return toChecksumAddress(address);

Check failure on line 486 in app/components/Views/confirmations/legacy/SendFlow/SendTo/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

'toChecksumAddress' is not defined
} catch (error) {
return address;
}
};

render = () => {
const { ticker, addressBook, globalChainId } = this.props;
const {
Expand All @@ -499,7 +507,7 @@
const colors = this.context.colors || mockTheme.colors;
const styles = createStyles(colors);

const checksummedAddress = toAccount && safeToChecksumAddress(toAccount);
const checksummedAddress = this.safeChecksumAddress(toAccount);
const existingAddressName = this.getAddressNameFromBookOrInternalAccounts(
toEnsAddressResolved || toAccount,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SendTo from './index';
import { ThemeContext, mockTheme } from '../../../../../../util/theme';
import initialRootState from '../../../../../../util/test/initial-root-state';
import { validateAddressOrENS } from '../../../../../../util/address';
import { SendViewSelectorsIDs } from '../../../../../../../e2e/selectors/SendFlow/SendView.selectors';

jest.mock('@react-navigation/native', () => {
const actualNav = jest.requireActual('@react-navigation/native');
Expand Down Expand Up @@ -54,7 +55,7 @@ describe('SendTo Component', () => {
);
});

it('should render', () => {
it('render matches snapshot', () => {
const wrapper = render(
<Provider store={store}>
<ThemeContext.Provider value={mockTheme}>
Expand All @@ -65,7 +66,7 @@ describe('SendTo Component', () => {
expect(wrapper).toMatchSnapshot();
});

it('should navigate to Amount screen', () => {
it('navigates to Amount screen', () => {
const MOCK_TARGET_ADDRESS = '0x0000000000000000000000000000000000000000';
const { navigate } = navigationPropMock;
const routeProps = {
Expand All @@ -86,4 +87,23 @@ describe('SendTo Component', () => {
fireEvent.press(screen.getByText('Next'));
expect(navigate).toHaveBeenCalledWith('Amount');
});

it('shows the warning message when the target address is invalid', () => {
const { getByText, getByTestId } = render(
<Provider store={store}>
<ThemeContext.Provider value={mockTheme}>
<SendTo navigation={navigationPropMock} route={routeMock} />
</ThemeContext.Provider>
</Provider>,
);

const toInput = getByTestId(SendViewSelectorsIDs.ADDRESS_INPUT);
fireEvent.changeText(toInput, 'invalid address');

const expectedWarningMessage = getByText(
'No address has been set for this name.',
);

expect(expectedWarningMessage).toBeOnTheScreen();
});
});
Loading