Skip to content
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

[queued-request-controller] Emit event when the network is switched #3983

Closed
Gudahtt opened this issue Feb 26, 2024 · 0 comments · Fixed by #3781
Closed

[queued-request-controller] Emit event when the network is switched #3983

Gudahtt opened this issue Feb 26, 2024 · 0 comments · Fixed by #3781

Comments

@Gudahtt
Copy link
Member

Gudahtt commented Feb 26, 2024

The updated designs for the Amon Hen RPC queue release no longer use a wallet_switchEthereumChain confirmation screen each time the network gets switched. Instead we are using a notification, informing the user that the switch happened rather than asking them each time.

The queued request controller should be updated to emit a custom event when it triggers a network switch, which can in turn trigger this notification. This would replace the call to ApprovalController:addRequest, which triggers the confirmation screen today.

@Gudahtt Gudahtt added the enhancement New feature or request label Feb 26, 2024
@Gudahtt Gudahtt self-assigned this Feb 27, 2024
Gudahtt added a commit that referenced this issue Feb 27, 2024
When the `QueuedRequestController` requires the globally selected
network to be changed, we now emit an event rather than triggering a
confirmation. This aligns with recent designs for this use case.

The actions `NetworkController:getNetworkConfigurationByNetworkClientId`
and `ApprovalController:addRequest` were only used for triggering the
switch network confirmation, so they are no longer needed now. They
have been removed. This removes the last dependency of this controller
on the `ApprovalController`, so it has been removed as a dependency as
well.

Closes #3983
Gudahtt added a commit that referenced this issue Feb 27, 2024
When the `QueuedRequestController` requires the globally selected
network to be changed, we now emit an event rather than triggering a
confirmation. This aligns with recent designs for this use case.

The actions `NetworkController:getNetworkConfigurationByNetworkClientId`
and `ApprovalController:addRequest` were only used for triggering the
switch network confirmation, so they are no longer needed now. They
have been removed. This removes the last dependency of this controller
on the `ApprovalController`, so it has been removed as a dependency as
well.

Closes #3983
Gudahtt added a commit that referenced this issue Feb 29, 2024
When the `QueuedRequestController` requires the globally selected
network to be changed, we now emit an event rather than triggering a
confirmation. This aligns with recent designs for this use case.

The actions `NetworkController:getNetworkConfigurationByNetworkClientId`
and `ApprovalController:addRequest` were only used for triggering the
switch network confirmation, so they are no longer needed now. They
have been removed. This removes the last dependency of this controller
on the `ApprovalController`, so it has been removed as a dependency as
well.

Closes #3983
Gudahtt added a commit that referenced this issue Feb 29, 2024
…nt (#3987)

## Explanation

When the `QueuedRequestController` requires the globally selected
network to be changed, we now emit an event rather than triggering a
confirmation. This aligns with recent designs for this use case.

The actions `NetworkController:getNetworkConfigurationByNetworkClientId`
and `ApprovalController:addRequest` were only used for triggering the
switch network confirmation, so they are no longer needed now. They have
been removed. This removes the last dependency of this controller on the
`ApprovalController`, so it has been removed as a dependency as well.

## References

Closes #3983

## Changelog

### `@metamask/package-a`

#### Changed
- **BREAKING:** The `QueuedRequestController` no longer triggers a
confirmation when a network switch is needed
  - The network switch now happens automatically, with no confirmation.
- A new `QueuedRequestController:networkSwitched` event has been added
to communicate when this has happened.
- The `QueuedRequestController` messenger no longer needs access to the
actions `NetworkController:getNetworkConfigurationByNetworkClientId` and
`ApprovalController:addRequest`.
- The package `@metamask/approval-controller` has been completely
removed as a dependency

## 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
Gudahtt added a commit that referenced this issue Mar 1, 2024
…nt (#3987)

## Explanation

When the `QueuedRequestController` requires the globally selected
network to be changed, we now emit an event rather than triggering a
confirmation. This aligns with recent designs for this use case.

The actions `NetworkController:getNetworkConfigurationByNetworkClientId`
and `ApprovalController:addRequest` were only used for triggering the
switch network confirmation, so they are no longer needed now. They have
been removed. This removes the last dependency of this controller on the
`ApprovalController`, so it has been removed as a dependency as well.

## References

Closes #3983

## Changelog

### `@metamask/package-a`

#### Changed
- **BREAKING:** The `QueuedRequestController` no longer triggers a
confirmation when a network switch is needed
  - The network switch now happens automatically, with no confirmation.
- A new `QueuedRequestController:networkSwitched` event has been added
to communicate when this has happened.
- The `QueuedRequestController` messenger no longer needs access to the
actions `NetworkController:getNetworkConfigurationByNetworkClientId` and
`ApprovalController:addRequest`.
- The package `@metamask/approval-controller` has been completely
removed as a dependency

## 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
@Gudahtt Gudahtt closed this as completed in 8d74b81 Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants