• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / lace / 8519959931

29 Mar 2024 01:42PM UTC coverage: 50.577% (-3.3%) from 53.839%
8519959931

push

github

b4f7c8
web-flow
chore: LW-9786 enable single pool delegation in multi-delegation view (#970)

* chore: enable single pool delegation in multi-delegation view

* fix: fix hw multi-delegation tx signing

* fix(extension): fix broken ledger connection

2172 of 5359 branches covered (40.53%)

Branch coverage included in aggregate %.

5146 of 9110 relevant lines covered (56.49%)

52.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

23.08
/apps/browser-extension-wallet/src/features/unlock-wallet/components/UnlockWalletContainer.tsx
1
import React, { useCallback, useEffect, useState } from 'react';
70✔
2
import { UnlockWallet } from './UnlockWallet';
70✔
3
import { useWalletManager } from '@src/hooks/useWalletManager';
70✔
4
import { useWalletStore } from '@src/stores';
70✔
5
import { useBackgroundServiceAPIContext } from '@providers/BackgroundServiceAPI';
70✔
6
import { saveValueInLocalStorage } from '@src/utils/local-storage';
70✔
7
import { useKeyboardShortcut } from '@lace/common';
70✔
8
import { BrowserViewSections } from '@lib/scripts/types';
70✔
9
import { useAnalyticsContext } from '@providers';
70✔
10
import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
70✔
11
import { getChainName } from '@src/utils/get-chain-name';
70✔
12

13
export interface UnlockWalletContainerProps {
14
  validateMnemonic?: boolean;
15
}
16

17
export const UnlockWalletContainer = ({ validateMnemonic }: UnlockWalletContainerProps): React.ReactElement => {
70✔
18
  const analytics = useAnalyticsContext();
×
19
  const { unlockWallet, lockWallet, deleteWallet } = useWalletManager();
×
20
  const { setDeletingWallet, resetWalletLock, setAddressesDiscoveryCompleted, currentChain } = useWalletStore();
×
21
  const backgroundService = useBackgroundServiceAPIContext();
×
22

23
  const [isVerifyingPassword, setIsVerifyingPassword] = useState(false);
×
24
  const [password, setPassword] = useState('');
×
25
  const [isValidPassword, setIsValidPassword] = useState(true);
×
26

27
  const handlePasswordChange = useCallback(
×
28
    ({ target: { value } }: React.ChangeEvent<HTMLInputElement>) => {
29
      if (!isValidPassword) {
×
30
        setIsValidPassword(true);
×
31
      }
32
      setPassword(value);
×
33
    },
34
    [isValidPassword]
35
  );
36

37
  useEffect(() => {
×
38
    // Force lock when has to validate mnemonic
39
    if (validateMnemonic) lockWallet();
×
40
  }, [lockWallet, validateMnemonic]);
41

42
  const onUnlock = async (): Promise<void> => {
×
43
    setIsVerifyingPassword(true);
×
44
    try {
×
45
      const decrypted = await unlockWallet(password);
×
46
      setIsValidPassword(decrypted);
×
47
      analytics.sendEventToPostHog(PostHogAction.UnlockWalletWelcomeBackUnlockClick);
×
48
      if (decrypted) {
×
49
        setAddressesDiscoveryCompleted(true);
×
50
        resetWalletLock();
×
51
      }
52
    } catch {
53
      setIsValidPassword(false);
×
54
    }
55
    setIsVerifyingPassword(false);
×
56
  };
57

58
  const onForgotPasswordClick = async (): Promise<void> => {
×
59
    await analytics.sendEventToPostHog(PostHogAction.UnlockWalletForgotPasswordProceedClick);
×
60
    saveValueInLocalStorage({ key: 'isForgotPasswordFlow', value: true });
×
61
    saveValueInLocalStorage({ key: 'appSettings', value: { chainName: getChainName(currentChain) } });
×
62
    setDeletingWallet(true);
×
63
    await deleteWallet(true);
×
64
    await backgroundService.handleOpenBrowser({ section: BrowserViewSections.FORGOT_PASSWORD });
×
65
    setDeletingWallet(false);
×
66
  };
67

68
  useKeyboardShortcut(['Enter'], onUnlock);
×
69

70
  return (
×
71
    <UnlockWallet
72
      isLoading={isVerifyingPassword}
73
      onUnlock={onUnlock}
74
      passwordInput={{ value: password, handleChange: handlePasswordChange, invalidPass: !isValidPassword }}
75
      unlockButtonDisabled={password === ''}
76
      onForgotPasswordClick={onForgotPasswordClick}
77
    />
78
  );
79
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc