fix: render token details for peanut wallet#653
fix: render token details for peanut wallet#653kushagrasarathe merged 3 commits intopeanut-walletfrom
Conversation
- fixes TASK-8400 where tokens were not rendered for penaut wallet even if a user has balance in wallet - also fixes TASK-8399 where disconnect button would appear on all wallet pages, independent of the connection status
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request introduces changes to wallet management and UI components. The primary modifications occur in the Changes
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
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 (2)
src/app/(mobile-ui)/wallet/page.tsx (2)
35-37: Consider using type guard instead of type assertion.The type assertion
as IWalletinisWalletConnected(walletDetails as IWallet)could be unsafe. Consider using a type guard to ensure type safety.-const isConnected = isWalletConnected(walletDetails as IWallet) +const isConnected = walletDetails ? isWalletConnected(walletDetails) : false
48-102: Consider extracting common rendering logic and improving type safety.While the function successfully addresses the token rendering issue, there are a few improvements that could be made:
- Extract common JSX structure to reduce duplication:
const BalanceSection = ({ title, children }: { title: string; children: React.ReactNode }) => ( <div className="space-y-3"> <div className="text-base font-semibold">Balance</div> <div className="border border-b-n-1"> {children} </div> </div> );
- Consider using constants for magic numbers in formatting:
const DECIMAL_PLACES = 2; const formatValue = (value: number) => value.toFixed(DECIMAL_PLACES);
- Add early return type guard:
-if (!walletDetails) return null; +if (!walletDetails || typeof walletDetails !== 'object') return null;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/app/(mobile-ui)/wallet/page.tsx(3 hunks)
🔇 Additional comments (3)
src/app/(mobile-ui)/wallet/page.tsx (3)
3-21: LGTM! Clean import organization.The new imports for wallet-related constants, types, and hooks are well-organized and align with the component's requirements.
128-129: Verify if top-up should be disabled.The top-up button is hardcoded as disabled. Is this intentional or should it be conditionally disabled based on wallet state?
134-143: LGTM! Clean implementation of connect/disconnect button.The conditional rendering and state management for the connect/disconnect button effectively addresses TASK-8399. The implementation properly handles the visibility based on wallet type and connection status.
| () => wallets.find((wallet) => wallet.address === focusedWallet), | ||
| [focusedWallet, wallets] | ||
| ) | ||
| const walletDetails = wallets.find((wallet) => wallet.address === focusedWallet) |
There was a problem hiding this comment.
Nit: why wallet.address is the id in this case? accountId from BE would be better imo. Then again we also have accountIdentifier in Backend, so address works kinda too. But the var names should be renamed if we add banking accounts to selectable accounts
| }} | ||
| metadata={{ | ||
| tokenLogo: ARBITRUM_ICON, | ||
| subText: `${formatAmount(formatUnits(walletDetails.balance, PEANUT_WALLET_TOKEN_DECIMALS))} USDC`, |
There was a problem hiding this comment.
I still hate formatAmount(formatUnits)
There was a problem hiding this comment.
ouch, this one can be fixed, my baddd, mee dummbbb
Hugo0
left a comment
There was a problem hiding this comment.
small pr, see no major issue. pls review comments and ping on discord if any answer
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
src/constants/zerodev.consts.ts (1)
Environment variables documentation is missing
The environment variables are properly used in the code, but there's a critical documentation gap:
- README mentions copying
.env.example, but the file is missing from the repository- ZeroDev environment variables are not documented anywhere in the codebase
- No setup instructions for these required environment variables
Please:
- Create an
.env.examplefile documenting all required environment variables- Add setup instructions for ZeroDev-specific variables in the README or documentation
- Include the source/documentation for obtaining these values from the ZeroDev dashboard
🔗 Analysis chain
Line range hint
4-11: Verify environment variables are properly configured.The configuration follows security best practices by using environment variables. Please ensure these environment variables are properly set in your deployment environment:
- NEXT_PUBLIC_ZERO_DEV_BUNDLER_URL
- NEXT_PUBLIC_ZERO_DEV_PAYMASTER_URL
- NEXT_PUBLIC_ZERO_DEV_PASSKEY_SERVER_URL
- NEXT_PUBLIC_ZERO_DEV_PASSKEY_PROJECT_ID
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check if environment variables are documented in README or .env.example echo "Checking for environment variables documentation..." rg -l "NEXT_PUBLIC_ZERO_DEV_(BUNDLER|PAYMASTER|PASSKEY)" --type md fd -e example -e sample -x rg "NEXT_PUBLIC_ZERO_DEV_(BUNDLER|PAYMASTER|PASSKEY)"Length of output: 264
Script:
#!/bin/bash # Search for all occurrences of ZeroDev environment variables echo "Searching for ZeroDev environment variables usage..." rg "NEXT_PUBLIC_ZERO_DEV_(BUNDLER|PAYMASTER|PASSKEY)" -l echo -e "\nChecking for .env files..." fd -H "^\.env" --type f echo -e "\nChecking for configuration files..." fd -e json -e js -e ts -e yaml -e yml --type f -d 1Length of output: 730
Script:
#!/bin/bash echo "Checking next.config.js for environment configuration..." cat next.config.js echo -e "\nChecking README.md for setup instructions..." if [ -f README.md ]; then cat README.md fi echo -e "\nChecking for documentation in docs directory..." fd -t d "^docs$"Length of output: 8202
Script:
#!/bin/bash echo "Searching for environment example files (case insensitive)..." fd -I "env.example|env.sample" --type f echo -e "\nChecking docs directory for environment setup..." fd . docs/ -t f -e md -e mdx | xargs cat echo -e "\nChecking for any env-related files..." fd -I "env" --type fLength of output: 7770
🧹 Nitpick comments (1)
src/constants/zerodev.consts.ts (1)
16-16: Maintain consistent comment style.For consistency with other comments in the file, add a space after //:
-export const PEANUT_WALLET_TOKEN_DECIMALS = 6 //USDC decimals +export const PEANUT_WALLET_TOKEN_DECIMALS = 6 // USDC decimals
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/app/(mobile-ui)/wallet/page.tsx(3 hunks)src/constants/zerodev.consts.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/app/(mobile-ui)/wallet/page.tsx
🧰 Additional context used
🪛 Gitleaks (8.21.2)
src/constants/zerodev.consts.ts
17-17: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🔇 Additional comments (2)
src/constants/zerodev.consts.ts (2)
1-2: LGTM! Import statements are correctly defined.
16-18: Verify USDC contract address and decimals.Please verify:
- The USDC contract address is correct for Arbitrum mainnet
- The decimals value matches the token's configuration
✅ Verification successful
✅ USDC configuration verified
The token configuration is correct and consistent:
- Contract address matches Arbitrum USDC across multiple files
- Decimals value of 6 is correct for USDC
- Token name is consistently referenced
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify USDC contract details on Arbitrum # Fetch contract details from Arbiscan API curl -s "https://api.arbiscan.io/api?module=token&action=tokeninfo&contractaddress=0xaf88d065e77c8cc2239327c5edb3a432268e5831&apikey=YourApiKey" | jq '.result | {name, symbol, decimals}'Length of output: 253
Script:
#!/bin/bash # Search for USDC contract address usage echo "=== Searching for USDC contract address ===" rg -i "0xaf88d065e77c8cc2239327c5edb3a432268e5831" -A 2 -B 2 echo -e "\n=== Searching for USDC decimals configuration ===" rg -i "decimals.*=.*6.*usdc" -A 2 -B 2 echo -e "\n=== Searching for USDC token configurations ===" rg -i "usdc.*contract|contract.*usdc" -A 2 -B 2Length of output: 1572
🧰 Tools
🪛 Gitleaks (8.21.2)
17-17: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
Summary by CodeRabbit
New Features
Improvements
Technical Updates