Skip to content

fix: remove duplicate swap fee fetch on startup#3920

Open
a-khushal wants to merge 3 commits intoZeusLN:masterfrom
a-khushal:fix/swap-fees-dupe
Open

fix: remove duplicate swap fee fetch on startup#3920
a-khushal wants to merge 3 commits intoZeusLN:masterfrom
a-khushal:fix/swap-fees-dupe

Conversation

@a-khushal
Copy link
Copy Markdown
Contributor

Description

Relates to issue: ZEUS-3911

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):

On-device

  • Embedded LND
  • LDK Node

Remote

  • 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

@a-khushal a-khushal marked this pull request as ready for review March 30, 2026 06:23
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 removes the call to SwapStore.getSwapFees() within the Wallet component's connection logic, specifically when node information is being fetched. There are no review comments to evaluate, and I have no feedback to provide.

Copy link
Copy Markdown
Contributor

@ajaysehwal ajaysehwal left a comment

Choose a reason for hiding this comment

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

https://github.com/a-khushal/zeus/blob/360e23986870b2b9a6ce6e186b3f2f173d2fc2fa/stores/SwapStore.ts#L54

@a-khushal, I think we should add { fireImmediately: true } to the getHost → getSwapFees reaction so the first fee load still runs when getHost doesn’t change after connect.

@a-khushal a-khushal force-pushed the fix/swap-fees-dupe branch 4 times, most recently from 9275eb8 to 2bc656d Compare April 4, 2026 06:20
@myxmaster
Copy link
Copy Markdown
Collaborator

There is a regression in Send.tsx and PaymentRequest.tsx: both views consume SwapStore.reverseInfo/subInfo to decide whether to show the swap icon in header, but neither fetches up-to-date fees/data themselves. Since startup no longer preloads data from swap provider, we would not see the swap icon, although amount is inside the min/max limits for a swap (isAmountValidToSwap returns false silently because the store data is empty).

My commit myxmaster@a0f742a (cherry-pick if you want) fixes this by:

  • Send.tsx: triggering getSwapFees() in componentDidUpdate when transactionType resolves to 'On-chain' (lazy, only when a swap is actually relevant), and moving the isAmountValidToSwap check out of local state into render() directly so MobX reactivity kicks in when swap fees/data arrive
  • PaymentRequest.tsx: same approach, getSwapFees() fire-and-forget in componentDidMount, and isAmountValidToSwap() evaluated in render() (not in the nested SwapButton sub-component, where MobX tracking wouldn't apply) so the button appears automatically once fees load

@a-khushal a-khushal force-pushed the fix/swap-fees-dupe branch 2 times, most recently from 971a9e1 to 3443681 Compare April 5, 2026 17:21
@a-khushal
Copy link
Copy Markdown
Contributor Author

There is a regression in Send.tsx and PaymentRequest.tsx: both views consume SwapStore.reverseInfo/subInfo to decide whether to show the swap icon in header, but neither fetches up-to-date fees/data themselves. Since startup no longer preloads data from swap provider, we would not see the swap icon, although amount is inside the min/max limits for a swap (isAmountValidToSwap returns false silently because the store data is empty).

My commit myxmaster@a0f742a (cherry-pick if you want) fixes this by:

  • Send.tsx: triggering getSwapFees() in componentDidUpdate when transactionType resolves to 'On-chain' (lazy, only when a swap is actually relevant), and moving the isAmountValidToSwap check out of local state into render() directly so MobX reactivity kicks in when swap fees/data arrive
  • PaymentRequest.tsx: same approach, getSwapFees() fire-and-forget in componentDidMount, and isAmountValidToSwap() evaluated in render() (not in the nested SwapButton sub-component, where MobX tracking wouldn't apply) so the button appears automatically once fees load

I cherry-picked your fix (a0f742a) into this branch.

@myxmaster
Copy link
Copy Markdown
Collaborator

Ah, we should also handle the empty initial state of reverseInfo/subInfo in isAmountValidToSwap in both Send.tsx:

if (!reverseInfo || Object.keys(reverseInfo).length === 0) {

and PaymentRequest.tsx:

if (!subInfo || Object.keys(subInfo).length === 0) {

Otherwise the swap icon is shortly displayed before fees are loaded.

Besides that:
tACK

@a-khushal a-khushal force-pushed the fix/swap-fees-dupe branch 2 times, most recently from 0e15ccf to fd2bd2d Compare April 7, 2026 09:55
@a-khushal a-khushal force-pushed the fix/swap-fees-dupe branch from fd2bd2d to 18aaa09 Compare April 7, 2026 10:03
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.

3 participants