feat: disable source amount input when destinationTokenAmount is fixed#457
feat: disable source amount input when destinationTokenAmount is fixed#457
Conversation
When destinationTokenAmount is provided, both source and destination amount inputs are now locked. Source amount is auto-calculated via EXACT_OUTPUT quote. Also adds fixed amount deposit demo.
Summary of ChangesHello @nnti3n, 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 enhances the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe 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
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 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a feature to handle fixed destination amounts by disabling the source amount input and calculating it based on an EXACT_OUTPUT quote. The changes in the SDK components look solid and correctly implement this logic. A new demo component FixedAmountDepositButton is also added to showcase this functionality. However, I've found a recurring issue in both the new and the modified demo components where providing a default zero address for an unauthenticated user breaks the logic for displaying a 'Please sign in' message. This should be addressed to ensure correct behavior for unauthenticated users.
|
|
||
| export function CustomDepositButton() { | ||
| const { address } = useAccountWallet(); | ||
| const { address = "0x0000000000000000000000000000000000000000" } = useAccountWallet(); |
There was a problem hiding this comment.
Providing a default value for address here makes it a truthy string (the zero address) even when no user is signed in. This causes the check !address on line 126 to always evaluate to false, preventing the 'Please sign in' message from being displayed. A similar issue exists in the new FixedAmountDepositButton component. To fix this, the condition on line 126 should be changed to check for the zero address, for example: address === '0x0000000000000000000000000000000000000000'. It would be best to import and use the ZERO_ADDRESS constant for both the default value and the check.
| {isModalOpen && ( | ||
| <div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50"> | ||
| <div className="relative w-full max-w-md overflow-y-auto overflow-x-hidden rounded-2xl bg-white shadow-xl"> | ||
| {!address ? ( |
There was a problem hiding this comment.
Since address is given a default value of the zero address on line 13, this check !address will always evaluate to false. To correctly check if a user is not signed in, you should compare address to the zero address. It's also a good practice to import and use the ZERO_ADDRESS constant for this check and the default value.
| {!address ? ( | |
| {address === "0x0000000000000000000000000000000000000000" ? ( |
When destinationTokenAmount is provided, both source and destination amount inputs are now locked. Source amount is auto-calculated via EXACT_OUTPUT quote. Also adds fixed amount deposit demo.
[LINEAR_ISSUE_ID_HERE]
Description
Write a description.
Test Plan
Screenshots
For BE, include snippets, response payloads and/or curl commands to test endpoints
[FE] Before
[FE] After
[BE] Snippets/Response/Curl
automerge=false