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

Remove providerConfig from NetworkController #4254

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented May 3, 2024

Explanation

Historically, the providerConfig property in NetworkController has been used to track the currently selected network as well as provide access to information about that network. The selected network is now tracked via selectedNetworkClientId, and information about that network can be retrieved by looking at the networkConfigurations property or the configuration property on the NetworkClient interface. This means that we no longer need providerConfig and we can remove this redundant state.

References

Fixes #4185.

Changelog

@metamask/assets-controllers

Changed

  • BREAKING: The messenger for NftController must allow NetworkController:getNetworkClientById (#4254)

@metamask/ens-controller

Changed

  • BREAKING: The messenger for NftController must allow NetworkController:getNetworkClientById (#4254)
  • Update listener argument to onNetworkDidChange so that it may take the full NetworkController state instead of simply an object with a providerConfig property (#4254)

@metamask/network-controller

Removed

  • BREAKING: Remove providerConfig property from state along with ProviderConfig type and NetworkController:getProviderConfig messenger action (#4254)
    • To obtain an equivalent configuration object, access the currently selected network via state.selectedNetworkClientId, pass this to the NetworkController:getNetworkClientId messenger action, and then access the configuration property on the network client.
  • Update networksMetadata state property so that the keys in the object will only ever contain network client IDs and not RPC URLs (#4254)

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

Base automatically changed from refactor-tokens-controller-tests to main May 6, 2024 15:06
Historically, the `providerConfig` property in NetworkController has
been used to track the currently selected network as well as provide
access to information about that network. The selected network is now
tracked via `selectedNetworkClientId`, and information about that
network can be retrieved by looking at the `networkConfigurations`
property or the `configuration` property on the NetworkClient interface.
This means that we no longer need `providerConfig` and we can remove
this redundant state.
@mcmire mcmire marked this pull request as ready for review May 6, 2024 17:05
@mcmire mcmire requested a review from a team as a code owner May 6, 2024 17:05
);
const { chainId } = selectedNetworkClient.configuration;

if (this.config.chainId !== chainId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a test-case for when chainId differs? If not, that could explain the reduced coverage %?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into this and I don't think it's due to additional logic. Somehow I have made something that was inadvertently tested not tested anymore. Regrettably I have added an istanbul directive to ignore the logic in question: be7f9c2

@mcmire
Copy link
Contributor Author

mcmire commented May 22, 2024

I'm going to break this up into multiple PRs as this one is rather large and difficult to review. Placing in draft until that's complete.

After that we can rebase this PR and reopen it for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs dev review
Development

Successfully merging this pull request may close these issues.

Remove providerConfig from NetworkController
2 participants