Skip to content

Commit

Permalink
Merge pull request #684 from secretkeylabs/release/v0.23.2
Browse files Browse the repository at this point in the history
  • Loading branch information
teebszet committed Nov 26, 2023
2 parents 01335bc + 21a45ee commit 9109e58
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 78 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xverse-web-extension",
"description": "A Bitcoin wallet for Web3",
"version": "0.23.0",
"version": "0.23.2",
"private": true,
"engines": {
"node": "^18.18.2"
Expand Down
1 change: 1 addition & 0 deletions src/app/screens/btcSendScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import useSendBtcRequest from '@hooks/useSendBtcRequest';
import useWalletSelector from '@hooks/useWalletSelector';
import { ErrorCodes, getBtcFiatEquivalent } from '@secretkeylabs/xverse-core';
import { BITCOIN_DUST_AMOUNT_SATS } from '@utils/constants';
import BigNumber from 'bignumber.js';
import { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
Expand Down
30 changes: 13 additions & 17 deletions src/app/screens/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Eye from '@assets/img/createPassword/Eye.svg';
import EyeSlash from '@assets/img/createPassword/EyeSlash.svg';
import logo from '@assets/img/xverse_logo.svg';
import ActionButton from '@components/button';
import useCacheMigration from '@hooks/useCacheMigration';
import useWalletReducer from '@hooks/useWalletReducer';
import { animated,useSpring } from '@react-spring/web';
import MigrationConfirmation from '@screens/migrationConfirmation';
Expand Down Expand Up @@ -130,20 +129,20 @@ function Login(): JSX.Element {
},
delay: 100,
});
const { migrateCachedStorage } = useCacheMigration();

const handleSkipMigration = async () => {
await unlockWallet(password);
setIsVerifying(false);
const skipTime = new Date().getTime();
const migrationReminder = addMinutes(skipTime, 10).getTime();
localStorage.setItem('migrationReminder', migrationReminder.toString());
navigate(-1);
};

const handleMigrateCache = async () => {
await migrateCachedStorage(password);
setIsVerifying(false);
try {
await unlockWallet(password);
setIsVerifying(false);
const skipTime = new Date().getTime();
const migrationReminder = addMinutes(skipTime, 10).getTime();
localStorage.setItem('migrationReminder', migrationReminder.toString());
navigate(-1);
} catch (err) {
setIsVerifying(false);
setShowMigration(false);
setError(t('VERIFY_PASSWORD_ERROR'));
}
};

const handleTogglePasswordView = () => {
Expand Down Expand Up @@ -230,10 +229,7 @@ function Login(): JSX.Element {
</ContentContainer>
</ScreenContainer>
) : (
<MigrationConfirmation
migrateCallback={handleMigrateCache}
skipCallback={handleSkipMigration}
/>
<MigrationConfirmation migrateCallback={handleMigrateCache} />
)}
</>
);
Expand Down
66 changes: 10 additions & 56 deletions src/app/screens/migrationConfirmation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import WarningStatus from '@assets/img/warningIcon.svg';
import ActionButton from '@components/button';
import { useState } from 'react';
import styled from 'styled-components';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import ActionButton from '@components/button';
import WarningStatus from '@assets/img/warningIcon.svg';
import CheckCircle from '@assets/img/createWalletSuccess/CheckCircle.svg';
import styled from 'styled-components';

const Container = styled.div`
display: flex;
Expand Down Expand Up @@ -42,11 +40,6 @@ const OnboardingContent = styled.div((props) => ({
textAlign: 'center',
}));

const SkipButtonContainer = styled.div((props) => ({
marginRight: props.theme.spacing(2),
width: '100%',
}));

const Icon = styled.img((props) => ({
width: 88,
height: 88,
Expand All @@ -57,67 +50,28 @@ const Icon = styled.img((props) => ({

interface Props {
migrateCallback: () => Promise<void>;
skipCallback: () => Promise<void>;
}

function MigrationConfirmation(props: Props): JSX.Element {
const { migrateCallback, skipCallback } = props;
const [hasFinishedMigrating, setHasFinishedMigrating] = useState(false);
const navigate = useNavigate();
const { migrateCallback } = props;
const [isLoading, setIsLoading] = useState(false);
const [isSkipping, setIsSkipping] = useState(false);
const { t } = useTranslation('translation', { keyPrefix: 'CACHE_MIGRATION_SCREEN' });

const handleConfirm = async () => {
setIsLoading(true);
await migrateCallback();
setHasFinishedMigrating(true);
setIsLoading(false);
};

const onCloseTab = () => {
navigate('/');
};

const handleSkip = async () => {
setIsSkipping(true);
await skipCallback();
setIsSkipping(false);
};

return (
<Container>
<OnBoardingContentContainer>
<Icon src={!hasFinishedMigrating ? WarningStatus : CheckCircle} />
{!hasFinishedMigrating ? (
<>
<OnboardingTitle>{t('TITLE')}</OnboardingTitle>
<OnboardingContent>{t('WARNING')}</OnboardingContent>
</>
) : (
<OnboardingTitle>{t('SUCCESS_TITLE')}</OnboardingTitle>
)}
{!hasFinishedMigrating ? (
<ButtonsContainer>
<SkipButtonContainer>
<ActionButton
text={t('SKIP_BUTTON')}
onPress={handleSkip}
warning
processing={isSkipping}
/>
</SkipButtonContainer>
<ActionButton
onPress={handleConfirm}
text={t('CONFIRM_BUTTON')}
processing={isLoading}
/>
</ButtonsContainer>
) : (
<ButtonsContainer>
<ActionButton text={t('CLOSE_TAB')} onPress={onCloseTab} />
</ButtonsContainer>
)}
<Icon src={WarningStatus} />
<OnboardingTitle>{t('TITLE')}</OnboardingTitle>
<OnboardingContent>{t('WARNING')}</OnboardingContent>
<ButtonsContainer>
<ActionButton text={t('CLOSE_TAB')} onPress={handleConfirm} processing={isLoading} />
</ButtonsContainer>
</OnBoardingContentContainer>
</Container>
);
Expand Down
4 changes: 2 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1025,11 +1025,11 @@
},
"CACHE_MIGRATION_SCREEN": {
"TITLE": "Your wallet data store needs to be updated in order to remain secure.",
"WARNING": "Please make sure you have your seed phrase backed up securely before moving forward.",
"WARNING": "Please make sure you have your seed phrase backed up securely and restore your wallet after resetting it from settings",
"SUCCESS_TITLE": "Update Complete",
"SKIP_BUTTON": "Do it later",
"CONFIRM_BUTTON": "Confirm",
"CLOSE_TAB": "Continue"
"CLOSE_TAB": "I understand"
},
"SWAP_SCREEN": {
"SWAP": "Swap",
Expand Down

0 comments on commit 9109e58

Please sign in to comment.