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: Use listenToKnownDevices from DMK #8566

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

valpinkman
Copy link
Member

@valpinkman valpinkman commented Dec 2, 2024

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • live-dmk package updated to trigger add and remove device event on listen
    • LLD useListenToHidDevices updated

📝 Description

Update useListenToHidDevices to be able to rely on the DMK listenToKnownDevices() when the feature flag is on.
Also update the way we register the transports so everything is available at any time (but the open on the LiveDMKTransport only works when FF is on)
Changed the default verbosity on the DMK Logger.

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

@valpinkman valpinkman requested review from a team as code owners December 2, 2024 14:31
Copy link

vercel bot commented Dec 2, 2024

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

Name Status Preview Comments Updated (UTC)
web-tools ❌ Failed (Inspect) Dec 2, 2024 3:54pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 3:54pm
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 3:54pm
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 3:54pm

Comment on lines 14 to 16
const store = useStore<State>();
const localOverrides = overriddenFeatureFlagsSelector(store.getState());
const ldmkFeatureFlag = getFeature({ key: "ldmkTransport", localOverrides });
Copy link
Contributor

@ofreyssinet-ledger ofreyssinet-ledger Dec 2, 2024

Choose a reason for hiding this comment

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

[SHOULD] Here you can just do const ldmkFeatureFlag = useFeature("ldmkTransport") since you're in a react context, with the FF provider & the store at the root of the app, the overrides will already be computed.
This logic was needed in live-common-setup.ts because it's not in a react context.

useEffect(() => {
let sub: Subscription;
function syncDevices() {
const devices: { [key: string]: boolean } = {};
const devices: { [key: string]: boolean } = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

[COULD] As we saw this variable is unused, it can be removed.

registerTransportModule({
id: "sdk",
open: (_id: string, timeoutMs?: number, context?: TraceContext) => {
if (!ldmkFeatureFlag().enabled) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

[SHOULD] also ensure that we return undefined in case we're using a vault device, or a speculos emulator, a proxy etc. as they are not yet supported in the DMK.

@valpinkman valpinkman force-pushed the feat/dsdk-508-listen-known-devices branch from b09b75e to 0322fd5 Compare December 2, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop Has changes in LLD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants