From eacdb5d92071059f5b32acf924ae607e19db95eb Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Mon, 4 May 2020 11:27:14 -0700 Subject: [PATCH] Move send selectors to selectors dir (#8505) --- .../gas-modal-page-container.container.js | 2 +- .../gas-modal-page-container-container.test.js | 2 +- .../currency-input/currency-input.container.js | 2 +- .../account-list-item.container.js | 2 +- .../tests/account-list-item-container.test.js | 2 +- .../add-recipient/add-recipient.container.js | 2 +- .../add-recipient/ens-input.container.js | 2 +- .../tests/add-recipient-container.test.js | 2 +- .../amount-max-button.container.js | 2 +- .../tests/amount-max-button-container.test.js | 2 +- .../send-amount-row.container.js | 2 +- .../tests/send-amount-row-container.test.js | 2 +- .../send-content/send-content.container.js | 2 +- .../send-gas-row/send-gas-row.container.js | 18 +++++++++--------- .../tests/send-gas-row-container.test.js | 2 +- .../send-row-error-message.container.js | 2 +- .../send-row-error-message-container.test.js | 2 +- .../send/send-footer/send-footer.container.js | 12 ++++++------ .../tests/send-footer-container.test.js | 2 +- .../send/send-header/send-header.container.js | 2 +- .../tests/send-header-container.test.js | 2 +- ui/app/pages/send/send.container.js | 2 +- .../add-contact/add-contact.container.js | 2 +- .../send.selectors.js => selectors/send.js} | 4 ++-- .../tests/send-selectors-test-data.js | 0 .../tests/send.test.js} | 4 ++-- 26 files changed, 40 insertions(+), 40 deletions(-) rename ui/app/{pages/send/send.selectors.js => selectors/send.js} (99%) rename ui/app/{pages/send => selectors}/tests/send-selectors-test-data.js (100%) rename ui/app/{pages/send/tests/send-selectors.test.js => selectors/tests/send.test.js} (99%) diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js index ba423d9d1..024d71b28 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js @@ -46,7 +46,7 @@ import { import { getTokenBalance, getSendMaxModeState, -} from '../../../../pages/send/send.selectors' +} from '../../../../selectors/send' import { formatCurrency, } from '../../../../helpers/utils/confirm-tx.util' diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js b/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js index d0fde261c..6ae04f961 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js @@ -46,7 +46,7 @@ proxyquire('../gas-modal-page-container.container.js', { '../../../../ducks/gas/gas.duck': gasActionSpies, '../../../../ducks/confirm-transaction/confirm-transaction.duck': confirmTransactionActionSpies, '../../../../ducks/send/send.duck': sendActionSpies, - '../../../../pages/send/send.selectors': { + '../../../../selectors/send': { getTokenBalance: (state) => state.metamask.send.tokenBalance || '0x0', }, }) diff --git a/ui/app/components/ui/currency-input/currency-input.container.js b/ui/app/components/ui/currency-input/currency-input.container.js index 0808a07cd..6cb6a919c 100644 --- a/ui/app/components/ui/currency-input/currency-input.container.js +++ b/ui/app/components/ui/currency-input/currency-input.container.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux' import CurrencyInput from './currency-input.component' import { ETH } from '../../../helpers/constants/common' -import { getSendMaxModeState } from '../../../pages/send/send.selectors' +import { getSendMaxModeState } from '../../../selectors/send' import { getIsMainnet, preferencesSelector } from '../../../selectors' const mapStateToProps = (state) => { diff --git a/ui/app/pages/send/account-list-item/account-list-item.container.js b/ui/app/pages/send/account-list-item/account-list-item.container.js index ece1c67e9..e68c1e183 100644 --- a/ui/app/pages/send/account-list-item/account-list-item.container.js +++ b/ui/app/pages/send/account-list-item/account-list-item.container.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux' import { getNativeCurrency, -} from '../send.selectors.js' +} from '../../../selectors/send' import { getIsMainnet, isBalanceCached, diff --git a/ui/app/pages/send/account-list-item/tests/account-list-item-container.test.js b/ui/app/pages/send/account-list-item/tests/account-list-item-container.test.js index e1b12c8ec..4865fd1cf 100644 --- a/ui/app/pages/send/account-list-item/tests/account-list-item-container.test.js +++ b/ui/app/pages/send/account-list-item/tests/account-list-item-container.test.js @@ -10,7 +10,7 @@ proxyquire('../account-list-item.container.js', { return () => ({}) }, }, - '../send.selectors.js': { + '../../../selectors/send': { getConversionRate: () => `mockConversionRate`, getCurrentCurrency: () => `mockCurrentCurrency`, getNativeCurrency: () => `mockNativeCurrency`, diff --git a/ui/app/pages/send/send-content/add-recipient/add-recipient.container.js b/ui/app/pages/send/send-content/add-recipient/add-recipient.container.js index dc09cdc27..dda3c3daa 100644 --- a/ui/app/pages/send/send-content/add-recipient/add-recipient.container.js +++ b/ui/app/pages/send/send-content/add-recipient/add-recipient.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import { getSendEnsResolution, getSendEnsResolutionError, -} from '../../send.selectors.js' +} from '../../../../selectors/send' import { accountsWithSendEtherInfoSelector, getAddressBook, diff --git a/ui/app/pages/send/send-content/add-recipient/ens-input.container.js b/ui/app/pages/send/send-content/add-recipient/ens-input.container.js index 2486f1046..4882b3522 100644 --- a/ui/app/pages/send/send-content/add-recipient/ens-input.container.js +++ b/ui/app/pages/send/send-content/add-recipient/ens-input.container.js @@ -3,7 +3,7 @@ import { getCurrentNetwork, getSendTo, getSendToNickname, -} from '../../send.selectors' +} from '../../../../selectors/send' import { getAddressBookEntry, } from '../../../../selectors' diff --git a/ui/app/pages/send/send-content/add-recipient/tests/add-recipient-container.test.js b/ui/app/pages/send/send-content/add-recipient/tests/add-recipient-container.test.js index f6eb32e21..f94f34d95 100644 --- a/ui/app/pages/send/send-content/add-recipient/tests/add-recipient-container.test.js +++ b/ui/app/pages/send/send-content/add-recipient/tests/add-recipient-container.test.js @@ -17,7 +17,7 @@ proxyquire('../add-recipient.container.js', { return () => ({}) }, }, - '../../send.selectors.js': { + '../../../../selectors/send': { getSendEnsResolution: (s) => `mockSendEnsResolution:${s}`, getSendEnsResolutionError: (s) => `mockSendEnsResolutionError:${s}`, }, diff --git a/ui/app/pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.container.js b/ui/app/pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.container.js index 2fb7493ae..033c07f65 100644 --- a/ui/app/pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.container.js +++ b/ui/app/pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.container.js @@ -5,7 +5,7 @@ import { getSendFromBalance, getTokenBalance, getSendMaxModeState, -} from '../../../send.selectors.js' +} from '../../../../../selectors/send' import { getBasicGasEstimateLoadingStatus } from '../../../../../selectors' import { calcMaxAmount } from './amount-max-button.utils.js' import { diff --git a/ui/app/pages/send/send-content/send-amount-row/amount-max-button/tests/amount-max-button-container.test.js b/ui/app/pages/send/send-content/send-amount-row/amount-max-button/tests/amount-max-button-container.test.js index 0c85cf2db..9651eae3c 100644 --- a/ui/app/pages/send/send-content/send-amount-row/amount-max-button/tests/amount-max-button-container.test.js +++ b/ui/app/pages/send/send-content/send-amount-row/amount-max-button/tests/amount-max-button-container.test.js @@ -21,7 +21,7 @@ proxyquire('../amount-max-button.container.js', { return () => ({}) }, }, - '../../../send.selectors.js': { + '../../../../../selectors/send': { getGasTotal: (s) => `mockGasTotal:${s}`, getSelectedToken: (s) => `mockSelectedToken:${s}`, getSendFromBalance: (s) => `mockBalance:${s}`, diff --git a/ui/app/pages/send/send-content/send-amount-row/send-amount-row.container.js b/ui/app/pages/send/send-content/send-amount-row/send-amount-row.container.js index 5c7e3cd58..5bc281140 100644 --- a/ui/app/pages/send/send-content/send-amount-row/send-amount-row.container.js +++ b/ui/app/pages/send/send-content/send-amount-row/send-amount-row.container.js @@ -9,7 +9,7 @@ import { getTokenBalance, getSendMaxModeState, sendAmountIsInError, -} from '../../send.selectors' +} from '../../../../selectors/send' import { getAmountErrorObject, getGasFeeErrorObject } from '../../send.utils' import { setMaxModeTo, diff --git a/ui/app/pages/send/send-content/send-amount-row/tests/send-amount-row-container.test.js b/ui/app/pages/send/send-content/send-amount-row/tests/send-amount-row-container.test.js index e5b8e9cea..141e336c7 100644 --- a/ui/app/pages/send/send-content/send-amount-row/tests/send-amount-row-container.test.js +++ b/ui/app/pages/send/send-content/send-amount-row/tests/send-amount-row-container.test.js @@ -19,7 +19,7 @@ proxyquire('../send-amount-row.container.js', { return () => ({}) }, }, - '../../send.selectors': { sendAmountIsInError: (s) => `mockInError:${s}` }, + '../../../../selectors/send': { sendAmountIsInError: (s) => `mockInError:${s}` }, '../../send.utils': { getAmountErrorObject: (mockDataObject) => ({ ...mockDataObject, mockChange: true }), getGasFeeErrorObject: (mockDataObject) => ({ ...mockDataObject, mockGasFeeErrorChange: true }), diff --git a/ui/app/pages/send/send-content/send-content.container.js b/ui/app/pages/send/send-content/send-content.container.js index 7b1d67215..085b321cf 100644 --- a/ui/app/pages/send/send-content/send-content.container.js +++ b/ui/app/pages/send/send-content/send-content.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import SendContent from './send-content.component' import { getSendTo, -} from '../send.selectors' +} from '../../../selectors/send' import { accountsWithSendEtherInfoSelector, getAddressBookEntry, diff --git a/ui/app/pages/send/send-content/send-gas-row/send-gas-row.container.js b/ui/app/pages/send/send-content/send-gas-row/send-gas-row.container.js index 0c75f1d44..3f5476a19 100644 --- a/ui/app/pages/send/send-content/send-gas-row/send-gas-row.container.js +++ b/ui/app/pages/send/send-content/send-gas-row/send-gas-row.container.js @@ -11,7 +11,15 @@ import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown, -} from '../../send.selectors.js' +} from '../../../../selectors/send' +import { + getAdvancedInlineGasShown, + getCurrentEthBalance, + getSelectedToken, + getBasicGasEstimateLoadingStatus, + getRenderableEstimateDataForSmallButtonsFromGWEI, + getDefaultActiveButtonIndex, +} from '../../../../selectors' import { isBalanceSufficient, calcGasTotal, @@ -27,14 +35,6 @@ import { setCustomGasLimit, } from '../../../../ducks/gas/gas.duck' import { showModal, setGasPrice, setGasLimit, setGasTotal, updateSendAmount } from '../../../../store/actions' -import { - getAdvancedInlineGasShown, - getCurrentEthBalance, - getSelectedToken, - getBasicGasEstimateLoadingStatus, - getRenderableEstimateDataForSmallButtonsFromGWEI, - getDefaultActiveButtonIndex, -} from '../../../../selectors' import SendGasRow from './send-gas-row.component' diff --git a/ui/app/pages/send/send-content/send-gas-row/tests/send-gas-row-container.test.js b/ui/app/pages/send/send-content/send-gas-row/tests/send-gas-row-container.test.js index eef357497..18de84c1d 100644 --- a/ui/app/pages/send/send-content/send-gas-row/tests/send-gas-row-container.test.js +++ b/ui/app/pages/send/send-content/send-gas-row/tests/send-gas-row-container.test.js @@ -30,7 +30,7 @@ proxyquire('../send-gas-row.container.js', { return () => ({}) }, }, - '../../send.selectors.js': { + '../../../../selectors/send': { getSendMaxModeState: (s) => `mockMaxModeOn:${s}`, }, '../../send.utils.js': { diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.container.js b/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.container.js index 59622047f..950f4d71d 100644 --- a/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.container.js +++ b/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.container.js @@ -1,5 +1,5 @@ import { connect } from 'react-redux' -import { getSendErrors } from '../../../send.selectors' +import { getSendErrors } from '../../../../../selectors/send' import SendRowErrorMessage from './send-row-error-message.component' export default connect(mapStateToProps)(SendRowErrorMessage) diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/tests/send-row-error-message-container.test.js b/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/tests/send-row-error-message-container.test.js index 370600f50..61aad7ab5 100644 --- a/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/tests/send-row-error-message-container.test.js +++ b/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/tests/send-row-error-message-container.test.js @@ -10,7 +10,7 @@ proxyquire('../send-row-error-message.container.js', { return () => ({}) }, }, - '../../../send.selectors': { getSendErrors: (s) => `mockErrors:${s}` }, + '../../../../../selectors/send': { getSendErrors: (s) => `mockErrors:${s}` }, }) describe('send-row-error-message container', function () { diff --git a/ui/app/pages/send/send-footer/send-footer.container.js b/ui/app/pages/send/send-footer/send-footer.container.js index 88ff063ef..77170ea35 100644 --- a/ui/app/pages/send/send-footer/send-footer.container.js +++ b/ui/app/pages/send/send-footer/send-footer.container.js @@ -23,17 +23,17 @@ import { getUnapprovedTxs, getSendErrors, isSendFormInError, -} from '../send.selectors' -import { - addressIsNew, - constructTxParams, - constructUpdatedTx, -} from './send-footer.utils' +} from '../../../selectors/send' import { getGasIsLoading, getRenderableEstimateDataForSmallButtonsFromGWEI, getDefaultActiveButtonIndex, } from '../../../selectors' +import { + addressIsNew, + constructTxParams, + constructUpdatedTx, +} from './send-footer.utils' export default connect(mapStateToProps, mapDispatchToProps)(SendFooter) diff --git a/ui/app/pages/send/send-footer/tests/send-footer-container.test.js b/ui/app/pages/send/send-footer/tests/send-footer-container.test.js index 3c8a38b76..c0c962016 100644 --- a/ui/app/pages/send/send-footer/tests/send-footer-container.test.js +++ b/ui/app/pages/send/send-footer/tests/send-footer-container.test.js @@ -27,7 +27,7 @@ proxyquire('../send-footer.container.js', { }, }, '../../../store/actions': actionSpies, - '../send.selectors': { + '../../../selectors/send': { getGasLimit: (s) => `mockGasLimit:${s}`, getGasPrice: (s) => `mockGasPrice:${s}`, getGasTotal: (s) => `mockGasTotal:${s}`, diff --git a/ui/app/pages/send/send-header/send-header.container.js b/ui/app/pages/send/send-header/send-header.container.js index 26d79da22..037b934e6 100644 --- a/ui/app/pages/send/send-header/send-header.container.js +++ b/ui/app/pages/send/send-header/send-header.container.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux' import { clearSend } from '../../../store/actions' import SendHeader from './send-header.component' -import { getTitleKey } from '../send.selectors' +import { getTitleKey } from '../../../selectors/send' export default connect(mapStateToProps, mapDispatchToProps)(SendHeader) diff --git a/ui/app/pages/send/send-header/tests/send-header-container.test.js b/ui/app/pages/send/send-header/tests/send-header-container.test.js index 504bc9ea1..11fa4e0ba 100644 --- a/ui/app/pages/send/send-header/tests/send-header-container.test.js +++ b/ui/app/pages/send/send-header/tests/send-header-container.test.js @@ -18,7 +18,7 @@ proxyquire('../send-header.container.js', { }, }, '../../../store/actions': actionSpies, - '../send.selectors': { + '../../../selectors/send': { getTitleKey: (s) => `mockTitleKey:${s}`, }, }) diff --git a/ui/app/pages/send/send.container.js b/ui/app/pages/send/send.container.js index f434c8aee..22fa3ae66 100644 --- a/ui/app/pages/send/send.container.js +++ b/ui/app/pages/send/send.container.js @@ -23,7 +23,7 @@ import { getTokenBalance, getQrCodeData, getTokens, -} from './send.selectors' +} from '../../selectors/send' import { getSelectedAddress, getAddressBook, diff --git a/ui/app/pages/settings/contact-list-tab/add-contact/add-contact.container.js b/ui/app/pages/settings/contact-list-tab/add-contact/add-contact.container.js index 2c9731704..b1a63a508 100644 --- a/ui/app/pages/settings/contact-list-tab/add-contact/add-contact.container.js +++ b/ui/app/pages/settings/contact-list-tab/add-contact/add-contact.container.js @@ -5,7 +5,7 @@ import { withRouter } from 'react-router-dom' import { addToAddressBook, showQrScanner, qrCodeDetected } from '../../../../store/actions' import { getQrCodeData, -} from '../../../send/send.selectors' +} from '../../../../selectors/send' const mapStateToProps = (state) => { return { diff --git a/ui/app/pages/send/send.selectors.js b/ui/app/selectors/send.js similarity index 99% rename from ui/app/pages/send/send.selectors.js rename to ui/app/selectors/send.js index 97780021b..6d2b2efee 100644 --- a/ui/app/pages/send/send.selectors.js +++ b/ui/app/selectors/send.js @@ -6,8 +6,8 @@ import { getTargetAccount, getSelectedAddress, getAveragePriceEstimateInHexWEI, -} from '../../selectors' -import { estimateGasPriceFromRecentBlocks, calcGasTotal } from './send.utils' +} from '.' +import { estimateGasPriceFromRecentBlocks, calcGasTotal } from '../pages/send/send.utils' export function getBlockGasLimit (state) { return state.metamask.currentBlockGasLimit diff --git a/ui/app/pages/send/tests/send-selectors-test-data.js b/ui/app/selectors/tests/send-selectors-test-data.js similarity index 100% rename from ui/app/pages/send/tests/send-selectors-test-data.js rename to ui/app/selectors/tests/send-selectors-test-data.js diff --git a/ui/app/pages/send/tests/send-selectors.test.js b/ui/app/selectors/tests/send.test.js similarity index 99% rename from ui/app/pages/send/tests/send-selectors.test.js rename to ui/app/selectors/tests/send.test.js index af069b2c5..4fda2a2eb 100644 --- a/ui/app/pages/send/tests/send-selectors.test.js +++ b/ui/app/selectors/tests/send.test.js @@ -3,7 +3,7 @@ import sinon from 'sinon' import { accountsWithSendEtherInfoSelector, getCurrentAccountWithSendEtherInfo, -} from '../../../selectors' +} from '..' import { getBlockGasLimit, getConversionRate, @@ -37,7 +37,7 @@ import { getTokens, getTitleKey, isSendFormInError, -} from '../send.selectors.js' +} from '../send' import mockState from './send-selectors-test-data' describe('send selectors', function () {