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

[LW-10194] unify codebase of the onboarding and multi-wallet flows #1140

Merged

Conversation

szymonmaslowski
Copy link
Contributor

@szymonmaslowski szymonmaslowski commented May 8, 2024

Checklist

  • JIRA - <link>
  • Proper tests implemented
  • Screenshots added.

Proposed solution

Adjust the multi-wallet code to be generic and able to be used for both multi-wallet and onboarding flows.
This PR creates some amount of dead code which will be removed in the subsequent cleanup PR.

Testing

All onboarding, multi-wallet and forgot password should work as exected without any change in a behavior.

Screenshots

Attach screenshots here if implementation involves some UI changes

@szymonmaslowski szymonmaslowski requested a review from a team as a code owner May 8, 2024 08:59
@szymonmaslowski szymonmaslowski self-assigned this May 8, 2024
Copy link

github-actions bot commented May 8, 2024

Allure Report

allure-report-publisher generated test report!

smokeTests: ✅ test report for bc54849e

passed failed skipped flaky total result
Total 30 0 0 0 30

@@ -69,7 +69,7 @@ export const postHogMultiWalletActions: PostHogMultiWalletActionsType = {
WALLET_ADDED: PostHogAction.MultiWalletRestoreAdded,
HD_WALLET: PostHogAction.MultiWalletRestoreHdWallet
},
hw: {
hardware: {
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏

@@ -39,7 +39,7 @@ export enum TxCreationType {
}

export type OnboardingFlows = 'create' | 'restore' | 'hw' | 'forgot_password' | 'onboarding';
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you do the same here with the naming?

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 want to avoid unnecessary changes in this PR. Once the old onboarding implementation is removed this can be renamed - next PR

export const CreateWallet = (): JSX.Element => (
<CreateWalletProvider>
{({ step }) => (
<>
Copy link
Contributor

Choose a reason for hiding this comment

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

Was there a reason we removed routing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two reasons:

  1. I don't see a value in it, but it can lead to problems: if the user refreshes the page while on the second step then he will lack a state from the previous step
  2. Simpler codebase unification I guess...

<MemoryRouter initialEntries={[walletRoutePaths.newWallet.hardware.connect]}>
<HardwareWallet providers={providers as Providers} />
</MemoryRouter>
<>
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if we remove the fragment 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.

Please take a look on the test files again 🙏


const wordList = wordlists.english;
const DEFAULT_MNEMONIC_LENGTH = 24;
const COPY_PASTE_TOOLTIP_URL = `${process.env.FAQ_URL}?question=best-practices-for-using-the-copy-to-clipboard-paste-from-clipboard-recovery-phrase-features`;

export const RestoreRecoveryPhrase = (): JSX.Element => {
const { t } = useTranslation();
const { forgotPasswordFlowActive, postHogActions } = useWalletOnboarding();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why get the analytics from hook if you can access them directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They differ depending on the flow: onboarding vs multi-wallet so they has to be passed from the above.

Copy link
Contributor

Choose a reason for hiding this comment

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

We cannot do import { postHogMultiWalletActions, postHogOnboardingActions } ?

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 mean this implementation is used now for both flows so events cannot be hardcoded. they are passed here and here

}
// delete "forgot_password" related data if user leaves the flow before completing
const clearWallet = () => {
deleteFromLocalStorage('wallet');
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have keys for the magic strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me check and improve that in a subsequent cleanup PR 😉

Copy link
Contributor

@shawnbusuttil shawnbusuttil left a comment

Choose a reason for hiding this comment

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

Left some comments.

Copy link
Contributor

@greatertomi greatertomi left a comment

Choose a reason for hiding this comment

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

This is some amazing refactoring. Well-done @szymonmaslowski 🚀

Looks generally good to me, but I don't have enough context on the multi-wallet code, would be a good idea to add @lucas-barros or @renanvalentin as a reviewer.

Copy link
Contributor

@shawnbusuttil shawnbusuttil left a comment

Choose a reason for hiding this comment

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

Left a reply. I think I also have an outstanding https://github.com/input-output-hk/lace/pull/1140/files#r1594016659 comment which wasn't addressed.

Base automatically changed from feat/LW-10244-port-HW-onboarding-revam-to-multi-wallet to main May 14, 2024 10:44
@szymonmaslowski szymonmaslowski force-pushed the feat/LW-10194-unify-multiwallet-and-onboarding-codebases branch 3 times, most recently from a9fca6a to 786b901 Compare May 15, 2024 15:29
@szymonmaslowski szymonmaslowski enabled auto-merge (squash) May 20, 2024 10:00
@szymonmaslowski szymonmaslowski force-pushed the feat/LW-10194-unify-multiwallet-and-onboarding-codebases branch from d2009df to bc54849 Compare May 20, 2024 12:58
Copy link

@szymonmaslowski szymonmaslowski merged commit b613cde into main May 20, 2024
12 checks passed
@szymonmaslowski szymonmaslowski deleted the feat/LW-10194-unify-multiwallet-and-onboarding-codebases branch May 20, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants