Commit 66388aa
authored
fix: switching networks from dapp permissions dapp icon has no effect (#22692)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
While connected to a dapp, if the user tries to switch networks from
dapp permissions, this has no effect. When switching networks, the icon
displayed is always the same. This happens because
`MultichainPermissionsSummary.tsx` uses `.hostname` while
`SelectedNetworkController` stores domains by origin (e.g.,
"https://example.com"). This mismatch prevents the lookup from finding
the per-dapp network.
This PR proposes a fix by using `.origin` instead.
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
## **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: fix issue where switching networks from dapp
permissions dapp icon has no effect
## **Related issues**
Fixes: #22423
## **Manual testing steps**
```gherkin
Feature: fix switching networks from dapp permissions dapp icon having no effect
Scenario: user switches network
Given it's done via top right icon of In App Browser
When user switches network
Then network icon should update accordingly
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
https://github.com/user-attachments/assets/472ff108-8e39-4a96-899a-93c9983bb260
<!-- [screenshots/recordings] -->
## **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]
> Replaces hostname with full URL origin for dapp host handling in
MultichainPermissionsSummary, updating navigation params and tests.
>
> - **MultichainPermissionsSummary**:
> - Compute `hostname` as `URL.origin` instead of `URL.hostname`.
> - Pass origin to `useNetworkInfo`, titles, and navigation params for
`CONNECTION_DETAILS` and `REVOKE_ALL_ACCOUNT_PERMISSIONS`
(`hostInfo.metadata.origin`).
> - **Tests**:
> - Update expectations to use `https://mock-dapp.example.com` for
`origin` in navigation assertions.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ffbe2d1. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 4d28c04 commit 66388aa
File tree
2 files changed
+4
-6
lines changed- app/components/Views/MultichainAccounts/MultichainPermissionsSummary
2 files changed
+4
-6
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
| 452 | + | |
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
| 478 | + | |
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
256 | | - | |
257 | | - | |
| 255 | + | |
258 | 256 | | |
259 | 257 | | |
260 | 258 | | |
| |||
0 commit comments