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/LIVE-12193 track swap cancel accept #6799

Merged
merged 15 commits into from May 13, 2024

Conversation

andreicovaciu
Copy link
Contributor

@andreicovaciu andreicovaciu commented May 2, 2024

βœ… Checklist

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

πŸ“ Description

Updates custom.exchange.start custom handler to return the device too.

❓ Context


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

@andreicovaciu andreicovaciu requested review from a team as code owners May 2, 2024 09:42
Copy link

vercel bot commented May 2, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

5 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-docs ⬜️ Ignored (Inspect) Visit Preview May 13, 2024 9:11am
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview May 13, 2024 9:11am
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview May 13, 2024 9:11am
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview May 13, 2024 9:11am
web-tools ⬜️ Ignored (Inspect) Visit Preview May 13, 2024 9:11am

@live-github-bot live-github-bot bot added desktop Has changes in LLD common Has changes in live-common mobile Has changes in LLM labels May 2, 2024
@andreicovaciu andreicovaciu force-pushed the feat/LIVE-12193-track-swap-cancel-accept branch from 5e551b4 to 2e26f0d Compare May 3, 2024 07:54
kallen-ledger
kallen-ledger previously approved these changes May 3, 2024
Copy link
Contributor

@kallen-ledger kallen-ledger left a comment

Choose a reason for hiding this comment

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

Nice, looks good to me. Let's wait for the wallet api team to take a look before merging πŸ’ͺ

Copy link
Contributor

@Justkant Justkant left a comment

Choose a reason for hiding this comment

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

I think we can move the logic from LLD and LLM to LLC and remove the uiHook for device as it doesn't really need ui in your context

Copy link
Contributor

@Justkant Justkant left a comment

Choose a reason for hiding this comment

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

I think we have the main logic good here just on desktop I'd like to modify it a bit to make sure we have a device in the end

libs/ledger-live-common/src/wallet-api/Exchange/server.ts Outdated Show resolved Hide resolved
libs/ledger-live-common/src/wallet-api/Exchange/server.ts Outdated Show resolved Hide resolved
@@ -57,10 +59,10 @@ export function usePTXCustomHandlers(manifest: WebviewProps["manifest"]) {
...exchangeParams,
exchangeType: ExchangeType[exchangeParams.exchangeType],
onResult: (nonce: string) => {
onSuccess(nonce);
onSuccess(nonce, device);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how much it keeps the device in sync here because it will be hoisted when the custom.exchange.start is called it could be the old value

It would probably be better if onResult and onCancel could return the device as it's done for LLM
I checked the code and it seems pretty straightforward to add some data:

Another solution could be to simply use const device = useSelector(getCurrentDevice); in apps/ledger-live-desktop/src/renderer/components/LiveAppDrawer.tsx because if we do the changes above we might want to update LLM so result.device comes from the action and not a state.

You can also cleanup this types that are not needed anymore
Screenshot 2024-05-06 at 16 08 00

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel this is a very deep understanding of the code and product to produce such detailed comment. Do you mind sharing any piece of documentation for future use cases? Thank you, @Justkant! πŸ™ŒπŸ½
P.S. I'll update accordingly

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey not sure we have a lot of documentation on the device actions and exchange part to be honest
I'm pretty familiar with this because I worked on some issues around it

My main concern here is to avoid having to much differences between LLD and LLM and sharing as much as possible, especially because you have a lot of ways to pass the data in the end correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@andreicovaciu andreicovaciu requested review from a team as code owners May 8, 2024 08:04
kallen-ledger
kallen-ledger previously approved these changes May 9, 2024
gre
gre previously approved these changes May 10, 2024
Copy link
Contributor

@ofreyssinet-ledger ofreyssinet-ledger left a comment

Choose a reason for hiding this comment

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

LGTM on the device experience team's scope πŸ‘

Copy link
Contributor

@Justkant Justkant left a comment

Choose a reason for hiding this comment

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

LGTM just some typings cleanup and we are good, good job

onCancel(
result.startExchangeError.error,
result.startExchangeError.device || device,
);
}

if (result.startExchangeResult) {
setDevice(result.device);
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll have to look at this result.device later on to see how we can remove this and instead use result.startExchangeResult.device

@Justkant Justkant merged commit 5b18e6a into develop May 13, 2024
58 checks passed
@Justkant Justkant deleted the feat/LIVE-12193-track-swap-cancel-accept branch May 13, 2024 13:50
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 mobile Has changes in LLM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants