mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 17:33:23 +01:00
Reorganize selectors directory (#8497)
This commit is contained in:
parent
11aa4029e8
commit
786e82791e
@ -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'
|
import { sendMetaMetricsEvent } from '../../../ui/app/helpers/utils/metametrics.util'
|
||||||
|
|
||||||
const inDevelopment = process.env.NODE_ENV === 'development'
|
const inDevelopment = process.env.NODE_ENV === 'development'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import assert from 'assert'
|
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 mockState from '../../../data/mock-state.json'
|
||||||
import Eth from 'ethjs'
|
import Eth from 'ethjs'
|
||||||
import { createTestProviderTools } from '../../../stub/provider'
|
import { createTestProviderTools } from '../../../stub/provider'
|
||||||
@ -120,11 +120,6 @@ describe('Selectors', function () {
|
|||||||
assert.equal(currentCurrency, 'usd')
|
assert.equal(currentCurrency, 'usd')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getSelectedTokenToFiatRate', function () {
|
|
||||||
const selectedTokenToFiatRate = selectors.getSelectedTokenToFiatRate(mockState)
|
|
||||||
assert.equal(selectedTokenToFiatRate, '0.21880988420033492152')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('#getSelectedTokenContract', function () {
|
it('#getSelectedTokenContract', function () {
|
||||||
global.eth = new Eth(provider)
|
global.eth = new Eth(provider)
|
||||||
const selectedTokenContract = selectors.getSelectedTokenContract(mockState)
|
const selectedTokenContract = selectors.getSelectedTokenContract(mockState)
|
||||||
|
@ -15,7 +15,7 @@ import {
|
|||||||
getMetaMaskKeyrings,
|
getMetaMaskKeyrings,
|
||||||
getOriginOfCurrentTab,
|
getOriginOfCurrentTab,
|
||||||
getSelectedAddress,
|
getSelectedAddress,
|
||||||
} from '../../../selectors/selectors'
|
} from '../../../selectors'
|
||||||
import AccountMenu from './account-menu.component'
|
import AccountMenu from './account-menu.component'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,7 @@ import { withRouter } from 'react-router-dom'
|
|||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
import AssetList from './asset-list.component'
|
import AssetList from './asset-list.component'
|
||||||
import { setSelectedToken } from '../../../store/actions'
|
import { setSelectedToken } from '../../../store/actions'
|
||||||
import { getSelectedAccount } from '../../../selectors/selectors'
|
import { getSelectedAccount } from '../../../selectors'
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
getAddressConnectedDomainMap,
|
getAddressConnectedDomainMap,
|
||||||
getOriginOfCurrentTab,
|
getOriginOfCurrentTab,
|
||||||
getSelectedAddress,
|
getSelectedAddress,
|
||||||
} from '../../../selectors/selectors'
|
} from '../../../selectors'
|
||||||
|
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
|
@ -3,7 +3,7 @@ import { withRouter } from 'react-router-dom'
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import AccountDetailsDropdown from './account-details-dropdown.component'
|
import AccountDetailsDropdown from './account-details-dropdown.component'
|
||||||
import * as actions from '../../../../store/actions'
|
import * as actions from '../../../../store/actions'
|
||||||
import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors/selectors'
|
import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors'
|
||||||
import genAccountLink from '../../../../../lib/account-link.js'
|
import genAccountLink from '../../../../../lib/account-link.js'
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
|
@ -31,8 +31,6 @@ import {
|
|||||||
getSelectedToken,
|
getSelectedToken,
|
||||||
isEthereumNetwork,
|
isEthereumNetwork,
|
||||||
preferencesSelector,
|
preferencesSelector,
|
||||||
} from '../../../../selectors/selectors.js'
|
|
||||||
import {
|
|
||||||
getBasicGasEstimateLoadingStatus,
|
getBasicGasEstimateLoadingStatus,
|
||||||
getGasEstimatesLoadingStatus,
|
getGasEstimatesLoadingStatus,
|
||||||
getCustomGasLimit,
|
getCustomGasLimit,
|
||||||
@ -42,11 +40,9 @@ import {
|
|||||||
getEstimatedGasTimes,
|
getEstimatedGasTimes,
|
||||||
getRenderableBasicEstimateData,
|
getRenderableBasicEstimateData,
|
||||||
getBasicGasEstimateBlockTime,
|
getBasicGasEstimateBlockTime,
|
||||||
isCustomPriceSafe,
|
|
||||||
} from '../../../../selectors/custom-gas'
|
|
||||||
import {
|
|
||||||
getTxParams,
|
getTxParams,
|
||||||
} from '../../../../selectors/transactions'
|
isCustomPriceSafe,
|
||||||
|
} from '../../../../selectors'
|
||||||
import {
|
import {
|
||||||
getTokenBalance,
|
getTokenBalance,
|
||||||
} from '../../../../pages/send/send.selectors'
|
} from '../../../../pages/send/send.selectors'
|
||||||
|
@ -35,19 +35,17 @@ proxyquire('../gas-modal-page-container.container.js', {
|
|||||||
return () => ({})
|
return () => ({})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'../../../../selectors/custom-gas': {
|
'../../../../selectors/': {
|
||||||
getBasicGasEstimateLoadingStatus: (s) => `mockBasicGasEstimateLoadingStatus:${Object.keys(s).length}`,
|
getBasicGasEstimateLoadingStatus: (s) => `mockBasicGasEstimateLoadingStatus:${Object.keys(s).length}`,
|
||||||
getRenderableBasicEstimateData: (s) => `mockRenderableBasicEstimateData:${Object.keys(s).length}`,
|
getRenderableBasicEstimateData: (s) => `mockRenderableBasicEstimateData:${Object.keys(s).length}`,
|
||||||
getDefaultActiveButtonIndex: (a, b) => a + b,
|
getDefaultActiveButtonIndex: (a, b) => a + b,
|
||||||
|
getCurrentEthBalance: (state) => state.metamask.balance || '0x0',
|
||||||
|
getSelectedToken: () => null,
|
||||||
},
|
},
|
||||||
'../../../../store/actions': actionSpies,
|
'../../../../store/actions': actionSpies,
|
||||||
'../../../../ducks/gas/gas.duck': gasActionSpies,
|
'../../../../ducks/gas/gas.duck': gasActionSpies,
|
||||||
'../../../../ducks/confirm-transaction/confirm-transaction.duck': confirmTransactionActionSpies,
|
'../../../../ducks/confirm-transaction/confirm-transaction.duck': confirmTransactionActionSpies,
|
||||||
'../../../../ducks/send/send.duck': sendActionSpies,
|
'../../../../ducks/send/send.duck': sendActionSpies,
|
||||||
'../../../../selectors/selectors.js': {
|
|
||||||
getCurrentEthBalance: (state) => state.metamask.balance || '0x0',
|
|
||||||
getSelectedToken: () => null,
|
|
||||||
},
|
|
||||||
'../../../../pages/send/send.selectors': {
|
'../../../../pages/send/send.selectors': {
|
||||||
getTokenBalance: (state) => state.metamask.send.tokenBalance || '0x0',
|
getTokenBalance: (state) => state.metamask.send.tokenBalance || '0x0',
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import LoadingNetworkScreen from './loading-network-screen.component'
|
import LoadingNetworkScreen from './loading-network-screen.component'
|
||||||
import * as actions from '../../../store/actions'
|
import * as actions from '../../../store/actions'
|
||||||
import { getNetworkIdentifier } from '../../../selectors/selectors'
|
import { getNetworkIdentifier } from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
const {
|
const {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { showModal, setAccountLabel } from '../../../../store/actions'
|
import { showModal, setAccountLabel } from '../../../../store/actions'
|
||||||
import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors/selectors'
|
import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors'
|
||||||
import AccountDetailsModal from './account-details-modal.component'
|
import AccountDetailsModal from './account-details-modal.component'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { hideModal } from '../../../../store/actions'
|
import { hideModal } from '../../../../store/actions'
|
||||||
import { getSelectedIdentity } from '../../../../selectors/selectors'
|
import { getSelectedIdentity } from '../../../../selectors'
|
||||||
import AccountModalContainer from './account-modal-container.component'
|
import AccountModalContainer from './account-modal-container.component'
|
||||||
|
|
||||||
function mapStateToProps (state, ownProps) {
|
function mapStateToProps (state, ownProps) {
|
||||||
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux'
|
|||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
import withModalProps from '../../../../helpers/higher-order-components/with-modal-props'
|
import withModalProps from '../../../../helpers/higher-order-components/with-modal-props'
|
||||||
import EditApprovalPermission from './edit-approval-permission.component'
|
import EditApprovalPermission from './edit-approval-permission.component'
|
||||||
import { getSelectedIdentity } from '../../../../selectors/selectors'
|
import { getSelectedIdentity } from '../../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
const modalStateProps = state.appState.modal.modalState.props || {}
|
const modalStateProps = state.appState.modal.modalState.props || {}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { exportAccount, hideWarning, showModal, hideModal } from '../../../../store/actions'
|
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'
|
import ExportPrivateKeyModal from './export-private-key-modal.component'
|
||||||
|
|
||||||
function mapStateToPropsFactory () {
|
function mapStateToPropsFactory () {
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
getPermissionsDescriptions,
|
getPermissionsDescriptions,
|
||||||
getTargetDomainMetadata,
|
getTargetDomainMetadata,
|
||||||
getMetaMaskIdentities,
|
getMetaMaskIdentities,
|
||||||
} from '../../../selectors/selectors'
|
} from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
const { request, cachedOrigin, selectedIdentities } = ownProps
|
const { request, cachedOrigin, selectedIdentities } = ownProps
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import SelectedAccount from './selected-account.component'
|
import SelectedAccount from './selected-account.component'
|
||||||
|
|
||||||
import { getSelectedIdentity } from '../../../selectors/selectors'
|
import { getSelectedIdentity } from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
return {
|
return {
|
||||||
|
@ -6,7 +6,7 @@ import { goHome } from '../../../store/actions'
|
|||||||
import {
|
import {
|
||||||
accountsWithSendEtherInfoSelector,
|
accountsWithSendEtherInfoSelector,
|
||||||
conversionRateSelector,
|
conversionRateSelector,
|
||||||
} from '../../../selectors/selectors.js'
|
} from '../../../selectors'
|
||||||
import { getAccountByAddress } from '../../../helpers/utils/util'
|
import { getAccountByAddress } from '../../../helpers/utils/util'
|
||||||
import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck'
|
import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck'
|
||||||
import SignatureRequestOriginal from './signature-request-original.component'
|
import SignatureRequestOriginal from './signature-request-original.component'
|
||||||
|
@ -3,7 +3,7 @@ import SignatureRequest from './signature-request.component'
|
|||||||
import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck'
|
import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck'
|
||||||
import {
|
import {
|
||||||
accountsWithSendEtherInfoSelector,
|
accountsWithSendEtherInfoSelector,
|
||||||
} from '../../../selectors/selectors.js'
|
} from '../../../selectors'
|
||||||
import { getAccountByAddress } from '../../../helpers/utils/util'
|
import { getAccountByAddress } from '../../../helpers/utils/util'
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import TokenCell from './token-cell.component'
|
import TokenCell from './token-cell.component'
|
||||||
import { getSelectedAddress } from '../../../selectors/selectors'
|
import { getSelectedAddress } from '../../../selectors'
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { getSelectedAddress } from '../../../selectors/selectors'
|
import { getSelectedAddress } from '../../../selectors'
|
||||||
import TokenList from './token-list.component'
|
import TokenList from './token-list.component'
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import R from 'ramda'
|
import R from 'ramda'
|
||||||
import TransactionActivityLog from './transaction-activity-log.component'
|
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 { combineTransactionHistories } from './transaction-activity-log.util'
|
||||||
import {
|
import {
|
||||||
TRANSACTION_RESUBMITTED_EVENT,
|
TRANSACTION_RESUBMITTED_EVENT,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import TransactionBreakdown from './transaction-breakdown.component'
|
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 { getHexGasTotal } from '../../../helpers/utils/confirm-tx.util'
|
||||||
import { sumHexes } from '../../../helpers/utils/transactions.util'
|
import { sumHexes } from '../../../helpers/utils/transactions.util'
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux'
|
|||||||
import TransactionListItemDetails from './transaction-list-item-details.component'
|
import TransactionListItemDetails from './transaction-list-item-details.component'
|
||||||
import { checksumAddress } from '../../../helpers/utils/util'
|
import { checksumAddress } from '../../../helpers/utils/util'
|
||||||
import { tryReverseResolveAddress } from '../../../store/actions'
|
import { tryReverseResolveAddress } from '../../../store/actions'
|
||||||
import { getAddressBook } from '../../../selectors/selectors'
|
import { getAddressBook } from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
const { metamask } = state
|
const { metamask } = state
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
conversionRateSelector,
|
conversionRateSelector,
|
||||||
getKnownMethodData,
|
getKnownMethodData,
|
||||||
getFeatureFlags,
|
getFeatureFlags,
|
||||||
} from '../../../selectors/selectors'
|
} from '../../../selectors'
|
||||||
import { isBalanceSufficient } from '../../../pages/send/send.utils'
|
import { isBalanceSufficient } from '../../../pages/send/send.utils'
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
|
@ -2,11 +2,13 @@ import { connect } from 'react-redux'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import TransactionList from './transaction-list.component'
|
import TransactionList from './transaction-list.component'
|
||||||
import {
|
import {
|
||||||
|
getAssetImages,
|
||||||
|
getFeatureFlags,
|
||||||
|
getSelectedAddress,
|
||||||
|
selectedTokenSelector,
|
||||||
nonceSortedCompletedTransactionsSelector,
|
nonceSortedCompletedTransactionsSelector,
|
||||||
nonceSortedPendingTransactionsSelector,
|
nonceSortedPendingTransactionsSelector,
|
||||||
} from '../../../selectors/transactions'
|
} from '../../../selectors'
|
||||||
import { getSelectedAddress, getAssetImages, getFeatureFlags } from '../../../selectors/selectors'
|
|
||||||
import { selectedTokenSelector } from '../../../selectors/tokens'
|
|
||||||
import { fetchBasicGasAndTimeEstimates, fetchGasEstimates } from '../../../ducks/gas/gas.duck'
|
import { fetchBasicGasAndTimeEstimates, fetchGasEstimates } from '../../../ducks/gas/gas.duck'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import TransactionTimeRemaining from './transaction-time-remaining.component'
|
import TransactionTimeRemaining from './transaction-time-remaining.component'
|
||||||
import {
|
|
||||||
getTxParams,
|
|
||||||
} from '../../../selectors/transactions'
|
|
||||||
import {
|
import {
|
||||||
getEstimatedGasPrices,
|
getEstimatedGasPrices,
|
||||||
getEstimatedGasTimes,
|
getEstimatedGasTimes,
|
||||||
} from '../../../selectors/custom-gas'
|
getTxParams,
|
||||||
|
} from '../../../selectors'
|
||||||
import { getRawTimeEstimateData } from '../../../helpers/utils/gas-time-estimates.util'
|
import { getRawTimeEstimateData } from '../../../helpers/utils/gas-time-estimates.util'
|
||||||
import { hexWEIToDecGWEI } from '../../../helpers/utils/conversions.util'
|
import { hexWEIToDecGWEI } from '../../../helpers/utils/conversions.util'
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
isBalanceCached,
|
isBalanceCached,
|
||||||
preferencesSelector,
|
preferencesSelector,
|
||||||
getIsMainnet,
|
getIsMainnet,
|
||||||
} from '../../../selectors/selectors'
|
} from '../../../selectors'
|
||||||
import { showModal } from '../../../store/actions'
|
import { showModal } from '../../../store/actions'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import UserPreferencedCurrencyDisplay from './user-preferenced-currency-display.component'
|
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'
|
import { ETH, PRIMARY, SECONDARY } from '../../../helpers/constants/common'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import UserPreferencedCurrencyInput from './user-preferenced-currency-input.component'
|
import UserPreferencedCurrencyInput from './user-preferenced-currency-input.component'
|
||||||
import { preferencesSelector } from '../../../selectors/selectors'
|
import { preferencesSelector } from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
const { useNativeCurrencyAsPrimaryCurrency } = preferencesSelector(state)
|
const { useNativeCurrencyAsPrimaryCurrency } = preferencesSelector(state)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import UserPreferencedTokenInput from './user-preferenced-token-input.component'
|
import UserPreferencedTokenInput from './user-preferenced-token-input.component'
|
||||||
import { preferencesSelector } from '../../../selectors/selectors'
|
import { preferencesSelector } from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
const { useNativeCurrencyAsPrimaryCurrency } = preferencesSelector(state)
|
const { useNativeCurrencyAsPrimaryCurrency } = preferencesSelector(state)
|
||||||
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux'
|
|||||||
import { withRouter } from 'react-router-dom'
|
import { withRouter } from 'react-router-dom'
|
||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
import WalletView from './wallet-view.component'
|
import WalletView from './wallet-view.component'
|
||||||
import { getSelectedAddress } from '../../../selectors/selectors'
|
import { getSelectedAddress } from '../../../selectors'
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
getMetaMaskAccounts,
|
getMetaMaskAccounts,
|
||||||
getIsMainnet,
|
getIsMainnet,
|
||||||
preferencesSelector,
|
preferencesSelector,
|
||||||
} from '../../../selectors/selectors'
|
} from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
const { showFiatInTestnets } = preferencesSelector(state)
|
const { showFiatInTestnets } = preferencesSelector(state)
|
||||||
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux'
|
|||||||
import CurrencyInput from './currency-input.component'
|
import CurrencyInput from './currency-input.component'
|
||||||
import { ETH } from '../../../helpers/constants/common'
|
import { ETH } from '../../../helpers/constants/common'
|
||||||
import { getMaxModeOn } from '../../../pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.selectors'
|
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 mapStateToProps = (state) => {
|
||||||
const { metamask: { nativeCurrency, currentCurrency, conversionRate } } = state
|
const { metamask: { nativeCurrency, currentCurrency, conversionRate } } = state
|
||||||
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux'
|
|||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
import withTokenTracker from '../../../helpers/higher-order-components/with-token-tracker'
|
import withTokenTracker from '../../../helpers/higher-order-components/with-token-tracker'
|
||||||
import TokenBalance from './token-balance.component'
|
import TokenBalance from './token-balance.component'
|
||||||
import { getSelectedAddress } from '../../../selectors/selectors'
|
import { getSelectedAddress } from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
return {
|
return {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import TokenInput from './token-input.component'
|
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 mapStateToProps = (state) => {
|
||||||
const { metamask: { currentCurrency } } = state
|
const { metamask: { currentCurrency } } = state
|
||||||
|
@ -3,7 +3,7 @@ import { captureException } from '@sentry/browser'
|
|||||||
|
|
||||||
import actionConstants from '../../store/actionConstants'
|
import actionConstants from '../../store/actionConstants'
|
||||||
import { addPermittedAccount } from '../../store/actions'
|
import { addPermittedAccount } from '../../store/actions'
|
||||||
import { getOriginOfCurrentTab, getSelectedAddress } from '../../selectors/selectors'
|
import { getOriginOfCurrentTab, getSelectedAddress } from '../../selectors'
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import {
|
|||||||
currentCurrencySelector,
|
currentCurrencySelector,
|
||||||
unconfirmedTransactionsHashSelector,
|
unconfirmedTransactionsHashSelector,
|
||||||
getNativeCurrency,
|
getNativeCurrency,
|
||||||
} from '../../selectors/confirm-transaction'
|
} from '../../selectors'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getValueFromWeiHex,
|
getValueFromWeiHex,
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
} from '../../helpers/utils/conversions.util'
|
} from '../../helpers/utils/conversions.util'
|
||||||
import {
|
import {
|
||||||
isEthereumNetwork,
|
isEthereumNetwork,
|
||||||
} from '../../selectors/selectors'
|
} from '../../selectors'
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
const BASIC_GAS_ESTIMATE_LOADING_FINISHED = 'metamask/gas/BASIC_GAS_ESTIMATE_LOADING_FINISHED'
|
const BASIC_GAS_ESTIMATE_LOADING_FINISHED = 'metamask/gas/BASIC_GAS_ESTIMATE_LOADING_FINISHED'
|
||||||
|
@ -9,10 +9,10 @@ import {
|
|||||||
getAccountType,
|
getAccountType,
|
||||||
getNumberOfAccounts,
|
getNumberOfAccounts,
|
||||||
getNumberOfTokens,
|
getNumberOfTokens,
|
||||||
} from '../../../selectors/selectors'
|
|
||||||
import {
|
|
||||||
txDataSelector,
|
txDataSelector,
|
||||||
} from '../../../selectors/confirm-transaction'
|
} from '../../../selectors'
|
||||||
|
|
||||||
import { getEnvironmentType } from '../../../../../app/scripts/lib/util'
|
import { getEnvironmentType } from '../../../../../app/scripts/lib/util'
|
||||||
import {
|
import {
|
||||||
sendMetaMetricsEvent,
|
sendMetaMetricsEvent,
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
conversionGreaterThan,
|
conversionGreaterThan,
|
||||||
} from './conversion-util'
|
} from './conversion-util'
|
||||||
|
|
||||||
import { unconfirmedTransactionsCountSelector } from '../../selectors/confirm-transaction'
|
import { unconfirmedTransactionsCountSelector } from '../../selectors'
|
||||||
|
|
||||||
export function increaseLastGasPrice (lastGasPrice) {
|
export function increaseLastGasPrice (lastGasPrice) {
|
||||||
return ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice || '0x0', 1.1, {
|
return ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice || '0x0', 1.1, {
|
||||||
|
@ -3,10 +3,10 @@ import { compose } from 'redux'
|
|||||||
import { withRouter } from 'react-router-dom'
|
import { withRouter } from 'react-router-dom'
|
||||||
import {
|
import {
|
||||||
contractExchangeRateSelector,
|
contractExchangeRateSelector,
|
||||||
|
tokenSelector,
|
||||||
transactionFeeSelector,
|
transactionFeeSelector,
|
||||||
} from '../../selectors/confirm-transaction'
|
} from '../../selectors'
|
||||||
import { showModal } from '../../store/actions'
|
import { showModal } from '../../store/actions'
|
||||||
import { tokenSelector } from '../../selectors/tokens'
|
|
||||||
import {
|
import {
|
||||||
getTokenData,
|
getTokenData,
|
||||||
} from '../../helpers/utils/transactions.util'
|
} from '../../helpers/utils/transactions.util'
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
getTargetAccountWithSendEtherInfo,
|
getTargetAccountWithSendEtherInfo,
|
||||||
conversionRateSelector,
|
conversionRateSelector,
|
||||||
} from '../../selectors/selectors'
|
} from '../../selectors'
|
||||||
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'
|
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'
|
||||||
import ConfirmDecryptMessage from './confirm-decrypt-message.component'
|
import ConfirmDecryptMessage from './confirm-decrypt-message.component'
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
conversionRateSelector,
|
conversionRateSelector,
|
||||||
getTargetAccountWithSendEtherInfo,
|
getTargetAccountWithSendEtherInfo,
|
||||||
} from '../../selectors/selectors'
|
} from '../../selectors'
|
||||||
|
|
||||||
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'
|
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'
|
||||||
import ConfirmEncryptionPublicKey from './confirm-encryption-public-key.component'
|
import ConfirmEncryptionPublicKey from './confirm-encryption-public-key.component'
|
||||||
|
@ -5,7 +5,7 @@ import ConfirmSendToken from './confirm-send-token.component'
|
|||||||
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'
|
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'
|
||||||
import { setSelectedToken, updateSend, showSendTokenPage } from '../../store/actions'
|
import { setSelectedToken, updateSend, showSendTokenPage } from '../../store/actions'
|
||||||
import { conversionUtil } from '../../helpers/utils/conversion-util'
|
import { conversionUtil } from '../../helpers/utils/conversion-util'
|
||||||
import { sendTokenTokenAmountAndToAddressSelector } from '../../selectors/confirm-transaction'
|
import { sendTokenTokenAmountAndToAddressSelector } from '../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
const { tokenAmount } = sendTokenTokenAmountAndToAddressSelector(state)
|
const { tokenAmount } = sendTokenTokenAmountAndToAddressSelector(state)
|
||||||
|
@ -4,9 +4,9 @@ import { withRouter } from 'react-router-dom'
|
|||||||
import ConfirmTokenTransactionBase from './confirm-token-transaction-base.component'
|
import ConfirmTokenTransactionBase from './confirm-token-transaction-base.component'
|
||||||
import {
|
import {
|
||||||
contractExchangeRateSelector,
|
contractExchangeRateSelector,
|
||||||
|
tokenSelector,
|
||||||
transactionFeeSelector,
|
transactionFeeSelector,
|
||||||
} from '../../selectors/confirm-transaction'
|
} from '../../selectors'
|
||||||
import { tokenSelector } from '../../selectors/tokens'
|
|
||||||
import {
|
import {
|
||||||
getTokenData,
|
getTokenData,
|
||||||
} from '../../helpers/utils/transactions.util'
|
} from '../../helpers/utils/transactions.util'
|
||||||
|
@ -27,8 +27,16 @@ import { isBalanceSufficient, calcGasTotal } from '../send/send.utils'
|
|||||||
import { conversionGreaterThan } from '../../helpers/utils/conversion-util'
|
import { conversionGreaterThan } from '../../helpers/utils/conversion-util'
|
||||||
import { MIN_GAS_LIMIT_DEC } from '../send/send.constants'
|
import { MIN_GAS_LIMIT_DEC } from '../send/send.constants'
|
||||||
import { checksumAddress, shortenAddress, valuesFor } from '../../helpers/utils/util'
|
import { checksumAddress, shortenAddress, valuesFor } from '../../helpers/utils/util'
|
||||||
import { getMetaMaskAccounts, getCustomNonceValue, getUseNonceField, getAdvancedInlineGasShown, preferencesSelector, getIsMainnet, getKnownMethodData } from '../../selectors/selectors'
|
import {
|
||||||
import { transactionFeeSelector } from '../../selectors/confirm-transaction'
|
getAdvancedInlineGasShown,
|
||||||
|
getCustomNonceValue,
|
||||||
|
getIsMainnet,
|
||||||
|
getKnownMethodData,
|
||||||
|
getMetaMaskAccounts,
|
||||||
|
getUseNonceField,
|
||||||
|
preferencesSelector,
|
||||||
|
transactionFeeSelector,
|
||||||
|
} from '../../selectors'
|
||||||
|
|
||||||
const casedContractMap = Object.keys(contractMap).reduce((acc, base) => {
|
const casedContractMap = Object.keys(contractMap).reduce((acc, base) => {
|
||||||
return {
|
return {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import ConfirmTransactionSwitch from './confirm-transaction-switch.component'
|
import ConfirmTransactionSwitch from './confirm-transaction-switch.component'
|
||||||
import { unconfirmedTransactionsListSelector } from '../../selectors/confirm-transaction'
|
import { unconfirmedTransactionsListSelector } from '../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
const { metamask: { unapprovedTxs } } = state
|
const { metamask: { unapprovedTxs } } = state
|
||||||
|
@ -17,7 +17,7 @@ import {
|
|||||||
getTokenParams,
|
getTokenParams,
|
||||||
} from '../../store/actions'
|
} from '../../store/actions'
|
||||||
import ConfirmTransaction from './confirm-transaction.component'
|
import ConfirmTransaction from './confirm-transaction.component'
|
||||||
import { unconfirmedTransactionsListSelector } from '../../selectors/confirm-transaction'
|
import { unconfirmedTransactionsListSelector } from '../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
const {
|
const {
|
||||||
|
@ -10,12 +10,10 @@ import {
|
|||||||
getConnectedDomainsForSelectedAddress,
|
getConnectedDomainsForSelectedAddress,
|
||||||
getCurrentAccountWithSendEtherInfo,
|
getCurrentAccountWithSendEtherInfo,
|
||||||
getOriginOfCurrentTab,
|
getOriginOfCurrentTab,
|
||||||
getSelectedAddress,
|
getPermissionDomains,
|
||||||
} from '../../selectors/selectors'
|
|
||||||
import {
|
|
||||||
getPermissionsDomains,
|
|
||||||
getPermittedAccountsByOrigin,
|
getPermittedAccountsByOrigin,
|
||||||
} from '../../selectors/permissions'
|
getSelectedAddress,
|
||||||
|
} from '../../selectors'
|
||||||
import { DEFAULT_ROUTE } from '../../helpers/constants/routes'
|
import { DEFAULT_ROUTE } from '../../helpers/constants/routes'
|
||||||
import { getOriginFromUrl } from '../../helpers/utils/util'
|
import { getOriginFromUrl } from '../../helpers/utils/util'
|
||||||
|
|
||||||
@ -42,7 +40,7 @@ const mapStateToProps = (state) => {
|
|||||||
return {
|
return {
|
||||||
accountLabel: getCurrentAccountWithSendEtherInfo(state).name,
|
accountLabel: getCurrentAccountWithSendEtherInfo(state).name,
|
||||||
connectedDomains,
|
connectedDomains,
|
||||||
domains: getPermissionsDomains(state),
|
domains: getPermissionDomains(state),
|
||||||
permittedAccountsByOrigin,
|
permittedAccountsByOrigin,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
tabToConnect,
|
tabToConnect,
|
||||||
|
@ -2,7 +2,7 @@ import React, { Component } from 'react'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import * as actions from '../../../store/actions'
|
import * as actions from '../../../store/actions'
|
||||||
import { getMetaMaskAccounts } from '../../../selectors/selectors'
|
import { getMetaMaskAccounts } from '../../../selectors'
|
||||||
import ConnectScreen from './connect-screen'
|
import ConnectScreen from './connect-screen'
|
||||||
import AccountList from './account-list'
|
import AccountList from './account-list'
|
||||||
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'
|
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'
|
||||||
|
@ -6,7 +6,7 @@ import { connect } from 'react-redux'
|
|||||||
import * as actions from '../../../store/actions'
|
import * as actions from '../../../store/actions'
|
||||||
import FileInput from 'react-simple-file-input'
|
import FileInput from 'react-simple-file-input'
|
||||||
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'
|
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'
|
||||||
import { getMetaMaskAccounts } from '../../../selectors/selectors'
|
import { getMetaMaskAccounts } from '../../../selectors'
|
||||||
import Button from '../../../components/ui/button'
|
import Button from '../../../components/ui/button'
|
||||||
|
|
||||||
const HELP_LINK = 'https://metamask.zendesk.com/hc/en-us/articles/360015489331-Importing-an-Account'
|
const HELP_LINK = 'https://metamask.zendesk.com/hc/en-us/articles/360015489331-Importing-an-Account'
|
||||||
|
@ -5,7 +5,7 @@ import PropTypes from 'prop-types'
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import * as actions from '../../../store/actions'
|
import * as actions from '../../../store/actions'
|
||||||
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'
|
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'
|
||||||
import { getMetaMaskAccounts } from '../../../selectors/selectors'
|
import { getMetaMaskAccounts } from '../../../selectors'
|
||||||
import Button from '../../../components/ui/button'
|
import Button from '../../../components/ui/button'
|
||||||
|
|
||||||
class PrivateKeyImportView extends Component {
|
class PrivateKeyImportView extends Component {
|
||||||
|
@ -4,12 +4,12 @@ import { connect } from 'react-redux'
|
|||||||
import { withRouter } from 'react-router-dom'
|
import { withRouter } from 'react-router-dom'
|
||||||
import {
|
import {
|
||||||
unconfirmedTransactionsCountSelector,
|
unconfirmedTransactionsCountSelector,
|
||||||
} from '../../selectors/confirm-transaction'
|
|
||||||
import {
|
|
||||||
getCurrentEthBalance,
|
getCurrentEthBalance,
|
||||||
getFirstPermissionRequest,
|
getFirstPermissionRequest,
|
||||||
getTotalUnapprovedCount,
|
getTotalUnapprovedCount,
|
||||||
} from '../../selectors/selectors'
|
} from '../../selectors'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
restoreFromThreeBox,
|
restoreFromThreeBox,
|
||||||
turnThreeBoxSyncingOn,
|
turnThreeBoxSyncingOn,
|
||||||
|
@ -7,10 +7,10 @@ import {
|
|||||||
getAccountsWithLabels,
|
getAccountsWithLabels,
|
||||||
getLastConnectedInfo,
|
getLastConnectedInfo,
|
||||||
getTargetDomainMetadata,
|
getTargetDomainMetadata,
|
||||||
} from '../../selectors/selectors'
|
|
||||||
import {
|
getPermissionDomains,
|
||||||
getPermissionsDomains,
|
} from '../../selectors'
|
||||||
} from '../../selectors/permissions'
|
|
||||||
import { formatDate } from '../../helpers/utils/util'
|
import { formatDate } from '../../helpers/utils/util'
|
||||||
import { approvePermissionsRequest, rejectPermissionsRequest, showModal, getCurrentWindowTab, getRequestAccountTabIds } from '../../store/actions'
|
import { approvePermissionsRequest, rejectPermissionsRequest, showModal, getCurrentWindowTab, getRequestAccountTabIds } from '../../store/actions'
|
||||||
import {
|
import {
|
||||||
@ -63,7 +63,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
newAccountNumber: accountsWithLabels.length + 1,
|
newAccountNumber: accountsWithLabels.length + 1,
|
||||||
nativeCurrency,
|
nativeCurrency,
|
||||||
addressLastConnectedMap,
|
addressLastConnectedMap,
|
||||||
domains: getPermissionsDomains(state),
|
domains: getPermissionDomains(state),
|
||||||
connectPath,
|
connectPath,
|
||||||
confirmPermissionPath,
|
confirmPermissionPath,
|
||||||
page,
|
page,
|
||||||
|
@ -5,8 +5,8 @@ import {
|
|||||||
getNetworkIdentifier,
|
getNetworkIdentifier,
|
||||||
hasPermissionRequests,
|
hasPermissionRequests,
|
||||||
preferencesSelector,
|
preferencesSelector,
|
||||||
} from '../../selectors/selectors'
|
submittedPendingTransactionsSelector,
|
||||||
import { submittedPendingTransactionsSelector } from '../../selectors/transactions'
|
} from '../../selectors'
|
||||||
import Routes from './routes.component'
|
import Routes from './routes.component'
|
||||||
import {
|
import {
|
||||||
hideSidebar,
|
hideSidebar,
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
getIsMainnet,
|
getIsMainnet,
|
||||||
isBalanceCached,
|
isBalanceCached,
|
||||||
preferencesSelector,
|
preferencesSelector,
|
||||||
} from '../../../selectors/selectors'
|
} from '../../../selectors'
|
||||||
import AccountListItem from './account-list-item.component'
|
import AccountListItem from './account-list-item.component'
|
||||||
|
|
||||||
export default connect(mapStateToProps)(AccountListItem)
|
export default connect(mapStateToProps)(AccountListItem)
|
||||||
|
@ -15,7 +15,7 @@ proxyquire('../account-list-item.container.js', {
|
|||||||
getCurrentCurrency: () => `mockCurrentCurrency`,
|
getCurrentCurrency: () => `mockCurrentCurrency`,
|
||||||
getNativeCurrency: () => `mockNativeCurrency`,
|
getNativeCurrency: () => `mockNativeCurrency`,
|
||||||
},
|
},
|
||||||
'../../../selectors/selectors': {
|
'../../../selectors/': {
|
||||||
isBalanceCached: () => `mockBalanceIsCached`,
|
isBalanceCached: () => `mockBalanceIsCached`,
|
||||||
preferencesSelector: ({ showFiatInTestnets }) => ({
|
preferencesSelector: ({ showFiatInTestnets }) => ({
|
||||||
showFiatInTestnets,
|
showFiatInTestnets,
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
accountsWithSendEtherInfoSelector,
|
accountsWithSendEtherInfoSelector,
|
||||||
getAddressBook,
|
getAddressBook,
|
||||||
getAddressBookEntry,
|
getAddressBookEntry,
|
||||||
} from '../../../../selectors/selectors'
|
} from '../../../../selectors'
|
||||||
import {
|
import {
|
||||||
updateSendTo,
|
updateSendTo,
|
||||||
} from '../../../../store/actions'
|
} from '../../../../store/actions'
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
} from '../../send.selectors'
|
} from '../../send.selectors'
|
||||||
import {
|
import {
|
||||||
getAddressBookEntry,
|
getAddressBookEntry,
|
||||||
} from '../../../../selectors/selectors'
|
} from '../../../../selectors'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ proxyquire('../add-recipient.container.js', {
|
|||||||
getSendEnsResolution: (s) => `mockSendEnsResolution:${s}`,
|
getSendEnsResolution: (s) => `mockSendEnsResolution:${s}`,
|
||||||
getSendEnsResolutionError: (s) => `mockSendEnsResolutionError:${s}`,
|
getSendEnsResolutionError: (s) => `mockSendEnsResolutionError:${s}`,
|
||||||
},
|
},
|
||||||
'../../../../selectors/selectors': {
|
'../../../../selectors/': {
|
||||||
getAddressBook: (s) => [{ name: `mockAddressBook:${s}` }],
|
getAddressBook: (s) => [{ name: `mockAddressBook:${s}` }],
|
||||||
getAddressBookEntry: (s) => `mockAddressBookEntry:${s}`,
|
getAddressBookEntry: (s) => `mockAddressBookEntry:${s}`,
|
||||||
accountsWithSendEtherInfoSelector: (s) => `mockAccountsWithSendEtherInfoSelector:${s}`,
|
accountsWithSendEtherInfoSelector: (s) => `mockAccountsWithSendEtherInfoSelector:${s}`,
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
getSendFromBalance,
|
getSendFromBalance,
|
||||||
getTokenBalance,
|
getTokenBalance,
|
||||||
} from '../../../send.selectors.js'
|
} from '../../../send.selectors.js'
|
||||||
import { getBasicGasEstimateLoadingStatus } from '../../../../../selectors/custom-gas'
|
import { getBasicGasEstimateLoadingStatus } from '../../../../../selectors'
|
||||||
import { getMaxModeOn } from './amount-max-button.selectors.js'
|
import { getMaxModeOn } from './amount-max-button.selectors.js'
|
||||||
import { calcMaxAmount } from './amount-max-button.utils.js'
|
import { calcMaxAmount } from './amount-max-button.utils.js'
|
||||||
import {
|
import {
|
||||||
|
@ -29,7 +29,7 @@ proxyquire('../amount-max-button.container.js', {
|
|||||||
},
|
},
|
||||||
'./amount-max-button.selectors.js': { getMaxModeOn: (s) => `mockMaxModeOn:${s}` },
|
'./amount-max-button.selectors.js': { getMaxModeOn: (s) => `mockMaxModeOn:${s}` },
|
||||||
'./amount-max-button.utils.js': { calcMaxAmount: (mockObj) => mockObj.val + 1 },
|
'./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,
|
'../../../../../store/actions': actionSpies,
|
||||||
'../../../../../ducks/send/send.duck': duckActionSpies,
|
'../../../../../ducks/send/send.duck': duckActionSpies,
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import SendAssetRow from './send-asset-row.component'
|
import SendAssetRow from './send-asset-row.component'
|
||||||
import { getMetaMaskAccounts } from '../../../../selectors/selectors'
|
import { getMetaMaskAccounts } from '../../../../selectors'
|
||||||
import { setSelectedToken } from '../../../../store/actions'
|
import { setSelectedToken } from '../../../../store/actions'
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
accountsWithSendEtherInfoSelector,
|
accountsWithSendEtherInfoSelector,
|
||||||
getAddressBookEntry,
|
getAddressBookEntry,
|
||||||
} from '../../../selectors/selectors'
|
} from '../../../selectors'
|
||||||
import * as actions from '../../../store/actions'
|
import * as actions from '../../../store/actions'
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
|
@ -16,11 +16,6 @@ import {
|
|||||||
calcGasTotal,
|
calcGasTotal,
|
||||||
} from '../../send.utils.js'
|
} from '../../send.utils.js'
|
||||||
import { calcMaxAmount } from '../send-amount-row/amount-max-button/amount-max-button.utils'
|
import { calcMaxAmount } from '../send-amount-row/amount-max-button/amount-max-button.utils'
|
||||||
import {
|
|
||||||
getBasicGasEstimateLoadingStatus,
|
|
||||||
getRenderableEstimateDataForSmallButtonsFromGWEI,
|
|
||||||
getDefaultActiveButtonIndex,
|
|
||||||
} from '../../../../selectors/custom-gas'
|
|
||||||
import {
|
import {
|
||||||
showGasButtonGroup,
|
showGasButtonGroup,
|
||||||
updateSendErrors,
|
updateSendErrors,
|
||||||
@ -32,7 +27,14 @@ import {
|
|||||||
} from '../../../../ducks/gas/gas.duck'
|
} from '../../../../ducks/gas/gas.duck'
|
||||||
import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown } from './send-gas-row.selectors.js'
|
import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown } from './send-gas-row.selectors.js'
|
||||||
import { showModal, setGasPrice, setGasLimit, setGasTotal, updateSendAmount } from '../../../../store/actions'
|
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'
|
import SendGasRow from './send-gas-row.component'
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import {
|
|||||||
getUnapprovedTxs,
|
getUnapprovedTxs,
|
||||||
getSendErrors,
|
getSendErrors,
|
||||||
} from '../send.selectors'
|
} from '../send.selectors'
|
||||||
import { getGasIsLoading } from '../../../selectors/selectors'
|
|
||||||
import {
|
import {
|
||||||
isSendFormInError,
|
isSendFormInError,
|
||||||
} from './send-footer.selectors'
|
} from './send-footer.selectors'
|
||||||
@ -33,9 +32,10 @@ import {
|
|||||||
constructUpdatedTx,
|
constructUpdatedTx,
|
||||||
} from './send-footer.utils'
|
} from './send-footer.utils'
|
||||||
import {
|
import {
|
||||||
|
getGasIsLoading,
|
||||||
getRenderableEstimateDataForSmallButtonsFromGWEI,
|
getRenderableEstimateDataForSmallButtonsFromGWEI,
|
||||||
getDefaultActiveButtonIndex,
|
getDefaultActiveButtonIndex,
|
||||||
} from '../../../selectors/custom-gas'
|
} from '../../../selectors'
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(SendFooter)
|
export default connect(mapStateToProps, mapDispatchToProps)(SendFooter)
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ proxyquire('../send-footer.container.js', {
|
|||||||
},
|
},
|
||||||
'./send-footer.selectors': { isSendFormInError: (s) => `mockInError:${s}` },
|
'./send-footer.selectors': { isSendFormInError: (s) => `mockInError:${s}` },
|
||||||
'./send-footer.utils': utilsStubs,
|
'./send-footer.utils': utilsStubs,
|
||||||
'../../../selectors/custom-gas': {
|
'../../../selectors/': {
|
||||||
getRenderableEstimateDataForSmallButtonsFromGWEI: (s) => ([{ gasEstimateType: `mockGasEstimateType:${s}` }]),
|
getRenderableEstimateDataForSmallButtonsFromGWEI: (s) => ([{ gasEstimateType: `mockGasEstimateType:${s}` }]),
|
||||||
getDefaultActiveButtonIndex: () => 0,
|
getDefaultActiveButtonIndex: () => 0,
|
||||||
},
|
},
|
||||||
|
@ -27,7 +27,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
getSelectedAddress,
|
getSelectedAddress,
|
||||||
getAddressBook,
|
getAddressBook,
|
||||||
} from '../../selectors/selectors'
|
} from '../../selectors'
|
||||||
import { getTokens } from './send-content/add-recipient/add-recipient.selectors'
|
import { getTokens } from './send-content/add-recipient/add-recipient.selectors'
|
||||||
import {
|
import {
|
||||||
updateSendTo,
|
updateSendTo,
|
||||||
|
@ -6,11 +6,9 @@ import {
|
|||||||
getSelectedAccount,
|
getSelectedAccount,
|
||||||
getTargetAccount,
|
getTargetAccount,
|
||||||
getSelectedAddress,
|
getSelectedAddress,
|
||||||
} from '../../selectors/selectors'
|
|
||||||
import { estimateGasPriceFromRecentBlocks, calcGasTotal } from './send.utils'
|
|
||||||
import {
|
|
||||||
getAveragePriceEstimateInHexWEI,
|
getAveragePriceEstimateInHexWEI,
|
||||||
} from '../../selectors/custom-gas'
|
} from '../../selectors'
|
||||||
|
import { estimateGasPriceFromRecentBlocks, calcGasTotal } from './send.utils'
|
||||||
|
|
||||||
export function getAmountConversionRate (state) {
|
export function getAmountConversionRate (state) {
|
||||||
return getSelectedToken(state)
|
return getSelectedToken(state)
|
||||||
|
@ -3,7 +3,7 @@ import sinon from 'sinon'
|
|||||||
import {
|
import {
|
||||||
accountsWithSendEtherInfoSelector,
|
accountsWithSendEtherInfoSelector,
|
||||||
getCurrentAccountWithSendEtherInfo,
|
getCurrentAccountWithSendEtherInfo,
|
||||||
} from '../../../selectors/selectors'
|
} from '../../../selectors'
|
||||||
import {
|
import {
|
||||||
getBlockGasLimit,
|
getBlockGasLimit,
|
||||||
getAmountConversionRate,
|
getAmountConversionRate,
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
setUseNonceField,
|
setUseNonceField,
|
||||||
setIpfsGateway,
|
setIpfsGateway,
|
||||||
} from '../../../store/actions'
|
} from '../../../store/actions'
|
||||||
import { preferencesSelector } from '../../../selectors/selectors'
|
import { preferencesSelector } from '../../../selectors'
|
||||||
|
|
||||||
export const mapStateToProps = (state) => {
|
export const mapStateToProps = (state) => {
|
||||||
const { appState: { warning }, metamask } = state
|
const { appState: { warning }, metamask } = state
|
||||||
|
@ -2,7 +2,7 @@ import ContactListTab from './contact-list-tab.component'
|
|||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { withRouter } from 'react-router-dom'
|
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 { ENVIRONMENT_TYPE_POPUP } from '../../../../../app/scripts/lib/enums'
|
||||||
import { getEnvironmentType } from '../../../../../app/scripts/lib/util'
|
import { getEnvironmentType } from '../../../../../app/scripts/lib/util'
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import EditContact from './edit-contact.component'
|
|||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { withRouter } from 'react-router-dom'
|
import { withRouter } from 'react-router-dom'
|
||||||
import { getAddressBookEntry } from '../../../../selectors/selectors'
|
import { getAddressBookEntry } from '../../../../selectors'
|
||||||
import {
|
import {
|
||||||
CONTACT_VIEW_ROUTE,
|
CONTACT_VIEW_ROUTE,
|
||||||
CONTACT_MY_ACCOUNTS_ROUTE,
|
CONTACT_MY_ACCOUNTS_ROUTE,
|
||||||
|
@ -2,7 +2,7 @@ import ViewContact from './my-accounts.component'
|
|||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { withRouter } from 'react-router-dom'
|
import { withRouter } from 'react-router-dom'
|
||||||
import { accountsWithSendEtherInfoSelector } from '../../../../selectors/selectors'
|
import { accountsWithSendEtherInfoSelector } from '../../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state,) => {
|
const mapStateToProps = (state,) => {
|
||||||
const myAccounts = accountsWithSendEtherInfoSelector(state)
|
const myAccounts = accountsWithSendEtherInfoSelector(state)
|
||||||
|
@ -2,7 +2,7 @@ import ViewContact from './view-contact.component'
|
|||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { withRouter } from 'react-router-dom'
|
import { withRouter } from 'react-router-dom'
|
||||||
import { getAddressBookEntry } from '../../../../selectors/selectors'
|
import { getAddressBookEntry } from '../../../../selectors'
|
||||||
import { checksumAddress } from '../../../../helpers/utils/util'
|
import { checksumAddress } from '../../../../helpers/utils/util'
|
||||||
import {
|
import {
|
||||||
CONTACT_EDIT_ROUTE,
|
CONTACT_EDIT_ROUTE,
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
setUseNativeCurrencyAsPrimaryCurrencyPreference,
|
setUseNativeCurrencyAsPrimaryCurrencyPreference,
|
||||||
setParticipateInMetaMetrics,
|
setParticipateInMetaMetrics,
|
||||||
} from '../../../store/actions'
|
} from '../../../store/actions'
|
||||||
import { preferencesSelector } from '../../../selectors/selectors'
|
import { preferencesSelector } from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
const { appState: { warning }, metamask } = state
|
const { appState: { warning }, metamask } = state
|
||||||
|
@ -2,7 +2,7 @@ import Settings from './settings.component'
|
|||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { withRouter } from 'react-router-dom'
|
import { withRouter } from 'react-router-dom'
|
||||||
import { getAddressBookEntryName } from '../../selectors/selectors'
|
import { getAddressBookEntryName } from '../../selectors'
|
||||||
import { isValidAddress } from '../../helpers/utils/util'
|
import { isValidAddress } from '../../helpers/utils/util'
|
||||||
import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums'
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums'
|
||||||
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
} from '../helpers/utils/conversion-util'
|
} from '../helpers/utils/conversion-util'
|
||||||
import {
|
import {
|
||||||
getCurrentCurrency, getIsMainnet, preferencesSelector,
|
getCurrentCurrency, getIsMainnet, preferencesSelector,
|
||||||
} from './selectors'
|
} from '.'
|
||||||
import {
|
import {
|
||||||
formatCurrency,
|
formatCurrency,
|
||||||
} from '../helpers/utils/confirm-tx.util'
|
} from '../helpers/utils/confirm-tx.util'
|
||||||
|
6
ui/app/selectors/index.js
Normal file
6
ui/app/selectors/index.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export * from './confirm-transaction'
|
||||||
|
export * from './custom-gas'
|
||||||
|
export * from './permissions'
|
||||||
|
export * from './selectors'
|
||||||
|
export * from './tokens'
|
||||||
|
export * from './transactions'
|
@ -1,3 +1,5 @@
|
|||||||
|
import { forOwn } from 'lodash'
|
||||||
|
import { getOriginOfCurrentTab } from './selectors'
|
||||||
import {
|
import {
|
||||||
CAVEAT_NAMES,
|
CAVEAT_NAMES,
|
||||||
} from '../../../app/scripts/controllers/permissions/enums'
|
} from '../../../app/scripts/controllers/permissions/enums'
|
||||||
@ -25,7 +27,7 @@ export function getPermittedAccounts (state, origin) {
|
|||||||
* @returns {Object} Permitted accounts by origin.
|
* @returns {Object} Permitted accounts by origin.
|
||||||
*/
|
*/
|
||||||
export function getPermittedAccountsByOrigin (state) {
|
export function getPermittedAccountsByOrigin (state) {
|
||||||
const domains = getPermissionsDomains(state)
|
const domains = getPermissionDomains(state)
|
||||||
return Object.keys(domains).reduce((acc, domainKey) => {
|
return Object.keys(domains).reduce((acc, domainKey) => {
|
||||||
const accounts = getAccountsFromPermission(
|
const accounts = getAccountsFromPermission(
|
||||||
getAccountsPermissionFromDomain(domains[domainKey])
|
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
|
// selector helpers
|
||||||
|
|
||||||
|
function getAccountsFromDomain (domain) {
|
||||||
|
return getAccountsFromPermission(
|
||||||
|
getAccountsPermissionFromDomain(domain)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function getAccountsPermissionFromDomain (domain = {}) {
|
function getAccountsPermissionFromDomain (domain = {}) {
|
||||||
return (
|
return (
|
||||||
Array.isArray(domain.permissions)
|
Array.isArray(domain.permissions)
|
||||||
@ -67,10 +136,14 @@ function getAccountsCaveatFromPermission (accountsPermission = {}) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPermissionsDomains (state) {
|
export function getPermissionDomains (state) {
|
||||||
return state.metamask.domains || {}
|
return state.metamask.domains || {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function domainSelector (state, origin) {
|
export function getPermissionDomainsMetadata (state) {
|
||||||
return origin && state.metamask.domains && state.metamask.domains[origin]
|
return state.metamask.domainMetadata || {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function domainSelector (state, origin) {
|
||||||
|
return origin && state.metamask?.domains[origin]
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import { flatten, forOwn } from 'lodash'
|
|
||||||
import { NETWORK_TYPES } from '../helpers/constants/common'
|
import { NETWORK_TYPES } from '../helpers/constants/common'
|
||||||
import { stripHexPrefix, addHexPrefix } from 'ethereumjs-util'
|
import { stripHexPrefix, addHexPrefix } from 'ethereumjs-util'
|
||||||
import { createSelector } from 'reselect'
|
import { createSelector } from 'reselect'
|
||||||
|
|
||||||
import abi from 'human-standard-token-abi'
|
import abi from 'human-standard-token-abi'
|
||||||
import { multiplyCurrencies } from '../helpers/utils/conversion-util'
|
|
||||||
import {
|
import {
|
||||||
shortenAddress,
|
shortenAddress,
|
||||||
checksumAddress,
|
checksumAddress,
|
||||||
@ -12,8 +10,6 @@ import {
|
|||||||
getAccountByAddress,
|
getAccountByAddress,
|
||||||
} from '../helpers/utils/util'
|
} from '../helpers/utils/util'
|
||||||
|
|
||||||
import { getPermittedAccountsByOrigin } from './permissions'
|
|
||||||
|
|
||||||
export function getNetworkIdentifier (state) {
|
export function getNetworkIdentifier (state) {
|
||||||
const { metamask: { provider: { type, nickname, rpcTarget } } } = state
|
const { metamask: { provider: { type, nickname, rpcTarget } } } = state
|
||||||
|
|
||||||
@ -193,10 +189,6 @@ export function getTokenExchangeRate (state, address) {
|
|||||||
return contractExchangeRates[address] || 0
|
return contractExchangeRates[address] || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export function conversionRateSelector (state) {
|
|
||||||
return state.metamask.conversionRate
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAddressBook (state) {
|
export function getAddressBook (state) {
|
||||||
const network = state.metamask.network
|
const network = state.metamask.network
|
||||||
if (!state.metamask.addressBook[network]) {
|
if (!state.metamask.addressBook[network]) {
|
||||||
@ -272,23 +264,6 @@ export function getCurrentCurrency (state) {
|
|||||||
return state.metamask.currentCurrency
|
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) {
|
export function getSelectedTokenContract (state) {
|
||||||
const selectedToken = getSelectedToken(state)
|
const selectedToken = getSelectedToken(state)
|
||||||
return selectedToken
|
return selectedToken
|
||||||
@ -429,33 +404,6 @@ export function hasPermissionRequests (state) {
|
|||||||
return Boolean(getFirstPermissionRequest(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) {
|
export function getOriginOfCurrentTab (state) {
|
||||||
const { activeTab } = state
|
const { activeTab } = state
|
||||||
return activeTab && activeTab.url && getOriginFromUrl(activeTab.url)
|
return activeTab && activeTab.url && getOriginFromUrl(activeTab.url)
|
||||||
@ -476,37 +424,3 @@ export function getLastConnectedInfo (state) {
|
|||||||
export function getIpfsGateway (state) {
|
export function getIpfsGateway (state) {
|
||||||
return state.metamask.ipfsGateway
|
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
|
|
||||||
}
|
|
||||||
|
@ -11,7 +11,7 @@ const {
|
|||||||
getPriceAndTimeEstimates,
|
getPriceAndTimeEstimates,
|
||||||
getRenderableBasicEstimateData,
|
getRenderableBasicEstimateData,
|
||||||
getRenderableEstimateDataForSmallButtonsFromGWEI,
|
getRenderableEstimateDataForSmallButtonsFromGWEI,
|
||||||
} = proxyquire('./custom-gas', {})
|
} = proxyquire('../custom-gas', {})
|
||||||
|
|
||||||
describe('custom-gas selectors', function () {
|
describe('custom-gas selectors', function () {
|
||||||
|
|
156
ui/app/selectors/tests/permissions.test.js
Normal file
156
ui/app/selectors/tests/permissions.test.js
Normal file
@ -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',
|
||||||
|
}])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
@ -1,5 +1,5 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import { getAddressBook, getConnectedDomainsForSelectedAddress } from '../selectors.js'
|
import { getAddressBook } from '../selectors'
|
||||||
import mockState from './selectors-test-data'
|
import mockState from './selectors-test-data'
|
||||||
|
|
||||||
describe('selectors', function () {
|
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',
|
|
||||||
}])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -15,7 +15,7 @@ import { getFastPriceEstimateInHexWEI } from './custom-gas'
|
|||||||
import {
|
import {
|
||||||
getSelectedToken,
|
getSelectedToken,
|
||||||
getSelectedAddress,
|
getSelectedAddress,
|
||||||
} from './selectors'
|
} from '.'
|
||||||
import txHelper from '../../lib/tx-helper'
|
import txHelper from '../../lib/tx-helper'
|
||||||
|
|
||||||
export const incomingTxListSelector = (state) => {
|
export const incomingTxListSelector = (state) => {
|
||||||
|
@ -18,7 +18,7 @@ import actionConstants from './actionConstants'
|
|||||||
import {
|
import {
|
||||||
getPermittedAccountsForCurrentTab,
|
getPermittedAccountsForCurrentTab,
|
||||||
getSelectedAddress,
|
getSelectedAddress,
|
||||||
} from '../selectors/selectors'
|
} from '../selectors'
|
||||||
import { switchedToUnconnectedAccount } from '../ducks/alerts/unconnected-account'
|
import { switchedToUnconnectedAccount } from '../ducks/alerts/unconnected-account'
|
||||||
|
|
||||||
let background = null
|
let background = null
|
||||||
|
Loading…
Reference in New Issue
Block a user