Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e620f03
feat: create account details component that switches into the correct…
hmalik88 Jun 25, 2025
92e1dd4
test: add mock account data
hmalik88 Jun 26, 2025
2379206
feat: add account details pages for various account types
hmalik88 Jun 26, 2025
94abd24
feat: conditionally render account details based on state 1 flag
hmalik88 Jun 26, 2025
f399be7
test: update tests
hmalik88 Jun 26, 2025
8a34473
chore: rename account details page to multichain account details
hmalik88 Jun 26, 2025
f7191e5
chore: remove extra account types from utils
hmalik88 Jun 26, 2025
4a250be
chore: update exports
hmalik88 Jun 26, 2025
164d8ce
refactor: remove unnecessary code from evm account details
hmalik88 Jun 26, 2025
f1b74a3
feat: move selectors into props, add useEffect for navigation, update…
hmalik88 Jun 26, 2025
79d4a34
Merge branch 'main' into hm/mul-283
hmalik88 Jun 26, 2025
fde920f
feat: add private key account details page
hmalik88 Jun 26, 2025
6862014
test: fix account details tests
hmalik88 Jun 26, 2025
cad293f
fix: update mock accounts and fix utils
hmalik88 Jun 26, 2025
5e1edbb
chore: remove unused props
hmalik88 Jun 26, 2025
9501960
feat: add multichain account details route
hmalik88 Jun 26, 2025
525fb8d
feat: add logic to conditionally push to multichain account details r…
hmalik88 Jun 26, 2025
0cd26c0
feat: add logic to prevent app header from appearing for account details
hmalik88 Jun 26, 2025
1d1dbd6
feat: add accountDetailsAddress selector back to multichain account d…
hmalik88 Jun 26, 2025
f5b0637
feat: add logic to prevent navigation to new account details page if …
hmalik88 Jun 26, 2025
6ebf8b4
feat: add logic to remove app header for address qr code page
hmalik88 Jun 26, 2025
43d4710
feat: add navigation protection for address qr code page
hmalik88 Jun 26, 2025
15be842
feat: add address qr code route
hmalik88 Jun 26, 2025
14f3f49
fix: update condition to be navigate protect when flag is NOT enabled
hmalik88 Jun 26, 2025
2ea64d5
Merge branch 'main' into hm/mul-283
hmalik88 Jun 26, 2025
f0b252c
feat: update smart contract account toggle components to use address …
hmalik88 Jun 26, 2025
0951f7e
fix: update prop type
hmalik88 Jun 26, 2025
922e4c2
feat: add address prop to smart contract account toggle section compo…
hmalik88 Jun 26, 2025
646da78
chore: update types
hmalik88 Jun 26, 2025
c926716
fix: update storybook file with correct props
hmalik88 Jun 27, 2025
02548a5
fix: resolve lint errors
hmalik88 Jun 27, 2025
7c6b8fb
Merge branch 'main' into hm/mul-283
hmalik88 Jun 27, 2025
5206ed6
chore: move 7702 toggles out of this PR
hmalik88 Jun 27, 2025
824167f
fix: apply lint fix
hmalik88 Jun 27, 2025
ddd7a33
fix: fix type error in utils tests
hmalik88 Jun 27, 2025
3d58992
fix: pass correct props to base account details in its tests
hmalik88 Jun 27, 2025
cb82654
chore: revert gitignore
hmalik88 Jun 27, 2025
3feaf71
test: add test for instiutional evm accounts
hmalik88 Jun 27, 2025
64fe3ed
Merge branch 'main' into hm/283without7702
hmalik88 Jun 30, 2025
6ba18a4
chore: revert 7702 changes
hmalik88 Jun 30, 2025
40a558e
feat: add push to account details route from wallet details
hmalik88 Jun 30, 2025
d286c99
chore: remove unnecessary path protection
hmalik88 Jun 30, 2025
d374bcd
chore: add param description in jsdoc
hmalik88 Jun 30, 2025
2006eb6
chore: remove unnecessary mocking of I18nContext
hmalik88 Jun 30, 2025
c9b272a
fix: lint fix
hmalik88 Jul 1, 2025
f839d61
fix: prevent wrapping of long values in account details row
hmalik88 Jul 1, 2025
59c5cdb
style: adjust container size
hmalik88 Jul 1, 2025
02fa170
style: add max width to account details
hmalik88 Jul 1, 2025
addb079
fix: apply code review
hmalik88 Jul 1, 2025
a4ff93f
Merge branch 'main' into hm/283without7702
hmalik88 Jul 1, 2025
9153933
fix: fix routing
hmalik88 Jul 1, 2025
066fb00
feat: add btc account details page
hmalik88 Jul 1, 2025
d853bf1
fix: apply fixes for text styling and navigation
hmalik88 Jul 1, 2025
38fc83a
test: add btc account tests
hmalik88 Jul 1, 2025
c5f638f
fix: add routing to account details tests
hmalik88 Jul 1, 2025
10f4217
fix: add routing to address qr code stories
hmalik88 Jul 1, 2025
ce6d4c8
fix: apply lint fix
hmalik88 Jul 1, 2025
5268bc1
fix: apply lint fix
hmalik88 Jul 1, 2025
f5d6676
fix: add routing to address qr code tests
hmalik88 Jul 1, 2025
da13839
Merge branch 'main' into hm/283without7702
hmalik88 Jul 1, 2025
cfabe05
fix: fix base account details test
hmalik88 Jul 1, 2025
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
80 changes: 80 additions & 0 deletions test/data/mock-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,84 @@ export const MOCK_ACCOUNT_EOA: InternalAccount = {
},
};

export const MOCK_ACCOUNT_PRIVATE_KEY: InternalAccount = {
id: 'd6ad74fa-ca5e-4d2d-ad53-95ababbfe872',
address: '0x2990079bcdee240329a520d2444386fc119da21a',
options: {},
methods: [
'personal_sign',
'eth_sign',
'eth_signTransaction',
'eth_signTypedData_v1',
'eth_signTypedData_v3',
'eth_signTypedData_v4',
],
scopes: [EthScope.Mainnet],
type: EthAccountType.Eoa,
metadata: {
name: 'Account 58',
importTime: 1750963640738,
keyring: { type: KeyringTypes.simple },
lastSelected: 1750963640759,
},
};

export const MOCK_ACCOUNT_HARDWARE: InternalAccount = {
id: 'a4a41a3d-13d9-4ef3-be2f-aa28f47879aa',
address: '0x3a3fc52253e62cf4f3573814aa410736c9db5d0c',
options: {},
methods: [
'personal_sign',
'eth_sign',
'eth_signTransaction',
'eth_signTypedData_v1',
'eth_signTypedData_v3',
'eth_signTypedData_v4',
],
scopes: [EthScope.Mainnet],
type: EthAccountType.Eoa,
metadata: {
name: 'Ledger 2',
importTime: 1750963627141,
keyring: { type: KeyringTypes.ledger },
lastSelected: 1750963627172,
nameLastUpdatedAt: 1750963627173,
},
};

export const MOCK_ACCOUNT_INSTITUTIONAL: InternalAccount = {
id: 'c0949edb-b843-4d20-be0b-80f2a8ef6552',
options: {
custodian: {
environmentName: 'neptune-prod',
displayName: 'Neptune',
deferPublication: false,
importOrigin: 'https://neptune-custody-ui.metamask-institutional.io',
},
accountName: 'Custody Account A',
},
address: '0xc073fd7d1522c4103e0d8e407fa763d3ac8417e6',
methods: [
'eth_signTransaction',
'personal_sign',
'eth_signTypedData_v3',
'eth_signTypedData_v4',
],
type: 'eip155:eoa',
scopes: ['eip155:0'],
metadata: {
name: 'Custody Account A',
importTime: 1751048625733,
keyring: { type: KeyringTypes.snap },
snap: {
id: 'npm:@metamask/institutional-wallet-snap',
name: 'Institutional Wallet',
enabled: true,
},
lastSelected: 1751048625755,
},
};

export const MOCK_ACCOUNT_ERC4337: InternalAccount = {
id: '4d5921f2-2022-44ce-a84f-9f6a0f142a5c',
address: '0x123',
Expand Down Expand Up @@ -97,4 +175,6 @@ export const MOCK_ACCOUNTS = {
[MOCK_ACCOUNT_BIP122_P2WPKH.id]: MOCK_ACCOUNT_BIP122_P2WPKH,
[MOCK_ACCOUNT_BIP122_P2WPKH_TESTNET.id]: MOCK_ACCOUNT_BIP122_P2WPKH_TESTNET,
[MOCK_ACCOUNT_SOLANA_MAINNET.id]: MOCK_ACCOUNT_SOLANA_MAINNET,
[MOCK_ACCOUNT_HARDWARE.id]: MOCK_ACCOUNT_HARDWARE,
[MOCK_ACCOUNT_PRIVATE_KEY.id]: MOCK_ACCOUNT_PRIVATE_KEY,
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
JustifyContent,
AlignItems,
TextColor,
TextVariant,
} from '../../../helpers/constants/design-system';

type AccountDetailsRowProps = {
Expand All @@ -31,9 +32,28 @@ export const AccountDetailsRow = ({
paddingRight={4}
alignItems={AlignItems.center}
>
<Text color={TextColor.textDefault}>{label}</Text>
<Box display={Display.Flex} alignItems={AlignItems.center}>
<Text color={TextColor.textAlternative}>{value}</Text>
<Text
color={TextColor.textDefault}
variant={TextVariant.bodyMdMedium}
paddingRight={12}
>
{label}
</Text>
<Box
display={Display.Flex}
alignItems={AlignItems.center}
style={{ minWidth: 0, flex: 1, justifyContent: 'flex-end' }}
>
<Text
color={TextColor.textAlternative}
variant={TextVariant.bodyMdMedium}
ellipsis
style={{
maxWidth: '150px',
}}
>
{value}
</Text>
{endAccessory}
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import {
ButtonPrimary,
FormTextField,
Box,
Text,
} from '../../component-library';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { setAccountLabel } from '../../../store/actions';
import {
Display,
FlexDirection,
TextColor,
TextVariant,
} from '../../../helpers/constants/design-system';

type EditAccountNameModalProps = {
Expand Down Expand Up @@ -54,14 +57,25 @@ export const EditAccountNameModal = ({
flexDirection={FlexDirection.Column}
gap={4}
>
<FormTextField
label={t('name')}
value={accountName}
onChange={(e) => setAccountName(e.target.value)}
placeholder={currentAccountName}
autoFocus
helpText={address}
/>
<Box>
<FormTextField
label={t('name')}
value={accountName}
onChange={(e) => setAccountName(e.target.value)}
placeholder={currentAccountName}
autoFocus
/>
<Text
variant={TextVariant.bodySm}
color={TextColor.textAlternative}
style={{
wordBreak: 'break-all',
}}
paddingTop={1}
>
{address}
</Text>
</Box>
<ButtonPrimary
onClick={handleSave}
disabled={!accountName.trim()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';

import { useHistory } from 'react-router-dom';
import { setAccountDetailsAddress } from '../../../store/actions';

import { MenuItem } from '../../ui/menu';
Expand All @@ -13,6 +14,8 @@ import {
} from '../../../../shared/constants/metametrics';
import { IconName, Text } from '../../component-library';
import { getHDEntropyIndex } from '../../../selectors/selectors';
import { getIsMultichainAccountsState1Enabled } from '../../../selectors/multichain-accounts/feature-flags';
import { ACCOUNT_DETAILS_ROUTE } from '../../../helpers/constants/routes';

export const AccountDetailsMenuItem = ({
metricsLocation,
Expand All @@ -24,7 +27,10 @@ export const AccountDetailsMenuItem = ({
const dispatch = useDispatch();
const trackEvent = useContext(MetaMetricsContext);
const hdEntropyIndex = useSelector(getHDEntropyIndex);

const history = useHistory();
const isMultichainAccountsState1Enabled = useSelector(
getIsMultichainAccountsState1Enabled,
);
const LABEL = t('accountDetails');

return (
Expand All @@ -39,6 +45,9 @@ export const AccountDetailsMenuItem = ({
hd_entropy_index: hdEntropyIndex,
},
});
if (isMultichainAccountsState1Enabled) {
history.push(`${ACCOUNT_DETAILS_ROUTE}/${address}`);
}
closeMenu?.();
}}
iconName={IconName.ScanBarcode}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import { InternalAccount } from '@metamask/keyring-internal-api';
import {
MOCK_ACCOUNT_BIP122_P2WPKH,
MOCK_ACCOUNT_EOA,
MOCK_ACCOUNT_ERC4337,
MOCK_ACCOUNT_HARDWARE,
MOCK_ACCOUNT_INSTITUTIONAL,
MOCK_ACCOUNT_PRIVATE_KEY,
MOCK_ACCOUNT_SOLANA_MAINNET,
} from '../../../../test/data/mock-accounts';
import {
getAccountTypeCategory,
isEVMAccount,
isSolanaAccount,
isHardwareAccount,
isPrivateKeyAccount,
isInstitutionalEVMAccount,
isBitcoinAccount,
} from './account-type-utils';

describe('Account Type Utils', () => {
describe('getAccountTypeCategory', () => {
it('should return "evm" for EOA accounts', () => {
expect(getAccountTypeCategory(MOCK_ACCOUNT_EOA)).toBe('evm');
});

it('should return "evm" for ERC-4337 accounts', () => {
expect(getAccountTypeCategory(MOCK_ACCOUNT_ERC4337)).toBe('evm');
});

it('should return "solana" for Solana accounts', () => {
expect(getAccountTypeCategory(MOCK_ACCOUNT_SOLANA_MAINNET)).toBe(
'solana',
);
});

it('should return "unknown" for null/undefined accounts', () => {
expect(getAccountTypeCategory(null as unknown as InternalAccount)).toBe(
'unknown',
);
expect(
getAccountTypeCategory(undefined as unknown as InternalAccount),
).toBe('unknown');
});
});

describe('isEVMAccount', () => {
it('should return true for EOA accounts', () => {
expect(isEVMAccount(MOCK_ACCOUNT_EOA)).toBe(true);
});

it('should return true for ERC-4337 accounts', () => {
expect(isEVMAccount(MOCK_ACCOUNT_ERC4337)).toBe(true);
});

it('should return false for Solana accounts', () => {
expect(isEVMAccount(MOCK_ACCOUNT_SOLANA_MAINNET)).toBe(false);
});
});

describe('isSolanaAccount', () => {
it('should return true for Solana accounts', () => {
expect(isSolanaAccount(MOCK_ACCOUNT_SOLANA_MAINNET)).toBe(true);
});

it('should return false for EOA accounts', () => {
expect(isSolanaAccount(MOCK_ACCOUNT_EOA)).toBe(false);
});

it('should return false for ERC-4337 accounts', () => {
expect(isSolanaAccount(MOCK_ACCOUNT_ERC4337)).toBe(false);
});
});

describe('isHardwareAccount', () => {
it('should return true for hardware accounts', () => {
expect(isHardwareAccount(MOCK_ACCOUNT_HARDWARE)).toBe(true);
});

it('should return false for EOA accounts', () => {
expect(isHardwareAccount(MOCK_ACCOUNT_EOA)).toBe(false);
});

it('should return false for Solana accounts', () => {
expect(isHardwareAccount(MOCK_ACCOUNT_SOLANA_MAINNET)).toBe(false);
});
});

describe('isPrivateKeyAccount', () => {
it('should return true for private key accounts', () => {
expect(isPrivateKeyAccount(MOCK_ACCOUNT_PRIVATE_KEY)).toBe(true);
});

it('should return false for EOA accounts', () => {
expect(isPrivateKeyAccount(MOCK_ACCOUNT_EOA)).toBe(false);
});

it('should return false for Solana accounts', () => {
expect(isPrivateKeyAccount(MOCK_ACCOUNT_SOLANA_MAINNET)).toBe(false);
});
});

describe('isInstitutionalEVMAccount', () => {
it('should return true for institutional EVM accounts', () => {
expect(isInstitutionalEVMAccount(MOCK_ACCOUNT_INSTITUTIONAL)).toBe(true);
});

it('should return false for regular EOA accounts', () => {
expect(isInstitutionalEVMAccount(MOCK_ACCOUNT_EOA)).toBe(false);
});

it('should return false for regular ERC-4337 accounts', () => {
expect(isInstitutionalEVMAccount(MOCK_ACCOUNT_ERC4337)).toBe(false);
});
});

describe('isBitcoinAccount', () => {
it('should return true for Bitcoin accounts', () => {
expect(isBitcoinAccount(MOCK_ACCOUNT_BIP122_P2WPKH)).toBe(true);
});

it('should return false for EOA accounts', () => {
expect(isBitcoinAccount(MOCK_ACCOUNT_EOA)).toBe(false);
});

it('should return false for Solana accounts', () => {
expect(isBitcoinAccount(MOCK_ACCOUNT_SOLANA_MAINNET)).toBe(false);
});
});
});
Loading
Loading