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

FIX/LIVE-15117: exchange.swap does not have up-to-date accounts list when attempting to swap with newly created account. #8564

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

kallen-ledger
Copy link
Contributor

βœ… Checklist

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

πŸ“ Description

  • When creating a new account on the swap live app interface.
  • The user will attempt to swap "to" this new account.
  • The user will then be unable to.

This was because the exchangeHandlers accounts param did not get updated when accounts were changed. Instead this PR proposes passing a getter function that will instead grab the users currents accounts when the function is run.

❓ Context

https://ledgerhq.atlassian.net/browse/LIVE-15117


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

@kallen-ledger kallen-ledger requested review from a team as code owners December 2, 2024 12:27
Copy link

vercel bot commented Dec 2, 2024

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

4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-github-bot ⬜️ Ignored (Inspect) Dec 2, 2024 0:27am
native-ui-storybook ⬜️ Ignored (Inspect) Dec 2, 2024 0:27am
react-ui-storybook ⬜️ Ignored (Inspect) Dec 2, 2024 0:27am
web-tools ⬜️ Ignored (Inspect) Dec 2, 2024 0:27am

@live-github-bot live-github-bot bot added desktop Has changes in LLD common Has changes in live-common labels Dec 2, 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.

LGTM πŸ”₯

@@ -55,6 +55,10 @@ import { registerTransportModules } from "~/renderer/live-common-setup";
const rootNode = document.getElementById("react-root");
const TAB_KEY = 9;

export const store = createStore({
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure it does not create a side effect to change where we create the store, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I can tell this does not create any side effects and just moves the creation of the store outside of the init function to allow access to the store directly.

Copy link
Contributor

@Justkant Justkant Dec 2, 2024

Choose a reason for hiding this comment

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

There is a side effect that you cannot reset the store by just calling init again
Not sure how much it impacts LLD but I suppose that it would have some risk with hot reloading in dev

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change necessary ?
It doesn't seem correct to init the rest and not this in the function

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 feel like this solution is bypassing the issue instead of solving it

Comment on lines +20 to +22
function getAccounts() {
return flattenAccountsSelector(store.getState());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It's quite strange to do that directly instead of using a the selector with useSelector
It's seems we're not addressing the root cause of the issue, a change to the accounts should be reflected to the handlers

@kallen-ledger
Copy link
Contributor Author

@Justkant @KVNLS agree that it is not solving the core issue, will take a re-look at this and try and figure out why the accounts are not getting updated on call. Thank you for the feedback πŸ™

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants