Skip to content

feat: disable source amount input when destinationTokenAmount is fixed#457

Open
nnti3n wants to merge 1 commit intomainfrom
feat/fixed-destination-amount-deposit
Open

feat: disable source amount input when destinationTokenAmount is fixed#457
nnti3n wants to merge 1 commit intomainfrom
feat/fixed-destination-amount-deposit

Conversation

@nnti3n
Copy link
Contributor

@nnti3n nnti3n commented Feb 11, 2026

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

  • Locally
  • Unit Tests
  • Manually
  • CI/CD

Screenshots

For BE, include snippets, response payloads and/or curl commands to test endpoints

[FE] Before

[FE] After

[BE] Snippets/Response/Curl


automerge=false

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.
@nnti3n nnti3n requested a review from a team as a code owner February 11, 2026 02:38
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 AnySpendDeposit component by introducing a mechanism to disable the source amount input when a fixed destination token amount is specified. This ensures that the source amount is automatically determined via an EXACT_OUTPUT quote, improving the clarity and control for users making fixed-target deposits. A new demo component has also been added to provide a clear example of this functionality.

Highlights

  • Input Locking for Fixed Destination Amounts: The source amount input is now automatically disabled when a fixed destinationTokenAmount is provided, ensuring a streamlined user experience for fixed-target transactions.
  • Automatic Source Amount Calculation: When the destination amount is fixed, the source amount is now auto-calculated using an EXACT_OUTPUT quote, removing the need for manual input.
  • Fixed Amount Deposit Demo: A new demo component has been added to showcase the functionality of fixed amount deposits, illustrating how the input locking and auto-calculation work in practice.

🧠 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
  • apps/anyspend-demo-nextjs/src/app/components/CustomDepositButton.tsx
    • Ensured address from useAccountWallet always has a default value of an empty address string.
    • Removed redundant || "" from normalizeAddress as address is now guaranteed to be a string.
  • apps/anyspend-demo-nextjs/src/app/components/FixedAmountDepositButton.tsx
    • Added a new FixedAmountDepositButton component to demonstrate fixed amount deposits (10 USDC) using the AnySpendDeposit component with a fixed destinationTokenAmount.
  • apps/anyspend-demo-nextjs/src/app/page.tsx
    • Imported the new FixedAmountDepositButton component.
    • Rendered the FixedAmountDepositButton on the main demo page.
  • packages/sdk/src/anyspend/react/components/AnySpend.tsx
    • Passed a new disableAmountInput prop to the CryptoPaySection component when destinationTokenAmount is present.
  • packages/sdk/src/anyspend/react/components/AnySpendCustomExactIn.tsx
    • Passed a new disableAmountInput prop to the CryptoPaySection component when destinationTokenAmount is present.
  • packages/sdk/src/anyspend/react/components/common/CryptoPaySection.tsx
    • Introduced a disableAmountInput prop to control the enabled state of the source amount input and the visibility of the MAX button.
    • Passed the disableAmountInput prop as disabled to the TokenInput component.
    • Passed the disableAmountInput prop as hideMaxButton to the TokenBalance component.
  • packages/sdk/src/anyspend/react/components/common/TokenBalance.tsx
    • Added a hideMaxButton prop to conditionally hide the 'MAX' button next to the balance display.
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.

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

  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
Contributor

@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 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();
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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 ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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.

Suggested change
{!address ? (
{address === "0x0000000000000000000000000000000000000000" ? (

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