Skip to content

Commit f41df4d

Browse files
committed
chore(runway): cherry-pick fix: fix recipient account icons cp-7.60.0 (#23362)
## **Description** The icon being used for each recipient addresses was not re-using their account group icons (we use the EVM address of a multichain account group as the seed of account's icons). This PR fixes this while keeping the original `recipient.address` as a fallback (which should never happen anyway). ## **Changelog** CHANGELOG entry: Fix account's icons for send flows ## **Related issues** Fixes: - #22806 ## **Manual testing steps** ```gherkin Feature: Send non-EVM token Scenario: user starts a send flow for Solana Given the user has funds When user selects the recipient address Then he should see the same icons than the one used for the account list ``` ## **Screenshots/Recordings** ### **Before** https://github.com/user-attachments/assets/100969c2-15e9-49c4-a2f3-cd24aac8e839 <img width="382" height="192" alt="Screenshot 2025-11-27 at 13 28 36" src="https://github.com/user-attachments/assets/53225dd9-8e47-4788-850e-09579c312e96" /> <img width="377" height="250" alt="Screenshot 2025-11-27 at 13 28 22" src="https://github.com/user-attachments/assets/07e5b9aa-4a1c-44ff-ac6a-402a0712bd1a" /> ### **After** https://github.com/user-attachments/assets/221c05e4-b040-4583-b81f-de674f716db1 <img width="385" height="220" alt="Screenshot 2025-11-27 at 13 29 52" src="https://github.com/user-attachments/assets/02b959f4-7334-454f-8939-931054f68bf3" /> <img width="383" height="194" alt="Screenshot 2025-11-27 at 13 29 36" src="https://github.com/user-attachments/assets/a1eb109d-e74a-4de2-9844-ec5675e565c3" /> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Recipient avatars now derive from the account group’s icon seed (with address fallback), and useAccounts returns accountGroupId; tests updated accordingly. > > - **UI (recipient)**: > - Avatar `accountAddress` now sourced from account group icon seed via `selectIconSeedAddressByAccountGroupId`, with fallback to `recipient.address`. > - `RecipientType` extended with `accountGroupId`; Redux selector added to compute avatar seed. > - **Hooks**: > - `useAccounts` now includes `accountGroupId` in returned recipient objects. > - **Tests**: > - Updated `useAccounts.test.ts` expectations to include `accountGroupId` across EVM, Solana, Bitcoin, and Tron cases. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit bcc1017. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 52de418 commit f41df4d

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

app/components/Views/confirmations/components/UI/recipient/recipient.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ import styleSheet from './recipient.styles';
1919
import { useStyles } from '../../../../../hooks/useStyles';
2020
import { AccountTypeLabel } from '../account-type-label';
2121
import { ACCOUNT_TYPE_LABELS } from '../../../../../../constants/account-type-labels';
22+
import { AccountGroupId } from '@metamask/account-api';
23+
import { useSelector } from 'react-redux';
24+
import { selectIconSeedAddressByAccountGroupId } from '../../../../../../selectors/multichainAccounts/accounts';
25+
import { RootState } from '../../../../../../reducers';
2226

2327
export interface RecipientType {
2428
address: string;
2529
accountName?: string;
30+
accountGroupId?: AccountGroupId;
2631
accountGroupName?: string;
2732
accountType?: string;
2833
contactName?: string;
@@ -46,6 +51,20 @@ export function Recipient({
4651
const tw = useTailwind();
4752
const { styles } = useStyles(styleSheet, {});
4853

54+
// Always default to recipient address if account group has no associated icon seed
55+
// address (which should never really happen).
56+
const accountAvatarSeedAddress = useSelector((state: RootState) => {
57+
if (!recipient.accountGroupId) return recipient.address;
58+
try {
59+
const selector = selectIconSeedAddressByAccountGroupId(
60+
recipient.accountGroupId,
61+
);
62+
return selector(state);
63+
} catch {
64+
return recipient.address;
65+
}
66+
});
67+
4968
const handlePressRecipient = useCallback(() => {
5069
onPress?.(recipient);
5170
}, [recipient, onPress]);
@@ -73,7 +92,7 @@ export function Recipient({
7392
<Avatar
7493
variant={AvatarVariant.Account}
7594
type={accountAvatarType}
76-
accountAddress={recipient.address}
95+
accountAddress={accountAvatarSeedAddress}
7796
size={AvatarSize.Md}
7897
/>
7998
</Box>

app/components/Views/confirmations/hooks/send/useAccounts.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ describe('useAccounts', () => {
212212

213213
expect(result.current).toEqual([
214214
{
215+
accountGroupId: 'group-1',
215216
accountGroupName: 'Group 1',
216217
accountName: 'Account 1',
217218
accountType: 'eip155:eoa',
@@ -273,6 +274,7 @@ describe('useAccounts', () => {
273274

274275
expect(result.current).toEqual([
275276
{
277+
accountGroupId: 'group-2',
276278
accountGroupName: 'Group 2',
277279
accountName: 'Solana Account 1',
278280
accountType: 'solana:data-account',
@@ -317,6 +319,7 @@ describe('useAccounts', () => {
317319

318320
expect(result.current).toEqual([
319321
{
322+
accountGroupId: 'group-3',
320323
accountGroupName: 'Group 3',
321324
accountName: 'Bitcoin Account 1',
322325
accountType: 'bip122:p2wpkh',
@@ -378,6 +381,7 @@ describe('useAccounts', () => {
378381

379382
expect(result.current).toEqual([
380383
{
384+
accountGroupId: 'group-4',
381385
accountGroupName: 'Group 4',
382386
accountName: 'Tron Account 1',
383387
accountType: 'tron:eoa',
@@ -598,13 +602,15 @@ describe('useAccounts', () => {
598602
expect(result.current).toEqual(
599603
expect.arrayContaining([
600604
{
605+
accountGroupId: 'group-1',
601606
accountGroupName: 'Group 1',
602607
accountName: 'Account 1',
603608
accountType: 'eip155:eoa',
604609
address: '0x1234567890123456789012345678901234567890',
605610
walletName: 'Wallet 1',
606611
},
607612
{
613+
accountGroupId: 'group-3',
608614
accountGroupName: 'Group 3',
609615
accountName: 'Account 2',
610616
accountType: 'eip155:eoa',

app/components/Views/confirmations/hooks/send/useAccounts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export const useAccounts = (): RecipientType[] => {
8585
if (!account) return null;
8686

8787
return {
88+
accountGroupId: accountGroup.id,
8889
accountGroupName: accountGroup.metadata.name,
8990
accountName: account.metadata.name,
9091
accountType: account.type,

0 commit comments

Comments
 (0)