diff --git a/test/unit/ui/app/selectors.spec.js b/test/unit/ui/app/selectors.spec.js index fff3f89d4..bff37828d 100644 --- a/test/unit/ui/app/selectors.spec.js +++ b/test/unit/ui/app/selectors.spec.js @@ -1,10 +1,6 @@ import assert from 'assert' import * as selectors from '../../../../ui/app/selectors' import mockState from '../../../data/mock-state.json' -import Eth from 'ethjs' -import { createTestProviderTools } from '../../../stub/provider' - -const provider = createTestProviderTools({ scaffold: {} }).provider describe('Selectors', function () { @@ -21,9 +17,13 @@ describe('Selectors', function () { }) it('returns selected identity', function () { - const identity = selectors.getSelectedIdentity(mockState) - assert.equal(identity.address, '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc') - assert.equal(identity.name, 'Test Account') + assert.deepEqual( + selectors.getSelectedIdentity(mockState), + { + address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', + name: 'Test Account', + } + ) }) it('returns selected account', function () { @@ -76,22 +76,11 @@ describe('Selectors', function () { assert.equal(gasIsLoading, false) }) - it('#getSendAmount', function () { - const sendAmount = selectors.getSendAmount(mockState) - assert.equal(sendAmount, '1bc16d674ec80000') - }) - it('#getCurrentCurrency', function () { const currentCurrency = selectors.getCurrentCurrency(mockState) assert.equal(currentCurrency, 'usd') }) - it('#getSelectedTokenContract', function () { - global.eth = new Eth(provider) - const selectedTokenContract = selectors.getSelectedTokenContract(mockState) - assert(selectedTokenContract.abi) - }) - it('#getTotalUnapprovedCount', function () { const totalUnapprovedCount = selectors.getTotalUnapprovedCount(mockState) assert.equal(totalUnapprovedCount, 1) diff --git a/ui/app/components/app/dropdowns/account-details-dropdown/account-details-dropdown.container.js b/ui/app/components/app/dropdowns/account-details-dropdown/account-details-dropdown.container.js index 8dae23742..8a76ce1e3 100644 --- a/ui/app/components/app/dropdowns/account-details-dropdown/account-details-dropdown.container.js +++ b/ui/app/components/app/dropdowns/account-details-dropdown/account-details-dropdown.container.js @@ -3,8 +3,11 @@ import { withRouter } from 'react-router-dom' import { connect } from 'react-redux' import AccountDetailsDropdown from './account-details-dropdown.component' import * as actions from '../../../../store/actions' -import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors' -import genAccountLink from '../../../../../lib/account-link.js' +import { + getSelectedIdentity, + getRpcPrefsForCurrentProvider, +} from '../../../../selectors' +import genAccountLink from '../../../../../lib/account-link' function mapStateToProps (state) { return { 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 024d71b28..f33b3eee5 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 @@ -42,11 +42,10 @@ import { getBasicGasEstimateBlockTime, getTxParams, isCustomPriceSafe, -} from '../../../../selectors' -import { getTokenBalance, getSendMaxModeState, -} from '../../../../selectors/send' +} from '../../../../selectors' + 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 6ae04f961..c6d9350bc 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 @@ -35,20 +35,18 @@ proxyquire('../gas-modal-page-container.container.js', { return () => ({}) }, }, - '../../../../selectors/': { + '../../../../selectors': { getBasicGasEstimateLoadingStatus: (s) => `mockBasicGasEstimateLoadingStatus:${Object.keys(s).length}`, getRenderableBasicEstimateData: (s) => `mockRenderableBasicEstimateData:${Object.keys(s).length}`, getDefaultActiveButtonIndex: (a, b) => a + b, getCurrentEthBalance: (state) => state.metamask.balance || '0x0', getSelectedToken: () => null, + getTokenBalance: (state) => state.metamask.send.tokenBalance || '0x0', }, '../../../../store/actions': actionSpies, '../../../../ducks/gas/gas.duck': gasActionSpies, '../../../../ducks/confirm-transaction/confirm-transaction.duck': confirmTransactionActionSpies, '../../../../ducks/send/send.duck': sendActionSpies, - '../../../../selectors/send': { - getTokenBalance: (state) => state.metamask.send.tokenBalance || '0x0', - }, }) describe('gas-modal-page-container container', function () { diff --git a/ui/app/components/app/modals/account-details-modal/account-details-modal.container.js b/ui/app/components/app/modals/account-details-modal/account-details-modal.container.js index cef5ad294..807fad84e 100644 --- a/ui/app/components/app/modals/account-details-modal/account-details-modal.container.js +++ b/ui/app/components/app/modals/account-details-modal/account-details-modal.container.js @@ -1,6 +1,9 @@ import { connect } from 'react-redux' import { showModal, setAccountLabel } from '../../../../store/actions' -import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors' +import { + getSelectedIdentity, + getRpcPrefsForCurrentProvider, +} from '../../../../selectors' import AccountDetailsModal from './account-details-modal.component' const mapStateToProps = (state) => { 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 6cb6a919c..1db999a70 100644 --- a/ui/app/components/ui/currency-input/currency-input.container.js +++ b/ui/app/components/ui/currency-input/currency-input.container.js @@ -1,8 +1,11 @@ import { connect } from 'react-redux' import CurrencyInput from './currency-input.component' import { ETH } from '../../../helpers/constants/common' -import { getSendMaxModeState } from '../../../selectors/send' -import { getIsMainnet, preferencesSelector } from '../../../selectors' +import { + getSendMaxModeState, + getIsMainnet, + preferencesSelector, +} from '../../../selectors' const mapStateToProps = (state) => { const { metamask: { nativeCurrency, currentCurrency, conversionRate } } = state diff --git a/ui/app/ducks/alerts/unconnected-account.js b/ui/app/ducks/alerts/unconnected-account.js index 6d09baf8a..ee61244a6 100644 --- a/ui/app/ducks/alerts/unconnected-account.js +++ b/ui/app/ducks/alerts/unconnected-account.js @@ -3,7 +3,10 @@ import { captureException } from '@sentry/browser' import actionConstants from '../../store/actionConstants' import { addPermittedAccount } from '../../store/actions' -import { getOriginOfCurrentTab, getSelectedAddress } from '../../selectors' +import { + getOriginOfCurrentTab, + getSelectedAddress, +} from '../../selectors' // Constants diff --git a/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js b/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js index e49fe6c4f..caacf7b12 100644 --- a/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js +++ b/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js @@ -9,7 +9,6 @@ import { getAccountType, getNumberOfAccounts, getNumberOfTokens, - txDataSelector, } from '../../../selectors' diff --git a/ui/app/pages/permissions-connect/permissions-connect.container.js b/ui/app/pages/permissions-connect/permissions-connect.container.js index b387849e3..4ac227868 100644 --- a/ui/app/pages/permissions-connect/permissions-connect.container.js +++ b/ui/app/pages/permissions-connect/permissions-connect.container.js @@ -7,7 +7,6 @@ import { getAccountsWithLabels, getLastConnectedInfo, getTargetDomainMetadata, - getPermissionDomains, } from '../../selectors' 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 e68c1e183..e528cd239 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,8 +1,6 @@ import { connect } from 'react-redux' import { getNativeCurrency, -} from '../../../selectors/send' -import { getIsMainnet, isBalanceCached, preferencesSelector, 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 4865fd1cf..dbb7de7a5 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,12 +10,10 @@ proxyquire('../account-list-item.container.js', { return () => ({}) }, }, - '../../../selectors/send': { + '../../../selectors': { getConversionRate: () => `mockConversionRate`, getCurrentCurrency: () => `mockCurrentCurrency`, getNativeCurrency: () => `mockNativeCurrency`, - }, - '../../../selectors/': { isBalanceCached: () => `mockBalanceIsCached`, preferencesSelector: ({ showFiatInTestnets }) => ({ showFiatInTestnets, 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 dda3c3daa..8ee7716cf 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,12 +2,11 @@ import { connect } from 'react-redux' import { getSendEnsResolution, getSendEnsResolutionError, -} from '../../../../selectors/send' -import { accountsWithSendEtherInfoSelector, getAddressBook, getAddressBookEntry, } from '../../../../selectors' + import { updateSendTo, } from '../../../../store/actions' 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 4882b3522..8fc563d97 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 @@ -1,14 +1,11 @@ +import { connect } from 'react-redux' import EnsInput from './ens-input.component' import { getCurrentNetwork, getSendTo, getSendToNickname, -} from '../../../../selectors/send' -import { getAddressBookEntry, } from '../../../../selectors' -import { connect } from 'react-redux' - export default connect( (state) => { 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 f94f34d95..8b13618f7 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,11 +17,9 @@ proxyquire('../add-recipient.container.js', { return () => ({}) }, }, - '../../../../selectors/send': { + '../../../../selectors': { getSendEnsResolution: (s) => `mockSendEnsResolution:${s}`, getSendEnsResolutionError: (s) => `mockSendEnsResolutionError:${s}`, - }, - '../../../../selectors/': { getAddressBook: (s) => [{ name: `mockAddressBook:${s}` }], getAddressBookEntry: (s) => `mockAddressBookEntry:${s}`, accountsWithSendEtherInfoSelector: (s) => `mockAccountsWithSendEtherInfoSelector:${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 033c07f65..41f5ac4e8 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,8 +5,8 @@ import { getSendFromBalance, getTokenBalance, getSendMaxModeState, -} from '../../../../../selectors/send' -import { getBasicGasEstimateLoadingStatus } from '../../../../../selectors' + getBasicGasEstimateLoadingStatus, +} from '../../../../../selectors' import { calcMaxAmount } from './amount-max-button.utils.js' import { updateSendAmount, 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 9651eae3c..72189d45c 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,15 +21,15 @@ proxyquire('../amount-max-button.container.js', { return () => ({}) }, }, - '../../../../../selectors/send': { + '../../../../../selectors': { getGasTotal: (s) => `mockGasTotal:${s}`, getSelectedToken: (s) => `mockSelectedToken:${s}`, getSendFromBalance: (s) => `mockBalance:${s}`, getTokenBalance: (s) => `mockTokenBalance:${s}`, getSendMaxModeState: (s) => `mockMaxModeOn:${s}`, + getBasicGasEstimateLoadingStatus: (s) => `mockButtonDataLoading:${s}`, }, './amount-max-button.utils.js': { calcMaxAmount: (mockObj) => mockObj.val + 1 }, - '../../../../../selectors/': { getBasicGasEstimateLoadingStatus: (s) => `mockButtonDataLoading:${s}` }, '../../../../../store/actions': actionSpies, '../../../../../ducks/send/send.duck': duckActionSpies, }) 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 5bc281140..706369edb 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 '../../../../selectors/send' +} from '../../../../selectors' 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 141e336c7..c031e0e41 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 () => ({}) }, }, - '../../../../selectors/send': { sendAmountIsInError: (s) => `mockInError:${s}` }, + '../../../../selectors': { 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 085b321cf..8ee785736 100644 --- a/ui/app/pages/send/send-content/send-content.container.js +++ b/ui/app/pages/send/send-content/send-content.container.js @@ -2,11 +2,10 @@ import { connect } from 'react-redux' import SendContent from './send-content.component' import { getSendTo, -} from '../../../selectors/send' -import { accountsWithSendEtherInfoSelector, getAddressBookEntry, } from '../../../selectors' + import * as actions from '../../../store/actions' function mapStateToProps (state) { 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 3f5476a19..fd8c5f434 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,8 +11,6 @@ import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown, -} from '../../../../selectors/send' -import { getAdvancedInlineGasShown, getCurrentEthBalance, getSelectedToken, 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 18de84c1d..2ebe617ce 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 () => ({}) }, }, - '../../../../selectors/send': { + '../../../../selectors': { 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 950f4d71d..c2cc53f59 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 '../../../../../selectors/send' +import { getSendErrors } from '../../../../../selectors' 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 61aad7ab5..8c57cf268 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 () => ({}) }, }, - '../../../../../selectors/send': { getSendErrors: (s) => `mockErrors:${s}` }, + '../../../../../selectors': { 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 77170ea35..67dadd477 100644 --- a/ui/app/pages/send/send-footer/send-footer.container.js +++ b/ui/app/pages/send/send-footer/send-footer.container.js @@ -7,7 +7,6 @@ import { signTx, updateTransaction, } from '../../../store/actions' -import SendFooter from './send-footer.component' import { getGasLimit, getGasPrice, @@ -23,12 +22,11 @@ import { getUnapprovedTxs, getSendErrors, isSendFormInError, -} from '../../../selectors/send' -import { getGasIsLoading, getRenderableEstimateDataForSmallButtonsFromGWEI, getDefaultActiveButtonIndex, } from '../../../selectors' +import SendFooter from './send-footer.component' import { addressIsNew, constructTxParams, 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 c0c962016..b23ed94dd 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, - '../../../selectors/send': { + '../../../selectors': { getGasLimit: (s) => `mockGasLimit:${s}`, getGasPrice: (s) => `mockGasPrice:${s}`, getGasTotal: (s) => `mockGasTotal:${s}`, @@ -43,12 +43,10 @@ proxyquire('../send-footer.container.js', { getUnapprovedTxs: (s) => `mockUnapprovedTxs:${s}`, getSendErrors: (s) => `mockSendErrors:${s}`, isSendFormInError: (s) => `mockInError:${s}`, - }, - './send-footer.utils': utilsStubs, - '../../../selectors/': { getRenderableEstimateDataForSmallButtonsFromGWEI: (s) => ([{ gasEstimateType: `mockGasEstimateType:${s}` }]), getDefaultActiveButtonIndex: () => 0, }, + './send-footer.utils': utilsStubs, }) describe('send-footer container', function () { 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 037b934e6..587bb51f2 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 '../../../selectors/send' +import { getTitleKey } from '../../../selectors' 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 11fa4e0ba..790ceb88a 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, - '../../../selectors/send': { + '../../../selectors': { getTitleKey: (s) => `mockTitleKey:${s}`, }, }) diff --git a/ui/app/pages/send/send.container.js b/ui/app/pages/send/send.container.js index 22fa3ae66..81eb8e0a8 100644 --- a/ui/app/pages/send/send.container.js +++ b/ui/app/pages/send/send.container.js @@ -23,11 +23,10 @@ import { getTokenBalance, getQrCodeData, getTokens, -} from '../../selectors/send' -import { getSelectedAddress, getAddressBook, } from '../../selectors' + import { updateSendTo, updateSendTokenBalance, 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 b1a63a508..4f9849cbc 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 '../../../../selectors/send' +} from '../../../../selectors' const mapStateToProps = (state) => { return { diff --git a/ui/app/selectors/confirm-transaction.js b/ui/app/selectors/confirm-transaction.js index de29db568..27e5d94f0 100644 --- a/ui/app/selectors/confirm-transaction.js +++ b/ui/app/selectors/confirm-transaction.js @@ -12,6 +12,7 @@ import { import { sumHexes, } from '../helpers/utils/transactions.util' +import { getNativeCurrency } from '.' const unapprovedTxsSelector = (state) => state.metamask.unapprovedTxs const unapprovedMsgsSelector = (state) => state.metamask.unapprovedMsgs @@ -123,7 +124,6 @@ export const unconfirmedTransactionsCountSelector = createSelector( export const currentCurrencySelector = (state) => state.metamask.currentCurrency export const conversionRateSelector = (state) => state.metamask.conversionRate -export const getNativeCurrency = (state) => state.metamask.nativeCurrency export const txDataSelector = (state) => state.confirmTransaction.txData const tokenDataSelector = (state) => state.confirmTransaction.tokenData diff --git a/ui/app/selectors/index.js b/ui/app/selectors/index.js index 33648b731..c585536aa 100644 --- a/ui/app/selectors/index.js +++ b/ui/app/selectors/index.js @@ -3,5 +3,6 @@ export * from './custom-gas' export * from './first-time-flow' export * from './permissions' export * from './selectors' +export * from './send' export * from './tokens' export * from './transactions' diff --git a/ui/app/selectors/selectors.js b/ui/app/selectors/selectors.js index 946bb5aad..4e7c48a68 100644 --- a/ui/app/selectors/selectors.js +++ b/ui/app/selectors/selectors.js @@ -1,14 +1,15 @@ import { NETWORK_TYPES } from '../helpers/constants/common' import { stripHexPrefix, addHexPrefix } from 'ethereumjs-util' import { createSelector } from 'reselect' - -import abi from 'human-standard-token-abi' import { shortenAddress, checksumAddress, getOriginFromUrl, getAccountByAddress, } from '../helpers/utils/util' +import { + getSelectedToken, +} from '.' export function getNetworkIdentifier (state) { const { metamask: { provider: { type, nickname, rpcTarget } } } = state @@ -156,15 +157,6 @@ export function getTargetAccount (state, targetAddress) { return accounts[targetAddress] } -export function getSelectedToken (state) { - const tokens = state.metamask.tokens || [] - const selectedTokenAddress = state.metamask.selectedTokenAddress - const selectedToken = tokens.filter(({ address }) => address === selectedTokenAddress)[0] - const sendToken = state.metamask.send && state.metamask.send.token - - return selectedToken || sendToken || null -} - export function getSelectedTokenExchangeRate (state) { const contractExchangeRates = state.metamask.contractExchangeRates const selectedToken = getSelectedToken(state) || {} @@ -243,21 +235,10 @@ export function getGasIsLoading (state) { return state.appState.gasIsLoading } -export function getSendAmount (state) { - return state.metamask.send.amount -} - export function getCurrentCurrency (state) { return state.metamask.currentCurrency } -export function getSelectedTokenContract (state) { - const selectedToken = getSelectedToken(state) - return selectedToken - ? global.eth.contract(abi).at(selectedToken.address) - : null -} - export function getTotalUnapprovedCount (state) { const { unapprovedMsgCount = 0, diff --git a/ui/app/selectors/send.js b/ui/app/selectors/send.js index 6d2b2efee..6e7681d5d 100644 --- a/ui/app/selectors/send.js +++ b/ui/app/selectors/send.js @@ -4,7 +4,6 @@ import { getAddressBook, getSelectedAccount, getTargetAccount, - getSelectedAddress, getAveragePriceEstimateInHexWEI, } from '.' import { estimateGasPriceFromRecentBlocks, calcGasTotal } from '../pages/send/send.utils' @@ -17,10 +16,6 @@ export function getConversionRate (state) { return state.metamask.conversionRate } -export function getCurrentCurrency (state) { - return state.metamask.currentCurrency -} - export function getNativeCurrency (state) { return state.metamask.nativeCurrency } @@ -54,25 +49,17 @@ export function getRecentBlocks (state) { return state.metamask.recentBlocks } -export function getSelectedIdentity (state) { - const selectedAddress = getSelectedAddress(state) - const identities = state.metamask.identities - - return identities[selectedAddress] -} - export function getSelectedToken (state) { const tokens = state.metamask.tokens || [] const selectedTokenAddress = state.metamask.selectedTokenAddress const selectedToken = tokens.filter(({ address }) => address === selectedTokenAddress)[0] - const sendToken = state.metamask.send.token + const sendToken = state.metamask?.send.token return selectedToken || sendToken || null } export function getSelectedTokenContract (state) { const selectedToken = getSelectedToken(state) - return selectedToken ? global.eth.contract(abi).at(selectedToken.address) : null diff --git a/ui/app/selectors/tests/send.test.js b/ui/app/selectors/tests/send.test.js index 4fda2a2eb..6aa3b51c1 100644 --- a/ui/app/selectors/tests/send.test.js +++ b/ui/app/selectors/tests/send.test.js @@ -7,7 +7,6 @@ import { import { getBlockGasLimit, getConversionRate, - getCurrentCurrency, getCurrentNetwork, getNativeCurrency, getGasLimit, @@ -15,7 +14,6 @@ import { getGasTotal, getPrimaryCurrency, getRecentBlocks, - getSelectedIdentity, getSelectedToken, getSelectedTokenContract, getSendAmount, @@ -125,15 +123,6 @@ describe('send selectors', function () { }) }) - describe('getCurrentCurrency()', function () { - it('should return the currently selected currency', function () { - assert.equal( - getCurrentCurrency(mockState), - 'USD' - ) - }) - }) - describe('getNativeCurrency()', function () { it('should return the ticker symbol of the selected network', function () { assert.equal( @@ -197,18 +186,6 @@ describe('send selectors', function () { }) }) - describe('getSelectedIdentity()', function () { - it('should return the identity object of the currently selected address', function () { - assert.deepEqual( - getSelectedIdentity(mockState), - { - address: '0xd85a4b6a394794842887b8284293d69163007bbb', - name: 'Send Account 4', - } - ) - }) - }) - describe('getSelectedToken()', function () { it('should return the currently selected token if selected', function () { assert.deepEqual(