-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Behavior for NetworkController.findNetworkClientIdByChainId
method/action is potentially surprising if more than one network has same chain ID
#3686
Comments
We intentionally mirrored the behavior of I wouldn't call it undefined, but it's certainly not a reasonable solution. For |
NetworkController.findNetworkClientIdByChainId
method/action is undefined if more than one network has same chain IDNetworkController.findNetworkClientIdByChainId
method/action is potentially surprising if more than one network has same chain ID
Right, it's coming back to me now, thanks for the pointer on that. I've updated the PR title to be more accurate. The reason I'm bringing up this method is that now that it's part of the public API, we might be tempted to use it in order to get from chain ID to network client ID (in fact I've seen it pop up in a PR recently). The existence of this method implies that there is a one-to-one mapping between chain ID and network client ID, but that's not true at all. So it's a pretty big footgun — but you wouldn't know it if you just stumbled across this. Considering that we had to create this for |
We can mark it as deprecated, that would work as a warning against using it |
This issue is still relevant, and I would mark it as a defect that we need to rectify. The Wallet API team can still use this method but I agree with deprecating it so that people do not use it long-term. |
We believe we can fix the method now rather than deprecate it. |
This might impact work on the Assets team. |
For more details on how we can fix the method, we can now:
|
This method returns the network client that hits the chain with the given identifier. This is a problem because more than one network client can be assigned to the same chain ID. This method just returns the first one that matches, but that may not be the network client that the consumer expected, especially if the user has added a custom network that overrides a built-in one (for instance, Mainnet).
The text was updated successfully, but these errors were encountered: