From 48351ccf68fc5ac8dcc21773f7e90af94aae49cd Mon Sep 17 00:00:00 2001
From: Maurice Dalderup
Date: Fri, 15 Nov 2019 11:40:26 +0100
Subject: [PATCH 1/3] feat(wallet): add label option in creation of mnemonic
wallet
---
package.json | 2 +-
.../components/NewWallet/Mnemonic/Mnemonic.js | 35 ++++++++++++++++---
.../components/NewWallet/Mnemonic/index.js | 9 +++++
src/renderer/shared/wallet/WalletHelpers.js | 9 +----
yarn.lock | 8 ++---
5 files changed, 46 insertions(+), 17 deletions(-)
diff --git a/package.json b/package.json
index 4bacc0307..7c718d150 100644
--- a/package.json
+++ b/package.json
@@ -62,7 +62,7 @@
"source-map-support": "0.5.16",
"spunky": "1.3.1",
"switch-tree": "0.2.2",
- "unique-names-generator": "3.0.1",
+ "unique-names-generator": "4.1.1",
"uuid": "3.3.3",
"what-input": "5.2.6",
"whatwg-url": "7.1.0"
diff --git a/src/renderer/shared/components/NewWallet/Mnemonic/Mnemonic.js b/src/renderer/shared/components/NewWallet/Mnemonic/Mnemonic.js
index 02a8b4dc4..6a9ed3940 100644
--- a/src/renderer/shared/components/NewWallet/Mnemonic/Mnemonic.js
+++ b/src/renderer/shared/components/NewWallet/Mnemonic/Mnemonic.js
@@ -22,7 +22,9 @@ export default class Mnemonic extends React.PureComponent {
setPassphrase: func.isRequired,
coinType: number.isRequired,
setCoinType: func.isRequired,
- addAccount: func.isRequired
+ addAccount: func.isRequired,
+ walletLabel: string.isRequired,
+ setWalletLabel: func.isRequired
};
static defaultProps = {
@@ -30,17 +32,26 @@ export default class Mnemonic extends React.PureComponent {
};
render() {
- const { className, account, coinType } = this.props;
+ const { className, account, coinType, passphrase, walletLabel } = this.props;
const { secretWord } = account;
return (
-nOS
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- nOS is a blockchain powered virtual operating system that serves as the gateway to Decentralized Applications.
-
-
- The nOS Client (Developer MVP Release) allows for the development of Decentralized Applications that interact with Smart Contracts in the back-end.
-
-
----
-
# Getting Started with nOS
The standalone client installers can be found [here](https://github.com/nos/client/releases). To build manually, the client can be cloned from GitHub and run using the development steps below.
-### Commands
+> Commands
```bash
# Cloning from Github
From ff13e2500a4d789b1b59c398bf06fa8802a1759b Mon Sep 17 00:00:00 2001
From: Maurice Dalderup
Date: Fri, 6 Dec 2019 19:43:00 +0100
Subject: [PATCH 3/3] chore(wallet): add random label when not passed
---
.../shared/components/NewWallet/Mnemonic/Mnemonic.js | 4 ++--
.../shared/components/NewWallet/Mnemonic/index.js | 10 +---------
src/renderer/shared/wallet/WalletHelpers.js | 10 +++++++++-
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/renderer/shared/components/NewWallet/Mnemonic/Mnemonic.js b/src/renderer/shared/components/NewWallet/Mnemonic/Mnemonic.js
index 6a9ed3940..9f9b91d50 100644
--- a/src/renderer/shared/components/NewWallet/Mnemonic/Mnemonic.js
+++ b/src/renderer/shared/components/NewWallet/Mnemonic/Mnemonic.js
@@ -90,7 +90,7 @@ export default class Mnemonic extends React.PureComponent {
cancel = () => {
const { onCancel, setPassphrase, setWalletLabel } = this.props;
setPassphrase('');
- setWalletLabel(''); // TODO set to random name?
+ setWalletLabel('');
onCancel();
};
@@ -113,7 +113,7 @@ export default class Mnemonic extends React.PureComponent {
addAccount({ account, passphrase, options });
setPassphrase('');
- setWalletLabel(''); // TODO set to random name?
+ setWalletLabel('');
};
getCoinTypes = () => {
diff --git a/src/renderer/shared/components/NewWallet/Mnemonic/index.js b/src/renderer/shared/components/NewWallet/Mnemonic/index.js
index 705880866..226811922 100644
--- a/src/renderer/shared/components/NewWallet/Mnemonic/index.js
+++ b/src/renderer/shared/components/NewWallet/Mnemonic/index.js
@@ -1,6 +1,5 @@
import { compose, withState } from 'recompose';
import { withActions, progressValues } from 'spunky';
-import { uniqueNamesGenerator, colors, animals } from 'unique-names-generator';
import { withErrorToast } from 'shared/hocs/withToast';
import { DEFAULT_COIN } from 'shared/values/coins';
@@ -11,13 +10,6 @@ import Mnemonic from './Mnemonic';
const { FAILED, LOADED } = progressValues;
-const config = {
- length: 2,
- separator: ' ',
- style: 'capital',
- dictionaries: [colors, animals]
-};
-
const mapAddAccountActionsToProps = (actions) => ({
addAccount: (data) => actions.call(data)
});
@@ -25,7 +17,7 @@ const mapAddAccountActionsToProps = (actions) => ({
export default compose(
withErrorToast(),
withState('passphrase', 'setPassphrase', ''),
- withState('walletLabel', 'setWalletLabel', uniqueNamesGenerator(config)),
+ withState('walletLabel', 'setWalletLabel', ''),
withState('coinType', 'setCoinType', ({ coinType }) => coinType || DEFAULT_COIN),
withActions(addWalletActions, mapAddAccountActionsToProps),
withProgressChange(addWalletActions, FAILED, (state, props) => {
diff --git a/src/renderer/shared/wallet/WalletHelpers.js b/src/renderer/shared/wallet/WalletHelpers.js
index b558a55c2..2fc9a9371 100644
--- a/src/renderer/shared/wallet/WalletHelpers.js
+++ b/src/renderer/shared/wallet/WalletHelpers.js
@@ -1,5 +1,6 @@
import uuid from 'uuid/v4';
import { isEmpty, omit, reduce, filter } from 'lodash';
+import { uniqueNamesGenerator, colors, animals } from 'unique-names-generator';
import { getStorage, setStorage } from 'shared/lib/storage';
import { DEFAULT_ACC_INDEX } from 'shared/values/profile';
@@ -10,6 +11,13 @@ import Wallet from './Wallet';
export const ID = 'wallets';
const walletFilterProps = ['signingFunction', 'wif', 'privateKey'];
+const config = {
+ length: 2,
+ separator: ' ',
+ style: 'capital',
+ dictionaries: [colors, animals]
+};
+
const newStorageWallet = ({
isHardware,
coinType, // coinType is required
@@ -27,7 +35,7 @@ const newStorageWallet = ({
}
const storageWallet = {
walletId: uuid(),
- walletLabel,
+ walletLabel: walletLabel || uniqueNamesGenerator(config),
canDelete,
isHardware,
index,