Skip to content

[queued-request-controller,selected-network-controller] Apply MiddlewareMessenger pattern, fix any#1970

Merged
MajorLift merged 29 commits intomainfrom
231101-typing-fixes-queued-request-controller
Nov 29, 2023
Merged

[queued-request-controller,selected-network-controller] Apply MiddlewareMessenger pattern, fix any#1970
MajorLift merged 29 commits intomainfrom
231101-typing-fixes-queued-request-controller

Conversation

@MajorLift
Copy link
Copy Markdown
Contributor

@MajorLift MajorLift commented Nov 1, 2023

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.
    • Defined 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

References

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

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@MajorLift MajorLift requested a review from a team as a code owner November 1, 2023 17:05
@MajorLift MajorLift assigned MajorLift and BelfordZ and unassigned BelfordZ and MajorLift Nov 1, 2023
@MajorLift MajorLift requested a review from BelfordZ November 1, 2023 18:35
@MajorLift MajorLift added the team-wallet-framework Deprecated: Please use `team-core-platform` instead. label Nov 1, 2023
@MajorLift MajorLift force-pushed the 231101-typing-fixes-queued-request-controller branch 3 times, most recently from 3b3147f to 455e5c7 Compare November 13, 2023 18:24
@MajorLift MajorLift changed the title Type definitions and fixes for QueuedRequestController [queued-request-controller] Type definitions and fixes Nov 13, 2023
Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I've been looking through all of these controller messenger-related PRs I've been slowly getting confused. I reached out on Slack for some clarifying questions so I think the answers to those questions should help me review these changes more easily.

@MajorLift MajorLift marked this pull request as draft November 13, 2023 23:55
@MajorLift MajorLift changed the title [queued-request-controller] Type definitions and fixes [queued-request-controller] Convert messengers and middleware to use RestrictedControllerMessenger Nov 14, 2023
@MajorLift MajorLift force-pushed the 231101-typing-fixes-queued-request-controller branch 4 times, most recently from e19cf32 to cc4e01c Compare November 17, 2023 03:05
@MajorLift MajorLift changed the base branch from main to jongsun/do-not-require-allowing-own-actions-events November 17, 2023 03:05
@MajorLift MajorLift force-pushed the 231101-typing-fixes-queued-request-controller branch 4 times, most recently from c16209d to 4efc27d Compare November 17, 2023 07:12
@MajorLift MajorLift changed the title [queued-request-controller] Convert messengers and middleware to use RestrictedControllerMessenger [queued-request-controller] Apply AllowedActions, MiddlewareMessenger patterns, fix any Nov 17, 2023
@MajorLift MajorLift force-pushed the 231101-typing-fixes-queued-request-controller branch 4 times, most recently from 49e7def to 637f2f6 Compare November 17, 2023 16:07
@MajorLift MajorLift force-pushed the 231101-typing-fixes-queued-request-controller branch from 01befcb to 12141b0 Compare November 24, 2023 17:17
@MajorLift MajorLift force-pushed the 231101-typing-fixes-queued-request-controller branch from 12141b0 to 48da295 Compare November 24, 2023 17:20
@MajorLift MajorLift changed the title [queued-request-controller] Apply AllowedActions, MiddlewareMessenger patterns, fix any [queued-request-controller,selected-network-controller] Apply AllowedActions, MiddlewareMessenger patterns, fix any Nov 24, 2023
Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super. Thanks for doing this. Just had a few comments and then I think we're good.

@MajorLift MajorLift changed the title [queued-request-controller,selected-network-controller] Apply AllowedActions, MiddlewareMessenger patterns, fix any [queued-request-controller,selected-network-controller] Apply MiddlewareMessenger pattern, fix any Nov 29, 2023
Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

@MajorLift MajorLift merged commit 3711905 into main Nov 29, 2023
@MajorLift MajorLift deleted the 231101-typing-fixes-queued-request-controller branch November 29, 2023 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-wallet-framework Deprecated: Please use `team-core-platform` instead.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[queued-request-controller, selected-network-controller] Apply AllowedActions, MiddlewareMessenger patterns, fix any

3 participants