-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
FIX: Changing network to solana from networks modal #4981
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request modifies the Changes
Sequence DiagramsequenceDiagram
participant User
participant NetworkModal
participant WalletService
User->>NetworkModal: Click Network Item
NetworkModal->>NetworkModal: Determine Chain Type
alt Is Solana Chain
NetworkModal->>WalletService: handleSignOutAndSignInWithSolana()
else Other Chains
NetworkModal->>WalletService: switchChain(networkId)
end
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/components/modals/SwitchNetwork.tsx (2)
63-75
: Fix typo in function namehandleSingOutAndSignInWithEVM
.There's a typo in the function name: "Sing" should be "Sign".
-handleSingOutAndSignInWithEVM(); +handleSignOutAndSignInWithEVM();
Line range hint
78-108
: Consider adding accessibility improvements.The network selection UI could benefit from keyboard navigation and ARIA attributes.
Consider adding:
- Keyboard navigation support
- ARIA labels for network items
- Focus management
<NetworkItem onClick={() => handleNetworkItemClick(networkId, chainType)} + role="button" + tabIndex={0} + aria-label={`Switch to ${getChainName(networkId, chainType)} network`} + aria-selected={networkId === chainId} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + handleNetworkItemClick(networkId, chainType); + } + }} $isSelected={networkId === chainId} key={networkId} $baseTheme={theme} >
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/modals/SwitchNetwork.tsx
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (1)
src/components/modals/SwitchNetwork.tsx (1)
90-92
: LGTM!The onClick handler correctly implements the updated function signature by passing both networkId and chainType parameters.
const handleNetworkItemClick = (networkId: number, chainType: string) => { | ||
if (walletChainType === ChainType.SOLANA) { | ||
setPendingNetworkId(networkId); | ||
handleSingOutAndSignInWithEVM(); | ||
closeModal(); // Close the modal since we cannot control the wallet modal | ||
} else { | ||
switchChain?.({ chainId: networkId }); | ||
if (chainType === ChainType.SOLANA) { | ||
handleSignOutAndSignInWithSolana(); | ||
} else { | ||
switchChain?.({ chainId: networkId }); | ||
} | ||
closeModal(); | ||
} |
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.
🛠️ Refactor suggestion
Add error handling and loading states for network switching operations.
The network switching logic lacks error handling and loading states, which could lead to a poor user experience if the operations fail.
Consider implementing:
- Try-catch blocks for error handling
- Loading states during network switching
- User feedback for failed operations
const handleNetworkItemClick = (networkId: number, chainType: string) => {
+ try {
+ setIsLoading(true);
if (walletChainType === ChainType.SOLANA) {
setPendingNetworkId(networkId);
handleSingOutAndSignInWithEVM();
- closeModal();
} else {
if (chainType === ChainType.SOLANA) {
handleSignOutAndSignInWithSolana();
} else {
- switchChain?.({ chainId: networkId });
+ await switchChain?.({ chainId: networkId });
}
- closeModal();
}
+ closeModal();
+ } catch (error) {
+ console.error('Network switch failed:', error);
+ setError(error.message);
+ } finally {
+ setIsLoading(false);
+ }
};
Committable suggestion skipped: line range outside the PR's diff.
Summary by CodeRabbit
New Features
Bug Fixes