-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: switch chain with walletconnect (#10394)
<!-- 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** MetaMask calls updateSession multiple times when the user tries to switch chain from the dapp. This causes the dapp to receive a `chainChanged` event before receiving the updated session from the wallet. * Compare addresses in lowercase * Parse chainId correctly * Clearing state variables of BackgroundBridge when the session is disconnected * Bumped walletconnect sdk versions to latest ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to https://lab.web3modal.com/library/ethers/ with an iPhone 2. Press the "Connect Wallet" button and select "Metamask" 3. Press "Open" to open MetaMask (if applies) 4. Accept the session proposal 5. Go back to the browser 6. Switch chain to Polygon (chain must be Already added as know network in Metamask) 7. Go to MetaMask and accept the switch popup 8. Go back to the browser and see there is a new redirect popup, which causes issues in the Wallet. The popup shouldn't be there ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** https://github.com/user-attachments/assets/4a0b4a1c-6496-4e2c-8e03-d04a51df2ce3 ### **After** https://github.com/user-attachments/assets/7441400e-6dfe-4595-a608-2eec30b1c478 ## **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 - [ ] 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. --------- Co-authored-by: Andrea Salvatore <andrea.salvatore@consensys.net>
- Loading branch information
1 parent
2df9eb5
commit c317aba
Showing
5 changed files
with
53 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters