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(core,extension): LW-9743 revamp "Save your recovery phrase" screen #919

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/browser-extension-wallet/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ USE_HIDE_MY_BALANCE=true
USE_ADA_HANDLE=true
USE_DATA_CHECK=false
USE_POSTHOG_ANALYTICS=true
USE_COMBINED_PASSWORD_NAME_STEP_COMPONENT=false
# TODO Remove redundant feature flags when Trezor and Ledger are supported (https://input-output.atlassian.net/browse/LW-9480)
USE_MULTI_DELEGATION_STAKING_LEDGER=false
USE_MULTI_DELEGATION_STAKING_TREZOR=false
Expand Down
1 change: 0 additions & 1 deletion apps/browser-extension-wallet/.env.developerpreview
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ USE_MULTI_DELEGATION_STAKING=true
USE_ADA_HANDLE=false
USE_DATA_CHECK=false
USE_POSTHOG_ANALYTICS=true
USE_COMBINED_PASSWORD_NAME_STEP_COMPONENT=false
USE_MULTI_DELEGATION_STAKING_ACTIVITY=false

USE_POSTHOG_ANALYTICS_FOR_OPTED_OUT=false
Expand Down
1 change: 0 additions & 1 deletion apps/browser-extension-wallet/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ USE_HANDLE_AB=false
USE_DATA_CHECK=false
USE_POSTHOG_ANALYTICS=true
USE_POSTHOG_ANALYTICS_FOR_OPTED_OUT=false
USE_COMBINED_PASSWORD_NAME_STEP_COMPONENT=false
USE_MULTI_DELEGATION_STAKING_ACTIVITY=true
USE_MULTI_DELEGATION_STAKING_GRID_VIEW=false
USE_ROS_STAKING_COLUMN=false
Expand Down
16 changes: 13 additions & 3 deletions apps/browser-extension-wallet/src/lib/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1283,10 +1283,20 @@
"passphraseInfo3": "Find out more.",
"passphraseError": "Make sure the words of your recovery phrase are in the right order and spelled correctly."
},
"walletSetupMnemonicIntroStep": {
"walletSetupMnemonicStepRevamp": {
"writePassphraseTitle": "Save your recovery phrase",
"enterPassphrase": "Enter your secret passphrase",
"enterPassphraseDescription": "Please enter each word of your recovery phrase in the right order to verify it and recover your wallet.",
"body": "Now let's check you've got the correct secret passphrase. Enter each word of your passphrase in the right order to verify it.",
"writePassphraseSubtitle1": "Consider your recovery phrase as the master key to your wallet.",
"writePassphraseSubtitle2": "Watch video.",
"passphraseError": "Make sure the words of your recovery phrase are in the right order and spelled correctly."
},
"mnemonicVideoPopupContent": {
"title": "Keeping your wallet secure",
"description": "Consider your recovery phrase as the master key to your wallet, and the only way to access your funds.",
"link": "Read More."
"description": "Learn about what is a recovery phrase, and how to keep it safe from the video below.",
"link": "Read More.",
"closeButton": "Got it"
},
"walletSetupMnemonicVerificationStep": {
"enterPassphrase": "Enter your secret passphrase"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
WalletSetupCreationStep,
WalletSetupFinalStep,
WalletSetupLegalStep,
WalletSetupMnemonicIntroStep,
MnemonicVideoPopupContent,
WalletSetupNamePasswordStep,
WalletSetupPasswordStep,
WalletSetupRecoveryPhraseLengthStep,
Expand Down Expand Up @@ -44,23 +44,12 @@ import { isScriptAddress } from '@cardano-sdk/wallet';
import { filter, firstValueFrom } from 'rxjs';
import { useWalletStore } from '@src/stores';

const isCombinedPasswordNameStepEnabled = process.env.USE_COMBINED_PASSWORD_NAME_STEP_COMPONENT === 'true';
const walletSetupWizardForABTest = {
...walletSetupWizard,
[WalletSetupSteps.PreMnemonic]: { ...walletSetupWizard['pre-mnemonic'], prev: WalletSetupSteps.Register },
[WalletSetupSteps.RecoveryPhraseLength]: {
...walletSetupWizard['recovery-phrase-length'],
prev: WalletSetupSteps.Register
},
[WalletSetupSteps.Mnemonic]: { ...walletSetupWizard.mnemonic, prev: WalletSetupSteps.Register }
};

const WalletSetupModeStep = React.lazy(() =>
import('@lace/core').then((module) => ({ default: module.WalletSetupModeStep }))
);

const WalletSetupMnemonicStep = React.lazy(() =>
import('@lace/core').then((module) => ({ default: module.WalletSetupMnemonicStep }))
const WalletSetupMnemonicStepRevamp = React.lazy(() =>
import('@lace/core').then((module) => ({ default: module.WalletSetupMnemonicStepRevamp }))
);

const WalletSetupMnemonicVerificationStep = React.lazy(() =>
Expand Down Expand Up @@ -145,14 +134,13 @@ export const WalletSetupWizard = ({
};

const walletSetupMnemonicStepTranslations = {
writePassphrase: t('core.walletSetupMnemonicStep.writePassphrase'),
body: t('core.walletSetupMnemonicStep.body'),
enterPassphrase: t('core.walletSetupMnemonicStep.enterPassphrase'),
enterPassphraseDescription: t('core.walletSetupMnemonicStep.enterPassphraseDescription'),
passphraseInfo1: t('core.walletSetupMnemonicStep.passphraseInfo1'),
passphraseInfo2: t('core.walletSetupMnemonicStep.passphraseInfo2'),
passphraseInfo3: t('core.walletSetupMnemonicStep.passphraseInfo3'),
passphraseError: t('core.walletSetupMnemonicStep.passphraseError')
writePassphraseTitle: t('core.walletSetupMnemonicStepRevamp.writePassphraseTitle'),
body: t('core.walletSetupMnemonicStepRevamp.body'),
enterPassphrase: t('core.walletSetupMnemonicStepRevamp.enterPassphrase'),
enterPassphraseDescription: t('core.walletSetupMnemonicStepRevamp.enterPassphraseDescription'),
writePassphraseSubtitle1: t('core.walletSetupMnemonicStepRevamp.writePassphraseSubtitle1'),
writePassphraseSubtitle2: t('core.walletSetupMnemonicStepRevamp.writePassphraseSubtitle2'),
passphraseError: t('core.walletSetupMnemonicStepRevamp.passphraseError')
};

const walletSetupModeStepTranslations = {
Expand All @@ -179,10 +167,11 @@ export const WalletSetupWizard = ({
followDiscord: t('core.walletSetupFinalStep.followDiscord')
};

const walletSetupMnemonicIntroStepTranslations = {
title: t('core.walletSetupMnemonicIntroStep.title'),
description: t('core.walletSetupMnemonicIntroStep.description'),
linkText: t('core.walletSetupMnemonicIntroStep.link')
const mnemonicVideoPopupContentTranslations = {
title: t('core.mnemonicVideoPopupContent.title'),
description: t('core.mnemonicVideoPopupContent.description'),
linkText: t('core.mnemonicVideoPopupContent.link'),
closeButton: t('core.mnemonicVideoPopupContent.closeButton')
};

const walletSetupRegisterStepTranslations = {
Expand Down Expand Up @@ -228,9 +217,7 @@ export const WalletSetupWizard = ({
}, [currentStep, setCurrentStep]);

const moveBack = () => {
const prevStep = isCombinedPasswordNameStepEnabled
? walletSetupWizardForABTest[currentStep].prev
: walletSetupWizard[currentStep].prev;
const prevStep = walletSetupWizard[currentStep].prev;

if (prevStep) {
setCurrentStep(prevStep);
Expand Down Expand Up @@ -332,7 +319,7 @@ export const WalletSetupWizard = ({

const createFlowPasswordNextStep = () => {
setupType === SetupType.CREATE
? skipTo(WalletSetupSteps.PreMnemonic)
? skipTo(WalletSetupSteps.Mnemonic)
: useDifferentMnemonicLengths
? skipTo(WalletSetupSteps.RecoveryPhraseLength)
: skipTo(WalletSetupSteps.Mnemonic);
Expand Down Expand Up @@ -400,32 +387,25 @@ export const WalletSetupWizard = ({
}

return (
<WalletSetupMnemonicStep
<WalletSetupMnemonicStepRevamp
mnemonic={mnemonic}
onReset={(resetStage) => {
setResetMnemonicStage(resetStage);
setIsResetMnemonicModalOpen(true);
}}
renderVideoPopupContent={({ onClose }) => (
<MnemonicVideoPopupContent
translations={mnemonicVideoPopupContentTranslations}
onClickVideo={() => {
// TODO: https://input-output.atlassian.net/browse/LW-9761 handle analytics here based on the stage argument
Copy link
Contributor

Choose a reason for hiding this comment

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

Very good adding TODOs with a JIRA ticket 💪

}}
videoSrc={process.env.YOUTUBE_RECOVERY_PHRASE_VIDEO_URL}
onClose={onClose}
/>
)}
onNext={moveForward}
onStepNext={(stage: MnemonicStage, step: number) => {
/* eslint-disable no-magic-numbers */
switch (step) {
case 0:
stage === 'input'
? sendAnalytics(postHogOnboardingActions[setupType]?.ENTER_PASSPHRASE_01_NEXT_CLICK)
: sendAnalytics(postHogOnboardingActions[setupType]?.WRITE_PASSPHRASE_01_NEXT_CLICK);
break;
case 1:
stage === 'input'
? sendAnalytics(postHogOnboardingActions[setupType]?.ENTER_PASSPHRASE_09_NEXT_CLICK)
: sendAnalytics(postHogOnboardingActions[setupType]?.WRITE_PASSPHRASE_09_NEXT_CLICK);
break;
case 2:
stage === 'input'
? sendAnalytics(postHogOnboardingActions[setupType]?.ENTER_PASSPHRASE_17_NEXT_CLICK)
: sendAnalytics(postHogOnboardingActions[setupType]?.WRITE_PASSPHRASE_17_NEXT_CLICK);
}
/* eslint-enable no-magic-numbers */
onStepNext={() => {
// TODO: https://input-output.atlassian.net/browse/LW-9761 handle analytics here based on the stage argument
}}
translations={walletSetupMnemonicStepTranslations}
suggestionList={wordList}
Expand Down Expand Up @@ -468,20 +448,6 @@ export const WalletSetupWizard = ({
translations={walletSetupAnalyticsStepTranslations}
/>
)}
{currentStep === WalletSetupSteps.PreMnemonic && (
<WalletSetupMnemonicIntroStep
onBack={moveBack}
onNext={() => {
analytics.sendEventToPostHog(postHogOnboardingActions[setupType]?.PASSPHRASE_INTRO_NEXT_CLICK);
moveForward();
}}
translations={walletSetupMnemonicIntroStepTranslations}
onClickVideo={() =>
analytics.sendEventToPostHog(postHogOnboardingActions[setupType]?.PASSPHRASE_INTRO_PLAY_VIDEO_CLICK)
}
videoSrc={process.env.YOUTUBE_RECOVERY_PHRASE_VIDEO_URL}
/>
)}
{currentStep === WalletSetupSteps.Mnemonic && (
<Suspense fallback={<Fallback />}>{renderedMnemonicStep()}</Suspense>
)}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export * from '@ui/components/InfoWallet';
export * from '@ui/components/OutputSummary';
export * from '@ui/components/OutputSummaryList';
export * from '@ui/components/WalletSetup';
export * from '@ui/components/WalletSetupRevamp';
export * from '@ui/components/ConnectedDapp';
export * from '@ui/components/SendReceive';
export * from '@ui/components/DappInfo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export enum WalletSetupSteps {
Legal = 'legal',
Analytics = 'analytics',
Mode = 'mode',
PreMnemonic = 'pre-mnemonic',
Mnemonic = 'mnemonic',
Register = 'register',
Password = 'password',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ export const walletSetupWizard: WalletSetupWizard = {
prev: WalletSetupSteps.Password,
next: WalletSetupSteps.Mnemonic
},
[WalletSetupSteps.PreMnemonic]: {
prev: WalletSetupSteps.Password,
next: WalletSetupSteps.Mnemonic
},
[WalletSetupSteps.Mnemonic]: {
prev: WalletSetupSteps.PreMnemonic,
prev: WalletSetupSteps.Password,
next: WalletSetupSteps.Create
},
[WalletSetupSteps.Create]: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@import '../../../../../common/src/ui/styles/abstracts/typography';

.container {
height: 100%;
display: flex;
flex-direction: column;
gap: size_unit(6);

.content {
display: flex;
flex-direction: column;
gap: size_unit(2);

.title {
@include text-heading;
color: var(--text-color-primary, #3d3b39);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if we need #3d3b39 as a fallback. I mean, if we lack --text-color-primary we would not notice it.

margin: 0;
}

.description {
font-size: var(--body) !important;
line-height: size_unit(3) !important;
color: var(--text-color-primary, #3d3b39);
margin: 0;
}

.videoContainer {
position: relative;
height: 272px;
border-radius: 16px;
border: 1px solid #efefef;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we don't use --text-color-secondary or similar instead of #efefef?


.overlay {
z-index: 1;
position: absolute;
width: 100%;
height: 100%;
border-radius: 16px;
top: 0;
left: 0;
opacity: 0;
}

.video {
width: 100%;
height: 100%;
border-radius: 16px;
border: none;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Button } from '@lace/ui';
import { TranslationsFor } from '@ui/utils/types';
import { urls } from '@ui/utils/constants';
import React, { ReactElement, useRef, useState } from 'react';
import styles from './MnemonicVideoPopupContent.module.scss';

type MnemonicVideoPopupContentProps = {
onClickVideo: () => void;
onClose: () => void;
translations: TranslationsFor<'title' | 'description' | 'linkText' | 'closeButton'>;
videoSrc: string;
};

export const MnemonicVideoPopupContent = ({
onClickVideo,
onClose,
translations,
videoSrc
}: MnemonicVideoPopupContentProps): ReactElement => {
const [overlayVisible, setOverlayVisible] = useState(true);
const videoRef = useRef<HTMLIFrameElement>();

return (
<div className={styles.container}>
<div className={styles.content} data-testid="wallet-setup-step-header">
<h1 className={styles.title}>{translations.title}</h1>
<p className={styles.description}>
{translations.description}{' '}
<a href={urls.faq.secretPassphrase} target="_blank" data-testid="faq-secret-passphrase-url">
{translations.linkText}
</a>
</p>
<div
className={styles.videoContainer}
onClick={() => {
setOverlayVisible(false);
videoRef.current.src += '&autoplay=1';
onClickVideo();
}}
>
{overlayVisible && <div className={styles.overlay} />}
<iframe
ref={videoRef}
className={styles.video}
src={videoSrc}
title="YouTube video player"
allow="accelerometer; fullscreen; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
data-testid="mnemonic-intro-yt-video-frame"
/>
</div>
</div>
<Button.CallToAction label={translations.closeButton} onClick={onClose} />
</div>
);
};
Loading
Loading