Skip to content

Commit c8ae5ed

Browse files
committed
Code Review improvements
1 parent b3d4c76 commit c8ae5ed

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

examples/wallet/app/actions/account.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,6 @@ export function setKeysWithUnlockWalletPassword(
6262
return function setKeysWithUnlockWalletPasswordThunk(dispatch) {
6363
const accountKeys = readEncryptedAccountInfo(unlockWalletPassword);
6464
if (accountKeys) {
65-
const unlockWalletPasswordKeys = {
66-
unlockWalletPassword
67-
};
68-
dispatch({
69-
type: SET_UNLOCK_WALLET_PASSWORD,
70-
...unlockWalletPasswordKeys
71-
});
72-
7365
return getAccountFromPrivateKey(accountKeys.privateKey).then(keys =>
7466
curry(initializeKeysAndRedirect)(dispatch, keys, unlockWalletPassword)
7567
);
@@ -94,8 +86,8 @@ export function setAccountFromPrivateKey(
9486
])
9587
.then(() => dispatch(push(routes.WALLET)))
9688
.catch(error => {
97-
console.log(error);
98-
dispatch(push(routes.INPUT_KEYS));
89+
console.error(error);
90+
dispatch(push(routes.WALLET));
9991
});
10092
});
10193
};

examples/wallet/app/components/RestoreWalletFromMnemonic.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ export default ({ setAccountFromMnemonic }: Props) => {
4242
confirmation
4343
) {
4444
if (!pass && !confirmation) return true;
45-
if (pass.length < 8) {
46-
setIsValidPassword(false);
47-
return false;
48-
}
49-
setIsValidPassword(true);
50-
5145
if (pass !== confirmation) {
5246
setArePasswordAndConfirmationEqual(false);
5347
return false;
5448
}
5549
setArePasswordAndConfirmationEqual(true);
50+
51+
if (!/^[0-9a-zA-Z]{8,}$/.test(password)) {
52+
setIsValidPassword(false);
53+
return false;
54+
}
55+
56+
setIsValidPassword(true);
5657
return true;
5758
};
5859

@@ -82,15 +83,17 @@ export default ({ setAccountFromMnemonic }: Props) => {
8283
onBlur={() => checkIsValidMnemonicPhrase()}
8384
/>
8485
<Form.Label className="text-danger" hidden={isMnemonicValid}>
85-
<code>The phrase can have 12, 15, 18, 21 or 24 valid words.</code>
86+
<em className="text-danger">
87+
The phrase can have 12, 15, 18, 21 or 24 valid words.
88+
</em>
8689
</Form.Label>
8790
<Form.Text>
8891
Example:
8992
<br />
90-
<code>
93+
<em className="text-danger">
9194
decade panther require cruise robust mail gadget advice tonight
9295
post inner snack
93-
</code>
96+
</em>
9497
</Form.Text>
9598
<Form.Control
9699
type="password"
@@ -101,8 +104,10 @@ export default ({ setAccountFromMnemonic }: Props) => {
101104
className="mt-3"
102105
/>
103106
<Form.Text>
104-
This secret password is part of the BIP39 standard to generate safer
105-
wallet seeds.
107+
<em className="text-danger">
108+
This secret password is part of the BIP39 standard to generate
109+
safer wallet seeds.
110+
</em>
106111
</Form.Text>
107112
<Form.Label className="mt-5">Unlock wallet (optional):</Form.Label>
108113
<Form.Group>
@@ -116,7 +121,9 @@ export default ({ setAccountFromMnemonic }: Props) => {
116121
onChange={event => setPassword(event.target.value)}
117122
/>
118123
<Form.Label className="text-danger" hidden={isValidPassword}>
119-
<code>The password must have at least 8 chars.</code>
124+
<em className="text-danger">
125+
The password must have at least 8 chars.
126+
</em>
120127
</Form.Label>
121128
<Form.Control
122129
type="password"
@@ -128,14 +135,18 @@ export default ({ setAccountFromMnemonic }: Props) => {
128135
className="mt-3"
129136
/>
130137
<Form.Text>
131-
This key allows you to unlock your wallet every time you start it
132-
and to keep your account data in a more secure way.
138+
<em className="text-danger">
139+
This key allows you to unlock your wallet every time you start
140+
it and to keep your account data in a more secure way.
141+
</em>
133142
</Form.Text>
134143
<Form.Label
135144
className="text-danger"
136145
hidden={arePasswordAndConfirmationEqual}
137146
>
138-
<code>password and confirmation must be the same.</code>
147+
<em className="text-danger">
148+
password and confirmation must be the same.
149+
</em>
139150
</Form.Label>
140151
</Form.Group>
141152
</Form.Group>

examples/wallet/app/components/RestoreWalletFromPrivateKey.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ export default ({ setAccount }: Props) => {
6666
<Form.Text>
6767
It&apos;s a string like:
6868
<br />
69-
<code>
69+
<em className="text-danger">
7070
ed25519e_sk15psr45hyqnpwcl8xd4lv0m32prenhh8kcltgte2305h5jgynndxect9274j0am0qmmd0snjuadnm6xkgssnkn2njvkg8et8qg0vevsgnwvmpl
71-
</code>
71+
</em>
7272
</Form.Text>
73-
<Form.Group>
73+
<Form.Group className="mt-3">
7474
<Form.Control
7575
type="password"
7676
id="password"
@@ -80,8 +80,10 @@ export default ({ setAccount }: Props) => {
8080
isInvalid={!isValidPassword}
8181
onChange={event => setPassword(event.target.value)}
8282
/>
83-
<Form.Label className="text-danger" hidden={isValidPassword}>
84-
<code>The password must have at least 8 chars.</code>
83+
<Form.Label º hidden={isValidPassword}>
84+
<em className="text-danger">
85+
The password must have at least 8 chars.
86+
</em>
8587
</Form.Label>
8688
<Form.Control
8789
type="password"
@@ -96,7 +98,9 @@ export default ({ setAccount }: Props) => {
9698
className="text-danger"
9799
hidden={arePasswordAndConfirmationEqual}
98100
>
99-
<code>Password and confirmation must be the same.</code>
101+
<em className="text-danger">
102+
Password and confirmation must be the same.
103+
</em>
100104
</Form.Label>
101105
</Form.Group>
102106
</Form.Group>

examples/wallet/app/reducers/account.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// @flow
22
import sortBy from 'lodash/sortBy';
33
import {
4-
SET_UNLOCK_WALLET_PASSWORD,
54
SET_KEYS,
65
SET_ACCOUNT_STATE,
76
SEND_TRANSACTION,
@@ -13,7 +12,6 @@ import type {
1312
SendTransactionAction,
1413
SetAccountStateAction,
1514
SetTransactionsAction,
16-
SetKeysWithUnlockWalletPasswordAction,
1715
SendStakeDelegation
1816
} from '../actions/account';
1917
import type { Account } from './types';
@@ -23,7 +21,6 @@ export default function account(
2321
state: Account,
2422
// eslint-disable-next-line flowtype/space-after-type-colon
2523
action:
26-
| SetKeysWithUnlockWalletPasswordAction
2724
| SetKeysAction
2825
| SetAccountStateAction
2926
| SendTransactionAction
@@ -34,10 +31,6 @@ export default function account(
3431
return { transactions: [] };
3532
}
3633
switch (action.type) {
37-
case SET_UNLOCK_WALLET_PASSWORD:
38-
return Object.assign({}, state, {
39-
unlockWalletPassword: action.unlockWalletPassword
40-
});
4134
case SET_KEYS:
4235
return Object.assign({}, state, {
4336
address: action.address,

0 commit comments

Comments
 (0)