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 (
{secretWord} + { + this.props.setWalletLabel(event.target.value); + }; + handleChangeCoinType = (coinId) => { this.props.setCoinType(coinId); }; cancel = () => { - const { onCancel, setPassphrase } = this.props; + const { onCancel, setPassphrase, setWalletLabel } = this.props; setPassphrase(''); + setWalletLabel(''); // TODO set to random name? onCancel(); }; confirm = () => { - const { account, passphrase, coinType, setPassphrase, addAccount } = this.props; + const { + account, + passphrase, + coinType, + setPassphrase, + setWalletLabel, + addAccount, + walletLabel + } = this.props; + const options = { coinType, + walletLabel, isHardware: account.isHardware }; addAccount({ account, passphrase, options }); setPassphrase(''); + setWalletLabel(''); // TODO set to random name? }; getCoinTypes = () => { diff --git a/src/renderer/shared/components/NewWallet/Mnemonic/index.js b/src/renderer/shared/components/NewWallet/Mnemonic/index.js index ec4aef7bf..705880866 100644 --- a/src/renderer/shared/components/NewWallet/Mnemonic/index.js +++ b/src/renderer/shared/components/NewWallet/Mnemonic/index.js @@ -1,5 +1,6 @@ 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'; @@ -10,6 +11,13 @@ 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) }); @@ -17,6 +25,7 @@ const mapAddAccountActionsToProps = (actions) => ({ export default compose( withErrorToast(), withState('passphrase', 'setPassphrase', ''), + withState('walletLabel', 'setWalletLabel', uniqueNamesGenerator(config)), 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 066cd6d0d..b558a55c2 100644 --- a/src/renderer/shared/wallet/WalletHelpers.js +++ b/src/renderer/shared/wallet/WalletHelpers.js @@ -1,6 +1,5 @@ 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'; @@ -11,12 +10,6 @@ import Wallet from './Wallet'; export const ID = 'wallets'; const walletFilterProps = ['signingFunction', 'wif', 'privateKey']; -const config = { - length: 2, - separator: ' ', - dictionaries: [colors, animals] -}; - const newStorageWallet = ({ isHardware, coinType, // coinType is required @@ -25,7 +18,7 @@ const newStorageWallet = ({ net = DEFAULT_NET, account = 0, change = 0, - walletLabel = uniqueNamesGenerator(config), + walletLabel, publicKey, isImport = false }) => { diff --git a/yarn.lock b/yarn.lock index 952cf8074..b46044315 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13939,10 +13939,10 @@ unique-filename@^1.1.0: dependencies: unique-slug "^2.0.0" -unique-names-generator@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/unique-names-generator/-/unique-names-generator-3.0.1.tgz#48b4709c319f3fa77150ea94d188a92b726a32dd" - integrity sha512-sDcUqltBNn/Ke5pOq7jAslBow7F6mLtlSefjU/OlB7DGPSZdTRd88RwEVHhtokC885CfRF8Z+Zy/H3sdKC3ySg== +unique-names-generator@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/unique-names-generator/-/unique-names-generator-4.1.1.tgz#e511b59021d98a1b5b697f46b2af944a419c3a1c" + integrity sha512-f3FzkJEBVUoUueeA17DzfOqa8eT7VinEKOP32Wdqbe8SzSkU/4afIEfm4KP5W+GCALpUQmW3X/SdSyTP5ES5MQ== unique-slug@^2.0.0: version "2.0.2" From 1a517dd48f1d4f66b7ef581aa4953eb41e4eedc8 Mon Sep 17 00:00:00 2001 From: Maurice Dalderup Date: Fri, 6 Dec 2019 19:23:13 +0100 Subject: [PATCH 2/3] chore(readme): update readme --- README.md | 61 ++++++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 86bf1b38e..3bf730a21 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,36 @@

- + +

nOS Client

+

+ nOS is a blockchain powered virtual operating system that serves as the gateway to Decentralized Applications. +

+

+ + + + + platforms + + + + + + + + + + +

+

+ The nOS Client (Developer MVP Release) allows for the development of Decentralized Applications that interact with Smart Contracts in the back-end. +

-

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,