Commit 4f90d1a
authored
fix: ShareAddressQR displays correct address for non-EVM assets (#21449)
## **Description**
### Problem
When viewing a non-EVM asset (e.g., Solana) and clicking "Receive", the
`ShareAddressQR` screen incorrectly displayed the user's EVM address
instead of the chain-specific address (e.g., Solana address).
### Root Cause
`AssetOverview.tsx:215` always passed `selectedInternalAccountAddress`
(EVM address) to the `ShareAddressQR` screen, regardless of the asset's
chain type.
### Solution
- Use `selectSelectedInternalAccountByScope` selector to get
chain-specific accounts
- For non-EVM assets: retrieve the account using
`getAccountByScope(asset.chainId as CaipChainId)`
- For EVM assets: continue using `selectedInternalAccount`
- Enhanced error logging with `isNonEvmAsset` and `assetChainId` fields
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: Fixed issue where QR code share screen shows the
incorrect wallet address
## **Related issues**
Fixes: #21447
## **Manual testing steps**
```gherkin
Feature: Receive QR Share Screen
Background:
Given the user has a wallet with both EVM and non-EVM accounts
And the user is on the Asset Overview screen
Scenario: User shares QR code for EVM asset
Given the user is viewing an Ethereum (EVM) asset
When the user taps the "Receive" button
Then the Share Address QR screen is displayed
And the QR code contains the user's EVM address
Scenario: User shares QR code for Solana asset
Given the user is viewing a Solana asset
When the user taps the "Receive" button
Then the Share Address QR screen is displayed
And the QR code contains the user's Solana address
```
## **Screenshots/Recordings**
`~`
### **Before**
https://github.com/user-attachments/assets/58872d26-829e-4bd1-aef7-08aa8abf2ff5
### **After**
https://github.com/user-attachments/assets/82ea57f2-c50a-4f91-9484-233f8363299f
## **Pre-merge author checklist**
- [x] 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).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] 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**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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]
> ShareAddressQR now shows the chain-specific address for non-EVM
assets; adds selector usage, logging, and tests for EVM and Solana.
>
> - **Asset Overview (Receive flow)**:
> - Use `selectSelectedInternalAccountByScope` to fetch chain-scoped
account for non-EVM assets (`CaipChainId`), falling back to
`selectedInternalAccount` for EVM.
> - Pass chain-appropriate `address` to
`Routes.SHEET.MULTICHAIN_ACCOUNT_DETAILS.SHARE_ADDRESS_QR`.
> - Improve error logging with `isNonEvmAsset` and `assetChainId`
context.
> - **Tests**:
> - Mock `selectSelectedInternalAccountByScope` and add cases for EVM
asset (uses EVM address) and Solana asset (uses Solana address, asserts
scope call).
> - Adjust existing receive test setup and cleanup to incorporate new
selector behavior.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
55c41ac. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 97ba5d6 commit 4f90d1a
File tree
2 files changed
+115
-7
lines changed- app/components/UI/AssetOverview
2 files changed
+115
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| |||
266 | 271 | | |
267 | 272 | | |
268 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
269 | 283 | | |
270 | 284 | | |
271 | 285 | | |
| |||
545 | 559 | | |
546 | 560 | | |
547 | 561 | | |
548 | | - | |
| 562 | + | |
549 | 563 | | |
550 | 564 | | |
551 | 565 | | |
552 | 566 | | |
553 | 567 | | |
554 | 568 | | |
555 | 569 | | |
556 | | - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
557 | 578 | | |
558 | 579 | | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
559 | 585 | | |
560 | 586 | | |
561 | 587 | | |
| |||
570 | 596 | | |
571 | 597 | | |
572 | 598 | | |
573 | | - | |
| 599 | + | |
574 | 600 | | |
575 | 601 | | |
576 | 602 | | |
577 | 603 | | |
578 | 604 | | |
579 | 605 | | |
580 | 606 | | |
581 | | - | |
| 607 | + | |
582 | 608 | | |
583 | 609 | | |
584 | 610 | | |
| |||
589 | 615 | | |
590 | 616 | | |
591 | 617 | | |
| 618 | + | |
592 | 619 | | |
593 | 620 | | |
594 | 621 | | |
| |||
640 | 667 | | |
641 | 668 | | |
642 | 669 | | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
643 | 739 | | |
644 | 740 | | |
645 | 741 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
| 115 | + | |
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
| |||
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
207 | 217 | | |
208 | | - | |
| 218 | + | |
209 | 219 | | |
210 | 220 | | |
211 | 221 | | |
212 | | - | |
| 222 | + | |
213 | 223 | | |
214 | 224 | | |
215 | 225 | | |
| |||
221 | 231 | | |
222 | 232 | | |
223 | 233 | | |
224 | | - | |
| 234 | + | |
225 | 235 | | |
226 | 236 | | |
| 237 | + | |
| 238 | + | |
227 | 239 | | |
228 | 240 | | |
229 | 241 | | |
| |||
0 commit comments