[WIP] feat: chain toggle changes wallet chain#530
Conversation
…chainid-and-rpc' into feature/si-1638-chain-toggle-changes-wallet-chain
Preview stand statusStand was demolished |
| getChainIdByChainType(newChainType, config.supportedChains) ?? | ||
| config.defaultChain; | ||
|
|
||
| switchChain({ chainId: newChainId }); |
There was a problem hiding this comment.
We need to check if cuurent connector has switchChain method and avoid calling this. Also error handlers that print warning to console if switchChain failed.
There was a problem hiding this comment.
Also would love to experiment with async UX, where we on user selecting chain and if there is switchChain avaliable:
- disable selector UI
- try with timeout to swithChain
- if successfull then commit changes with
setChainType - if error toast user
| }, [walletChainId, isConnected, setChainType]); | ||
|
|
||
| const handleSetChainType = useCallback<React.Dispatch<DAPP_CHAIN_TYPE>>( | ||
| (newChainType) => { |
There was a problem hiding this comment.
I am thinking we try something here:
Instead of chainType on selector, we select chainId. So for tesntent we would have Holesky and OP sepolia namings. No changes to prod UX. Also would allow in dev to select any chain you have in supported. This would also simpligy this code as chainId->chainType mapping is very clear.
ChainType still serves a purpose, as it allows us to get correct UI color and etc.
|
This is pending the integration of the new SDK |
|
see: #571 |
Description
A click of chain toggle changes wallet chain id.
More precisely, the widget request to the wallet to switch the network, each wallet processes such a request differently.
Testing notes
We don't understand whether it will work on all wallets.
Checklist: