-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update swaps controller ethereum provider on demand instead of on net…
…work events (#21958) While QAing v11.5.2, this issue was discovered: 1. Add a network, through the popular network list, that you have tokens on. 2. use "+ Import tokens" form to import a token that that you have on this network 3. try to swap that token for the network's native currency, fetching quotes will fail and an "Error fetching quotes" message will be shown We thought we fixed this with #21923, but the case of adding a network and then immediately trying to swap an erc20 token on that network, was not covered by that solution. The reasons for that are detailed extensively here https://consensys.slack.com/archives/GTQAGKY5V/p1700700399190349 tldr: When the `NetworkDidChange` event occurs during the network adding flow, the network's status is not yet "Available" and so the swaps controller subscriber for network changes does allow the provider to update The fix in this PR, which also covers the problem addressed by the aforementioned PR, is to only update the swaps controller's ethersProvider at the time it is needed, within the `fetchAndSetQuotes`, and to stop subscribing to network controller changes. 1. Add a network, through the popular network list, that you have tokens on. 2. use "+ Import tokens" form to import a token that that you have on this network 3. try to swap that token for the network's native currency, fetching quotes should succeed https://github.com/MetaMask/metamask-extension/assets/7499938/acc62c6c-ac67-41be-a4a9-78e7d9941043 https://github.com/MetaMask/metamask-extension/assets/7499938/3eeea1c2-9d14-4f56-9a66-4669af9ae0e1 - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [x] I've included screenshots/recordings if applicable - [ ] 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-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [x] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". - [ ] 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.
- Loading branch information
Showing
3 changed files
with
133 additions
and
170 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