Skip to content

feat: add privy#3

Open
luu-alex wants to merge 18 commits intoprodfrom
add-privy
Open

feat: add privy#3
luu-alex wants to merge 18 commits intoprodfrom
add-privy

Conversation

@luu-alex
Copy link

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces Privy, a comprehensive authentication and wallet management solution, to simplify user onboarding and interaction with the application. It refactors existing wallet connection components to utilize Privy's capabilities, removing custom implementations. Additionally, the changes include updates to the trading logic to fully support Hyperliquid's unified account system, enabling more flexible use of stablecoin collateral for perp trading. These updates aim to provide a more robust and user-friendly experience for wallet connections and account management.

Highlights

  • Privy Integration: Integrated Privy for streamlined wallet authentication and management, replacing the previous custom wallet dialogs across the application.
  • Unified Account Logic: Enhanced the trading logic to better support Hyperliquid's unified account system, allowing spot USD stablecoin balances (USDC/USDH) to be used as collateral for perpetual futures (perp) markets.
  • Improved User Experience: Simplified the 'Connect Wallet' and 'Disconnect' flows by leveraging Privy's hooks, reducing boilerplate code and centralizing authentication state management.
  • Build Process Enhancements: Added vite-plugin-node-polyfills to the build configuration to ensure compatibility with certain Web3 libraries, and updated SSR stubbing for Privy-related modules.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a major architectural change by integrating Privy for user authentication, replacing the previous custom wagmi-based wallet connection logic. This significantly simplifies wallet management and adds support for social logins. The implementation is thorough, touching providers, UI components, and build configurations.

Key improvements include:

  • Privy Integration: Replaces the custom wallet dialog with Privy's login modal.
  • Unified Account Support: The registration flow now automatically upgrades users to Hyperliquid's unified account mode, and balance calculations have been updated to correctly use spot stablecoin balances as collateral for perpetuals.
  • Code Simplification: The wagmi configuration is simplified, and a significant amount of custom wallet and mock wallet code has been removed.
  • Reliability: A usePrivyWagmiSync hook has been added to prevent state desynchronization between Privy and wagmi, and HTTP timeouts for the Hyperliquid client have been increased for better reliability on testnet.

The changes are well-executed. I have one suggestion regarding code cleanup.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 18, 2026

Deploying hyperterminal with  Cloudflare Pages  Cloudflare Pages

Latest commit: ef1b36d
Status:🚫  Build failed.

View logs

@socket-security
Copy link

socket-security bot commented Mar 18, 2026

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm vite is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: package.jsonnpm/vite@8.0.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/vite@8.0.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@luu-alex
Copy link
Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a major feature by integrating Privy for authentication and wallet management. The changes are extensive, replacing the previous wagmi-based wallet connection logic with Privy's hooks and UI. This includes updating dependencies, removing the old wallet dialog, and refactoring components across the application to use the new authentication flow. The PR also adds a testnet faucet feature and improves support for unified accounts by considering spot stablecoin balances as collateral and automatically upgrading user accounts. The implementation is thorough and consistent. I've found one potential issue in the token selector logic that could affect user experience, which I've detailed in a specific comment. Overall, this is a significant and well-executed enhancement.

setHighlightedIndex(0);
}
}, [deferredSearch, scope, subcategory]);
}, [open]);

Choose a reason for hiding this comment

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

medium

The dependency array for this useEffect has been changed to only include open. This is a regression, as it no longer resets the highlighted index when filters (deferredSearch, scope, subcategory) are changed while the selector is open. This can lead to a confusing user experience. To fix this and also keep the reset-on-open behavior, the dependency array should include open as well as the variables that affect the list of items.

Suggested change
}, [open]);
}, [open, deferredSearch, scope, subcategory]);

@luu-alex
Copy link
Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a significant and well-executed refactor to integrate Privy for user authentication, replacing the previous custom wallet connection logic. This simplifies the codebase and adds support for social logins and embedded wallets. Key changes include integrating Privy's hooks, removing the custom WalletDialog, adding a testnet faucet, and refactoring the application to support Hyperliquid's "Unified Account" model. The implementation appears robust, particularly the integration between Privy's wallet and the Hyperliquid SDK. My main feedback is a medium-severity suggestion to add a user confirmation step before automatically upgrading their account mode on Hyperliquid.

Comment on lines +56 to +62
// Switch to unified account if user is in default/DEX abstraction mode.
// Unified account allows spot USDH/USDC balances to be used as perp collateral.
const abstractionMode = await fetchUserAbstraction(env, address);
if (abstractionMode === "default" || abstractionMode === "dexAbstraction") {
setCurrentStep("abstraction");
await setAbstraction.mutateAsync({ user: address, abstraction: "unifiedAccount" });
}

Choose a reason for hiding this comment

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

medium

The automatic upgrade of a user's account to unifiedAccount mode within the register function is a significant action that is likely irreversible. While this enables the unified account features, performing this upgrade without explicit user consent could be surprising.

Consider adding a confirmation step, like a modal dialog, to inform the user about this one-time account upgrade. This dialog could explain the benefits (e.g., using spot balances as collateral for perpetuals) and ask for their explicit consent before proceeding. This would improve transparency and ensure users are aware of the changes being made to their Hyperliquid account.

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.

1 participant