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

WIP: Live 1792: Synchronized onboarding logic #214

Closed
wants to merge 23 commits into from

Conversation

alexandremgo
Copy link
Contributor

@alexandremgo alexandremgo commented May 30, 2022

❓ Context

This PR is WIP (don't bother with all the console.log) but ready for comments and feedbacks👷

  • Impacted projects: LIVE-1792
  • Linked resource(s):

The main features are:

  • Function to extract the device onboarding state from byte flags
  • Polling mechanism to retrieve the device onboarding state
  • Make the polling mechanism available as a react hook for LLM and LLD
  • First implementation/POC of the synchronous onboarding in LLM:
    • BLE pairing of not seeded device
    • Screen to display the current onboarding state of the device using the above hook

🕵️‍♂️ Compared to the previous PR on the live-common and ledger-live-mobile, this feature fixed (parts, some are still WIP) comments from this PR and:

  • In polling mechanism: replace timer that would push for a request every period time, without waiting for the previous request -> now custom Observable is created with a repeat
    • the new Observable way has been chosen, compared to just used rxjs operators etc., with a system to not delay for the first run (and then repeat with a delay of X ms) because repeat({ delay: (count) => count > 0 ? timer(periodMs) : timer(0) }) does not exist in rxjs v6
  • Refactor the retry strategy: before on error was a "black box" where the system was not notified of an error, but was just retrying -> now a allowedError and a fatalError is returned from the polling mechanism and the hook so the app (LLM and LLD) are notified when an error occurred

✅ Checklist

  • Test coverage: Did you write any tests to cover the changes introduced by this pull request?
    • [x]: Unit tests for the extract function & the hook polling function
  • Atomic delivery: Is this pull request standalone? In order words, does it depend on nothing else?
  • No breaking changes: Does this pull request contain breaking changes of any kind? If so, please explain why.

📸 Demo

Will record a new demo video after on slack

🚀 Expectations to reach

Please make sure you follow these Important Steps.

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

@vercel
Copy link

vercel bot commented May 30, 2022

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

Name Status Preview Updated
live-common-tools ✅ Ready (Inspect) Visit Preview Jun 9, 2022 at 3:34PM (UTC)
3 Ignored Deployments
Name Status Preview Updated
ledger-live-github-bot ⬜️ Ignored (Inspect) Jun 9, 2022 at 3:34PM (UTC)
native-ui-storybook ⬜️ Ignored (Inspect) Jun 9, 2022 at 3:34PM (UTC)
react-ui-storybook ⬜️ Ignored (Inspect) Jun 9, 2022 at 3:34PM (UTC)

@changeset-bot
Copy link

changeset-bot bot commented May 30, 2022

⚠️ No Changeset found

Latest commit: e75cc11

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions github-actions bot added common Has changes in live-common ledgerjs Has changes in the ledgerjs open source libs mobile Has changes in LLM translations Translation files have been touched labels May 30, 2022
@codecov
Copy link

codecov bot commented May 30, 2022

Codecov Report

Merging #214 (e75cc11) into develop (113be36) will increase coverage by 14.58%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##           develop     #214       +/-   ##
============================================
+ Coverage    56.23%   70.81%   +14.58%     
============================================
  Files          471       63      -408     
  Lines        20945     4067    -16878     
  Branches      5322      762     -4560     
============================================
- Hits         11778     2880     -8898     
+ Misses        9115     1178     -7937     
+ Partials        52        9       -43     
Flag Coverage Δ
bot ?
test 70.81% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...-live-common/src/families/algorand/js-broadcast.ts
...-common/src/families/algorand/api/indexer.types.ts
...n/src/families/filecoin/deviceTransactionConfig.ts
...r-live-common/src/families/hedera/hw-getAddress.ts
...edger-live-common/src/families/hedera/bridge/js.ts
...r-live-common/src/families/solana/bridge/bridge.ts
libs/ledger-live-common/src/mock/account.ts
...live-common/src/families/polkadot/hw-getAddress.ts
.../ledger-live-common/src/families/solana/tx-fees.ts
...dger-live-common/src/families/solana/api/logged.ts
... and 524 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 113be36...e75cc11. Read the comment docs.

@github-actions
Copy link

github-actions bot commented May 30, 2022

@alexandremgo

Screenshots: ❌

It seems this PR contains screenshots that are different from the base branch.
If you are sure all those changes are correct, you can comment on this PR with /generate-screenshots to update those screenshots.

Make sure all the changes are correct before running the command, as it will commit and push the new result to the PR.

windows

Actual Diff Expected
market-btc-buy-page-actual market-btc-buy-page-diff market-btc-buy-page-expected
market-btc-buy-page-actual market-btc-buy-page-diff market-btc-buy-page-expected

Copy link
Contributor

@gre gre left a comment

Choose a reason for hiding this comment

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

really cool to see this happening 👏

setStepIndex(7);
break;
default:
setStepIndex(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

there may be a way to simplify this with an array containing all the steps that you are currently switch()ing on.

const steps = [OnboardingStep.WelcomeScreen, ...]
const stepIndex = steps.indexOf(onboardingState?.currentOnboardingStep) + 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, definitely I'll try to make something simpler like this ! Right now for this screen it was to demo and show that the polling mechanism was working ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

@grsoares21 grsoares21 left a comment

Choose a reason for hiding this comment

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

Looking good. Just a few comments on code clarity / style.

@alexandremgo
Copy link
Contributor Author

FYI: i will move the onboardingStatePolling used by the hook to live-common/src/hw/getOnboardingStatePolling to keep the file containing the hook useOnboardingStatePolling.ts simple

Copy link
Contributor

@juan-cortes juan-cortes left a comment

Choose a reason for hiding this comment

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

lgtm, so many tests, cleanup the logs and such though

@@ -109,7 +109,7 @@ platform :ios do

build_number = latest_testflight_build_number(
version: trim_version_number(package["version"]),
app_identifier: MY_APP_BUNDLE_ID
app_identifier: "com.ledger.live"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was a fixed to be able to build iOS that Valentin told me to try -> as this PR won't be merged, i did not put any comment on it. But Valentin merged this fix on develop yesterday ;)

from(getVersion(t)),
).toPromise();
} catch (_) {
// Silently swwallowing error, we only want to trigger the native ble pairing step
Copy link
Contributor

Choose a reason for hiding this comment

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

ww

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙈 sorry forgot about this feedback - i'm thinking on working on the BLE part in a new PR as my next step (after merging stuff from live-common in a new/clean PR)

route.params?.onDone?.(device);
// To avoid passing a onDone function param that is not serializable
if (route.params?.onDoneNavigateTo === ScreenName.SyncOnboardingWelcome) {
console.log("PairDevices: 🦮 navigate directly to SyncOnboarding");
Copy link
Contributor

Choose a reason for hiding this comment

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

🪓

// it does not matter.
// So as long as the device is not onboarded, the LLM will ask for a pairing.
useEffect(() => {
console.log("SyncOnboarding: navigate to pairDevices");
Copy link
Contributor

Choose a reason for hiding this comment

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

🪓

setStepIndex(7);
break;
default:
setStepIndex(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@valpinkman valpinkman deleted the feat/LIVE-1792 branch February 23, 2023 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli common Has changes in live-common ledgerjs Has changes in the ledgerjs open source libs mobile Has changes in LLM translations Translation files have been touched
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants