Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix logic and refactor app install #8401

Merged
merged 11 commits into from
Nov 25, 2024

Conversation

chrisduma-ledger
Copy link
Contributor

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • ...

📝 Description

We had an issue where if the app was not installed the sell/card would crash. This PR fixes it.
Also, i have refactored the logic a little.

❓ Context

Ticket


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@chrisduma-ledger chrisduma-ledger requested review from a team as code owners November 19, 2024 14:02
Copy link

vercel bot commented Nov 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-ui-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 25, 2024 8:48am
web-tools ❌ Failed (Inspect) Nov 25, 2024 8:48am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Nov 25, 2024 8:48am
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Nov 25, 2024 8:48am

@live-github-bot live-github-bot bot added the common Has changes in live-common label Nov 19, 2024
CremaFR
CremaFR previously approved these changes Nov 19, 2024
Copy link
Member

@CremaFR CremaFR left a comment

Choose a reason for hiding this comment

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

I've done the QA for swaps no issue ;)

sarneijim
sarneijim previously approved these changes Nov 19, 2024
Copy link
Contributor

@sarneijim sarneijim left a comment

Choose a reason for hiding this comment

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

We need applied the same change for FUND.
If we can merge today, tomorrow you need to deliver a new exchangeSDK version (patch) and send it to Mercuryo and Moonpay.

Comment on lines -138 to -141
const shouldAddEthApp =
(mainFromAccount.currency.family === "evm" || mainToAccount.currency.family === "evm") &&
mainFromAccount.currency.managerAppName !== "Ethereum" &&
mainToAccount.currency.managerAppName !== "Ethereum";
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you removed a recent fix I did here, any reason we removed it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello. Yes, I have removed that and just added this part:
dependencies.push({ appName: mainFromAccount?.currency?.managerAppName });

It makes the code easier to read, and adds any app as needed. @CremaFR tested it for swaps, and it works well.

Copy link
Contributor

@Justkant Justkant Nov 19, 2024

Choose a reason for hiding this comment

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

Yes but we need to keep the above logic to add ethereum in case of avax as it's needed for swap
And instead of doing a specific logic for only one coin we do a semi-generic thing here to add ethereum in the deps for evm families
https://ledgerhq.atlassian.net/browse/LIVE-14666

Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a comment next time to explain such changes? This was incredibly obscure, and no one could have guessed it without context.
Even just linking the JIRA ticket would have been enough, as we often do for similar quirks in swaps https://github.com/LedgerHQ/ledger-live/blob/develop/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/index.tsx#L388

Copy link
Member

Choose a reason for hiding this comment

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

Or put in a function like addAvaxAppDep

Copy link
Member

Choose a reason for hiding this comment

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

And I'll make a PR to add PTX owner of this file too from now on

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes sure, the name of the variable and the logic was not that hard to follow IMO and I understand that you probably wanted to remove this but if something is obscure or doesn't make sense I usually find the author of the change and try to get answers before doing a change if none are provided in the source code
I'll keep this in mind if I end up in a similar situation, as I usually add context if needed for strange changes

Copy link
Member

Choose a reason for hiding this comment

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

You're right, could’ve reached out first. Now that I know about managerAppName not being reliable for swap, it makes sense.
but seeing appManagerName to use directly instead of getting accounts like

const dependencies: AppRequest["dependencies"] = [
          {
            account: mainFromAccount,
          },
          {
            account: mainToAccount,
          },
        ];

I assume your fix was an issue with accounts not installing correct apps and you just didn't refacto the thing, and that we should just have used managerAppName directly...

anyway invited you to #ptx-pr-review , it's the kind of changes I like to follow and know about 😹

@chrisduma-ledger chrisduma-ledger dismissed stale reviews from sarneijim and CremaFR via fa11bae November 20, 2024 11:20
CremaFR
CremaFR previously approved these changes Nov 20, 2024
Justkant
Justkant previously approved these changes Nov 20, 2024
sarneijim
sarneijim previously approved these changes Nov 21, 2024
jiyuzhuang
jiyuzhuang previously approved these changes Nov 22, 2024
erge branch 'develop' of github.com:LedgerHQ/ledger-live into feat/support-app-install
@chrisduma-ledger chrisduma-ledger merged commit 38916d5 into develop Nov 25, 2024
53 of 55 checks passed
@chrisduma-ledger chrisduma-ledger deleted the feat/support-app-install branch November 25, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Has changes in live-common
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants