core icon indicating copy to clipboard operation
core copied to clipboard

Ensure initial networkType/chainID is passed into each controller

Open Gudahtt opened this issue 3 years ago • 4 comments

Many controllers initialize with the chainId or networkType set to 1 or MAINNET respectively, because that is the default network. The configuration gets updated whenever the network state changes, but until the first state change it might be invalid.

As a general rule we should ensure the initial chainId/networkType is set via the actual network controller state, passed in via the constructor.

Gudahtt avatar May 31 '22 16:05 Gudahtt

Maybe best to wait until after #808 is merged, to avoid conflicts

Gudahtt avatar May 31 '22 16:05 Gudahtt

We should see whether we still want controllers to take chainId or whether it would be better at this point to take a networkClientId.

mcmire avatar Apr 22 '24 18:04 mcmire

It sounds like we want to use chainId long-term: https://github.com/MetaMask/core/issues/3793#issuecomment-2072919588

mcmire avatar Apr 24 '24 20:04 mcmire

This problem is largely solved already: all but one of the controllers already take a chainId (or a function that can be used to obtain the current chain ID) and then initialize it or something that uses it in the constructor.

The only controller that we need to do this for now is EnsController.

mcmire avatar May 01 '24 17:05 mcmire