From 548ce78fe3bd5ed1f550008bab37a1b273cdad5e Mon Sep 17 00:00:00 2001 From: Vanessa Rodriguez Cristobal Date: Fri, 8 Dec 2023 10:58:41 +0000 Subject: [PATCH] fix: lw-9273 handle successful confirmation window (#779) --- .../features/dapp/components/DappTransactionSuccess.tsx | 6 ++++++ .../src/hooks/useWalletManager.ts | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/apps/browser-extension-wallet/src/features/dapp/components/DappTransactionSuccess.tsx b/apps/browser-extension-wallet/src/features/dapp/components/DappTransactionSuccess.tsx index c69b4bf66..5e2b8bcda 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/DappTransactionSuccess.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/DappTransactionSuccess.tsx @@ -6,10 +6,12 @@ import Success from '../../../assets/icons/success-staking.svg'; import styles from './Layout.module.scss'; import { useAnalyticsContext } from '@providers'; import { TX_CREATION_TYPE_KEY, TxCreationType } from '@providers/AnalyticsProvider/analyticsTracker'; +import { useWalletManager } from '@hooks'; export const DappTransactionSuccess = (): React.ReactElement => { const analytics = useAnalyticsContext(); const { t } = useTranslation(); + const { clearPassword } = useWalletManager(); const onClose = async () => { await analytics?.sendEventToPostHog(PostHogAction.SendAllDoneCloseClick, { @@ -18,6 +20,10 @@ export const DappTransactionSuccess = (): React.ReactElement => { window.close(); }; + useEffect(() => { + clearPassword(); + }, [clearPassword]); + useEffect(() => { analytics?.sendEventToPostHog(PostHogAction.SendAllDoneView, { [TX_CREATION_TYPE_KEY]: TxCreationType.External diff --git a/apps/browser-extension-wallet/src/hooks/useWalletManager.ts b/apps/browser-extension-wallet/src/hooks/useWalletManager.ts index b28833677..e8a29a8a7 100644 --- a/apps/browser-extension-wallet/src/hooks/useWalletManager.ts +++ b/apps/browser-extension-wallet/src/hooks/useWalletManager.ts @@ -60,6 +60,7 @@ export interface UseWalletManager { saveHardwareWallet: (wallet: Wallet.CardanoWalletByChain, chainName?: Wallet.ChainName) => Promise; deleteWallet: (isForgotPasswordFlow?: boolean) => Promise; executeWithPassword: (password: string, promiseFn: () => Promise, cleanPassword?: boolean) => Promise; + clearPassword: () => void; switchNetwork: (chainName: Wallet.ChainName) => Promise; updateAddresses: (args: { addresses: Wallet.KeyManagement.GroupedAddress[]; @@ -144,6 +145,13 @@ export const useWalletManager = (): UseWalletManager => { [backgroundService] ); + /** + * Clears the wallet password + */ + const clearPassword = useCallback(() => { + backgroundService.setWalletPassword(); + }, [backgroundService]); + /** * Deletes wallet info in storage, which should be stored encrypted with the wallet password as lock */ @@ -481,6 +489,7 @@ export const useWalletManager = (): UseWalletManager => { saveHardwareWallet, deleteWallet, executeWithPassword, + clearPassword, switchNetwork, updateAddresses };