2021-02-04 19:15:23 +01:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { connect } from 'react-redux';
|
2018-07-05 19:09:55 +02:00
|
|
|
import {
|
|
|
|
createNewVaultAndRestore,
|
|
|
|
unMarkPasswordForgotten,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../store/actions';
|
|
|
|
import { DEFAULT_ROUTE } from '../../helpers/constants/routes';
|
2022-02-03 15:06:43 +01:00
|
|
|
import CreateNewVault from '../../components/app/create-new-vault';
|
2022-02-22 16:45:19 +01:00
|
|
|
import Button from '../../components/ui/button';
|
|
|
|
import Box from '../../components/ui/box';
|
|
|
|
import Typography from '../../components/ui/typography';
|
|
|
|
import ZENDESK_URLS from '../../helpers/constants/zendesk-url';
|
2023-02-02 21:15:26 +01:00
|
|
|
import {
|
|
|
|
TextColor,
|
|
|
|
TypographyVariant,
|
|
|
|
} from '../../helpers/constants/design-system';
|
2023-04-03 17:31:04 +02:00
|
|
|
import { MetaMetricsEventCategory } from '../../../shared/constants/metametrics';
|
2021-07-22 19:34:53 +02:00
|
|
|
|
2018-07-05 19:09:55 +02:00
|
|
|
class RestoreVaultPage extends Component {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2022-03-29 15:46:24 +02:00
|
|
|
trackEvent: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-11-29 05:24:35 +01:00
|
|
|
|
2018-07-05 19:09:55 +02:00
|
|
|
static propTypes = {
|
|
|
|
createNewVaultAndRestore: PropTypes.func.isRequired,
|
|
|
|
leaveImportSeedScreenState: PropTypes.func,
|
|
|
|
history: PropTypes.object,
|
|
|
|
isLoading: PropTypes.bool,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-07-05 19:09:55 +02:00
|
|
|
|
2022-02-03 15:06:43 +01:00
|
|
|
handleImport = async (password, seedPhrase) => {
|
2018-07-05 19:09:55 +02:00
|
|
|
const {
|
2020-08-18 18:36:45 +02:00
|
|
|
// eslint-disable-next-line no-shadow
|
2018-07-05 19:09:55 +02:00
|
|
|
createNewVaultAndRestore,
|
|
|
|
leaveImportSeedScreenState,
|
|
|
|
history,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = this.props;
|
2018-07-05 19:09:55 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
leaveImportSeedScreenState();
|
2022-02-03 15:06:43 +01:00
|
|
|
await createNewVaultAndRestore(password, seedPhrase);
|
2022-03-29 15:46:24 +02:00
|
|
|
this.context.trackEvent({
|
2023-04-03 17:31:04 +02:00
|
|
|
category: MetaMetricsEventCategory.Retention,
|
2022-03-29 15:46:24 +02:00
|
|
|
event: 'onboardingRestoredVault',
|
|
|
|
properties: {
|
2022-02-03 15:06:43 +01:00
|
|
|
action: 'userEntersSeedPhrase',
|
2022-03-29 15:46:24 +02:00
|
|
|
legacy_event: true,
|
2020-11-03 00:41:28 +01:00
|
|
|
},
|
2022-02-03 15:06:43 +01:00
|
|
|
});
|
|
|
|
history.push(DEFAULT_ROUTE);
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-09-02 17:45:09 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { t } = this.context;
|
|
|
|
const { isLoading } = this.props;
|
2017-11-29 05:24:35 +01:00
|
|
|
|
|
|
|
return (
|
2022-02-22 16:45:19 +01:00
|
|
|
<Box className="first-view-main-wrapper">
|
|
|
|
<Box className="first-view-main">
|
|
|
|
<Box className="import-account">
|
2018-07-05 19:09:55 +02:00
|
|
|
<a
|
|
|
|
className="import-account__back-button"
|
2020-02-15 21:34:12 +01:00
|
|
|
onClick={(e) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
e.preventDefault();
|
|
|
|
this.props.leaveImportSeedScreenState();
|
2023-01-09 12:19:53 +01:00
|
|
|
this.props.history.push(DEFAULT_ROUTE);
|
2018-07-05 19:09:55 +02:00
|
|
|
}}
|
|
|
|
href="#"
|
|
|
|
>
|
2021-06-08 19:02:34 +02:00
|
|
|
{`< ${t('back')}`}
|
2018-07-05 19:09:55 +02:00
|
|
|
</a>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Typography
|
|
|
|
variant={TypographyVariant.H1}
|
|
|
|
color={TextColor.textDefault}
|
|
|
|
>
|
2022-02-22 16:45:19 +01:00
|
|
|
{t('resetWallet')}
|
|
|
|
</Typography>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Typography color={TextColor.textDefault}>
|
2022-02-22 16:45:19 +01:00
|
|
|
{t('resetWalletSubHeader')}
|
|
|
|
</Typography>
|
2022-07-20 22:47:51 +02:00
|
|
|
<Typography
|
2023-02-02 21:15:26 +01:00
|
|
|
color={TextColor.textDefault}
|
2022-07-20 22:47:51 +02:00
|
|
|
marginTop={4}
|
|
|
|
marginBottom={4}
|
|
|
|
>
|
2022-02-22 16:45:19 +01:00
|
|
|
{t('resetWalletUsingSRP', [
|
|
|
|
<Button
|
|
|
|
type="link"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
href={ZENDESK_URLS.ADD_MISSING_ACCOUNTS}
|
|
|
|
key="import-account-secretphase"
|
|
|
|
className="import-account__link"
|
|
|
|
>
|
|
|
|
{t('reAddAccounts')}
|
|
|
|
</Button>,
|
|
|
|
<Button
|
|
|
|
type="link"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
href={ZENDESK_URLS.IMPORT_ACCOUNTS}
|
|
|
|
key="import-account-reimport-accounts"
|
|
|
|
className="import-account__link"
|
|
|
|
>
|
|
|
|
{t('reAdded')}
|
|
|
|
</Button>,
|
|
|
|
<Button
|
|
|
|
type="link"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
href={ZENDESK_URLS.ADD_CUSTOM_TOKENS}
|
|
|
|
key="import-account-readd-tokens"
|
|
|
|
className="import-account__link"
|
|
|
|
>
|
|
|
|
{t('reAdded')}
|
|
|
|
</Button>,
|
|
|
|
])}
|
|
|
|
</Typography>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Typography
|
|
|
|
color={TextColor.textDefault}
|
|
|
|
margin={0}
|
|
|
|
marginBottom={4}
|
|
|
|
>
|
2022-02-22 16:45:19 +01:00
|
|
|
{t('resetWalletWarning')}
|
|
|
|
</Typography>
|
2022-02-03 15:06:43 +01:00
|
|
|
<CreateNewVault
|
|
|
|
disabled={isLoading}
|
2021-12-10 20:32:13 +01:00
|
|
|
onSubmit={this.handleImport}
|
2022-02-03 15:06:43 +01:00
|
|
|
submitText={t('restore')}
|
|
|
|
/>
|
2022-02-22 16:45:19 +01:00
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
</Box>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2017-11-29 05:24:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:09:55 +02:00
|
|
|
export default connect(
|
2019-12-08 04:10:47 +01:00
|
|
|
({ appState: { isLoading } }) => ({ isLoading }),
|
2020-02-15 21:34:12 +01:00
|
|
|
(dispatch) => ({
|
2018-07-05 19:09:55 +02:00
|
|
|
leaveImportSeedScreenState: () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(unMarkPasswordForgotten());
|
2017-11-29 05:24:35 +01:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
createNewVaultAndRestore: (pw, seed) =>
|
|
|
|
dispatch(createNewVaultAndRestore(pw, seed)),
|
2020-07-14 17:20:41 +02:00
|
|
|
}),
|
2021-02-04 19:15:23 +01:00
|
|
|
)(RestoreVaultPage);
|