Skip to content
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

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

solidovic
Copy link
Contributor

@solidovic solidovic commented Oct 30, 2024

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:

  • Checked the changes locally.
  • Created / updated analytics events.
  • Created / updated the technical documentation (README.md / docs / etc.).
  • Affects / requires changes in other services (Matomo / Sentry / CloudFlare / etc.).

@solidovic solidovic marked this pull request as ready for review October 30, 2024 11:03
@solidovic solidovic requested review from a team as code owners October 30, 2024 11:03
…chainid-and-rpc' into feature/si-1638-chain-toggle-changes-wallet-chain
@preview-stands
Copy link

preview-stands bot commented Oct 30, 2024

Preview stand status

Stand was demolished

getChainIdByChainType(newChainType, config.supportedChains) ??
config.defaultChain;

switchChain({ chainId: newChainId });
Copy link
Contributor

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.

Copy link
Contributor

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) => {
Copy link
Contributor

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.

Base automatically changed from feature/si-1641-refactoring-single-source-of-truth-for-chainid-and-rpc to develop November 4, 2024 12:10
@solidovic solidovic marked this pull request as draft November 6, 2024 08:12
@solidovic
Copy link
Contributor Author

This is pending the integration of the new SDK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants