Skip to content

Commit

Permalink
fix: lw-9273 handle successful confirmation window (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
VanessaPC authored and pczeglik-iohk committed Dec 8, 2023
1 parent 8d78ac1 commit 548ce78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions apps/browser-extension-wallet/src/hooks/useWalletManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface UseWalletManager {
saveHardwareWallet: (wallet: Wallet.CardanoWalletByChain, chainName?: Wallet.ChainName) => Promise<void>;
deleteWallet: (isForgotPasswordFlow?: boolean) => Promise<void>;
executeWithPassword: <T>(password: string, promiseFn: () => Promise<T>, cleanPassword?: boolean) => Promise<T>;
clearPassword: () => void;
switchNetwork: (chainName: Wallet.ChainName) => Promise<void>;
updateAddresses: (args: {
addresses: Wallet.KeyManagement.GroupedAddress[];
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -481,6 +489,7 @@ export const useWalletManager = (): UseWalletManager => {
saveHardwareWallet,
deleteWallet,
executeWithPassword,
clearPassword,
switchNetwork,
updateAddresses
};
Expand Down

0 comments on commit 548ce78

Please sign in to comment.