-
Notifications
You must be signed in to change notification settings - Fork 13
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
[WIP] feat: chain toggle changes wallet chain #530
base: develop
Are you sure you want to change the base?
[WIP] feat: chain toggle changes wallet chain #530
Conversation
…chainid-and-rpc' into feature/si-1638-chain-toggle-changes-wallet-chain
Preview stand statusPreview stand available on testnet |
getChainIdByChainType(newChainType, config.supportedChains) ?? | ||
config.defaultChain; | ||
|
||
switchChain({ chainId: newChainId }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -139,12 +141,25 @@ export const SupportL2Chains: React.FC<React.PropsWithChildren> = ({ | |||
} | |||
}, [walletChainId, isConnected, setChainType]); | |||
|
|||
const handleSetChainType = useCallback<React.Dispatch<DAPP_CHAIN_TYPE>>( | |||
(newChainType) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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: