Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RN-306]: allow delete keys without backup #564

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 5 additions & 14 deletions src/navigation/tabs/settings/components/WalletsAndKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import {
SettingTitle,
} from '../../../../components/styled/Containers';
import {Link} from '../../../../components/styled/Text';
import {showBottomNotificationModal} from '../../../../store/app/app.actions';
import {Key} from '../../../../store/wallet/wallet.models';
import {useAppDispatch, useAppSelector} from '../../../../utils/hooks';
import {keyBackupRequired} from '../../home/components/Crypto';
import {useAppSelector} from '../../../../utils/hooks';
import {SettingsComponent} from '../SettingsRoot';
import {DisabledOpacity} from '../../home/components/Styled';

Expand All @@ -25,22 +23,15 @@ const CreateOrImportLink = styled(Link)`
const WalletsAndKeys = () => {
const {t} = useTranslation();
const navigation = useNavigation();
const dispatch = useAppDispatch();
const keys = useAppSelector(({WALLET}) => WALLET.keys);
const keyList = Object.values(keys);
const deferredImport = useAppSelector(({WALLET}) => WALLET.deferredImport);

const onPressKey = (key: Key) => {
key.backupComplete
? navigation.navigate('Wallet', {
screen: 'KeySettings',
params: {key},
})
: dispatch(
showBottomNotificationModal(
keyBackupRequired(key, navigation, dispatch, 'settings'),
),
);
navigation.navigate('Wallet', {
screen: 'KeySettings',
params: {key},
});
};

return (
Expand Down
90 changes: 47 additions & 43 deletions src/navigation/wallet/screens/KeySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const KeySettings = () => {
);

const _key: Key = useAppSelector(({WALLET}) => WALLET.keys[key.id]);
const {keyName, hideKeyBalance} = _key || {};
const {keyName, hideKeyBalance, backupComplete} = _key || {};

useEffect(() => {
if (context === 'createEncryptPassword') {
Expand Down Expand Up @@ -374,7 +374,7 @@ const KeySettings = () => {
),
)}

{_key && !_key.isReadOnly ? (
{_key && !_key.isReadOnly && backupComplete ? (
<VerticalPadding style={{alignItems: 'center'}}>
<AddWalletText
onPress={() => {
Expand Down Expand Up @@ -430,45 +430,49 @@ const KeySettings = () => {

<Hr />

<SettingView>
<WalletSettingsTitle>
{t('Request Encrypt Password')}
</WalletSettingsTitle>

<RequestEncryptPasswordToggle currentKey={key} />
</SettingView>

<Info>
<InfoTriangle />

<InfoHeader>
<InfoImageContainer infoMargin={'0 8px 0 0'}>
<InfoSvg />
</InfoImageContainer>

<InfoTitle>{t('Password Not Recoverable')}</InfoTitle>
</InfoHeader>
<InfoDescription>
{t(
'This password cannot be recovered. If this password is lost, funds can only be recovered by reimporting your 12-word recovery phrase.',
)}
</InfoDescription>

<VerticalPadding>
<TouchableOpacity
activeOpacity={ActiveOpacity}
onPress={() => {
haptic('impactLight');
dispatch(
openUrlWithInAppBrowser(URL.HELP_SPENDING_PASSWORD),
);
}}>
<Link>{t('Learn More')}</Link>
</TouchableOpacity>
</VerticalPadding>
</Info>
{backupComplete ? (
<>
<SettingView>
<WalletSettingsTitle>
{t('Request Encrypt Password')}
</WalletSettingsTitle>

<Hr />
<RequestEncryptPasswordToggle currentKey={key} />
</SettingView>

<Info>
<InfoTriangle />

<InfoHeader>
<InfoImageContainer infoMargin={'0 8px 0 0'}>
<InfoSvg />
</InfoImageContainer>

<InfoTitle>{t('Password Not Recoverable')}</InfoTitle>
</InfoHeader>
<InfoDescription>
{t(
'This password cannot be recovered. If this password is lost, funds can only be recovered by reimporting your 12-word recovery phrase.',
)}
</InfoDescription>

<VerticalPadding>
<TouchableOpacity
activeOpacity={ActiveOpacity}
onPress={() => {
haptic('impactLight');
dispatch(
openUrlWithInAppBrowser(URL.HELP_SPENDING_PASSWORD),
);
}}>
<Link>{t('Learn More')}</Link>
</TouchableOpacity>
</VerticalPadding>
</Info>

<Hr />
</>
) : null}

{_key?.methods?.isPrivKeyEncrypted() ? (
<>
Expand All @@ -494,7 +498,7 @@ const KeySettings = () => {

<VerticalPadding>
<Title>{t('Advanced')}</Title>
{_key && !_key.isReadOnly ? (
{_key && !_key.isReadOnly && backupComplete ? (
<>
<Setting
activeOpacity={ActiveOpacity}
Expand All @@ -520,7 +524,7 @@ const KeySettings = () => {
</>
) : null}

{_key && !_key.isReadOnly ? (
{_key && !_key.isReadOnly && backupComplete ? (
<>
<Setting
activeOpacity={ActiveOpacity}
Expand Down Expand Up @@ -558,7 +562,7 @@ const KeySettings = () => {
</>
) : null}

{_key && !_key.isReadOnly ? (
{_key && !_key.isReadOnly && backupComplete ? (
<>
<Setting
activeOpacity={ActiveOpacity}
Expand Down