-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request Queue Controller #1806
Request Queue Controller #1806
Conversation
@metamaskbot publish-preview |
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
packages/queued-request-controller/src/QueuedRequestController.ts
Outdated
Show resolved
Hide resolved
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
packages/queued-request-controller/src/QueuedRequestMiddleware.ts
Outdated
Show resolved
Hide resolved
packages/queued-request-controller/src/QueuedRequestMiddleware.ts
Outdated
Show resolved
Hide resolved
packages/queued-request-controller/src/QueuedRequestMiddleware.ts
Outdated
Show resolved
Hide resolved
packages/queued-request-controller/tests/QueuedRequestController.test.ts
Outdated
Show resolved
Hide resolved
packages/queued-request-controller/tests/QueuedRequestController.test.ts
Outdated
Show resolved
Hide resolved
packages/queued-request-controller/tests/QueuedRequestMiddleware.test.ts
Outdated
Show resolved
Hide resolved
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
6d59afb
to
4e2d674
Compare
@metamaskbot publish-preview |
@metamaskbot publish-preview |
Co-authored-by: Jongsun Suh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question/suggestion, but I'm good on this otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@metamaskbot publish-preview |
Here are the updates for consolidating messenger and |
@MajorLift What do you think if we included those changes in a new PR? I know there are some other refactors mentioned here that we could possibly include there or in another PR as well. |
Yes the typing fixes could definitely be done in a separate PR.👍 |
…wareMessenger` pattern, fix `any` (#1970) ## Explanation ### Apply controller-messenger pattern - Defines `QueuedRequestMiddlewareMessenger`, `SelectedNetworkMiddlewareMessenger` types to represent external controller messengers in the middleware chain. - Reserved for internal use and not exported at package level. - Defines separate allow lists for `QueuedRequest{Controller,Middleware}Messenger` and `SelectedNetwork{Controller,Middleware}Messenger`. ### Type fixes - Defines and exports `QueuedRequestMiddlewareJsonRpcRequest`, `SelectedNetworkMiddlewareJsonRpcRequest` types. - Fix `any` usage in `createSelectedNetworkMiddleware` ### Tests - Fixes `any`, `as any` usage in `QueuedRequestController`, `QueuedRequestMiddleware` tests. - Moves util functions for building test messengers into individual test files. - For context: #1970 (comment) ## References - Follow-up from #1806 - Builds on #2051 - Closes #2038 ## Changelog ### `@metamask/queued-request-controller` - **ADDED**: Add `QueuedRequestMiddlewareJsonRpcRequest` typee - **BREAKING:** `QueuedRequestControllerMessenger` can no longer be defined with any allowed actions or events. - **CHANGED**: Move `@metamask/approval-controller` from devDeps to deps. ### `@metamask/selected-network-controller` - **ADDED**: Add `SelectedNetworkMiddlewareJsonRpcRequest` type - **BREAKING:** Rename `SelectedNetworkControllerAction` to `SelectedNetworkControllerActions` and `SelectedNetworkControllerEvent` to `SelectedNetworkControllerEvents` for consistency with corresponding type exports from other controllers. - **BREAKING:** `createSelectedNetworkMiddleware` return type is constrained to satisfy `JsonRpcMiddleware<JsonRpcParams, Json>`, and the `req` parameter needs to satisfy `SelectedNetworkMiddlewareJsonRpcRequest`. ## 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 --------- Co-authored-by: Elliot Winkler <[email protected]>
Explanation
What is the current state of things and why does it need to change?
Currently, dapps must keep track of what metamasks selected network is, and switch the network appropriately. We recently added a selectedNetworkController that keeps track of what dapp has requested what network. This PR adds some middleware that will automatically prompt the user to switch metamasks network if the saved network for the dapp doesnt match. It also adds a queue, which will cause requests which require confirmations to be processed in a first-in-first-out manner.
The queued request controller provides this api mechanism and serves as a place to interate on the queueing implementation.
The selected network controller is updated to provide a proxy provider - that is, a provider that will be swapped out based on the dapps network selections.
References
needs these
Parent issue: https://github.com/MetaMask/MetaMask-planning/issues/1316
Changelog
@metamask/queued-request-controller
@metamask/selected-network-controller
Checklist