diff --git a/app/scripts/lib/backend-metametrics.js b/app/scripts/lib/backend-metametrics.js index beb23d622..892e06416 100644 --- a/app/scripts/lib/backend-metametrics.js +++ b/app/scripts/lib/backend-metametrics.js @@ -1,4 +1,4 @@ -import { getMetaMetricState } from '../../../ui/app/selectors/selectors' +import { getMetaMetricState } from '../../../ui/app/selectors' import { sendMetaMetricsEvent } from '../../../ui/app/helpers/utils/metametrics.util' const inDevelopment = process.env.NODE_ENV === 'development' diff --git a/test/unit/ui/app/selectors.spec.js b/test/unit/ui/app/selectors.spec.js index 9b3b2c01d..af5788a04 100644 --- a/test/unit/ui/app/selectors.spec.js +++ b/test/unit/ui/app/selectors.spec.js @@ -1,5 +1,5 @@ import assert from 'assert' -import * as selectors from '../../../../ui/app/selectors/selectors' +import * as selectors from '../../../../ui/app/selectors' import mockState from '../../../data/mock-state.json' import Eth from 'ethjs' import { createTestProviderTools } from '../../../stub/provider' @@ -120,11 +120,6 @@ describe('Selectors', function () { assert.equal(currentCurrency, 'usd') }) - it('#getSelectedTokenToFiatRate', function () { - const selectedTokenToFiatRate = selectors.getSelectedTokenToFiatRate(mockState) - assert.equal(selectedTokenToFiatRate, '0.21880988420033492152') - }) - it('#getSelectedTokenContract', function () { global.eth = new Eth(provider) const selectedTokenContract = selectors.getSelectedTokenContract(mockState) diff --git a/ui/app/components/app/account-menu/account-menu.container.js b/ui/app/components/app/account-menu/account-menu.container.js index f024cb4d5..e6f64335c 100644 --- a/ui/app/components/app/account-menu/account-menu.container.js +++ b/ui/app/components/app/account-menu/account-menu.container.js @@ -15,7 +15,7 @@ import { getMetaMaskKeyrings, getOriginOfCurrentTab, getSelectedAddress, -} from '../../../selectors/selectors' +} from '../../../selectors' import AccountMenu from './account-menu.component' /** diff --git a/ui/app/components/app/asset-list/asset-list.container.js b/ui/app/components/app/asset-list/asset-list.container.js index 17d844fab..64225b47e 100644 --- a/ui/app/components/app/asset-list/asset-list.container.js +++ b/ui/app/components/app/asset-list/asset-list.container.js @@ -3,7 +3,7 @@ import { withRouter } from 'react-router-dom' import { compose } from 'redux' import AssetList from './asset-list.component' import { setSelectedToken } from '../../../store/actions' -import { getSelectedAccount } from '../../../selectors/selectors' +import { getSelectedAccount } from '../../../selectors' function mapStateToProps (state) { return { diff --git a/ui/app/components/app/connected-status-indicator/connected-status-indicator.container.js b/ui/app/components/app/connected-status-indicator/connected-status-indicator.container.js index f9dbef153..9cdaea0fa 100644 --- a/ui/app/components/app/connected-status-indicator/connected-status-indicator.container.js +++ b/ui/app/components/app/connected-status-indicator/connected-status-indicator.container.js @@ -10,7 +10,7 @@ import { getAddressConnectedDomainMap, getOriginOfCurrentTab, getSelectedAddress, -} from '../../../selectors/selectors' +} from '../../../selectors' const mapStateToProps = (state) => { 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 6353d1afe..8dae23742 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,7 +3,7 @@ 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/selectors' +import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors' import genAccountLink from '../../../../../lib/account-link.js' function mapStateToProps (state) { 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 aab5af416..5c751d831 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 @@ -31,8 +31,6 @@ import { getSelectedToken, isEthereumNetwork, preferencesSelector, -} from '../../../../selectors/selectors.js' -import { getBasicGasEstimateLoadingStatus, getGasEstimatesLoadingStatus, getCustomGasLimit, @@ -42,11 +40,9 @@ import { getEstimatedGasTimes, getRenderableBasicEstimateData, getBasicGasEstimateBlockTime, - isCustomPriceSafe, -} from '../../../../selectors/custom-gas' -import { getTxParams, -} from '../../../../selectors/transactions' + isCustomPriceSafe, +} from '../../../../selectors' import { getTokenBalance, } from '../../../../pages/send/send.selectors' 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 9c756e25f..d0fde261c 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,19 +35,17 @@ proxyquire('../gas-modal-page-container.container.js', { return () => ({}) }, }, - '../../../../selectors/custom-gas': { + '../../../../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, }, '../../../../store/actions': actionSpies, '../../../../ducks/gas/gas.duck': gasActionSpies, '../../../../ducks/confirm-transaction/confirm-transaction.duck': confirmTransactionActionSpies, '../../../../ducks/send/send.duck': sendActionSpies, - '../../../../selectors/selectors.js': { - getCurrentEthBalance: (state) => state.metamask.balance || '0x0', - getSelectedToken: () => null, - }, '../../../../pages/send/send.selectors': { getTokenBalance: (state) => state.metamask.send.tokenBalance || '0x0', }, diff --git a/ui/app/components/app/loading-network-screen/loading-network-screen.container.js b/ui/app/components/app/loading-network-screen/loading-network-screen.container.js index 3cebdc628..2b5456e4d 100644 --- a/ui/app/components/app/loading-network-screen/loading-network-screen.container.js +++ b/ui/app/components/app/loading-network-screen/loading-network-screen.container.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux' import LoadingNetworkScreen from './loading-network-screen.component' import * as actions from '../../../store/actions' -import { getNetworkIdentifier } from '../../../selectors/selectors' +import { getNetworkIdentifier } from '../../../selectors' const mapStateToProps = (state) => { const { 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 b4e9c282e..cef5ad294 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,6 @@ import { connect } from 'react-redux' import { showModal, setAccountLabel } from '../../../../store/actions' -import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors/selectors' +import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors' import AccountDetailsModal from './account-details-modal.component' const mapStateToProps = (state) => { diff --git a/ui/app/components/app/modals/account-modal-container/account-modal-container.container.js b/ui/app/components/app/modals/account-modal-container/account-modal-container.container.js index ad118f92d..0c85c67cf 100644 --- a/ui/app/components/app/modals/account-modal-container/account-modal-container.container.js +++ b/ui/app/components/app/modals/account-modal-container/account-modal-container.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import { hideModal } from '../../../../store/actions' -import { getSelectedIdentity } from '../../../../selectors/selectors' +import { getSelectedIdentity } from '../../../../selectors' import AccountModalContainer from './account-modal-container.component' function mapStateToProps (state, ownProps) { diff --git a/ui/app/components/app/modals/edit-approval-permission/edit-approval-permission.container.js b/ui/app/components/app/modals/edit-approval-permission/edit-approval-permission.container.js index 223185f75..b70451a41 100644 --- a/ui/app/components/app/modals/edit-approval-permission/edit-approval-permission.container.js +++ b/ui/app/components/app/modals/edit-approval-permission/edit-approval-permission.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import { compose } from 'redux' import withModalProps from '../../../../helpers/higher-order-components/with-modal-props' import EditApprovalPermission from './edit-approval-permission.component' -import { getSelectedIdentity } from '../../../../selectors/selectors' +import { getSelectedIdentity } from '../../../../selectors' const mapStateToProps = (state) => { const modalStateProps = state.appState.modal.modalState.props || {} diff --git a/ui/app/components/app/modals/export-private-key-modal/export-private-key-modal.container.js b/ui/app/components/app/modals/export-private-key-modal/export-private-key-modal.container.js index 1b8f63c94..313729217 100644 --- a/ui/app/components/app/modals/export-private-key-modal/export-private-key-modal.container.js +++ b/ui/app/components/app/modals/export-private-key-modal/export-private-key-modal.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import { exportAccount, hideWarning, showModal, hideModal } from '../../../../store/actions' -import { getSelectedIdentity } from '../../../../selectors/selectors' +import { getSelectedIdentity } from '../../../../selectors' import ExportPrivateKeyModal from './export-private-key-modal.component' function mapStateToPropsFactory () { diff --git a/ui/app/components/app/permission-page-container/permission-page-container.container.js b/ui/app/components/app/permission-page-container/permission-page-container.container.js index 2c2e5ec53..827e12c8f 100644 --- a/ui/app/components/app/permission-page-container/permission-page-container.container.js +++ b/ui/app/components/app/permission-page-container/permission-page-container.container.js @@ -4,7 +4,7 @@ import { getPermissionsDescriptions, getTargetDomainMetadata, getMetaMaskIdentities, -} from '../../../selectors/selectors' +} from '../../../selectors' const mapStateToProps = (state, ownProps) => { const { request, cachedOrigin, selectedIdentities } = ownProps diff --git a/ui/app/components/app/selected-account/selected-account.container.js b/ui/app/components/app/selected-account/selected-account.container.js index 4f1061aee..57a91cd10 100644 --- a/ui/app/components/app/selected-account/selected-account.container.js +++ b/ui/app/components/app/selected-account/selected-account.container.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux' import SelectedAccount from './selected-account.component' -import { getSelectedIdentity } from '../../../selectors/selectors' +import { getSelectedIdentity } from '../../../selectors' const mapStateToProps = (state) => { return { diff --git a/ui/app/components/app/signature-request-original/signature-request-original.container.js b/ui/app/components/app/signature-request-original/signature-request-original.container.js index 4dfe44fe0..0ee4519df 100644 --- a/ui/app/components/app/signature-request-original/signature-request-original.container.js +++ b/ui/app/components/app/signature-request-original/signature-request-original.container.js @@ -6,7 +6,7 @@ import { goHome } from '../../../store/actions' import { accountsWithSendEtherInfoSelector, conversionRateSelector, -} from '../../../selectors/selectors.js' +} from '../../../selectors' import { getAccountByAddress } from '../../../helpers/utils/util' import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck' import SignatureRequestOriginal from './signature-request-original.component' diff --git a/ui/app/components/app/signature-request/signature-request.container.js b/ui/app/components/app/signature-request/signature-request.container.js index 701e02dee..d97cc37b1 100644 --- a/ui/app/components/app/signature-request/signature-request.container.js +++ b/ui/app/components/app/signature-request/signature-request.container.js @@ -3,7 +3,7 @@ import SignatureRequest from './signature-request.component' import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck' import { accountsWithSendEtherInfoSelector, -} from '../../../selectors/selectors.js' +} from '../../../selectors' import { getAccountByAddress } from '../../../helpers/utils/util' function mapStateToProps (state) { diff --git a/ui/app/components/app/token-cell/token-cell.container.js b/ui/app/components/app/token-cell/token-cell.container.js index cc29a941e..a35ea3429 100644 --- a/ui/app/components/app/token-cell/token-cell.container.js +++ b/ui/app/components/app/token-cell/token-cell.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import TokenCell from './token-cell.component' -import { getSelectedAddress } from '../../../selectors/selectors' +import { getSelectedAddress } from '../../../selectors' function mapStateToProps (state) { return { diff --git a/ui/app/components/app/token-list/token-list.container.js b/ui/app/components/app/token-list/token-list.container.js index 0ab4552ae..c22e0dea8 100644 --- a/ui/app/components/app/token-list/token-list.container.js +++ b/ui/app/components/app/token-list/token-list.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import PropTypes from 'prop-types' -import { getSelectedAddress } from '../../../selectors/selectors' +import { getSelectedAddress } from '../../../selectors' import TokenList from './token-list.component' function mapStateToProps (state) { diff --git a/ui/app/components/app/transaction-activity-log/transaction-activity-log.container.js b/ui/app/components/app/transaction-activity-log/transaction-activity-log.container.js index a6ecb3617..a7ab8a5d9 100644 --- a/ui/app/components/app/transaction-activity-log/transaction-activity-log.container.js +++ b/ui/app/components/app/transaction-activity-log/transaction-activity-log.container.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux' import R from 'ramda' import TransactionActivityLog from './transaction-activity-log.component' -import { conversionRateSelector, getNativeCurrency } from '../../../selectors/selectors' +import { conversionRateSelector, getNativeCurrency } from '../../../selectors' import { combineTransactionHistories } from './transaction-activity-log.util' import { TRANSACTION_RESUBMITTED_EVENT, diff --git a/ui/app/components/app/transaction-breakdown/transaction-breakdown.container.js b/ui/app/components/app/transaction-breakdown/transaction-breakdown.container.js index 0398853a5..a65769d31 100644 --- a/ui/app/components/app/transaction-breakdown/transaction-breakdown.container.js +++ b/ui/app/components/app/transaction-breakdown/transaction-breakdown.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import TransactionBreakdown from './transaction-breakdown.component' -import { getIsMainnet, getNativeCurrency, preferencesSelector } from '../../../selectors/selectors' +import { getIsMainnet, getNativeCurrency, preferencesSelector } from '../../../selectors' import { getHexGasTotal } from '../../../helpers/utils/confirm-tx.util' import { sumHexes } from '../../../helpers/utils/transactions.util' diff --git a/ui/app/components/app/transaction-list-item-details/transaction-list-item-details.container.js b/ui/app/components/app/transaction-list-item-details/transaction-list-item-details.container.js index ca5f1a1cd..935b80b48 100644 --- a/ui/app/components/app/transaction-list-item-details/transaction-list-item-details.container.js +++ b/ui/app/components/app/transaction-list-item-details/transaction-list-item-details.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import TransactionListItemDetails from './transaction-list-item-details.component' import { checksumAddress } from '../../../helpers/utils/util' import { tryReverseResolveAddress } from '../../../store/actions' -import { getAddressBook } from '../../../selectors/selectors' +import { getAddressBook } from '../../../selectors' const mapStateToProps = (state, ownProps) => { const { metamask } = state diff --git a/ui/app/components/app/transaction-list-item/transaction-list-item.container.js b/ui/app/components/app/transaction-list-item/transaction-list-item.container.js index 2a6089ff7..eea6b7b0d 100644 --- a/ui/app/components/app/transaction-list-item/transaction-list-item.container.js +++ b/ui/app/components/app/transaction-list-item/transaction-list-item.container.js @@ -20,7 +20,7 @@ import { conversionRateSelector, getKnownMethodData, getFeatureFlags, -} from '../../../selectors/selectors' +} from '../../../selectors' import { isBalanceSufficient } from '../../../pages/send/send.utils' const mapStateToProps = (state, ownProps) => { diff --git a/ui/app/components/app/transaction-list/transaction-list.container.js b/ui/app/components/app/transaction-list/transaction-list.container.js index be8904974..92dde3aaf 100644 --- a/ui/app/components/app/transaction-list/transaction-list.container.js +++ b/ui/app/components/app/transaction-list/transaction-list.container.js @@ -2,11 +2,13 @@ import { connect } from 'react-redux' import PropTypes from 'prop-types' import TransactionList from './transaction-list.component' import { + getAssetImages, + getFeatureFlags, + getSelectedAddress, + selectedTokenSelector, nonceSortedCompletedTransactionsSelector, nonceSortedPendingTransactionsSelector, -} from '../../../selectors/transactions' -import { getSelectedAddress, getAssetImages, getFeatureFlags } from '../../../selectors/selectors' -import { selectedTokenSelector } from '../../../selectors/tokens' +} from '../../../selectors' import { fetchBasicGasAndTimeEstimates, fetchGasEstimates } from '../../../ducks/gas/gas.duck' const mapStateToProps = (state) => { diff --git a/ui/app/components/app/transaction-time-remaining/transaction-time-remaining.container.js b/ui/app/components/app/transaction-time-remaining/transaction-time-remaining.container.js index a9ed6f4dc..76bd7e82b 100644 --- a/ui/app/components/app/transaction-time-remaining/transaction-time-remaining.container.js +++ b/ui/app/components/app/transaction-time-remaining/transaction-time-remaining.container.js @@ -1,12 +1,10 @@ import { connect } from 'react-redux' import TransactionTimeRemaining from './transaction-time-remaining.component' -import { - getTxParams, -} from '../../../selectors/transactions' import { getEstimatedGasPrices, getEstimatedGasTimes, -} from '../../../selectors/custom-gas' + getTxParams, +} from '../../../selectors' import { getRawTimeEstimateData } from '../../../helpers/utils/gas-time-estimates.util' import { hexWEIToDecGWEI } from '../../../helpers/utils/conversions.util' diff --git a/ui/app/components/app/transaction-view-balance/transaction-view-balance.container.js b/ui/app/components/app/transaction-view-balance/transaction-view-balance.container.js index e9fdbe141..51af54df2 100644 --- a/ui/app/components/app/transaction-view-balance/transaction-view-balance.container.js +++ b/ui/app/components/app/transaction-view-balance/transaction-view-balance.container.js @@ -11,7 +11,7 @@ import { isBalanceCached, preferencesSelector, getIsMainnet, -} from '../../../selectors/selectors' +} from '../../../selectors' import { showModal } from '../../../store/actions' const mapStateToProps = (state) => { diff --git a/ui/app/components/app/user-preferenced-currency-display/user-preferenced-currency-display.container.js b/ui/app/components/app/user-preferenced-currency-display/user-preferenced-currency-display.container.js index 8b4c2ae4d..b94bec6d1 100644 --- a/ui/app/components/app/user-preferenced-currency-display/user-preferenced-currency-display.container.js +++ b/ui/app/components/app/user-preferenced-currency-display/user-preferenced-currency-display.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import UserPreferencedCurrencyDisplay from './user-preferenced-currency-display.component' -import { preferencesSelector, getIsMainnet } from '../../../selectors/selectors' +import { preferencesSelector, getIsMainnet } from '../../../selectors' import { ETH, PRIMARY, SECONDARY } from '../../../helpers/constants/common' const mapStateToProps = (state) => { diff --git a/ui/app/components/app/user-preferenced-currency-input/user-preferenced-currency-input.container.js b/ui/app/components/app/user-preferenced-currency-input/user-preferenced-currency-input.container.js index 4f3795c6d..9bed0bf3d 100644 --- a/ui/app/components/app/user-preferenced-currency-input/user-preferenced-currency-input.container.js +++ b/ui/app/components/app/user-preferenced-currency-input/user-preferenced-currency-input.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import UserPreferencedCurrencyInput from './user-preferenced-currency-input.component' -import { preferencesSelector } from '../../../selectors/selectors' +import { preferencesSelector } from '../../../selectors' const mapStateToProps = (state) => { const { useNativeCurrencyAsPrimaryCurrency } = preferencesSelector(state) diff --git a/ui/app/components/app/user-preferenced-token-input/user-preferenced-token-input.container.js b/ui/app/components/app/user-preferenced-token-input/user-preferenced-token-input.container.js index 6263928ba..712ab98c8 100644 --- a/ui/app/components/app/user-preferenced-token-input/user-preferenced-token-input.container.js +++ b/ui/app/components/app/user-preferenced-token-input/user-preferenced-token-input.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import UserPreferencedTokenInput from './user-preferenced-token-input.component' -import { preferencesSelector } from '../../../selectors/selectors' +import { preferencesSelector } from '../../../selectors' const mapStateToProps = (state) => { const { useNativeCurrencyAsPrimaryCurrency } = preferencesSelector(state) diff --git a/ui/app/components/app/wallet-view/wallet-view.container.js b/ui/app/components/app/wallet-view/wallet-view.container.js index a5e4f6be0..1f2566057 100644 --- a/ui/app/components/app/wallet-view/wallet-view.container.js +++ b/ui/app/components/app/wallet-view/wallet-view.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import { compose } from 'redux' import WalletView from './wallet-view.component' -import { getSelectedAddress } from '../../../selectors/selectors' +import { getSelectedAddress } from '../../../selectors' function mapStateToProps (state) { return { diff --git a/ui/app/components/ui/balance/balance.container.js b/ui/app/components/ui/balance/balance.container.js index 997935ee7..806fca756 100644 --- a/ui/app/components/ui/balance/balance.container.js +++ b/ui/app/components/ui/balance/balance.container.js @@ -8,7 +8,7 @@ import { getMetaMaskAccounts, getIsMainnet, preferencesSelector, -} from '../../../selectors/selectors' +} from '../../../selectors' const mapStateToProps = (state) => { const { showFiatInTestnets } = preferencesSelector(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 64a8d96b4..76c903602 100644 --- a/ui/app/components/ui/currency-input/currency-input.container.js +++ b/ui/app/components/ui/currency-input/currency-input.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import CurrencyInput from './currency-input.component' import { ETH } from '../../../helpers/constants/common' import { getMaxModeOn } from '../../../pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.selectors' -import { getIsMainnet, preferencesSelector } from '../../../selectors/selectors' +import { getIsMainnet, preferencesSelector } from '../../../selectors' const mapStateToProps = (state) => { const { metamask: { nativeCurrency, currentCurrency, conversionRate } } = state diff --git a/ui/app/components/ui/token-balance/token-balance.container.js b/ui/app/components/ui/token-balance/token-balance.container.js index 30efeeb31..10a23961a 100644 --- a/ui/app/components/ui/token-balance/token-balance.container.js +++ b/ui/app/components/ui/token-balance/token-balance.container.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import { compose } from 'redux' import withTokenTracker from '../../../helpers/higher-order-components/with-token-tracker' import TokenBalance from './token-balance.component' -import { getSelectedAddress } from '../../../selectors/selectors' +import { getSelectedAddress } from '../../../selectors' const mapStateToProps = (state) => { return { diff --git a/ui/app/components/ui/token-input/token-input.container.js b/ui/app/components/ui/token-input/token-input.container.js index 7d614f7c4..933766bac 100644 --- a/ui/app/components/ui/token-input/token-input.container.js +++ b/ui/app/components/ui/token-input/token-input.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import TokenInput from './token-input.component' -import { getIsMainnet, getSelectedToken, getSelectedTokenExchangeRate, preferencesSelector } from '../../../selectors/selectors' +import { getIsMainnet, getSelectedToken, getSelectedTokenExchangeRate, preferencesSelector } from '../../../selectors' const mapStateToProps = (state) => { const { metamask: { currentCurrency } } = state diff --git a/ui/app/ducks/alerts/unconnected-account.js b/ui/app/ducks/alerts/unconnected-account.js index 92ed69798..6d09baf8a 100644 --- a/ui/app/ducks/alerts/unconnected-account.js +++ b/ui/app/ducks/alerts/unconnected-account.js @@ -3,7 +3,7 @@ import { captureException } from '@sentry/browser' import actionConstants from '../../store/actionConstants' import { addPermittedAccount } from '../../store/actions' -import { getOriginOfCurrentTab, getSelectedAddress } from '../../selectors/selectors' +import { getOriginOfCurrentTab, getSelectedAddress } from '../../selectors' // Constants diff --git a/ui/app/ducks/confirm-transaction/confirm-transaction.duck.js b/ui/app/ducks/confirm-transaction/confirm-transaction.duck.js index 150ac1d06..416407d5d 100644 --- a/ui/app/ducks/confirm-transaction/confirm-transaction.duck.js +++ b/ui/app/ducks/confirm-transaction/confirm-transaction.duck.js @@ -3,7 +3,7 @@ import { currentCurrencySelector, unconfirmedTransactionsHashSelector, getNativeCurrency, -} from '../../selectors/confirm-transaction' +} from '../../selectors' import { getValueFromWeiHex, diff --git a/ui/app/ducks/gas/gas.duck.js b/ui/app/ducks/gas/gas.duck.js index a5eded548..168bd56fb 100644 --- a/ui/app/ducks/gas/gas.duck.js +++ b/ui/app/ducks/gas/gas.duck.js @@ -9,7 +9,7 @@ import { } from '../../helpers/utils/conversions.util' import { isEthereumNetwork, -} from '../../selectors/selectors' +} from '../../selectors' // Actions const BASIC_GAS_ESTIMATE_LOADING_FINISHED = 'metamask/gas/BASIC_GAS_ESTIMATE_LOADING_FINISHED' 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 ed49d5a9b..e49fe6c4f 100644 --- a/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js +++ b/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js @@ -9,10 +9,10 @@ import { getAccountType, getNumberOfAccounts, getNumberOfTokens, -} from '../../../selectors/selectors' -import { + txDataSelector, -} from '../../../selectors/confirm-transaction' +} from '../../../selectors' + import { getEnvironmentType } from '../../../../../app/scripts/lib/util' import { sendMetaMetricsEvent, diff --git a/ui/app/helpers/utils/confirm-tx.util.js b/ui/app/helpers/utils/confirm-tx.util.js index 0895cf7b0..e1cd83615 100644 --- a/ui/app/helpers/utils/confirm-tx.util.js +++ b/ui/app/helpers/utils/confirm-tx.util.js @@ -10,7 +10,7 @@ import { conversionGreaterThan, } from './conversion-util' -import { unconfirmedTransactionsCountSelector } from '../../selectors/confirm-transaction' +import { unconfirmedTransactionsCountSelector } from '../../selectors' export function increaseLastGasPrice (lastGasPrice) { return ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice || '0x0', 1.1, { diff --git a/ui/app/pages/confirm-approve/confirm-approve.container.js b/ui/app/pages/confirm-approve/confirm-approve.container.js index f7f2c8d46..ef16a79a7 100644 --- a/ui/app/pages/confirm-approve/confirm-approve.container.js +++ b/ui/app/pages/confirm-approve/confirm-approve.container.js @@ -3,10 +3,10 @@ import { compose } from 'redux' import { withRouter } from 'react-router-dom' import { contractExchangeRateSelector, + tokenSelector, transactionFeeSelector, -} from '../../selectors/confirm-transaction' +} from '../../selectors' import { showModal } from '../../store/actions' -import { tokenSelector } from '../../selectors/tokens' import { getTokenData, } from '../../helpers/utils/transactions.util' diff --git a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.container.js b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.container.js index 25e9835a5..59c6948f6 100644 --- a/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.container.js +++ b/ui/app/pages/confirm-decrypt-message/confirm-decrypt-message.container.js @@ -11,7 +11,7 @@ import { import { getTargetAccountWithSendEtherInfo, conversionRateSelector, -} from '../../selectors/selectors' +} from '../../selectors' import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck' import ConfirmDecryptMessage from './confirm-decrypt-message.component' diff --git a/ui/app/pages/confirm-encryption-public-key/confirm-encryption-public-key.container.js b/ui/app/pages/confirm-encryption-public-key/confirm-encryption-public-key.container.js index 6b21d529c..8be2f25a1 100644 --- a/ui/app/pages/confirm-encryption-public-key/confirm-encryption-public-key.container.js +++ b/ui/app/pages/confirm-encryption-public-key/confirm-encryption-public-key.container.js @@ -11,7 +11,7 @@ import { import { conversionRateSelector, getTargetAccountWithSendEtherInfo, -} from '../../selectors/selectors' +} from '../../selectors' import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck' import ConfirmEncryptionPublicKey from './confirm-encryption-public-key.component' diff --git a/ui/app/pages/confirm-send-token/confirm-send-token.container.js b/ui/app/pages/confirm-send-token/confirm-send-token.container.js index c2399f981..833b06195 100644 --- a/ui/app/pages/confirm-send-token/confirm-send-token.container.js +++ b/ui/app/pages/confirm-send-token/confirm-send-token.container.js @@ -5,7 +5,7 @@ import ConfirmSendToken from './confirm-send-token.component' import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck' import { setSelectedToken, updateSend, showSendTokenPage } from '../../store/actions' import { conversionUtil } from '../../helpers/utils/conversion-util' -import { sendTokenTokenAmountAndToAddressSelector } from '../../selectors/confirm-transaction' +import { sendTokenTokenAmountAndToAddressSelector } from '../../selectors' const mapStateToProps = (state) => { const { tokenAmount } = sendTokenTokenAmountAndToAddressSelector(state) diff --git a/ui/app/pages/confirm-token-transaction-base/confirm-token-transaction-base.container.js b/ui/app/pages/confirm-token-transaction-base/confirm-token-transaction-base.container.js index 6c5889dba..bb5e831ab 100644 --- a/ui/app/pages/confirm-token-transaction-base/confirm-token-transaction-base.container.js +++ b/ui/app/pages/confirm-token-transaction-base/confirm-token-transaction-base.container.js @@ -4,9 +4,9 @@ import { withRouter } from 'react-router-dom' import ConfirmTokenTransactionBase from './confirm-token-transaction-base.component' import { contractExchangeRateSelector, + tokenSelector, transactionFeeSelector, -} from '../../selectors/confirm-transaction' -import { tokenSelector } from '../../selectors/tokens' +} from '../../selectors' import { getTokenData, } from '../../helpers/utils/transactions.util' diff --git a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js index 5917ebf71..3a15c660c 100644 --- a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js +++ b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js @@ -27,8 +27,16 @@ import { isBalanceSufficient, calcGasTotal } from '../send/send.utils' import { conversionGreaterThan } from '../../helpers/utils/conversion-util' import { MIN_GAS_LIMIT_DEC } from '../send/send.constants' import { checksumAddress, shortenAddress, valuesFor } from '../../helpers/utils/util' -import { getMetaMaskAccounts, getCustomNonceValue, getUseNonceField, getAdvancedInlineGasShown, preferencesSelector, getIsMainnet, getKnownMethodData } from '../../selectors/selectors' -import { transactionFeeSelector } from '../../selectors/confirm-transaction' +import { + getAdvancedInlineGasShown, + getCustomNonceValue, + getIsMainnet, + getKnownMethodData, + getMetaMaskAccounts, + getUseNonceField, + preferencesSelector, + transactionFeeSelector, +} from '../../selectors' const casedContractMap = Object.keys(contractMap).reduce((acc, base) => { return { diff --git a/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.container.js b/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.container.js index bb5bc12c0..11daa6cc6 100644 --- a/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.container.js +++ b/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import ConfirmTransactionSwitch from './confirm-transaction-switch.component' -import { unconfirmedTransactionsListSelector } from '../../selectors/confirm-transaction' +import { unconfirmedTransactionsListSelector } from '../../selectors' const mapStateToProps = (state, ownProps) => { const { metamask: { unapprovedTxs } } = state diff --git a/ui/app/pages/confirm-transaction/confirm-transaction.container.js b/ui/app/pages/confirm-transaction/confirm-transaction.container.js index cdfedd1ec..2fcf5e8a8 100644 --- a/ui/app/pages/confirm-transaction/confirm-transaction.container.js +++ b/ui/app/pages/confirm-transaction/confirm-transaction.container.js @@ -17,7 +17,7 @@ import { getTokenParams, } from '../../store/actions' import ConfirmTransaction from './confirm-transaction.component' -import { unconfirmedTransactionsListSelector } from '../../selectors/confirm-transaction' +import { unconfirmedTransactionsListSelector } from '../../selectors' const mapStateToProps = (state, ownProps) => { const { diff --git a/ui/app/pages/connected-sites/connected-sites.container.js b/ui/app/pages/connected-sites/connected-sites.container.js index 85dc40c57..be78a4314 100644 --- a/ui/app/pages/connected-sites/connected-sites.container.js +++ b/ui/app/pages/connected-sites/connected-sites.container.js @@ -10,12 +10,10 @@ import { getConnectedDomainsForSelectedAddress, getCurrentAccountWithSendEtherInfo, getOriginOfCurrentTab, - getSelectedAddress, -} from '../../selectors/selectors' -import { - getPermissionsDomains, + getPermissionDomains, getPermittedAccountsByOrigin, -} from '../../selectors/permissions' + getSelectedAddress, +} from '../../selectors' import { DEFAULT_ROUTE } from '../../helpers/constants/routes' import { getOriginFromUrl } from '../../helpers/utils/util' @@ -42,7 +40,7 @@ const mapStateToProps = (state) => { return { accountLabel: getCurrentAccountWithSendEtherInfo(state).name, connectedDomains, - domains: getPermissionsDomains(state), + domains: getPermissionDomains(state), permittedAccountsByOrigin, selectedAddress, tabToConnect, diff --git a/ui/app/pages/create-account/connect-hardware/index.js b/ui/app/pages/create-account/connect-hardware/index.js index 2e3afb812..b05da36e1 100644 --- a/ui/app/pages/create-account/connect-hardware/index.js +++ b/ui/app/pages/create-account/connect-hardware/index.js @@ -2,7 +2,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import * as actions from '../../../store/actions' -import { getMetaMaskAccounts } from '../../../selectors/selectors' +import { getMetaMaskAccounts } from '../../../selectors' import ConnectScreen from './connect-screen' import AccountList from './account-list' import { DEFAULT_ROUTE } from '../../../helpers/constants/routes' diff --git a/ui/app/pages/create-account/import-account/json.js b/ui/app/pages/create-account/import-account/json.js index f270b9f05..1db5e0b09 100644 --- a/ui/app/pages/create-account/import-account/json.js +++ b/ui/app/pages/create-account/import-account/json.js @@ -6,7 +6,7 @@ import { connect } from 'react-redux' import * as actions from '../../../store/actions' import FileInput from 'react-simple-file-input' import { DEFAULT_ROUTE } from '../../../helpers/constants/routes' -import { getMetaMaskAccounts } from '../../../selectors/selectors' +import { getMetaMaskAccounts } from '../../../selectors' import Button from '../../../components/ui/button' const HELP_LINK = 'https://metamask.zendesk.com/hc/en-us/articles/360015489331-Importing-an-Account' diff --git a/ui/app/pages/create-account/import-account/private-key.js b/ui/app/pages/create-account/import-account/private-key.js index 29aaaf5e8..aa21c1bb0 100644 --- a/ui/app/pages/create-account/import-account/private-key.js +++ b/ui/app/pages/create-account/import-account/private-key.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types' import { connect } from 'react-redux' import * as actions from '../../../store/actions' import { DEFAULT_ROUTE } from '../../../helpers/constants/routes' -import { getMetaMaskAccounts } from '../../../selectors/selectors' +import { getMetaMaskAccounts } from '../../../selectors' import Button from '../../../components/ui/button' class PrivateKeyImportView extends Component { diff --git a/ui/app/pages/home/home.container.js b/ui/app/pages/home/home.container.js index 9faddd4ec..4e7b969f7 100644 --- a/ui/app/pages/home/home.container.js +++ b/ui/app/pages/home/home.container.js @@ -4,12 +4,12 @@ import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import { unconfirmedTransactionsCountSelector, -} from '../../selectors/confirm-transaction' -import { + getCurrentEthBalance, getFirstPermissionRequest, getTotalUnapprovedCount, -} from '../../selectors/selectors' +} from '../../selectors' + import { restoreFromThreeBox, turnThreeBoxSyncingOn, diff --git a/ui/app/pages/permissions-connect/permissions-connect.container.js b/ui/app/pages/permissions-connect/permissions-connect.container.js index 815d2e700..b387849e3 100644 --- a/ui/app/pages/permissions-connect/permissions-connect.container.js +++ b/ui/app/pages/permissions-connect/permissions-connect.container.js @@ -7,10 +7,10 @@ import { getAccountsWithLabels, getLastConnectedInfo, getTargetDomainMetadata, -} from '../../selectors/selectors' -import { - getPermissionsDomains, -} from '../../selectors/permissions' + + getPermissionDomains, +} from '../../selectors' + import { formatDate } from '../../helpers/utils/util' import { approvePermissionsRequest, rejectPermissionsRequest, showModal, getCurrentWindowTab, getRequestAccountTabIds } from '../../store/actions' import { @@ -63,7 +63,7 @@ const mapStateToProps = (state, ownProps) => { newAccountNumber: accountsWithLabels.length + 1, nativeCurrency, addressLastConnectedMap, - domains: getPermissionsDomains(state), + domains: getPermissionDomains(state), connectPath, confirmPermissionPath, page, diff --git a/ui/app/pages/routes/routes.container.js b/ui/app/pages/routes/routes.container.js index 0c3f5fad6..4d5b7244b 100644 --- a/ui/app/pages/routes/routes.container.js +++ b/ui/app/pages/routes/routes.container.js @@ -5,8 +5,8 @@ import { getNetworkIdentifier, hasPermissionRequests, preferencesSelector, -} from '../../selectors/selectors' -import { submittedPendingTransactionsSelector } from '../../selectors/transactions' + submittedPendingTransactionsSelector, +} from '../../selectors' import Routes from './routes.component' import { hideSidebar, 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 2e393ba58..ece1c67e9 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 @@ -6,7 +6,7 @@ import { getIsMainnet, isBalanceCached, preferencesSelector, -} from '../../../selectors/selectors' +} from '../../../selectors' import AccountListItem from './account-list-item.component' export default connect(mapStateToProps)(AccountListItem) 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 a1c2434e3..e1b12c8ec 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 @@ -15,7 +15,7 @@ proxyquire('../account-list-item.container.js', { getCurrentCurrency: () => `mockCurrentCurrency`, getNativeCurrency: () => `mockNativeCurrency`, }, - '../../../selectors/selectors': { + '../../../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 d62df109d..dc09cdc27 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 @@ -7,7 +7,7 @@ import { accountsWithSendEtherInfoSelector, getAddressBook, getAddressBookEntry, -} from '../../../../selectors/selectors' +} 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 74e7f4b54..2486f1046 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 @@ -6,7 +6,7 @@ import { } from '../../send.selectors' import { getAddressBookEntry, -} from '../../../../selectors/selectors' +} from '../../../../selectors' import { connect } from 'react-redux' 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 ab509ebdd..f6eb32e21 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 @@ -21,7 +21,7 @@ proxyquire('../add-recipient.container.js', { getSendEnsResolution: (s) => `mockSendEnsResolution:${s}`, getSendEnsResolutionError: (s) => `mockSendEnsResolutionError:${s}`, }, - '../../../../selectors/selectors': { + '../../../../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 09cb14bcf..d1a7eef9f 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, } from '../../../send.selectors.js' -import { getBasicGasEstimateLoadingStatus } from '../../../../../selectors/custom-gas' +import { getBasicGasEstimateLoadingStatus } from '../../../../../selectors' import { getMaxModeOn } from './amount-max-button.selectors.js' 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 e13eab9a4..a588dc657 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 @@ -29,7 +29,7 @@ proxyquire('../amount-max-button.container.js', { }, './amount-max-button.selectors.js': { getMaxModeOn: (s) => `mockMaxModeOn:${s}` }, './amount-max-button.utils.js': { calcMaxAmount: (mockObj) => mockObj.val + 1 }, - '../../../../../selectors/custom-gas': { getBasicGasEstimateLoadingStatus: (s) => `mockButtonDataLoading:${s}` }, + '../../../../../selectors/': { getBasicGasEstimateLoadingStatus: (s) => `mockButtonDataLoading:${s}` }, '../../../../../store/actions': actionSpies, '../../../../../ducks/send/send.duck': duckActionSpies, }) diff --git a/ui/app/pages/send/send-content/send-asset-row/send-asset-row.container.js b/ui/app/pages/send/send-content/send-asset-row/send-asset-row.container.js index dd40608f9..e8c5bef52 100644 --- a/ui/app/pages/send/send-content/send-asset-row/send-asset-row.container.js +++ b/ui/app/pages/send/send-content/send-asset-row/send-asset-row.container.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux' import SendAssetRow from './send-asset-row.component' -import { getMetaMaskAccounts } from '../../../../selectors/selectors' +import { getMetaMaskAccounts } from '../../../../selectors' import { setSelectedToken } from '../../../../store/actions' function mapStateToProps (state) { 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 2b7486f2e..7b1d67215 100644 --- a/ui/app/pages/send/send-content/send-content.container.js +++ b/ui/app/pages/send/send-content/send-content.container.js @@ -6,7 +6,7 @@ import { import { accountsWithSendEtherInfoSelector, getAddressBookEntry, -} from '../../../selectors/selectors' +} 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 7998816df..7d14f96db 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 @@ -16,11 +16,6 @@ import { calcGasTotal, } from '../../send.utils.js' import { calcMaxAmount } from '../send-amount-row/amount-max-button/amount-max-button.utils' -import { - getBasicGasEstimateLoadingStatus, - getRenderableEstimateDataForSmallButtonsFromGWEI, - getDefaultActiveButtonIndex, -} from '../../../../selectors/custom-gas' import { showGasButtonGroup, updateSendErrors, @@ -32,7 +27,14 @@ import { } from '../../../../ducks/gas/gas.duck' import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown } from './send-gas-row.selectors.js' import { showModal, setGasPrice, setGasLimit, setGasTotal, updateSendAmount } from '../../../../store/actions' -import { getAdvancedInlineGasShown, getCurrentEthBalance, getSelectedToken } from '../../../../selectors/selectors' +import { + getAdvancedInlineGasShown, + getCurrentEthBalance, + getSelectedToken, + getBasicGasEstimateLoadingStatus, + getRenderableEstimateDataForSmallButtonsFromGWEI, + getDefaultActiveButtonIndex, +} from '../../../../selectors' import SendGasRow from './send-gas-row.component' 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 81859cb1a..a3170911d 100644 --- a/ui/app/pages/send/send-footer/send-footer.container.js +++ b/ui/app/pages/send/send-footer/send-footer.container.js @@ -23,7 +23,6 @@ import { getUnapprovedTxs, getSendErrors, } from '../send.selectors' -import { getGasIsLoading } from '../../../selectors/selectors' import { isSendFormInError, } from './send-footer.selectors' @@ -33,9 +32,10 @@ import { constructUpdatedTx, } from './send-footer.utils' import { + getGasIsLoading, getRenderableEstimateDataForSmallButtonsFromGWEI, getDefaultActiveButtonIndex, -} from '../../../selectors/custom-gas' +} from '../../../selectors' 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 0d4655c9d..9fde4283a 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 @@ -45,7 +45,7 @@ proxyquire('../send-footer.container.js', { }, './send-footer.selectors': { isSendFormInError: (s) => `mockInError:${s}` }, './send-footer.utils': utilsStubs, - '../../../selectors/custom-gas': { + '../../../selectors/': { getRenderableEstimateDataForSmallButtonsFromGWEI: (s) => ([{ gasEstimateType: `mockGasEstimateType:${s}` }]), getDefaultActiveButtonIndex: () => 0, }, diff --git a/ui/app/pages/send/send.container.js b/ui/app/pages/send/send.container.js index 71b7338bf..ed5934bf4 100644 --- a/ui/app/pages/send/send.container.js +++ b/ui/app/pages/send/send.container.js @@ -27,7 +27,7 @@ import { import { getSelectedAddress, getAddressBook, -} from '../../selectors/selectors' +} from '../../selectors' import { getTokens } from './send-content/add-recipient/add-recipient.selectors' import { updateSendTo, diff --git a/ui/app/pages/send/send.selectors.js b/ui/app/pages/send/send.selectors.js index 36c1ab710..9f6d9cc82 100644 --- a/ui/app/pages/send/send.selectors.js +++ b/ui/app/pages/send/send.selectors.js @@ -6,11 +6,9 @@ import { getSelectedAccount, getTargetAccount, getSelectedAddress, -} from '../../selectors/selectors' -import { estimateGasPriceFromRecentBlocks, calcGasTotal } from './send.utils' -import { getAveragePriceEstimateInHexWEI, -} from '../../selectors/custom-gas' +} from '../../selectors' +import { estimateGasPriceFromRecentBlocks, calcGasTotal } from './send.utils' export function getAmountConversionRate (state) { return getSelectedToken(state) diff --git a/ui/app/pages/send/tests/send-selectors.test.js b/ui/app/pages/send/tests/send-selectors.test.js index aaada09ed..3df4754bf 100644 --- a/ui/app/pages/send/tests/send-selectors.test.js +++ b/ui/app/pages/send/tests/send-selectors.test.js @@ -3,7 +3,7 @@ import sinon from 'sinon' import { accountsWithSendEtherInfoSelector, getCurrentAccountWithSendEtherInfo, -} from '../../../selectors/selectors' +} from '../../../selectors' import { getBlockGasLimit, getAmountConversionRate, diff --git a/ui/app/pages/settings/advanced-tab/advanced-tab.container.js b/ui/app/pages/settings/advanced-tab/advanced-tab.container.js index 3875418dd..b7a9f1dfb 100644 --- a/ui/app/pages/settings/advanced-tab/advanced-tab.container.js +++ b/ui/app/pages/settings/advanced-tab/advanced-tab.container.js @@ -13,7 +13,7 @@ import { setUseNonceField, setIpfsGateway, } from '../../../store/actions' -import { preferencesSelector } from '../../../selectors/selectors' +import { preferencesSelector } from '../../../selectors' export const mapStateToProps = (state) => { const { appState: { warning }, metamask } = state diff --git a/ui/app/pages/settings/contact-list-tab/contact-list-tab.container.js b/ui/app/pages/settings/contact-list-tab/contact-list-tab.container.js index 5bd3c2251..bfe64fa68 100644 --- a/ui/app/pages/settings/contact-list-tab/contact-list-tab.container.js +++ b/ui/app/pages/settings/contact-list-tab/contact-list-tab.container.js @@ -2,7 +2,7 @@ import ContactListTab from './contact-list-tab.component' import { compose } from 'redux' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' -import { getAddressBook } from '../../../selectors/selectors' +import { getAddressBook } from '../../../selectors' import { ENVIRONMENT_TYPE_POPUP } from '../../../../../app/scripts/lib/enums' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' diff --git a/ui/app/pages/settings/contact-list-tab/edit-contact/edit-contact.container.js b/ui/app/pages/settings/contact-list-tab/edit-contact/edit-contact.container.js index 0cf37ee49..4959f70ee 100644 --- a/ui/app/pages/settings/contact-list-tab/edit-contact/edit-contact.container.js +++ b/ui/app/pages/settings/contact-list-tab/edit-contact/edit-contact.container.js @@ -2,7 +2,7 @@ import EditContact from './edit-contact.component' import { compose } from 'redux' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' -import { getAddressBookEntry } from '../../../../selectors/selectors' +import { getAddressBookEntry } from '../../../../selectors' import { CONTACT_VIEW_ROUTE, CONTACT_MY_ACCOUNTS_ROUTE, diff --git a/ui/app/pages/settings/contact-list-tab/my-accounts/my-accounts.container.js b/ui/app/pages/settings/contact-list-tab/my-accounts/my-accounts.container.js index 962bd989d..8790125ae 100644 --- a/ui/app/pages/settings/contact-list-tab/my-accounts/my-accounts.container.js +++ b/ui/app/pages/settings/contact-list-tab/my-accounts/my-accounts.container.js @@ -2,7 +2,7 @@ import ViewContact from './my-accounts.component' import { compose } from 'redux' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' -import { accountsWithSendEtherInfoSelector } from '../../../../selectors/selectors' +import { accountsWithSendEtherInfoSelector } from '../../../../selectors' const mapStateToProps = (state,) => { const myAccounts = accountsWithSendEtherInfoSelector(state) diff --git a/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.container.js b/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.container.js index 4384b9297..e69df8536 100644 --- a/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.container.js +++ b/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.container.js @@ -2,7 +2,7 @@ import ViewContact from './view-contact.component' import { compose } from 'redux' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' -import { getAddressBookEntry } from '../../../../selectors/selectors' +import { getAddressBookEntry } from '../../../../selectors' import { checksumAddress } from '../../../../helpers/utils/util' import { CONTACT_EDIT_ROUTE, diff --git a/ui/app/pages/settings/settings-tab/settings-tab.container.js b/ui/app/pages/settings/settings-tab/settings-tab.container.js index ff7d9c658..b27b2e553 100644 --- a/ui/app/pages/settings/settings-tab/settings-tab.container.js +++ b/ui/app/pages/settings/settings-tab/settings-tab.container.js @@ -7,7 +7,7 @@ import { setUseNativeCurrencyAsPrimaryCurrencyPreference, setParticipateInMetaMetrics, } from '../../../store/actions' -import { preferencesSelector } from '../../../selectors/selectors' +import { preferencesSelector } from '../../../selectors' const mapStateToProps = (state) => { const { appState: { warning }, metamask } = state diff --git a/ui/app/pages/settings/settings.container.js b/ui/app/pages/settings/settings.container.js index a10b4ca7e..8d2e7e9ff 100644 --- a/ui/app/pages/settings/settings.container.js +++ b/ui/app/pages/settings/settings.container.js @@ -2,7 +2,7 @@ import Settings from './settings.component' import { compose } from 'redux' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' -import { getAddressBookEntryName } from '../../selectors/selectors' +import { getAddressBookEntryName } from '../../selectors' import { isValidAddress } from '../../helpers/utils/util' import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums' import { getEnvironmentType } from '../../../../app/scripts/lib/util' diff --git a/ui/app/selectors/custom-gas.js b/ui/app/selectors/custom-gas.js index b3575b5d9..ea2e00d92 100644 --- a/ui/app/selectors/custom-gas.js +++ b/ui/app/selectors/custom-gas.js @@ -6,7 +6,7 @@ import { } from '../helpers/utils/conversion-util' import { getCurrentCurrency, getIsMainnet, preferencesSelector, -} from './selectors' +} from '.' import { formatCurrency, } from '../helpers/utils/confirm-tx.util' diff --git a/ui/app/selectors/index.js b/ui/app/selectors/index.js new file mode 100644 index 000000000..ee758f156 --- /dev/null +++ b/ui/app/selectors/index.js @@ -0,0 +1,6 @@ +export * from './confirm-transaction' +export * from './custom-gas' +export * from './permissions' +export * from './selectors' +export * from './tokens' +export * from './transactions' diff --git a/ui/app/selectors/permissions.js b/ui/app/selectors/permissions.js index ac47d5a05..e7800d925 100644 --- a/ui/app/selectors/permissions.js +++ b/ui/app/selectors/permissions.js @@ -1,3 +1,5 @@ +import { forOwn } from 'lodash' +import { getOriginOfCurrentTab } from './selectors' import { CAVEAT_NAMES, } from '../../../app/scripts/controllers/permissions/enums' @@ -25,7 +27,7 @@ export function getPermittedAccounts (state, origin) { * @returns {Object} Permitted accounts by origin. */ export function getPermittedAccountsByOrigin (state) { - const domains = getPermissionsDomains(state) + const domains = getPermissionDomains(state) return Object.keys(domains).reduce((acc, domainKey) => { const accounts = getAccountsFromPermission( getAccountsPermissionFromDomain(domains[domainKey]) @@ -37,8 +39,75 @@ export function getPermittedAccountsByOrigin (state) { }, {}) } +export function getConnectedDomainsForSelectedAddress (state) { + const { + selectedAddress, + } = state.metamask + const domains = getPermissionDomains(state) + const domainMetadata = getPermissionDomainsMetadata(state) + + const connectedDomains = [] + + forOwn(domains, (domainValue, domainKey) => { + const exposedAccounts = getAccountsFromDomain(domainValue) + if (!exposedAccounts.includes(selectedAddress)) { + return + } + + const { + extensionId, + name, + icon, + } = domainMetadata[domainKey] || {} + + connectedDomains.push({ + extensionId, + key: domainKey, + name, + icon, + }) + }) + + return connectedDomains +} + +export function getPermittedAccountsForCurrentTab (state) { + const permittedAccountsMap = getPermittedAccountsByOrigin(state) + const originOfCurrentTab = getOriginOfCurrentTab(state) + return permittedAccountsMap[originOfCurrentTab] || [] +} + +export function getAddressConnectedDomainMap (state) { + const domainMetadata = getPermissionDomainsMetadata(state) + + const accountsMap = getPermittedAccountsByOrigin(state) + const addressConnectedIconMap = {} + + Object.keys(accountsMap).forEach((domainKey) => { + + const { icon, name } = domainMetadata[domainKey] || {} + + accountsMap[domainKey].forEach((address) => { + + const nameToRender = name || domainKey + + addressConnectedIconMap[address] = addressConnectedIconMap[address] + ? { ...addressConnectedIconMap[address], [domainKey]: { icon, name: nameToRender } } + : { [domainKey]: { icon, name: nameToRender } } + }) + }) + + return addressConnectedIconMap +} + // selector helpers +function getAccountsFromDomain (domain) { + return getAccountsFromPermission( + getAccountsPermissionFromDomain(domain) + ) +} + function getAccountsPermissionFromDomain (domain = {}) { return ( Array.isArray(domain.permissions) @@ -67,10 +136,14 @@ function getAccountsCaveatFromPermission (accountsPermission = {}) { ) } -export function getPermissionsDomains (state) { +export function getPermissionDomains (state) { return state.metamask.domains || {} } -function domainSelector (state, origin) { - return origin && state.metamask.domains && state.metamask.domains[origin] +export function getPermissionDomainsMetadata (state) { + return state.metamask.domainMetadata || {} +} + +function domainSelector (state, origin) { + return origin && state.metamask?.domains[origin] } diff --git a/ui/app/selectors/selectors.js b/ui/app/selectors/selectors.js index bfde89f5e..b144a7f88 100644 --- a/ui/app/selectors/selectors.js +++ b/ui/app/selectors/selectors.js @@ -1,10 +1,8 @@ -import { flatten, forOwn } from 'lodash' 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 { multiplyCurrencies } from '../helpers/utils/conversion-util' import { shortenAddress, checksumAddress, @@ -12,8 +10,6 @@ import { getAccountByAddress, } from '../helpers/utils/util' -import { getPermittedAccountsByOrigin } from './permissions' - export function getNetworkIdentifier (state) { const { metamask: { provider: { type, nickname, rpcTarget } } } = state @@ -193,10 +189,6 @@ export function getTokenExchangeRate (state, address) { return contractExchangeRates[address] || 0 } -export function conversionRateSelector (state) { - return state.metamask.conversionRate -} - export function getAddressBook (state) { const network = state.metamask.network if (!state.metamask.addressBook[network]) { @@ -272,23 +264,6 @@ export function getCurrentCurrency (state) { return state.metamask.currentCurrency } -export function getNativeCurrency (state) { - return state.metamask.nativeCurrency -} - -export function getSelectedTokenToFiatRate (state) { - const selectedTokenExchangeRate = getSelectedTokenExchangeRate(state) - const conversionRate = conversionRateSelector(state) - - const tokenToFiatRate = multiplyCurrencies( - conversionRate, - selectedTokenExchangeRate, - { toNumericBase: 'dec' } - ) - - return tokenToFiatRate -} - export function getSelectedTokenContract (state) { const selectedToken = getSelectedToken(state) return selectedToken @@ -429,33 +404,6 @@ export function hasPermissionRequests (state) { return Boolean(getFirstPermissionRequest(state)) } -export function getAddressConnectedDomainMap (state) { - const { - domainMetadata, - } = state.metamask - - const accountsMap = getPermittedAccountsByOrigin(state) - const addressConnectedIconMap = {} - - Object.keys(accountsMap).forEach((domainKey) => { - const { icon, name } = domainMetadata[domainKey] || {} - accountsMap[domainKey].forEach((address) => { - const nameToRender = name || domainKey - addressConnectedIconMap[address] = addressConnectedIconMap[address] - ? { ...addressConnectedIconMap[address], [domainKey]: { icon, name: nameToRender } } - : { [domainKey]: { icon, name: nameToRender } } - }) - }) - - return addressConnectedIconMap -} - -export function getPermittedAccountsForCurrentTab (state) { - const permittedAccountsMap = getPermittedAccountsByOrigin(state) - const originOfCurrentTab = getOriginOfCurrentTab(state) - return permittedAccountsMap[originOfCurrentTab] || [] -} - export function getOriginOfCurrentTab (state) { const { activeTab } = state return activeTab && activeTab.url && getOriginFromUrl(activeTab.url) @@ -476,37 +424,3 @@ export function getLastConnectedInfo (state) { export function getIpfsGateway (state) { return state.metamask.ipfsGateway } - -export function getConnectedDomainsForSelectedAddress (state) { - const { - domains = {}, - domainMetadata, - selectedAddress, - } = state.metamask - - const connectedDomains = [] - - forOwn(domains, (value, domain) => { - const exposedAccounts = flatten(value.permissions.map( - (p) => p.caveats?.find(({ name }) => name === 'exposedAccounts').value || [] - )) - if (!exposedAccounts.includes(selectedAddress)) { - return - } - - const { - extensionId, - name, - icon, - } = domainMetadata[domain] || {} - - connectedDomains.push({ - extensionId, - key: domain, - name, - icon, - }) - }) - - return connectedDomains -} diff --git a/ui/app/selectors/custom-gas.test.js b/ui/app/selectors/tests/custom-gas.test.js similarity index 99% rename from ui/app/selectors/custom-gas.test.js rename to ui/app/selectors/tests/custom-gas.test.js index a3481808d..5b9c5db53 100644 --- a/ui/app/selectors/custom-gas.test.js +++ b/ui/app/selectors/tests/custom-gas.test.js @@ -11,7 +11,7 @@ const { getPriceAndTimeEstimates, getRenderableBasicEstimateData, getRenderableEstimateDataForSmallButtonsFromGWEI, -} = proxyquire('./custom-gas', {}) +} = proxyquire('../custom-gas', {}) describe('custom-gas selectors', function () { diff --git a/ui/app/selectors/tests/permissions.test.js b/ui/app/selectors/tests/permissions.test.js new file mode 100644 index 000000000..3217ba10e --- /dev/null +++ b/ui/app/selectors/tests/permissions.test.js @@ -0,0 +1,156 @@ +import assert from 'assert' +import { getConnectedDomainsForSelectedAddress } from '../permissions' + +describe('selectors', function () { + + describe('getConnectedDomainsForSelectedAddress', function () { + it('should return the list of connected domains when there is 1 connected account', function () { + const mockState = { + metamask: { + selectedAddress: '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', + domainMetadata: { + 'peepeth.com': { + 'icon': 'https://peepeth.com/favicon-32x32.png', + 'name': 'Peepeth', + }, + 'remix.ethereum.org': { + 'icon': 'https://remix.ethereum.org/icon.png', + 'name': 'Remix - Ethereum IDE', + }, + }, + domains: { + 'peepeth.com': { + 'permissions': [ + { + '@context': [ + 'https://github.com/MetaMask/rpc-cap', + ], + 'caveats': [ + { + 'name': 'exposedAccounts', + 'type': 'filterResponse', + 'value': [ + '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', + ], + }, + ], + 'date': 1585676177970, + 'id': '840d72a0-925f-449f-830a-1aa1dd5ce151', + 'invoker': 'peepeth.com', + 'parentCapability': 'eth_accounts', + }, + ], + }, + 'remix.ethereum.org': { + 'permissions': [ + { + '@context': [ + 'https://github.com/MetaMask/rpc-cap', + ], + 'caveats': [ + { + 'type': 'filterResponse', + 'value': [ + '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', + ], + 'name': 'exposedAccounts', + }, + ], + 'date': 1585685128948, + 'id': '6b9615cc-64e4-4317-afab-3c4f8ee0244a', + 'invoker': 'remix.ethereum.org', + 'parentCapability': 'eth_accounts', + }, + ], + }, + }, + }, + } + const extensionId = undefined + assert.deepEqual(getConnectedDomainsForSelectedAddress(mockState), [{ + extensionId, + icon: 'https://peepeth.com/favicon-32x32.png', + key: 'peepeth.com', + name: 'Peepeth', + }, { + extensionId, + name: 'Remix - Ethereum IDE', + icon: 'https://remix.ethereum.org/icon.png', + key: 'remix.ethereum.org', + }]) + }) + + it('should return the list of connected domains when there are 2 connected accounts', function () { + const mockState = { + metamask: { + selectedAddress: '0x7250739de134d33ec7ab1ee592711e15098c9d2d', + domainMetadata: { + 'peepeth.com': { + 'icon': 'https://peepeth.com/favicon-32x32.png', + 'name': 'Peepeth', + }, + 'remix.ethereum.org': { + 'icon': 'https://remix.ethereum.org/icon.png', + 'name': 'Remix - Ethereum IDE', + }, + }, + domains: { + 'peepeth.com': { + 'permissions': [ + { + '@context': [ + 'https://github.com/MetaMask/rpc-cap', + ], + 'caveats': [ + { + 'name': 'exposedAccounts', + 'type': 'filterResponse', + 'value': [ + '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', + ], + }, + ], + 'date': 1585676177970, + 'id': '840d72a0-925f-449f-830a-1aa1dd5ce151', + 'invoker': 'peepeth.com', + 'parentCapability': 'eth_accounts', + }, + ], + }, + 'remix.ethereum.org': { + 'permissions': [ + { + '@context': [ + 'https://github.com/MetaMask/rpc-cap', + ], + 'caveats': [ + { + 'type': 'filterResponse', + 'value': [ + '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', + '0x7250739de134d33ec7ab1ee592711e15098c9d2d', + ], + 'name': 'exposedAccounts', + }, + ], + 'date': 1585685128948, + 'id': '6b9615cc-64e4-4317-afab-3c4f8ee0244a', + 'invoker': 'remix.ethereum.org', + 'parentCapability': 'eth_accounts', + }, + ], + }, + }, + }, + } + const extensionId = undefined + assert.deepEqual(getConnectedDomainsForSelectedAddress(mockState), [{ + extensionId, + name: 'Remix - Ethereum IDE', + icon: 'https://remix.ethereum.org/icon.png', + key: 'remix.ethereum.org', + }]) + }) + }) + +}) diff --git a/ui/app/selectors/tests/selectors.test.js b/ui/app/selectors/tests/selectors.test.js index 5dbe2018d..b86d33b82 100644 --- a/ui/app/selectors/tests/selectors.test.js +++ b/ui/app/selectors/tests/selectors.test.js @@ -1,5 +1,5 @@ import assert from 'assert' -import { getAddressBook, getConnectedDomainsForSelectedAddress } from '../selectors.js' +import { getAddressBook } from '../selectors' import mockState from './selectors-test-data' describe('selectors', function () { @@ -20,155 +20,4 @@ describe('selectors', function () { ) }) }) - - describe('getConnectedDomainsForSelectedAddress', function () { - it('should return the list of connected domains when there is 1 connected account', function () { - const mockState = { - metamask: { - selectedAddress: '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', - domainMetadata: { - 'peepeth.com': { - 'icon': 'https://peepeth.com/favicon-32x32.png', - 'name': 'Peepeth', - }, - 'remix.ethereum.org': { - 'icon': 'https://remix.ethereum.org/icon.png', - 'name': 'Remix - Ethereum IDE', - }, - }, - domains: { - 'peepeth.com': { - 'permissions': [ - { - '@context': [ - 'https://github.com/MetaMask/rpc-cap', - ], - 'caveats': [ - { - 'name': 'exposedAccounts', - 'type': 'filterResponse', - 'value': [ - '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', - ], - }, - ], - 'date': 1585676177970, - 'id': '840d72a0-925f-449f-830a-1aa1dd5ce151', - 'invoker': 'peepeth.com', - 'parentCapability': 'eth_accounts', - }, - ], - }, - 'remix.ethereum.org': { - 'permissions': [ - { - '@context': [ - 'https://github.com/MetaMask/rpc-cap', - ], - 'caveats': [ - { - 'type': 'filterResponse', - 'value': [ - '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', - ], - 'name': 'exposedAccounts', - }, - ], - 'date': 1585685128948, - 'id': '6b9615cc-64e4-4317-afab-3c4f8ee0244a', - 'invoker': 'remix.ethereum.org', - 'parentCapability': 'eth_accounts', - }, - ], - }, - }, - }, - } - const extensionId = undefined - assert.deepEqual(getConnectedDomainsForSelectedAddress(mockState), [{ - extensionId, - icon: 'https://peepeth.com/favicon-32x32.png', - key: 'peepeth.com', - name: 'Peepeth', - }, { - extensionId, - name: 'Remix - Ethereum IDE', - icon: 'https://remix.ethereum.org/icon.png', - key: 'remix.ethereum.org', - }]) - }) - - it('should return the list of connected domains when there are 2 connected accounts', function () { - const mockState = { - metamask: { - selectedAddress: '0x7250739de134d33ec7ab1ee592711e15098c9d2d', - domainMetadata: { - 'peepeth.com': { - 'icon': 'https://peepeth.com/favicon-32x32.png', - 'name': 'Peepeth', - }, - 'remix.ethereum.org': { - 'icon': 'https://remix.ethereum.org/icon.png', - 'name': 'Remix - Ethereum IDE', - }, - }, - domains: { - 'peepeth.com': { - 'permissions': [ - { - '@context': [ - 'https://github.com/MetaMask/rpc-cap', - ], - 'caveats': [ - { - 'name': 'exposedAccounts', - 'type': 'filterResponse', - 'value': [ - '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', - ], - }, - ], - 'date': 1585676177970, - 'id': '840d72a0-925f-449f-830a-1aa1dd5ce151', - 'invoker': 'peepeth.com', - 'parentCapability': 'eth_accounts', - }, - ], - }, - 'remix.ethereum.org': { - 'permissions': [ - { - '@context': [ - 'https://github.com/MetaMask/rpc-cap', - ], - 'caveats': [ - { - 'type': 'filterResponse', - 'value': [ - '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5', - '0x7250739de134d33ec7ab1ee592711e15098c9d2d', - ], - 'name': 'exposedAccounts', - }, - ], - 'date': 1585685128948, - 'id': '6b9615cc-64e4-4317-afab-3c4f8ee0244a', - 'invoker': 'remix.ethereum.org', - 'parentCapability': 'eth_accounts', - }, - ], - }, - }, - }, - } - const extensionId = undefined - assert.deepEqual(getConnectedDomainsForSelectedAddress(mockState), [{ - extensionId, - name: 'Remix - Ethereum IDE', - icon: 'https://remix.ethereum.org/icon.png', - key: 'remix.ethereum.org', - }]) - }) - }) - }) diff --git a/ui/app/selectors/transactions.js b/ui/app/selectors/transactions.js index caa32f51b..2c740c98e 100644 --- a/ui/app/selectors/transactions.js +++ b/ui/app/selectors/transactions.js @@ -15,7 +15,7 @@ import { getFastPriceEstimateInHexWEI } from './custom-gas' import { getSelectedToken, getSelectedAddress, -} from './selectors' +} from '.' import txHelper from '../../lib/tx-helper' export const incomingTxListSelector = (state) => { diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index 1f2871001..9b23ed774 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -18,7 +18,7 @@ import actionConstants from './actionConstants' import { getPermittedAccountsForCurrentTab, getSelectedAddress, -} from '../selectors/selectors' +} from '../selectors' import { switchedToUnconnectedAccount } from '../ducks/alerts/unconnected-account' let background = null