From e0fa58bbdc520da0d9cc419de83645b7e87da854 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Thu, 2 Nov 2017 10:56:51 +0100 Subject: [PATCH 01/12] Move networks constant to constasts folder and rename it to getNetworks --- src/constants/getNetworks.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/constants/getNetworks.js diff --git a/src/constants/getNetworks.js b/src/constants/getNetworks.js new file mode 100644 index 000000000..1ee4b8113 --- /dev/null +++ b/src/constants/getNetworks.js @@ -0,0 +1,16 @@ +export default () => ([ + {// network name translation t('Mainnet'); + name: 'Mainnet', + ssl: true, + port: 443, + }, {// network name translation t('Testnet'); + name: 'Testnet', + testnet: true, + ssl: true, + port: 443, + }, {// network name translation t('Custom Node'); + name: 'Custom Node', + custom: true, + address: 'http://localhost:4000', + }, +]); From bf4711dfb275d8b54234df4ac8e74ac4126d07db Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Thu, 2 Nov 2017 10:58:30 +0100 Subject: [PATCH 02/12] Change path of getNetworks in login component --- src/components/login/login.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/login/login.js b/src/components/login/login.js index 6bcc4bc85..9da281d65 100644 --- a/src/components/login/login.js +++ b/src/components/login/login.js @@ -4,7 +4,7 @@ import Input from 'react-toolbox/lib/input'; import Dropdown from 'react-toolbox/lib/dropdown'; import Button from 'react-toolbox/lib/button'; import i18next from 'i18next'; -import getNetworks from './networks'; +import getNetworks from '../../constants/getNetworks'; import PassphraseInput from '../passphraseInput'; import styles from './login.css'; import env from '../../constants/env'; From c233bbb8f70d75df3d4f5e1cd79edaa8a8f43e54 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Thu, 2 Nov 2017 10:59:18 +0100 Subject: [PATCH 03/12] Change path of getNetworks in register component --- src/components/register/register.js | 2 +- src/components/register/register.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/register/register.js b/src/components/register/register.js index 55d64f5db..9ef5f41e3 100644 --- a/src/components/register/register.js +++ b/src/components/register/register.js @@ -1,7 +1,7 @@ import React from 'react'; import Passphrase from '../passphrase'; import networks from '../../constants/networks'; -import getNetworks from '../login/networks'; +import getNetworks from '../../constants/getNetworks'; import { validateUrl, getLoginData } from '../../utils/login'; const Register = ({ diff --git a/src/components/register/register.test.js b/src/components/register/register.test.js index 69e3dc42d..39d80949c 100644 --- a/src/components/register/register.test.js +++ b/src/components/register/register.test.js @@ -7,7 +7,7 @@ import configureMockStore from 'redux-mock-store'; import i18n from '../../i18n'; import networks from '../../constants/networks'; import Register from './register'; -import getNetworks from '../login/networks'; +import getNetworks from '../../constants/getNetworks'; import * as Utils from '../../utils/login'; From acaf9afa2b4ed256200a177f05542b9b85438a8e Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Thu, 2 Nov 2017 10:59:47 +0100 Subject: [PATCH 04/12] Change path of getNetworks in saveAccount component --- src/components/saveAccount/saveAccount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/saveAccount/saveAccount.js b/src/components/saveAccount/saveAccount.js index 817db3b69..9cb426f6c 100644 --- a/src/components/saveAccount/saveAccount.js +++ b/src/components/saveAccount/saveAccount.js @@ -1,7 +1,7 @@ import React from 'react'; import InfoParagraph from '../infoParagraph'; import ActionBar from '../actionBar'; -import getNetworks from '../login/networks'; +import getNetworks from '../../constants/getNetworks'; const SaveAccount = ({ network, From 4165d0755d5bc6ca6c150771c0c97018bdee5710 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Thu, 2 Nov 2017 11:00:49 +0100 Subject: [PATCH 05/12] Remove networks constant --- src/components/login/networks.js | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 src/components/login/networks.js diff --git a/src/components/login/networks.js b/src/components/login/networks.js deleted file mode 100644 index 1ee4b8113..000000000 --- a/src/components/login/networks.js +++ /dev/null @@ -1,16 +0,0 @@ -export default () => ([ - {// network name translation t('Mainnet'); - name: 'Mainnet', - ssl: true, - port: 443, - }, {// network name translation t('Testnet'); - name: 'Testnet', - testnet: true, - ssl: true, - port: 443, - }, {// network name translation t('Custom Node'); - name: 'Custom Node', - custom: true, - address: 'http://localhost:4000', - }, -]); From 97288b1731fa3dd41e4525244fef7cd199f2df81 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Fri, 3 Nov 2017 11:30:01 +0100 Subject: [PATCH 06/12] Delete getNetworks and add its data as networksDetail to networks.js --- src/constants/getNetworks.js | 16 ---------------- src/constants/networks.js | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 src/constants/getNetworks.js diff --git a/src/constants/getNetworks.js b/src/constants/getNetworks.js deleted file mode 100644 index 1ee4b8113..000000000 --- a/src/constants/getNetworks.js +++ /dev/null @@ -1,16 +0,0 @@ -export default () => ([ - {// network name translation t('Mainnet'); - name: 'Mainnet', - ssl: true, - port: 443, - }, {// network name translation t('Testnet'); - name: 'Testnet', - testnet: true, - ssl: true, - port: 443, - }, {// network name translation t('Custom Node'); - name: 'Custom Node', - custom: true, - address: 'http://localhost:4000', - }, -]); diff --git a/src/constants/networks.js b/src/constants/networks.js index cba7395de..405e0dc29 100644 --- a/src/constants/networks.js +++ b/src/constants/networks.js @@ -1,7 +1,24 @@ -const networks = { +export const networksCode = { mainnet: 0, testnet: 1, customNode: 2, }; -export default networks; +export const networksDetail = [ + { // network name translation t('Mainnet'); + name: 'Mainnet', + ssl: true, + port: 443, + }, + { // network name translation t('Testnet'); + name: 'Testnet', + testnet: true, + ssl: true, + port: 443, + }, + { // network name translation t('Custom Node'); + name: 'Custom Node', + custom: true, + address: 'http://localhost:4000', + }, +]; From 94818c509a6e4d17cf9f272674f09b1b0c9b0c05 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Fri, 3 Nov 2017 17:15:50 +0100 Subject: [PATCH 07/12] Refactor network.js and add getNetworks functionality to it --- src/constants/networks.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/constants/networks.js b/src/constants/networks.js index 405e0dc29..ea3e699a6 100644 --- a/src/constants/networks.js +++ b/src/constants/networks.js @@ -1,24 +1,31 @@ -export const networksCode = { - mainnet: 0, - testnet: 1, - customNode: 2, -}; - -export const networksDetail = [ - { // network name translation t('Mainnet'); +export const networksDetail = { + mainnet: { // network name translation t('Mainnet'); name: 'Mainnet', ssl: true, port: 443, + code: 0, }, - { // network name translation t('Testnet'); + testnet: { // network name translation t('Testnet'); name: 'Testnet', testnet: true, ssl: true, port: 443, + code: 1, }, - { // network name translation t('Custom Node'); + customNode: { // network name translation t('Custom Node'); name: 'Custom Node', custom: true, address: 'http://localhost:4000', + code: 2, }, -]; +}; + +export const getNetwork = (code) => { + let network; + Object.keys(networksDetail).forEach((key) => { + if (networksDetail[key].code === code) { + network = networksDetail[key]; + } + }, this); + return network; +}; From 0091f638c6160b374e07d89ae6a399e4ecd10798 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Fri, 3 Nov 2017 17:16:53 +0100 Subject: [PATCH 08/12] Use the new version on network.js in login component --- src/components/login/login.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/login/login.js b/src/components/login/login.js index 9da281d65..75cd4f64b 100644 --- a/src/components/login/login.js +++ b/src/components/login/login.js @@ -4,11 +4,10 @@ import Input from 'react-toolbox/lib/input'; import Dropdown from 'react-toolbox/lib/dropdown'; import Button from 'react-toolbox/lib/button'; import i18next from 'i18next'; -import getNetworks from '../../constants/getNetworks'; import PassphraseInput from '../passphraseInput'; import styles from './login.css'; import env from '../../constants/env'; -import networks from '../../constants/networks'; +import { networksDetail, getNetwork } from '../../constants/networks'; import LanguageDropdown from '../languageDropdown'; import RelativeLink from '../relativeLink'; import { validateUrl, getLoginData } from '../../utils/login'; @@ -24,7 +23,7 @@ class Login extends React.Component { this.state = { passphrase: '', address: '', - network: networks.mainnet, + network: networksDetail.mainnet.code, }; this.validators = { @@ -43,8 +42,8 @@ class Login extends React.Component { } getNetworksList() { - this.networks = getNetworks().map((network, index) => ({ - label: i18next.t(network.name), + this.networks = Object.keys(networksDetail).map((network, index) => ({ + label: i18next.t(networksDetail[network].name), value: index, })); } @@ -64,8 +63,8 @@ class Login extends React.Component { } onLoginSubmission(passphrase) { - const network = Object.assign({}, getNetworks()[this.state.network]); - if (this.state.network === networks.customNode) { + const network = Object.assign({}, getNetwork(this.state.network)); + if (this.state.network === networksDetail.customNode.code) { network.address = this.state.address; } @@ -129,8 +128,8 @@ class Login extends React.Component { const { savedAccounts } = this.props; if (savedAccounts && savedAccounts.length > 0 && !this.props.account.afterLogout) { this.account = savedAccounts[0]; - const network = Object.assign({}, getNetworks()[this.account.network]); - if (this.account.network === networks.customNode) { + const network = Object.assign({}, networksDetail[this.account.network]); + if (this.account.network === networksDetail.customNode.code) { network.address = this.account.address; } @@ -161,7 +160,7 @@ class Login extends React.Component { className={`${styles.network} network`} /> { - this.state.network === networks.customNode && + this.state.network === networksDetail.customNode.code && From 6c949084d8b253361e6c6287daeaa0782d6c5f55 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Fri, 3 Nov 2017 17:17:19 +0100 Subject: [PATCH 09/12] Use the new version on network.js in register component --- src/components/register/register.js | 13 +++++++------ src/components/register/register.test.js | 21 ++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/register/register.js b/src/components/register/register.js index 9ef5f41e3..30cd3f006 100644 --- a/src/components/register/register.js +++ b/src/components/register/register.js @@ -1,7 +1,6 @@ import React from 'react'; import Passphrase from '../passphrase'; -import networks from '../../constants/networks'; -import getNetworks from '../../constants/getNetworks'; +import { networksDetail, getNetwork } from '../../constants/networks'; import { validateUrl, getLoginData } from '../../utils/login'; const Register = ({ @@ -12,12 +11,14 @@ const Register = ({ let index = networkIndex; - if (!index || (index === networks.customNode && validateUrl(address).addressValidity !== '')) { - index = networks.mainnet; + // if (!index || (index === networksCode.customNode && + // validateUrl(address).addressValidity !== '')) { + if (!index || (index === networksDetail.customNode.code && validateUrl(address).addressValidity !== '')) { + index = networksDetail.mainnet.code; } - const network = Object.assign({}, getNetworks()[index]); - if (index === networks.customNode) { network.address = address; } + const network = Object.assign({}, getNetwork(index)); + if (index === networksDetail.customNode.code) { network.address = address; } // set active peer activePeerSet({ diff --git a/src/components/register/register.test.js b/src/components/register/register.test.js index 39d80949c..8f2b8bafa 100644 --- a/src/components/register/register.test.js +++ b/src/components/register/register.test.js @@ -5,9 +5,8 @@ import { spy, stub } from 'sinon'; import PropTypes from 'prop-types'; import configureMockStore from 'redux-mock-store'; import i18n from '../../i18n'; -import networks from '../../constants/networks'; +import { networksDetail, getNetwork } from '../../constants/networks'; import Register from './register'; -import getNetworks from '../../constants/getNetworks'; import * as Utils from '../../utils/login'; @@ -60,11 +59,11 @@ describe('Register', () => { it('should call activePeerSet if props.onPassGenerated is called', () => { const props = wrapper.find('Passphrase').props(); - loginData.returns({ address: 'some address', networkIndex: networks.mainnet }); - + loginData.returns({ address: 'some address', networkIndex: networksDetail.mainnet.code }); props.onPassGenerated('sample passphrase'); + expect(prop.activePeerSet).to.have.been.calledWith({ - network: getNetworks()[networks.mainnet], + network: getNetwork(networksDetail.mainnet.code), passphrase: 'sample passphrase', }); }); @@ -72,13 +71,13 @@ describe('Register', () => { it('should call activePeerSet with testnet if network index is testnet', () => { const props = wrapper.find('Passphrase').props(); - loginData.returns({ address: 'invalid address', networkIndex: networks.testnet }); + loginData.returns({ address: 'invalid address', networkIndex: networksDetail.testnet.code }); props.onPassGenerated('sample passphrase'); expect(loginData).to.have.been.calledWith(); expect(prop.activePeerSet).to.have.been.calledWith({ - network: getNetworks()[networks.testnet], + network: getNetwork(networksDetail.testnet.code), passphrase: 'sample passphrase', }); }); @@ -86,13 +85,13 @@ describe('Register', () => { it('should call activePeerSet with mainnet if network index is custom node and address is invalid', () => { const props = wrapper.find('Passphrase').props(); - loginData.returns({ address: 'invalid address', networkIndex: networks.customNode }); + loginData.returns({ address: 'invalid address', networkIndex: networksDetail.customNode.code }); props.onPassGenerated('sample passphrase'); expect(loginData).to.have.been.calledWith(); expect(prop.activePeerSet).to.have.been.calledWith({ - network: getNetworks()[networks.mainnet], + network: getNetwork(networksDetail.mainnet.code), passphrase: 'sample passphrase', }); }); @@ -100,12 +99,12 @@ describe('Register', () => { it('should call activePeerSet with custom node if network index is custom node and address is valid', () => { const props = wrapper.find('Passphrase').props(); - loginData.returns({ address: '127.0.0.1:8080', networkIndex: networks.customNode }); + loginData.returns({ address: '127.0.0.1:8080', networkIndex: networksDetail.customNode.code }); props.onPassGenerated('sample passphrase'); expect(loginData).to.have.been.calledWith(); - const network = getNetworks()[networks.customNode]; + const network = getNetwork(networksDetail.customNode.code); network.address = '127.0.0.1:8080'; expect(prop.activePeerSet).to.have.been.calledWith({ network, From a2eb74a1f0aad1d507cd34a38d58ec06602e89d4 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Fri, 3 Nov 2017 17:17:49 +0100 Subject: [PATCH 10/12] Use the new version on network.js in saveAccount component --- src/components/saveAccount/saveAccount.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/saveAccount/saveAccount.js b/src/components/saveAccount/saveAccount.js index 9cb426f6c..1ddd279ed 100644 --- a/src/components/saveAccount/saveAccount.js +++ b/src/components/saveAccount/saveAccount.js @@ -1,7 +1,7 @@ import React from 'react'; import InfoParagraph from '../infoParagraph'; import ActionBar from '../actionBar'; -import getNetworks from '../../constants/getNetworks'; +import { networksDetail } from '../../constants/networks'; const SaveAccount = ({ network, @@ -13,8 +13,8 @@ const SaveAccount = ({ }) => { const save = () => { // eslint-disable-next-line arrow-body-style - const index = getNetworks().map((item, i) => { - return (item.name === network) ? i : null; + const index = Object.keys(networksDetail).map((item, i) => { + return (networksDetail[item].name === network) ? i : null; }).find(item => item !== null); accountSaved({ network: index, From 76fa4a710f5c4a510ba56bca06e0e79e533325b6 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Fri, 3 Nov 2017 18:14:28 +0100 Subject: [PATCH 11/12] Remove getNetworks function form networks.js and move it to getNetworks file --- src/constants/networks.js | 12 +----------- src/utils/getNetwork.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 src/utils/getNetwork.js diff --git a/src/constants/networks.js b/src/constants/networks.js index ea3e699a6..39cbf0e08 100644 --- a/src/constants/networks.js +++ b/src/constants/networks.js @@ -1,4 +1,4 @@ -export const networksDetail = { +export default { mainnet: { // network name translation t('Mainnet'); name: 'Mainnet', ssl: true, @@ -19,13 +19,3 @@ export const networksDetail = { code: 2, }, }; - -export const getNetwork = (code) => { - let network; - Object.keys(networksDetail).forEach((key) => { - if (networksDetail[key].code === code) { - network = networksDetail[key]; - } - }, this); - return network; -}; diff --git a/src/utils/getNetwork.js b/src/utils/getNetwork.js new file mode 100644 index 000000000..745a28945 --- /dev/null +++ b/src/utils/getNetwork.js @@ -0,0 +1,11 @@ +import networks from '../constants/networks'; + +export default (code) => { + let network; + Object.keys(networks).forEach((key) => { + if (networks[key].code === code) { + network = networks[key]; + } + }, this); + return network; +}; From 073d97856315ae115f49b324e7394d2ff9509213 Mon Sep 17 00:00:00 2001 From: yasharAyari Date: Fri, 3 Nov 2017 18:15:15 +0100 Subject: [PATCH 12/12] Fix some bugs in login an register component --- src/components/login/login.js | 19 ++++++++++--------- src/components/register/register.js | 9 +++++---- src/components/register/register.test.js | 18 +++++++++--------- src/components/saveAccount/saveAccount.js | 6 +++--- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/components/login/login.js b/src/components/login/login.js index 75cd4f64b..7cefc0f40 100644 --- a/src/components/login/login.js +++ b/src/components/login/login.js @@ -7,7 +7,8 @@ import i18next from 'i18next'; import PassphraseInput from '../passphraseInput'; import styles from './login.css'; import env from '../../constants/env'; -import { networksDetail, getNetwork } from '../../constants/networks'; +import networks from '../../constants/networks'; +import getNetwork from '../../utils/getNetwork'; import LanguageDropdown from '../languageDropdown'; import RelativeLink from '../relativeLink'; import { validateUrl, getLoginData } from '../../utils/login'; @@ -23,7 +24,7 @@ class Login extends React.Component { this.state = { passphrase: '', address: '', - network: networksDetail.mainnet.code, + network: networks.mainnet.code, }; this.validators = { @@ -42,8 +43,8 @@ class Login extends React.Component { } getNetworksList() { - this.networks = Object.keys(networksDetail).map((network, index) => ({ - label: i18next.t(networksDetail[network].name), + this.networks = Object.keys(networks).map((network, index) => ({ + label: i18next.t(networks[network].name), value: index, })); } @@ -64,7 +65,7 @@ class Login extends React.Component { onLoginSubmission(passphrase) { const network = Object.assign({}, getNetwork(this.state.network)); - if (this.state.network === networksDetail.customNode.code) { + if (this.state.network === networks.customNode.code) { network.address = this.state.address; } @@ -128,8 +129,8 @@ class Login extends React.Component { const { savedAccounts } = this.props; if (savedAccounts && savedAccounts.length > 0 && !this.props.account.afterLogout) { this.account = savedAccounts[0]; - const network = Object.assign({}, networksDetail[this.account.network]); - if (this.account.network === networksDetail.customNode.code) { + const network = Object.assign({}, getNetwork(this.state.network)); + if (this.account.network === networks.customNode.code) { network.address = this.account.address; } @@ -160,7 +161,7 @@ class Login extends React.Component { className={`${styles.network} network`} /> { - this.state.network === networksDetail.customNode.code && + this.state.network === networks.customNode.code && diff --git a/src/components/register/register.js b/src/components/register/register.js index 30cd3f006..7dec52cf6 100644 --- a/src/components/register/register.js +++ b/src/components/register/register.js @@ -1,6 +1,7 @@ import React from 'react'; import Passphrase from '../passphrase'; -import { networksDetail, getNetwork } from '../../constants/networks'; +import networks from '../../constants/networks'; +import getNetwork from '../../utils/getNetwork'; import { validateUrl, getLoginData } from '../../utils/login'; const Register = ({ @@ -13,12 +14,12 @@ const Register = ({ // if (!index || (index === networksCode.customNode && // validateUrl(address).addressValidity !== '')) { - if (!index || (index === networksDetail.customNode.code && validateUrl(address).addressValidity !== '')) { - index = networksDetail.mainnet.code; + if (!index || (index === networks.customNode.code && validateUrl(address).addressValidity !== '')) { + index = networks.mainnet.code; } const network = Object.assign({}, getNetwork(index)); - if (index === networksDetail.customNode.code) { network.address = address; } + if (index === networks.customNode.code) { network.address = address; } // set active peer activePeerSet({ diff --git a/src/components/register/register.test.js b/src/components/register/register.test.js index 8f2b8bafa..04b4cccc3 100644 --- a/src/components/register/register.test.js +++ b/src/components/register/register.test.js @@ -5,7 +5,7 @@ import { spy, stub } from 'sinon'; import PropTypes from 'prop-types'; import configureMockStore from 'redux-mock-store'; import i18n from '../../i18n'; -import { networksDetail, getNetwork } from '../../constants/networks'; +import networks from '../../constants/networks'; import Register from './register'; import * as Utils from '../../utils/login'; @@ -59,11 +59,11 @@ describe('Register', () => { it('should call activePeerSet if props.onPassGenerated is called', () => { const props = wrapper.find('Passphrase').props(); - loginData.returns({ address: 'some address', networkIndex: networksDetail.mainnet.code }); + loginData.returns({ address: 'some address', networkIndex: networks.mainnet.code }); props.onPassGenerated('sample passphrase'); expect(prop.activePeerSet).to.have.been.calledWith({ - network: getNetwork(networksDetail.mainnet.code), + network: networks.mainnet, passphrase: 'sample passphrase', }); }); @@ -71,13 +71,13 @@ describe('Register', () => { it('should call activePeerSet with testnet if network index is testnet', () => { const props = wrapper.find('Passphrase').props(); - loginData.returns({ address: 'invalid address', networkIndex: networksDetail.testnet.code }); + loginData.returns({ address: 'invalid address', networkIndex: networks.testnet.code }); props.onPassGenerated('sample passphrase'); expect(loginData).to.have.been.calledWith(); expect(prop.activePeerSet).to.have.been.calledWith({ - network: getNetwork(networksDetail.testnet.code), + network: networks.testnet, passphrase: 'sample passphrase', }); }); @@ -85,13 +85,13 @@ describe('Register', () => { it('should call activePeerSet with mainnet if network index is custom node and address is invalid', () => { const props = wrapper.find('Passphrase').props(); - loginData.returns({ address: 'invalid address', networkIndex: networksDetail.customNode.code }); + loginData.returns({ address: 'invalid address', networkIndex: networks.customNode.code }); props.onPassGenerated('sample passphrase'); expect(loginData).to.have.been.calledWith(); expect(prop.activePeerSet).to.have.been.calledWith({ - network: getNetwork(networksDetail.mainnet.code), + network: networks.mainnet, passphrase: 'sample passphrase', }); }); @@ -99,12 +99,12 @@ describe('Register', () => { it('should call activePeerSet with custom node if network index is custom node and address is valid', () => { const props = wrapper.find('Passphrase').props(); - loginData.returns({ address: '127.0.0.1:8080', networkIndex: networksDetail.customNode.code }); + loginData.returns({ address: '127.0.0.1:8080', networkIndex: networks.customNode.code }); props.onPassGenerated('sample passphrase'); expect(loginData).to.have.been.calledWith(); - const network = getNetwork(networksDetail.customNode.code); + const network = networks.customNode; network.address = '127.0.0.1:8080'; expect(prop.activePeerSet).to.have.been.calledWith({ network, diff --git a/src/components/saveAccount/saveAccount.js b/src/components/saveAccount/saveAccount.js index 1ddd279ed..da86a6540 100644 --- a/src/components/saveAccount/saveAccount.js +++ b/src/components/saveAccount/saveAccount.js @@ -1,7 +1,7 @@ import React from 'react'; import InfoParagraph from '../infoParagraph'; import ActionBar from '../actionBar'; -import { networksDetail } from '../../constants/networks'; +import networks from '../../constants/networks'; const SaveAccount = ({ network, @@ -13,8 +13,8 @@ const SaveAccount = ({ }) => { const save = () => { // eslint-disable-next-line arrow-body-style - const index = Object.keys(networksDetail).map((item, i) => { - return (networksDetail[item].name === network) ? i : null; + const index = Object.keys(networks).map((item, i) => { + return (networks[item].name === network) ? i : null; }).find(item => item !== null); accountSaved({ network: index,