Skip to content

Conversation

@kingsleydon
Copy link
Collaborator

Summary

  • Create reusable hooks and components to reduce code duplication across the app
  • Add useAddTokenToWallet hook for wallet token/network addition with wagmi
  • Add shared UI components: MetaMaskIcon, MetaMaskButton, GradientText, ChainBadge
  • Replace "Phala L2" terminology with "Phala Mainnet" across the codebase

Test plan

  • Verify MetaMask "Add token" buttons work on homepage and staking page
  • Verify "Add Phala Mainnet" network button works correctly
  • Confirm chain badges display correctly on claim-assets page
  • Test wallet switching behavior when adding tokens on different chains

🤖 Generated with Claude Code

- Create useAddTokenToWallet hook to encapsulate wallet token/network addition logic
- Create MetaMaskIcon component for shared MetaMask SVG icon
- Create MetaMaskButton component with consistent styling
- Create GradientText component for gradient typography
- Create ChainBadge component for Ethereum/Phala Mainnet badges
- Update content.tsx, stake.tsx to use useAddTokenToWallet hook
- Update asset-card.tsx to use MetaMaskButton component
- Update claim-assets.tsx to use ChainBadge component
- Replace "Phala L2" terminology with "Phala Mainnet" across codebase

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Nov 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
app Ready Ready Preview Comment Nov 26, 2025 11:53pm

Comment on lines +29 to +39
address,
symbol,
decimals,
image,
},
})
return true
} catch (error) {
console.error('Failed to add token to wallet:', error)
return false
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The useAddTokenToWallet hook uses synchronous watchAsset instead of watchAssetAsync, causing broken error handling and false success reporting.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The useAddTokenToWallet hook incorrectly uses the synchronous watchAsset function instead of the asynchronous watchAssetAsync from useWatchAsset(). This prevents the try-catch block from properly handling errors during the token addition process, as watchAsset does not return a promise and is not awaited. Consequently, the function returns true immediately, providing a false success indication to callers even if the wallet interaction fails or is pending user confirmation. This defeats the purpose of error handling and leads to functional failure in the token addition workflow.

💡 Suggested Fix

Replace watchAsset with watchAssetAsync from useWatchAsset() and ensure it is awaited to correctly handle asynchronous operations and catch potential errors.

🤖 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/hooks/use-add-token-to-wallet.ts#L25-L39

Potential issue: The `useAddTokenToWallet` hook incorrectly uses the synchronous
`watchAsset` function instead of the asynchronous `watchAssetAsync` from
`useWatchAsset()`. This prevents the `try-catch` block from properly handling errors
during the token addition process, as `watchAsset` does not return a promise and is not
awaited. Consequently, the function returns `true` immediately, providing a false
success indication to callers even if the wallet interaction fails or is pending user
confirmation. This defeats the purpose of error handling and leads to functional failure
in the token addition workflow.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3918799

@kingsleydon kingsleydon merged commit b86b47b into main Nov 26, 2025
4 checks passed
@kingsleydon kingsleydon deleted the refactor/code-reuse-optimization branch November 26, 2025 23:53
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