Pass isInitializingStreamProvider to metamask_getProviderState #422
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In order to initialize the state of the StreamProvider,
metamask_getProviderState
must be called. In the extension, the current implementation of this RPC method retrieves the network version of the currently selected network vianet_version
and returns it along with other information. This creates a problem, however. Because the StreamProvider must be initialized in order to load the UI, if the network is slow or unresponsive, then users will see an infinite spinner until the request is resolved.To fix this, we inform the RPC method that the StreamProvider is being initialized. The idea is that for this special case, the extension will opt not to make a request for the network version, returning "loading". For requests for
metamask_getProviderState
outside of StreamProvider this will not be the case and the network version will be retrieved as usual.This means that StreamProvider will not have a network version initially. However, while they do expect
metamask_getProviderState
to return anetworkVersion
property, neither BaseProvider nor StreamProvider seem to do anything with it (unlike MetaMaskInpageProvider, which tracks it and allows dapps to read it).Related to MetaMask/metamask-extension#34214.
Also see MetaMask/metamask-extension#35516 where this parameter is being used.