From 80c8a2269ae2153c7a370691b9581218ebf8c9dc Mon Sep 17 00:00:00 2001 From: Renan Ferreira Date: Thu, 28 Mar 2024 11:36:53 -0300 Subject: [PATCH] feat(extension): hide show recovery phrase when key material is empty --- .../src/stores/slices/wallet-info-slice.ts | 6 +++++- apps/browser-extension-wallet/src/stores/types.ts | 1 + apps/browser-extension-wallet/src/utils/mocks/store.tsx | 1 + .../features/settings/components/SettingsSecurity.tsx | 6 +++--- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/browser-extension-wallet/src/stores/slices/wallet-info-slice.ts b/apps/browser-extension-wallet/src/stores/slices/wallet-info-slice.ts index dad9a491cc..97927123aa 100644 --- a/apps/browser-extension-wallet/src/stores/slices/wallet-info-slice.ts +++ b/apps/browser-extension-wallet/src/stores/slices/wallet-info-slice.ts @@ -23,6 +23,7 @@ export const walletInfoSlice: SliceCreator @@ -36,7 +37,10 @@ export const walletInfoSlice: SliceCreator 0 }), setCurrentChain: (chain: Wallet.ChainName) => { set({ currentChain: Wallet.Cardano.ChainIds[chain], environmentName: chain }); diff --git a/apps/browser-extension-wallet/src/stores/types.ts b/apps/browser-extension-wallet/src/stores/types.ts index e919434d38..914d1e20cc 100644 --- a/apps/browser-extension-wallet/src/stores/types.ts +++ b/apps/browser-extension-wallet/src/stores/types.ts @@ -116,6 +116,7 @@ export interface WalletInfoSlice { walletType: WalletType; isInMemoryWallet: boolean; isHardwareWallet: boolean; + hasKeyMaterial: boolean; deletingWallet?: boolean; stayOnAllDonePage?: boolean; setDeletingWallet: (deletingWallet: boolean) => void; diff --git a/apps/browser-extension-wallet/src/utils/mocks/store.tsx b/apps/browser-extension-wallet/src/utils/mocks/store.tsx index 34c062e52c..c047a4e4fa 100644 --- a/apps/browser-extension-wallet/src/utils/mocks/store.tsx +++ b/apps/browser-extension-wallet/src/utils/mocks/store.tsx @@ -46,6 +46,7 @@ export const walletStoreMock = async ( walletType: WalletType.InMemory, isInMemoryWallet: true, isHardwareWallet: false, + hasKeyMaterial: true, // TODO: mock [LW-5454] cardanoWallet: undefined, isWalletLocked: jest.fn(() => false), diff --git a/apps/browser-extension-wallet/src/views/browser-view/features/settings/components/SettingsSecurity.tsx b/apps/browser-extension-wallet/src/views/browser-view/features/settings/components/SettingsSecurity.tsx index a69391380c..1f5b80a9e8 100644 --- a/apps/browser-extension-wallet/src/views/browser-view/features/settings/components/SettingsSecurity.tsx +++ b/apps/browser-extension-wallet/src/views/browser-view/features/settings/components/SettingsSecurity.tsx @@ -27,7 +27,7 @@ export const SettingsSecurity = ({ const [isShowPassphraseDrawerOpen, setIsShowPassphraseDrawerOpen] = useState(false); const [hideShowPassphraseSetting, setHideShowPassphraseSetting] = useState(true); const { t } = useTranslation(); - const { isWalletLocked, isInMemoryWallet } = useWalletStore(); + const { isWalletLocked, isInMemoryWallet, hasKeyMaterial } = useWalletStore(); const [settings] = useAppSettingsContext(); const { mnemonicVerificationFrequency } = settings; const frequency = PHRASE_FREQUENCY_OPTIONS.find(({ value }) => value === mnemonicVerificationFrequency)?.label; @@ -54,8 +54,8 @@ export const SettingsSecurity = ({ }; const isMnemonicAvailable = useCallback(async () => { - setHideShowPassphraseSetting(isWalletLocked() || !isInMemoryWallet); - }, [isInMemoryWallet, isWalletLocked]); + setHideShowPassphraseSetting(isWalletLocked() || !isInMemoryWallet || !hasKeyMaterial); + }, [isInMemoryWallet, isWalletLocked, hasKeyMaterial]); const handleCloseShowPassphraseDrawer = () => { setIsShowPassphraseDrawerOpen(false);