refactor: improve page metadata and code organization#442
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| import '@rainbow-me/rainbowkit/styles.css' | ||
| import {WagmiProvider, cookieToInitialState} from 'wagmi' | ||
|
|
||
| const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID as string |
There was a problem hiding this comment.
Bug: Missing runtime validation for NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID can lead to undefined being passed to critical initialization functions.
Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The code uses as string assertions without runtime validation in apps/app/lib/wagmi.ts:5 and apps/app/components/Web3Provider.tsx:10. If NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID is not set, projectId becomes undefined. This undefined value is passed directly to WagmiAdapter and createAppKit(), which expect a string. Without validation or error handling, these libraries will throw an error during initialization, causing the application to crash before rendering.
💡 Suggested Fix
Add runtime validation for NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID before passing it to WagmiAdapter and createAppKit(). Throw an explicit error if it's undefined to provide clear configuration feedback.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: apps/app/components/Web3Provider.tsx#L10
Potential issue: The code uses `as string` assertions without runtime validation in
`apps/app/lib/wagmi.ts:5` and `apps/app/components/Web3Provider.tsx:10`. If
`NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID` is not set, `projectId` becomes `undefined`. This
`undefined` value is passed directly to `WagmiAdapter` and `createAppKit()`, which
expect a string. Without validation or error handling, these libraries will throw an
error during initialization, causing the application to crash before rendering.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3652791
5c6228c to
23bcfb0
Compare
23bcfb0 to
dfa9f8f
Compare
dfa9f8f to
e49972b
Compare
e49972b to
28572f8
Compare
28572f8 to
6ca3e37
Compare
- Add Next.js metadata exports to all pages (staking, gpu-mining, khala-assets) - Remove unnecessary 'use client' directives from page components - Extract client-side logic into separate content.tsx files - Replace DePHY text link with SVG logo in GPU Mining page - Remove unused Title component - Simplify PageHeader component props - Migrate from RainbowKit to Reown AppKit for wallet connection - Update MUI package versions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
6ca3e37 to
8ebc082
Compare
- Move favicon and icons from public/ to app/ directory - Replace static site.webmanifest with manifest.ts using Metadata API - Remove manual icons config from layout.tsx (auto-detected by Next.js) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove cSpell words from VSCode settings - Simplify README content 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Replace useAccount with useAppKitAccount for wallet connection state - Replace useSwitchChain with useAppKitNetwork.switchNetwork for chain switching - Update mainnet import from viem/chains to @reown/appkit/networks - Rename all component/hook files to kebab-case naming convention - Add variant="contained" to Connect Wallet buttons for solid style - Remove unused createPolkadotApi and weightedAverage utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Created a reusable toAddress function in lib/wagmi.ts that uses viem's isAddress type guard to safely convert string addresses to the Address type required by wagmi hooks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add StakingStats component with StatCard for APR, Your Stake, and TVL - Create useValidConnection hook to reduce code duplication - Fix SSR hydration flash for SwitchChainButton - Update terminology: Unstake -> Withdrawal, Countdown -> Time Remaining - Improve responsive layout and spacing consistency - Remove blur overlay for stats cards, show "-" when not connected 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add new homepage with portfolio summary, asset cards, and quick actions - Create PortfolioSummary component for total balance display - Create AssetCard component for individual asset display - Create QuickActions component for common staking operations - Improve claim-assets component with better layout and network validation - Add network validation to disable RPC queries on wrong network - Update wagmi config and Next.js configuration - Fix trimAddress utility for address formatting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
e2d7f95 to
57cabcb
Compare
Summary
Test plan
🤖 Generated with Claude Code