-
Notifications
You must be signed in to change notification settings - Fork 17
Description
At the moment you have the rLogin.showChangeNetwork() functionality.
This dialog basically shows the available network ids (which for me as a user, doesn't say too much compared to the network name..) and lets me choose the selected one.
Today in most modern dapps, the dapp itself has a dropdown to switch the chain it works with.
This is in order to provide a much better UX as it's there at the front of the page and not in a dedicated dialog that requires more clicks.
Here is Uniswap for example (but really any multichain dapp has something similar):

That means that the dapp has already information on the chain the user would like to connect to.
So while rLogin has the function showChangeNetwork, IMHO a much more needed function is: switchNetwork / changeNetwork (I prefer switch as it's the terminology metamask uses.
While I can do it with the provider directly, IMHO it would be easier for the developers using rLogin to have such an easy function supported.
That way if someone would like to use the showChangeNetwork, they can still do it. My bet is that most dapps will need the switchNetwork more as if they support multichain (which due to multichain.org coming to RSK more and more dapps will need it), they most likely already know which network to switch to thanks to their network picker dropdown.
Special case
What happens when I'm choosing a network to connect to (using the dapp's dropdown) and then I don't have the chain setup on my metamask/wallet?
Uniswap and all the major dapps already solve that as well!

When trying to switch the network, rLogin could also invoke the register new network details if needed.
@ilanolkies and I talked about why should rLogin do that instead of just using the provider by the developers. IMO the answer is - to make it easier for developers using rLogin. Instead of us need to handle these cases, it can be done once by rLogin and make everyone else's lives easier.
Bottom line
- Add the
switchNetworkmethod to rLogin - This method should get the network full details (so it could handle registering the network in case needed). For example:
const options = {
chainId: 42161,
networkName: "Arbitrum",
networkRpcUrl: "....",
nativeCurrencySymbol: "ETH",
blockExplorerUrl: "https://arbiscan.io/"
};
this.rLogin.switchNetwork(options);