Skip to content

Commit

Permalink
QueuedRequestController: Fix list of methods that should have request…
Browse files Browse the repository at this point in the history
…s enqueued and/or switch the globally selected network (#4066)

## Explanation

Previously we were not properly enqueuing requests that could trigger a
confirmation notification as well as not switching networks for methods
that either require it or would exhibit unexpected UI/UX without doing
so beforehand. This PR improves the specificity of which methods should
be handled differently in the queued request flow which covers many
methods not previously handled correctly.

## References

See:
MetaMask/metamask-extension#22865 (comment)

## Changelog

### `@metamask/queued-request-controller`

#### Added
- **BREAKING**: The `QueuedRequestMiddleware` constructor now requires
the `methodsWithConfirmation` param which should be a list of methods
that can trigger confirmations
([#4066](#4066))
- **BREAKING**: The `QueuedRequestController` constructor now requires
the `methodsRequiringNetworkSwitch` param which should be a list of
methods that need the globally selected network to switched to the dapp
selected network before being processed
([#4066](#4066))

#### Changed
- **BREAKING**: `QueuedRequestController.enqueueRequest()` now ensures
the globally selected network matches the dapp selected network before
processing methods listed in the `methodsRequiringNetworkSwitch`
constructor param. This replaces the previous behavior of switching for
all methods except `eth_requestAccounts`.
([#4066](#4066))

 
## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
  • Loading branch information
jiexi committed Apr 8, 2024
1 parent 8769bd8 commit 590c9db
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 184 deletions.
9 changes: 9 additions & 0 deletions packages/queued-request-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- **BREAKING**: The `QueuedRequestMiddleware` constructor now requires the `methodsWithConfirmation` param which should be a list of methods that can trigger confirmations ([#4066](https://github.com/MetaMask/core/pull/4066))
- **BREAKING**: The `QueuedRequestController` constructor now requires the `methodsRequiringNetworkSwitch` param which should be a list of methods that need the globally selected network to switched to the dapp selected network before being processed ([#4066](https://github.com/MetaMask/core/pull/4066))

### Changed

- **BREAKING**: `QueuedRequestController.enqueueRequest()` now ensures the globally selected network matches the dapp selected network before processing methods listed in the `methodsRequiringNetworkSwitch` constructor param. This replaces the previous behavior of switching for all methods except `eth_requestAccounts`. ([#4066](https://github.com/MetaMask/core/pull/4066))

## [0.7.0]

### Changed
Expand Down
Loading

0 comments on commit 590c9db

Please sign in to comment.