Conversation
- also fixes scroll issue on mobile devices - also fixes weird cut-off of wallet cards on home screen
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request encompasses modifications across multiple files in the mobile UI and wallet management components. The changes primarily focus on improving layout, styling, and error handling. Key updates include adjusting vertical and horizontal padding in components, refining wallet connection logic, enhancing authentication-based rendering, and introducing more robust error handling mechanisms for transactions and network interactions. Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/components/Global/FlowHeader/index.tsx (1)
2-2: LGTM! Consider adding error boundaries.The authentication-based rendering control is a good addition. However, since this is a global component, consider wrapping it with error boundaries to gracefully handle any authentication-related errors.
+import { ErrorBoundary } from '@/components/ErrorBoundary' import { useAuth } from '@/context/authContext' const FlowHeader = ({ onPrev, disableBackBtn, disableWalletHeader = false }: FlowHeaderProps) => { const { user } = useAuth() if (!user) return null return ( + <ErrorBoundary> <div className="flex w-full flex-row items-center justify-between pb-3"> {/* ... rest of the component ... */} </div> + </ErrorBoundary> ) }Also applies to: 13-15
src/components/Request/Pay/Views/Initial.view.tsx (2)
Line range hint
274-289: Enhance error handling in network switching.The network switching implementation could be improved to provide more specific error information.
Consider this enhancement:
const switchNetwork = async (chainId: string): Promise<boolean> => { try { await switchNetworkUtil({ chainId, currentChainId: String(currentChain?.id), setLoadingState, switchChainAsync: async ({ chainId }) => { await switchChainAsync({ chainId: chainId as number }) }, }) console.log(`Switched to chain ${chainId}`) return true } catch (error) { - console.error('Failed to switch network:', error) - throw new Error(`Failed to switch to network ${chainId}`) + const errorMessage = error instanceof Error ? error.message : 'Unknown error' + console.error('Failed to switch network:', errorMessage) + throw new Error(`Failed to switch to network ${chainId}: ${errorMessage}`) } }
474-485: Clear user guidance based on wallet type.The conditional messaging provides clear instructions for both Peanut wallet and external wallet users.
However, consider extracting these messages to constants to maintain consistency and enable easier updates:
+const WALLET_MESSAGES = { + PEANUT: (tokenName: string, chainName: string) => + `You can only fulfill this payment request with ${tokenName} on ${chainName}. If you wish to use a different token or chain, please switch to an external wallet.`, + EXTERNAL: + 'You can fulfill this payment request with any token on any chain. Pick the token and chain that you want to fulfill this request with.', +} {isPeanutWallet ? ( <label className="text-start text-h9 font-light"> - You can only fulfill this payment request with {PEANUT_WALLET_TOKEN_NAME} on{' '} - {PEANUT_WALLET_CHAIN.name}. If you wish to use a different token or chain, please - switch to an external wallet. + {WALLET_MESSAGES.PEANUT(PEANUT_WALLET_TOKEN_NAME, PEANUT_WALLET_CHAIN.name)} </label> ) : ( <label className="text-start text-h9 font-light"> - You can fulfill this payment request with any token on any chain. Pick the token and - chain that you want to fulfill this request with. + {WALLET_MESSAGES.EXTERNAL} </label> )}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/app/(mobile-ui)/home/page.tsx(1 hunks)src/app/(mobile-ui)/layout.tsx(3 hunks)src/components/Global/FlowHeader/index.tsx(2 hunks)src/components/Request/Pay/Views/GeneralViews/AlreadyPaid.view.tsx(1 hunks)src/components/Request/Pay/Views/Initial.view.tsx(13 hunks)src/hooks/wallet/useWallet.ts(5 hunks)src/utils/sdkErrorHandler.utils.tsx(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- src/components/Request/Pay/Views/GeneralViews/AlreadyPaid.view.tsx
- src/app/(mobile-ui)/home/page.tsx
🧰 Additional context used
📓 Learnings (1)
src/components/Request/Pay/Views/Initial.view.tsx (1)
Learnt from: jjramirezn
PR: peanutprotocol/peanut-ui#551
File: src/components/Request/Create/Views/Initial.view.tsx:151-156
Timestamp: 2024-12-02T17:19:18.532Z
Learning: In the `InitialView` component at `src/components/Request/Create/Views/Initial.view.tsx`, when setting the default chain and token in the `useEffect` triggered by `isPeanutWallet`, it's acceptable to omit the setters from the dependency array and not include additional error handling for invalid defaults.
🔇 Additional comments (12)
src/app/(mobile-ui)/layout.tsx (3)
50-50: Great use of dynamic viewport height!Using
h-[100dvh]instead ofh-screenis a good choice as it handles mobile browser chrome better, particularly addressing the scrolling issue mentioned in the PR objectives.
76-77: LGTM! Consistent padding handling.The conditional padding for support and home pages improves the mobile layout, which aligns with the PR objective of fixing mobile UI issues.
131-131: LGTM! Consistent branding.The capitalization of "Peanut" in the wallet link text maintains brand consistency.
src/utils/sdkErrorHandler.utils.tsx (1)
64-70: LGTM! Enhanced error handling for gas-related issues.The new error cases provide clear, actionable messages for users encountering gas-related issues:
- Fee cap and gas fee errors now suggest checking fund availability
- Gas estimation errors now suggest network switching as a solution
src/hooks/wallet/useWallet.ts (3)
42-47: LGTM! Enhanced wallet account handling.Good improvement in destructuring the useAccount hook to include external wallet address and connection status.
232-232: LGTM! Improved connection status handling.Good enhancement to:
- Fallback to external wallet address when selected wallet is undefined
- Consider both selected wallet and wagmi connection status
Also applies to: 234-234
139-145: Verify the filter condition logic.The current implementation might have an edge case where a user's wallet could be filtered out if they log in after connecting their wallet.
src/components/Request/Pay/Views/Initial.view.tsx (5)
10-16: LGTM! Clean import organization.The new imports from constants are well-organized and follow a consistent pattern.
84-90: Improved wallet connection logic.The refactored wallet connection logic now correctly handles both external and Peanut wallets through a unified
isConnectedcheck.
296-304: LGTM! Robust validation checks.The validation checks for wallet address and transaction data are well-placed and provide clear error messages.
339-346: LGTM! Comprehensive cross-chain validation.The cross-chain transaction validation checks are thorough and provide clear error messages.
382-421: Well-structured button click handler.The
handleSubmitfunction effectively manages different wallet states and error scenarios.
fixes TASK-8582
fixes TASK-8456
fixes TASK-8585
fixes TASK-8080
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
UI/UX Improvements
Performance