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

Bugfix/live 8698 Manager API v2 breaking changes adaptations #4896

Merged
merged 22 commits into from
Oct 26, 2023

Conversation

ofreyssinet-ledger
Copy link
Contributor

@ofreyssinet-ledger ofreyssinet-ledger commented Sep 29, 2023

📝 Description

Some breaking changes have been introduced on the Manager API v2 (in staging so far).
Today we are using v1 of the API unless a feature flag listAppsV2 is enabled, but we should still handle those breaking changes anyway because using the v2 API brings a big network optimisation and we should aim to activate the flag soon.

Changes in the Manager v2 API (backend)

  • Optimisations
    • /api/v2/apps/hash: now outputs the apps in the same order as the input which makes it easier for us to use.
  • Breaking changes:
    • /api/v2/apps/hash: now can return some apps as null if the hash does not match any app

Changes in LL (this PR):

  • Both of those API changes are addressed in this PR.
  • A new feature flag listAppsV2minor1 is introduced in order to not activate the old one by mistake which would break old versions of LL.
  • The polyfilling of app's data has also been fixed to match the behaviour of v1:
    • Previously, in list apps v2, the currencyId from the backend was never taken so in some cases ("Binance Chain" or "Persistence") there would be no associated currency, so in the My Ledger list of apps there would be a different icon, no ticker ("Persistence (XPRT)" with "(XPRT)" being the ticker), and no associated market cap, so the app would be at the bottom of the list when the "ranking by market cap" option is chosen.
    • Now the currencyId from the backend is taken by default and if it doesn't exist, it is polyfilled with the same logic as in list apps v1 (matching app's name and a currency's currency.name or currency.managerName.
  • A fix regarding the uninstallation of apps which other installed apps depends on, from the InstalledAppsModal. For instance with Ethereum and Polygon installed, if you open the InstalledAppsModal listing all the installed apps, it would be impossible to uninstall Ethereum from there because the drawer UninstallDependenciesModal would be blocked by the currently opened modal (InstalledAppsModal).
    • The reason is that InstalledAppsModal was not using a QueuedDrawer, and also UninstallDependenciesModal should use the isForcingToBeOpened prop of QueuedDrawer. This is actually unrelated to listAppsV2 but it was noticed by QA so I fixed it here 🤷‍♂️ .
    • Refactor prop drilling nightmare of setAppInstallWithDependencies/setAppUninstallWithDependencies with a simple React.Context.
  • Refactor InstalledAppDependenciesModal and UninstallAppDependenciesModal to have no business logic inside
  • Rename action creator installAppFirstTime to setHasInstalledAnyApp for more clarity
  • sorry i got a bit carried away with refactos unrelated to the initial purpose of the PR but it was itching me 😆

More context:
As a reminder this is the original work from Juan with more details about the optimisation in the PR description: #3097
And as an example of the optimisation, here's a before/after of networking when opening the manager on LLD:

before: Screenshot 2023-10-02 at 14 22 12
after: Screenshot 2023-10-02 at 14 20 39

What I tested:

  • LLD macOS
    • build from this PR
    • Infra VPN setup
    • open with MANAGER_API_BASE=https://manager.api.live.stg.ledger-test.com/api /Applications/Ledger\ Live\ Beta.app/Contents/MacOS/Ledger\ Live\ Beta
    • activate listAppsV2minor1 feature flag
    • restart LLD
    • open manager
    • all apps installed on device are listed (eth, bitcoin, xrp, cardano ada, fido (this one is special because it doesn't have a fixed hash so the /api/hash returns null for it, which would break on a develop build), tron)
  • LLM Android
    • build from https://github.com/LedgerHQ/ledger-live/actions/runs/6394873605
    • Infra VPN setup
    • open app
    • activate listAppsV2minor1 feature flag
    • set env var MANAGER_API_BASE=https://manager.api.live.stg.ledger-test.com/api in debug settings
    • open manager
    • all apps installed on device are listed (eth, bitcoin, xrp, cardano ada, fido (this one is special because it doesn't have a fixed hash so the /api/hash returns null for it, which would break on a develop build), tron)

❓ Context

  • Impacted projects: lld, llm, common, types-live
  • Linked resource(s): LIVE-8698

✅ Checklist

  • Test coverage
  • Atomic delivery
  • No breaking changes

📸 Demo

🚀 Expectations to reach

How to test ?

  • activate the Infra VPN
  • the feature flag listAppsV2minor1 must be enabled
  • different APIs:
    • staging API (requires VPN): MANAGER_API_BASE=https://manager.api.live.stg.ledger-test.com/api
    • degraded staging API (required VPN) in case the other one returns 403 (no HTTPS): MANAGER_API_BASE=http://appstore.api.aws.stg.ldg-tech.com/api
      • LLD: also bypass CORS with BYPASS_CORS=1
      • LLM: does not work outside of debug builds because of HTTP cleartext
    • prod API (for now the changes are not in the prod api) MANAGER_API_BASE=https://manager.api.live.ledger.com/api
      • no additional config

Please make sure you follow these Important Steps.

Pull Requests must pass the CI and be internally validated in order to be merged.

@changeset-bot
Copy link

changeset-bot bot commented Sep 29, 2023

🦋 Changeset detected

Latest commit: b8806a4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@ledgerhq/types-live Patch
@ledgerhq/live-common Patch
ledger-live-desktop Patch
live-mobile Patch
@ledgerhq/live-cli Patch
web-tools Patch
@ledgerhq/coin-algorand Patch
@ledgerhq/coin-evm Patch
@ledgerhq/coin-framework Patch
@ledgerhq/coin-polkadot Patch
@ledgerhq/domain-service Patch
@ledgerhq/hw-app-eth Patch
@ledgerhq/test-utils Patch
dummy-wallet-app Patch
@ledgerhq/swift-bridge-hw-app-eth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Sep 29, 2023

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

Name Status Preview Comments Updated (UTC)
live-common-tools ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 25, 2023 4:43pm
5 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-docs ⬜️ Ignored (Inspect) Visit Preview Oct 25, 2023 4:43pm
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Oct 25, 2023 4:43pm
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Oct 25, 2023 4:43pm
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Oct 25, 2023 4:43pm
web-tools ⬜️ Ignored (Inspect) Visit Preview Oct 25, 2023 4:43pm

@github-actions github-actions bot added desktop Has changes in LLD mobile Has changes in LLM common Has changes in live-common ledgerjs Has changes in the ledgerjs open source libs labels Sep 29, 2023
@ofreyssinet-ledger ofreyssinet-ledger changed the title Bugfix/live 8698 listapps v2 adaptations Bugfix/live 8698 Manager API v2 breaking changes adaptations Oct 2, 2023
@ofreyssinet-ledger ofreyssinet-ledger force-pushed the bugfix/LIVE-8698-listapps-v2-adaptations branch from 1f3726d to e8b8d9a Compare October 3, 2023 14:38
@ofreyssinet-ledger ofreyssinet-ledger force-pushed the bugfix/LIVE-8698-listapps-v2-adaptations branch from e1b4f30 to 3bd5f99 Compare October 17, 2023 07:38
@ofreyssinet-ledger ofreyssinet-ledger force-pushed the bugfix/LIVE-8698-listapps-v2-adaptations branch from 4cbb1c1 to 9f3275a Compare October 17, 2023 14:39
@ofreyssinet-ledger ofreyssinet-ledger marked this pull request as ready for review October 18, 2023 09:29
@ofreyssinet-ledger ofreyssinet-ledger force-pushed the bugfix/LIVE-8698-listapps-v2-adaptations branch from e6773aa to 0c9f64d Compare October 19, 2023 12:21
@ofreyssinet-ledger ofreyssinet-ledger force-pushed the bugfix/LIVE-8698-listapps-v2-adaptations branch from 8a383d9 to 09fa47f Compare October 23, 2023 11:36
@ofreyssinet-ledger ofreyssinet-ledger force-pushed the bugfix/LIVE-8698-listapps-v2-adaptations branch from 09fa47f to cf8f707 Compare October 24, 2023 13:36
Copy link
Contributor

@alexandremgo alexandremgo left a comment

Choose a reason for hiding this comment

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

Great work ! Thx for all the refactoring ! 🦖

@ofreyssinet-ledger ofreyssinet-ledger force-pushed the bugfix/LIVE-8698-listapps-v2-adaptations branch from c5ee7a4 to b8806a4 Compare October 25, 2023 16:42
@ofreyssinet-ledger ofreyssinet-ledger merged commit 95cf52e into develop Oct 26, 2023
55 of 56 checks passed
@ofreyssinet-ledger ofreyssinet-ledger deleted the bugfix/LIVE-8698-listapps-v2-adaptations branch October 26, 2023 07:52
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 desktop Has changes in LLD ledgerjs Has changes in the ledgerjs open source libs mobile Has changes in LLM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants