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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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]

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
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class SendFlow extends PureComponent {
const { toAccount } = this.state;
const { addressBook, globalChainId, internalAccounts } = this.props;
const networkAddressBook = addressBook[globalChainId] || {};
const checksummedAddress = toChecksumAddress(toAccount);
const checksummedAddress = this.safeChecksumAddress(toAccount);
return !!(
networkAddressBook[checksummedAddress] ||
internalAccounts.find((account) =>
Expand Down Expand Up @@ -381,7 +381,7 @@ class SendFlow extends PureComponent {

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

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

safeChecksumAddress = (address) => {
try {
return toChecksumAddress(address);
} catch (error) {
return address;
}
};

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

const checksummedAddress = toAccount && toChecksumAddress(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