Skip to content

Commit 74c048d

Browse files
DeeJayEllynikolaglumacTomislav Horaček
authored
[DDW-105] Force setting password on passwordless wallets (#1957)
* [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets - updating translations * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets * [DDW-105] - Force setting password on passwordless wallets - fixing storybooks * [DDW-105] - Force setting password on passwordless wallets - fixing storybooks * [DDW-105] - Force setting password on passwordless wallets - removing forceSetPassword * [DDW-105] - Force setting password on passwordless wallets - fixing positioning * [DDW-105] - Force setting password on passwordless wallets - fixing lint * [DDW-105] Improve code style * [DDW-105] - Force setting password on passwordless wallets - fixing translations * [DDW-105] - Force setting password on passwordless wallets - fixing storybook * [DDW-105] - Force setting password on passwordless wallets - fixing storybook * [DDW-105] - Force setting password on passwordless wallets - storybook * [DDW-105] - Force setting password on passwordless wallets - storybook * [DDW-105] - Force setting password on passwordless wallets - storybook * [DDW-105] - Force setting password on passwordless wallets - quick fix * [DDW-105] - Force setting password on passwordless wallets - storybook fixes * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-105] Update storybook wallet stories and genereate address after wallet password creation * [DDW-105] Add missing story layout flow declaration * [DDW-105] Small code improvement * [DDW-106] Update storybook wallets data * [DDW-105] Update address generation handling Co-authored-by: Nikola Glumac <[email protected]> Co-authored-by: Tomislav Horaček <[email protected]>
1 parent 6082330 commit 74c048d

32 files changed

+598
-152
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Changelog
33

44
## vNext
55

6+
### Features
7+
8+
- Force setting spending password on passwordless wallets ([PR 1957](https://github.com/input-output-hk/daedalus/pull/1957))
9+
610
### Chores
711

812
- Separated handling of `cardano-wallet` and `cardano-node` logs ([PR 1960](https://github.com/input-output-hk/daedalus/pull/1960))

source/renderer/app/api/api.js

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ export default class AdaApi {
551551
'random'
552552
);
553553

554-
// Genearte address for the newly created Byron wallet
554+
// Generate address for the newly created Byron wallet
555555
const { id: walletId } = legacyWallet;
556556
const address: Address = await createByronWalletAddress(this.config, {
557557
passphrase: spendingPassword,
@@ -992,20 +992,14 @@ export default class AdaApi {
992992
type
993993
);
994994

995-
// Genearte address for restored Byron wallet without addresses
996995
if (!isIncentivizedTestnet) {
996+
// Generate address for the newly restored Byron wallet
997997
const { id: walletId } = legacyWallet;
998-
const walletAddresses = await getByronWalletAddresses(
999-
this.config,
1000-
walletId
1001-
);
1002-
if (!walletAddresses || (walletAddresses && !walletAddresses.length)) {
1003-
const address: Address = await createByronWalletAddress(this.config, {
1004-
passphrase: spendingPassword,
1005-
walletId,
1006-
});
1007-
logger.debug('AdaApi::createAddress (Byron) success', { address });
1008-
}
998+
const address: Address = await createByronWalletAddress(this.config, {
999+
passphrase: spendingPassword,
1000+
walletId,
1001+
});
1002+
logger.debug('AdaApi::createAddress (Byron) success', { address });
10091003
}
10101004

10111005
const extraLegacyWalletProps = {
@@ -1062,23 +1056,6 @@ export default class AdaApi {
10621056
{ walletInitData },
10631057
type
10641058
);
1065-
1066-
// Genearte address for restored Byron wallet without addresses
1067-
if (!isIncentivizedTestnet) {
1068-
const { id: walletId } = legacyWallet;
1069-
const walletAddresses = await getByronWalletAddresses(
1070-
this.config,
1071-
walletId
1072-
);
1073-
if (!walletAddresses || (walletAddresses && !walletAddresses.length)) {
1074-
const address: Address = await createByronWalletAddress(this.config, {
1075-
passphrase: spendingPassword,
1076-
walletId,
1077-
});
1078-
logger.debug('AdaApi::createAddress (Byron) success', { address });
1079-
}
1080-
}
1081-
10821059
const extraLegacyWalletProps = {
10831060
address_pool_gap: 0, // Not needed for legacy wallets
10841061
delegation: {
@@ -1400,6 +1377,15 @@ export default class AdaApi {
14001377
oldPassword,
14011378
newPassword,
14021379
});
1380+
1381+
if (!isIncentivizedTestnet && !oldPassword) {
1382+
// Generate address for the Byron wallet for which password was set for the 1st time
1383+
const address: Address = await createByronWalletAddress(this.config, {
1384+
passphrase: newPassword,
1385+
walletId,
1386+
});
1387+
logger.debug('AdaApi::createAddress (Byron) success', { address });
1388+
}
14031389
} else {
14041390
await updateSpendingPassword(this.config, {
14051391
walletId,
Lines changed: 14 additions & 0 deletions
Loading

source/renderer/app/components/wallet/layouts/WalletWithNavigation.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,43 @@ import { observer } from 'mobx-react';
55
import WalletNavigation from '../navigation/WalletNavigation';
66
import styles from './WalletWithNavigation.scss';
77
import NotResponding from '../not-responding/NotResponding';
8+
import SetWalletPassword from '../settings/SetWalletPassword';
89

910
type Props = {
1011
children?: Node,
1112
activeItem: string,
13+
hasNotification?: boolean,
14+
hasPassword: boolean,
1215
isActiveScreen: Function,
1316
isLegacy: boolean,
14-
onWalletNavItemClick: Function,
15-
onRestartNode: Function,
16-
onOpenExternalLink: Function,
17-
hasNotification?: boolean,
1817
isNotResponding: boolean,
18+
isSetWalletPasswordDialogOpen: boolean,
19+
onOpenExternalLink: Function,
20+
onRestartNode: Function,
21+
onSetWalletPassword: Function,
22+
onWalletNavItemClick: Function,
1923
};
2024

2125
@observer
2226
export default class WalletWithNavigation extends Component<Props> {
2327
render() {
2428
const {
2529
children,
26-
isActiveScreen,
27-
isLegacy,
28-
onWalletNavItemClick,
2930
activeItem,
3031
hasNotification,
32+
hasPassword,
33+
isActiveScreen,
34+
isLegacy,
3135
isNotResponding,
32-
onRestartNode,
36+
isSetWalletPasswordDialogOpen,
3337
onOpenExternalLink,
38+
onRestartNode,
39+
onSetWalletPassword,
40+
onWalletNavItemClick,
3441
} = this.props;
42+
3543
return (
3644
<div className={styles.component}>
37-
{isNotResponding && (
38-
<NotResponding
39-
walletName={activeItem}
40-
onRestartNode={onRestartNode}
41-
onOpenExternalLink={onOpenExternalLink}
42-
/>
43-
)}
4445
<div className={styles.navigation}>
4546
<WalletNavigation
4647
isActiveNavItem={isActiveScreen}
@@ -50,7 +51,23 @@ export default class WalletWithNavigation extends Component<Props> {
5051
hasNotification={hasNotification}
5152
/>
5253
</div>
54+
5355
<div className={styles.page}>{children}</div>
56+
57+
{!hasPassword && (
58+
<SetWalletPassword
59+
isSetWalletPasswordDialogOpen={isSetWalletPasswordDialogOpen}
60+
onSetWalletPassword={onSetWalletPassword}
61+
/>
62+
)}
63+
64+
{isNotResponding && (
65+
<NotResponding
66+
walletName={activeItem}
67+
onRestartNode={onRestartNode}
68+
onOpenExternalLink={onOpenExternalLink}
69+
/>
70+
)}
5471
</div>
5572
);
5673
}

source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ type Props = {
8585
isSubmitting: boolean,
8686
error: ?LocalizableError,
8787
isSpendingPasswordSet: boolean,
88-
forceSetPassword: boolean,
8988
walletName: string,
9089
};
9190

@@ -201,7 +200,6 @@ export default class ChangeSpendingPasswordDialog extends Component<Props> {
201200
isSubmitting,
202201
error,
203202
isSpendingPasswordSet,
204-
forceSetPassword,
205203
walletName,
206204
} = this.props;
207205
const dialogClasses = classnames([
@@ -240,12 +238,10 @@ export default class ChangeSpendingPasswordDialog extends Component<Props> {
240238
{ walletName }
241239
)}
242240
actions={actions}
243-
closeOnOverlayClick={!forceSetPassword}
244-
onClose={!isSubmitting && !forceSetPassword ? onCancel : () => {}}
241+
closeOnOverlayClick
242+
onClose={!isSubmitting ? onCancel : () => {}}
245243
className={dialogClasses}
246-
closeButton={
247-
!forceSetPassword ? <DialogCloseButton onClose={onCancel} /> : null
248-
}
244+
closeButton={<DialogCloseButton onClose={onCancel} />}
249245
>
250246
<div className={styles.spendingPasswordFields}>
251247
{isSpendingPasswordSet && (
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// @flow
2+
import React, { Component } from 'react';
3+
import { observer } from 'mobx-react';
4+
import { defineMessages, intlShape } from 'react-intl';
5+
import SVGInline from 'react-svg-inline';
6+
import insecureWalletIcon from '../../../assets/images/insecure-wallet.inline.svg';
7+
import styles from './SetWalletPassword.scss';
8+
import ChangeSpendingPasswordDialogContainer from '../../../containers/wallet/dialogs/settings/ChangeSpendingPasswordDialogContainer';
9+
10+
const messages = defineMessages({
11+
setPasswordButton: {
12+
id: 'wallet.settings.setWalletPassword.dialog.setPasswordButton',
13+
defaultMessage: '!!!Set a password',
14+
description:
15+
'Label for the "Set a password" button in the set wallet password dialog.',
16+
},
17+
setPasswordMessage: {
18+
id: 'wallet.settings.setWalletPassword.dialog.setPasswordMessage',
19+
defaultMessage:
20+
'!!!To keep your wallet secure and start using it in Daedalus, you need to set a spending password.',
21+
description:
22+
'Message for the "Set a password" button in the set wallet password dialog.',
23+
},
24+
setPasswordTitle: {
25+
id: 'wallet.settings.setWalletPassword.dialog.setPasswordTitle',
26+
defaultMessage: '!!!Your wallet is not protected with a password',
27+
description:
28+
'Title for the "Set wallet password" dialog when there is not password set.',
29+
},
30+
});
31+
32+
type Props = {
33+
isSetWalletPasswordDialogOpen: boolean,
34+
onSetWalletPassword: Function,
35+
};
36+
37+
@observer
38+
export default class SetWalletPassword extends Component<Props> {
39+
static contextTypes = {
40+
intl: intlShape.isRequired,
41+
};
42+
43+
render() {
44+
const { intl } = this.context;
45+
const { isSetWalletPasswordDialogOpen, onSetWalletPassword } = this.props;
46+
47+
return (
48+
<>
49+
<div className={styles.component}>
50+
<div className={styles.setPasswordDialog}>
51+
<div className={styles.setPasswordWrapper}>
52+
<SVGInline
53+
svg={insecureWalletIcon}
54+
className={styles.insecureWalletIcon}
55+
/>
56+
<h2 className={styles.setPasswordTitle}>
57+
{intl.formatMessage(messages.setPasswordTitle)}
58+
</h2>
59+
<p className={styles.setPasswordMessage}>
60+
{intl.formatMessage(messages.setPasswordMessage)}
61+
</p>
62+
<button
63+
className={styles.setPasswordButton}
64+
onClick={onSetWalletPassword}
65+
>
66+
{intl.formatMessage(messages.setPasswordButton)}
67+
</button>
68+
</div>
69+
</div>
70+
</div>
71+
72+
{isSetWalletPasswordDialogOpen && (
73+
<ChangeSpendingPasswordDialogContainer />
74+
)}
75+
</>
76+
);
77+
}
78+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
.component {
2+
background-color: var(
3+
--theme-dialog-set-wallet-password-background-color
4+
) !important;
5+
border-radius: 0 !important;
6+
box-shadow: 0 5px 20px 0 var(--theme-dialog-set-wallet-password-box-shadow) !important;
7+
display: flex;
8+
flex-direction: column;
9+
height: 100%;
10+
justify-content: center;
11+
position: absolute;
12+
width: 100%;
13+
z-index: 9;
14+
15+
.setPasswordDialog {
16+
font-family: var(--font-regular);
17+
height: 100%;
18+
width: 100%;
19+
20+
.setPasswordWrapper {
21+
align-items: center;
22+
display: flex;
23+
flex-direction: column;
24+
height: 100%;
25+
justify-content: center;
26+
27+
.insecureWalletIcon {
28+
height: 105px;
29+
object-fit: contain;
30+
width: 105px;
31+
32+
svg {
33+
path,
34+
rect,
35+
circle {
36+
stroke: var(--theme-dialog-set-wallet-password-message-color);
37+
}
38+
39+
g > g path:last-child {
40+
fill: var(--theme-dialog-set-wallet-password-message-color);
41+
}
42+
}
43+
}
44+
45+
.setPasswordTitle {
46+
color: var(--theme-dialog-set-wallet-password-title-color);
47+
font-size: 20px;
48+
line-height: 1.2;
49+
padding-top: 36px;
50+
text-align: center;
51+
}
52+
53+
.setPasswordMessage {
54+
color: var(--theme-dialog-set-wallet-password-message-color);
55+
font-size: 16px;
56+
line-height: 1.38;
57+
max-width: 670px;
58+
opacity: 0.7;
59+
padding-top: 11px;
60+
text-align: center;
61+
}
62+
63+
.setPasswordButton {
64+
background-color: var(
65+
--theme-dialog-set-wallet-password-button-background-color
66+
);
67+
border: solid 1px
68+
var(--theme-dialog-set-wallet-password-button-border-color);
69+
border-radius: 5px;
70+
color: var(--theme-dialog-set-wallet-password-button-color);
71+
font-family: var(--font-regular);
72+
font-size: 14px;
73+
font-weight: 500;
74+
height: 50px;
75+
line-height: 1.36;
76+
margin-top: 30px;
77+
text-align: center;
78+
width: 360px !important;
79+
80+
&:hover {
81+
background-color: var(
82+
--theme-dialog-set-wallet-password-button-background-color-hover
83+
);
84+
color: var(--theme-dialog-set-wallet-password-button-color-hover);
85+
cursor: pointer;
86+
}
87+
}
88+
}
89+
}
90+
}

0 commit comments

Comments
 (0)