Skip to content

feat: Choose Payment Method: highlight ability to do swaps#3777

Draft
ajaysehwal wants to merge 4 commits intoZeusLN:masterfrom
ajaysehwal:choose-payment-swap
Draft

feat: Choose Payment Method: highlight ability to do swaps#3777
ajaysehwal wants to merge 4 commits intoZeusLN:masterfrom
ajaysehwal:choose-payment-swap

Conversation

@ajaysehwal
Copy link
Copy Markdown
Contributor

@ajaysehwal ajaysehwal commented Mar 2, 2026

Description

Please enter a description and screenshots, if appropriate, of the work covered in this PR

Simulator Screenshot - iPhone 17 Pro - 2026-03-03 at 19 20 41

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Configuration change
  • Locales update
  • Quality assurance
  • Other

Checklist

  • I’ve run yarn run tsc and made sure my code compiles correctly
  • I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • I’ve run yarn run prettier and made sure my code is formatted correctly
  • I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • Android
  • iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

  • Embedded LND
  • LND (REST)
  • LND (Lightning Node Connect)
  • Core Lightning (CLNRest)
  • Nostr Wallet Connect
  • LndHub

Locales

  • I’ve added new locale text that requires translations
  • I’m aware that new translations should be made on the ZEUS Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • Contributors will need to run yarn after this PR is merged in
  • 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • Changes were made that require an update to the README
  • Changes were made that require an update to onboarding

@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 enhances the "Choose Payment Method" screen by introducing the ability to initiate swaps directly from this interface. It integrates swap-related state management and logic, allowing the application to evaluate if a user's entered amount is suitable for a swap. When a swap is feasible, a dedicated icon appears, providing a quick pathway to the swap functionality, thereby streamlining the user experience for converting funds between on-chain and lightning networks.

Highlights

  • Swap Integration: Integrated the SwapStore into the ChoosePaymentMethod component to manage swap-related data and logic.
  • Swap Eligibility Logic: Implemented new methods (bigCeil, calculateSendAmount, calculateLimit, isAmountValidToSwap) to determine if a given amount is valid for a swap based on service fees, miner fees, and swap limits.
  • Dynamic Swap Button: Added a SwapIconButton that appears in the header of the ChoosePaymentMethod screen, allowing users to initiate a swap if the entered amount is eligible.
  • Navigation to Swaps: Introduced a navigateToSwaps function to transition the user to the 'Swaps' screen, pre-filling it with the initial invoice and amount for an OnChain to LN swap.
Changelog
  • views/ChoosePaymentMethod.tsx
    • Imported TouchableOpacity, BigNumber, SwapStore, and SwapIcon.
    • Added SwapStore to the component's props and injected it using @Inject.
    • Introduced validAmountToSwap to the component's state to track swap eligibility.
    • Modified componentDidMount to calculate and set validAmountToSwap after state updates.
    • Implemented utility functions bigCeil, calculateSendAmount, and calculateLimit for swap fee and limit calculations.
    • Added isAmountValidToSwap method to check if the current amount falls within swap limits.
    • Created navigateToSwaps to handle navigation to the 'Swaps' screen with relevant invoice and amount data.
    • Defined a SwapIconButton component to render the swap icon.
    • Conditionally rendered the SwapIconButton in the Header's rightComponent based on canSwap eligibility.
Activity
  • No specific activity (comments, reviews, etc.) was provided in the context.
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
Copy Markdown
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 adds a convenient swap icon to the 'Choose Payment Method' screen, allowing users to quickly navigate to the swaps feature when a payment amount is valid for a swap. The implementation correctly identifies when a swap is possible and renders the icon accordingly. My review includes suggestions to improve code quality by removing duplicated utility functions, simplifying state updates, improving type safety, and avoiding a React anti-pattern for better performance and maintainability.

@ajaysehwal ajaysehwal force-pushed the choose-payment-swap branch 4 times, most recently from af82ee5 to 22fb5f3 Compare March 2, 2026 15:41
@ajaysehwal ajaysehwal force-pushed the choose-payment-swap branch from b6a8d64 to b4063fc Compare March 3, 2026 13:44
@ajaysehwal ajaysehwal force-pushed the choose-payment-swap branch from b4063fc to 618d719 Compare March 3, 2026 13:49
@ajaysehwal ajaysehwal force-pushed the choose-payment-swap branch from a40aab7 to fea17be Compare March 3, 2026 14:07
@ajaysehwal ajaysehwal marked this pull request as ready for review March 3, 2026 14:18
@ajaysehwal
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
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 helpful feature that highlights the possibility of performing a swap directly from the 'Choose Payment Method' screen. The implementation is well-structured, but a critical correctness issue in the swap amount validation logic, specifically regarding minerFee calculation, has been identified and should be addressed.

@ajaysehwal ajaysehwal force-pushed the choose-payment-swap branch from 3b10ff8 to 8f59d71 Compare March 3, 2026 15:06
@ajaysehwal ajaysehwal marked this pull request as draft March 3, 2026 15:41
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