Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0e3d705
chore: remove legacy accounts component code (pre BIP-44)
gantunesr Jan 19, 2026
d9c66a1
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
gantunesr Jan 19, 2026
f0751b4
test: add BIP-44 state 2 fixture
gantunesr Jan 19, 2026
27e2977
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
gantunesr Jan 26, 2026
1a8da44
Merge branch 'main' into gar/chore/remove-legacy-bip44/components
gantunesr Jan 26, 2026
79744c0
Merge branch 'main' into gar/chore/remove-legacy-bip44/components
gantunesr Jan 27, 2026
a6c61f5
chore: revert E2E changes
gantunesr Jan 27, 2026
c09108b
Merge branch 'main' into gar/chore/remove-legacy-bip44/components
gantunesr Jan 27, 2026
fd86470
Merge branch 'main' into gar/chore/remove-legacy-bip44/components
gantunesr Jan 27, 2026
c5cd450
chore: remove unused hook
gantunesr Jan 27, 2026
99b4b82
test: update selector
gantunesr Jan 27, 2026
f2e329d
Merge branch 'gar/chore/remove-legacy-bip44/components' of https://gi…
gantunesr Jan 27, 2026
671ab67
Merge branch 'main' into gar/chore/remove-legacy-bip44/components
gantunesr Jan 28, 2026
63f90b0
chore: update AssetOverview
gantunesr Jan 28, 2026
238aa97
test: revert changes
gantunesr Jan 28, 2026
16519e0
chore: review feedback
gantunesr Jan 29, 2026
599c491
chore: remove redundant branch
gantunesr Jan 29, 2026
ccde54c
test: solve test failures
gantunesr Jan 29, 2026
24450ff
Merge branch 'main' into gar/chore/remove-legacy-bip44/components
gantunesr Jan 29, 2026
5d0d3b8
Merge branch 'main' into gar/chore/remove-legacy-bip44/components
gantunesr Jan 29, 2026
0910923
chore: revert AssetOverview
gantunesr Jan 30, 2026
1d5030f
Merge branch 'gar/chore/remove-legacy-bip44/components' of https://gi…
gantunesr Jan 30, 2026
68452f0
test: update snapshots
gantunesr Jan 30, 2026
0516e6e
Merge branch 'main' into gar/chore/remove-legacy-bip44/components
gantunesr Jan 30, 2026
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
25 changes: 4 additions & 21 deletions app/components/UI/AddressCopy/AddressCopy.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react';
import { InternalAccount } from '@metamask/keyring-internal-api';

import AddressCopy from './AddressCopy';
import { WalletViewSelectorsIDs } from '../../Views/Wallet/WalletView.testIds';
import renderWithProvider from '../../../util/test/renderWithProvider';
import { createMockInternalAccount } from '../../../util/test/accountsControllerTestUtils';
import { ToastContext } from '../../../component-library/components/Toast';

// Mock navigation before importing renderWithProvider
jest.mock('@react-navigation/native', () => ({
Expand All @@ -15,32 +12,18 @@ jest.mock('@react-navigation/native', () => ({
}),
}));

const mockShowToast = jest.fn();
const mockCloseToast = jest.fn();
const mockToastRef = {
current: { showToast: mockShowToast, closeToast: mockCloseToast },
};

const renderWithAddressCopy = (account: InternalAccount) =>
renderWithProvider(
<ToastContext.Provider value={{ toastRef: mockToastRef }}>
<AddressCopy account={account} />
</ToastContext.Provider>,
);
const renderAddressCopy = () => renderWithProvider(<AddressCopy />);

describe('AddressCopy', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('renders correctly the component', () => {
const component = renderWithAddressCopy(
createMockInternalAccount('0xaddress', 'Account 1'),
);
it('renders the copy button', () => {
const { getByTestId } = renderAddressCopy();

expect(component).toBeDefined();
expect(
component.getByTestId(WalletViewSelectorsIDs.ACCOUNT_COPY_BUTTON),
getByTestId(WalletViewSelectorsIDs.ACCOUNT_COPY_BUTTON),
).toBeDefined();
});
});
78 changes: 4 additions & 74 deletions app/components/UI/AddressCopy/AddressCopy.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Third parties dependencies
import React, { useCallback, useContext } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import React, { useCallback } from 'react';
import { useSelector } from 'react-redux';
import { View } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { AccountGroupId } from '@metamask/account-api';
Expand All @@ -11,27 +11,15 @@ import {
ButtonIconSize,
IconName,
} from '@metamask/design-system-react-native';
import ClipboardManager from '../../../core/ClipboardManager';
import { protectWalletModalVisible } from '../../../actions/user';
import {
ToastContext,
ToastVariants,
} from '../../../component-library/components/Toast';
import { IconName as ComponentLibraryIconName } from '../../../component-library/components/Icons/Icon';

import { strings } from '../../../../locales/i18n';
import { MetaMetricsEvents } from '../../../core/Analytics';
import { useStyles } from '../../../component-library/hooks';
import { WalletViewSelectorsIDs } from '../../Views/Wallet/WalletView.testIds';
import { selectMultichainAccountsState2Enabled } from '../../../selectors/featureFlagController/multichainAccounts/enabledMultichainAccounts';
import { selectSelectedAccountGroupId } from '../../../selectors/multichainAccounts/accountTreeController';
import { createAddressListNavigationDetails } from '../../Views/MultichainAccounts/AddressList';

// Internal dependencies
import styleSheet from './AddressCopy.styles';
import { useMetrics } from '../../../components/hooks/useMetrics';
import { useTheme } from '../../../util/theme';
import { getFormattedAddressFromInternalAccount } from '../../../core/Multichain/utils';
import type { AddressCopyProps } from './AddressCopy.types';
import {
endTrace,
Expand All @@ -40,59 +28,13 @@ import {
TraceOperation,
} from '../../../util/trace';

const AddressCopy = ({ account, iconColor, hitSlop }: AddressCopyProps) => {
const AddressCopy = ({ iconColor, hitSlop }: AddressCopyProps) => {
const { styles } = useStyles(styleSheet, {});
const { navigate } = useNavigation();
const { colors } = useTheme();

const dispatch = useDispatch();
const { trackEvent, createEventBuilder } = useMetrics();
const { toastRef } = useContext(ToastContext);

const isMultichainAccountsState2Enabled = useSelector(
selectMultichainAccountsState2Enabled,
);
const selectedAccountGroupId = useSelector(selectSelectedAccountGroupId);

const handleProtectWalletModalVisible = useCallback(
() => dispatch(protectWalletModalVisible()),
[dispatch],
);

/**
* A string that represents the selected address
*/

const copyAccountToClipboard = useCallback(async () => {
await ClipboardManager.setString(
getFormattedAddressFromInternalAccount(account),
);
toastRef?.current?.showToast({
variant: ToastVariants.Icon,
iconName: ComponentLibraryIconName.CheckBold,
iconColor: colors.accent03.dark,
backgroundColor: colors.accent03.normal,
labelOptions: [
{ label: strings('account_details.account_copied_to_clipboard') },
],
hasNoTimeout: false,
});
setTimeout(() => handleProtectWalletModalVisible(), 2000);

trackEvent(
createEventBuilder(MetaMetricsEvents.WALLET_COPIED_ADDRESS).build(),
);
}, [
account,
colors.accent03.dark,
colors.accent03.normal,
createEventBuilder,
handleProtectWalletModalVisible,
toastRef,
trackEvent,
]);

const navigateToAddressList = useCallback(() => {
const handleOnPress = useCallback(() => {
// Start the trace before navigating to the address list to include the
// navigation and render times in the trace.
trace({
Expand All @@ -116,18 +58,6 @@ const AddressCopy = ({ account, iconColor, hitSlop }: AddressCopyProps) => {
);
}, [navigate, selectedAccountGroupId]);

const handleOnPress = useCallback(() => {
if (isMultichainAccountsState2Enabled) {
navigateToAddressList();
} else {
copyAccountToClipboard();
}
}, [
copyAccountToClipboard,
isMultichainAccountsState2Enabled,
navigateToAddressList,
]);

return (
<View style={styles.address}>
<ButtonIcon
Expand Down
2 changes: 0 additions & 2 deletions app/components/UI/AddressCopy/AddressCopy.types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { InternalAccount } from '@metamask/keyring-internal-api';
import { IconColor } from '@metamask/design-system-react-native';

export interface AddressCopyProps {
account: InternalAccount;
iconColor?: IconColor;
hitSlop?: {
top?: number;
Expand Down
Loading
Loading