From ad496bda715ee1cc621163e1fa988fbcf41c9024 Mon Sep 17 00:00:00 2001 From: Sneh Date: Tue, 22 Jan 2019 12:10:54 -0500 Subject: [PATCH 1/3] the repeated getSelectedAddress() func from the send.selectors.js is removed --- ui/app/components/app/send/send.container.js | 5 ++++- ui/app/components/app/send/send.selectors.js | 8 +------- .../components/app/send/tests/send-container.test.js | 5 ++++- .../components/app/send/tests/send-selectors.test.js | 10 ---------- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/ui/app/components/app/send/send.container.js b/ui/app/components/app/send/send.container.js index e65463b9321f..303639c760a5 100644 --- a/ui/app/components/app/send/send.container.js +++ b/ui/app/components/app/send/send.container.js @@ -2,6 +2,10 @@ import { connect } from 'react-redux' import SendEther from './send.component' import { withRouter } from 'react-router-dom' import { compose } from 'recompose' +const { + getSelectedAddress, +} = require('../../../selectors/selectors') + import { getAmountConversionRate, getBlockGasLimit, @@ -12,7 +16,6 @@ import { getGasTotal, getPrimaryCurrency, getRecentBlocks, - getSelectedAddress, getSelectedToken, getSelectedTokenContract, getSelectedTokenToFiatRate, diff --git a/ui/app/components/app/send/send.selectors.js b/ui/app/components/app/send/send.selectors.js index 2ec677ad1b73..22ff614379bc 100644 --- a/ui/app/components/app/send/send.selectors.js +++ b/ui/app/components/app/send/send.selectors.js @@ -5,6 +5,7 @@ const { } = require('../../../helpers/utils/conversion-util') const { getMetaMaskAccounts, + getSelectedAddress } = require('../../../selectors/selectors') const { estimateGasPriceFromRecentBlocks, @@ -33,7 +34,6 @@ const selectors = { getPrimaryCurrency, getRecentBlocks, getSelectedAccount, - getSelectedAddress, getSelectedIdentity, getSelectedToken, getSelectedTokenContract, @@ -149,12 +149,6 @@ function getSelectedAccount (state) { return accounts[selectedAddress] } -function getSelectedAddress (state) { - const selectedAddress = state.metamask.selectedAddress || Object.keys(getMetaMaskAccounts(state))[0] - - return selectedAddress -} - function getSelectedIdentity (state) { const selectedAddress = getSelectedAddress(state) const identities = state.metamask.identities diff --git a/ui/app/components/app/send/tests/send-container.test.js b/ui/app/components/app/send/tests/send-container.test.js index 9538b67b38e5..2cb6da4a6dbd 100644 --- a/ui/app/components/app/send/tests/send-container.test.js +++ b/ui/app/components/app/send/tests/send-container.test.js @@ -35,7 +35,6 @@ proxyquire('../send.container.js', { getGasTotal: (s) => `mockGasTotal:${s}`, getPrimaryCurrency: (s) => `mockPrimaryCurrency:${s}`, getRecentBlocks: (s) => `mockRecentBlocks:${s}`, - getSelectedAddress: (s) => `mockSelectedAddress:${s}`, getSelectedToken: (s) => `mockSelectedToken:${s}`, getSelectedTokenContract: (s) => `mockTokenContract:${s}`, getSelectedTokenToFiatRate: (s) => `mockTokenToFiatRate:${s}`, @@ -47,11 +46,15 @@ proxyquire('../send.container.js', { getTokenBalance: (s) => `mockTokenBalance:${s}`, getQrCodeData: (s) => `mockQrCodeData:${s}`, }, + '../../../selectors/selectors': { + getSelectedAddress: (s) => `mockSelectedAddress:${s}`, + }, '../../../store/actions': actionSpies, '../../../ducks/send/send.duck': duckActionSpies, './send.utils.js': { calcGasTotal: (gasLimit, gasPrice) => gasLimit + gasPrice, }, + }) describe('send container', () => { diff --git a/ui/app/components/app/send/tests/send-selectors.test.js b/ui/app/components/app/send/tests/send-selectors.test.js index cdc86fe59b49..50bd08491e22 100644 --- a/ui/app/components/app/send/tests/send-selectors.test.js +++ b/ui/app/components/app/send/tests/send-selectors.test.js @@ -20,7 +20,6 @@ const { getPrimaryCurrency, getRecentBlocks, getSelectedAccount, - getSelectedAddress, getSelectedIdentity, getSelectedToken, getSelectedTokenContract, @@ -274,15 +273,6 @@ describe('send selectors', () => { }) }) - describe('getSelectedAddress()', () => { - it('should', () => { - assert.equal( - getSelectedAddress(mockState), - '0xd85a4b6a394794842887b8284293d69163007bbb' - ) - }) - }) - describe('getSelectedIdentity()', () => { it('should return the identity object of the currently selected address', () => { assert.deepEqual( From c8ef7d3dfc449776092e4d37b8e0c49743f972cc Mon Sep 17 00:00:00 2001 From: Sneh Date: Wed, 23 Jan 2019 12:53:09 -0500 Subject: [PATCH 2/3] lint added --- ui/app/components/app/send/tests/send-selectors.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/app/components/app/send/tests/send-selectors.test.js b/ui/app/components/app/send/tests/send-selectors.test.js index 50bd08491e22..ccc1267959d3 100644 --- a/ui/app/components/app/send/tests/send-selectors.test.js +++ b/ui/app/components/app/send/tests/send-selectors.test.js @@ -273,6 +273,7 @@ describe('send selectors', () => { }) }) + describe('getSelectedIdentity()', () => { it('should return the identity object of the currently selected address', () => { assert.deepEqual( From 80724481ff201bc2374b292f509c6a915b8fb656 Mon Sep 17 00:00:00 2001 From: Sneh Koul Date: Mon, 8 Apr 2019 13:11:09 -0700 Subject: [PATCH 3/3] changes according to the comments --- ui/app/components/app/send/send.selectors.js | 2 +- ui/app/components/app/send/tests/send-container.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/app/components/app/send/send.selectors.js b/ui/app/components/app/send/send.selectors.js index 22ff614379bc..89f047d50191 100644 --- a/ui/app/components/app/send/send.selectors.js +++ b/ui/app/components/app/send/send.selectors.js @@ -5,7 +5,7 @@ const { } = require('../../../helpers/utils/conversion-util') const { getMetaMaskAccounts, - getSelectedAddress + getSelectedAddress, } = require('../../../selectors/selectors') const { estimateGasPriceFromRecentBlocks, diff --git a/ui/app/components/app/send/tests/send-container.test.js b/ui/app/components/app/send/tests/send-container.test.js index 2cb6da4a6dbd..9d7365ac9f19 100644 --- a/ui/app/components/app/send/tests/send-container.test.js +++ b/ui/app/components/app/send/tests/send-container.test.js @@ -54,7 +54,7 @@ proxyquire('../send.container.js', { './send.utils.js': { calcGasTotal: (gasLimit, gasPrice) => gasLimit + gasPrice, }, - + }) describe('send container', () => {