1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Rename preferencesSelector selector to getPreferences (#8647)

This commit is contained in:
Whymarrh Whitby 2020-05-26 03:41:58 -02:30 committed by GitHub
parent 835386bf35
commit ab11e0b623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 34 additions and 34 deletions

View File

@ -30,7 +30,7 @@ import {
getIsMainnet, getIsMainnet,
getSelectedToken, getSelectedToken,
isEthereumNetwork, isEthereumNetwork,
preferencesSelector, getPreferences,
getBasicGasEstimateLoadingStatus, getBasicGasEstimateLoadingStatus,
getGasEstimatesLoadingStatus, getGasEstimatesLoadingStatus,
getCustomGasLimit, getCustomGasLimit,
@ -98,7 +98,7 @@ const mapStateToProps = (state, ownProps) => {
const estimatedTimes = getEstimatedGasTimes(state) const estimatedTimes = getEstimatedGasTimes(state)
const balance = getCurrentEthBalance(state) const balance = getCurrentEthBalance(state)
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
const isMainnet = getIsMainnet(state) const isMainnet = getIsMainnet(state)
const showFiat = Boolean(isMainnet || showFiatInTestnets) const showFiat = Boolean(isMainnet || showFiatInTestnets)

View File

@ -1,13 +1,13 @@
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' import { getIsMainnet, getNativeCurrency, getPreferences } 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'
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
const { transaction } = ownProps const { transaction } = ownProps
const { txParams: { gas, gasPrice, value } = {}, txReceipt: { gasUsed } = {} } = transaction const { txParams: { gas, gasPrice, value } = {}, txReceipt: { gasUsed } = {} } = transaction
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
const isMainnet = getIsMainnet(state) const isMainnet = getIsMainnet(state)
const gasLimit = typeof gasUsed === 'string' ? gasUsed : gas const gasLimit = typeof gasUsed === 'string' ? gasUsed : gas

View File

@ -15,7 +15,7 @@ import {
} from '../../../ducks/gas/gas.duck' } from '../../../ducks/gas/gas.duck'
import { import {
getIsMainnet, getIsMainnet,
preferencesSelector, getPreferences,
getSelectedAddress, getSelectedAddress,
conversionRateSelector, conversionRateSelector,
getKnownMethodData, getKnownMethodData,
@ -25,7 +25,7 @@ import { isBalanceSufficient } from '../../../pages/send/send.utils'
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
const { metamask: { accounts, provider, frequentRpcListDetail } } = state const { metamask: { accounts, provider, frequentRpcListDetail } } = state
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
const isMainnet = getIsMainnet(state) const isMainnet = getIsMainnet(state)
const { transactionGroup: { primaryTransaction } = {} } = ownProps const { transactionGroup: { primaryTransaction } = {} } = ownProps
const { txParams: { gas: gasLimit, gasPrice, data } = {}, transactionCategory } = primaryTransaction const { txParams: { gas: gasLimit, gasPrice, data } = {}, transactionCategory } = primaryTransaction

View File

@ -1,9 +1,9 @@
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' import { getPreferences } from '../../../selectors'
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const { useNativeCurrencyAsPrimaryCurrency } = preferencesSelector(state) const { useNativeCurrencyAsPrimaryCurrency } = getPreferences(state)
return { return {
useNativeCurrencyAsPrimaryCurrency, useNativeCurrencyAsPrimaryCurrency,

View File

@ -1,9 +1,9 @@
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' import { getPreferences } from '../../../selectors'
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const { useNativeCurrencyAsPrimaryCurrency } = preferencesSelector(state) const { useNativeCurrencyAsPrimaryCurrency } = getPreferences(state)
return { return {
useNativeCurrencyAsPrimaryCurrency, useNativeCurrencyAsPrimaryCurrency,

View File

@ -4,12 +4,12 @@ import { ETH } from '../../../helpers/constants/common'
import { import {
getSendMaxModeState, getSendMaxModeState,
getIsMainnet, getIsMainnet,
preferencesSelector, getPreferences,
} from '../../../selectors' } from '../../../selectors'
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const { metamask: { nativeCurrency, currentCurrency, conversionRate } } = state const { metamask: { nativeCurrency, currentCurrency, conversionRate } } = state
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
const isMainnet = getIsMainnet(state) const isMainnet = getIsMainnet(state)
const maxModeOn = getSendMaxModeState(state) const maxModeOn = getSendMaxModeState(state)

View File

@ -4,12 +4,12 @@ import {
getIsMainnet, getIsMainnet,
getSelectedToken, getSelectedToken,
getSelectedTokenExchangeRate, getSelectedTokenExchangeRate,
preferencesSelector, getPreferences,
} from '../../../selectors' } from '../../../selectors'
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const { metamask: { currentCurrency } } = state const { metamask: { currentCurrency } } = state
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
const isMainnet = getIsMainnet(state) const isMainnet = getIsMainnet(state)
return { return {

View File

@ -2,7 +2,7 @@ import assert from 'assert'
import { renderHook } from '@testing-library/react-hooks' import { renderHook } from '@testing-library/react-hooks'
import { useUserPreferencedCurrency } from '../useUserPreferencedCurrency' import { useUserPreferencedCurrency } from '../useUserPreferencedCurrency'
import * as reactRedux from 'react-redux' import * as reactRedux from 'react-redux'
import { preferencesSelector, getShouldShowFiat } from '../../selectors' import { getPreferences, getShouldShowFiat } from '../../selectors'
import sinon from 'sinon' import sinon from 'sinon'
const tests = [ const tests = [
@ -113,7 +113,7 @@ const tests = [
function getFakeUseSelector (state) { function getFakeUseSelector (state) {
return (selector) => { return (selector) => {
if (selector === preferencesSelector) { if (selector === getPreferences) {
return state return state
} else if (selector === getShouldShowFiat) { } else if (selector === getShouldShowFiat) {
return state.showFiat return state.showFiat

View File

@ -1,4 +1,4 @@
import { preferencesSelector, getShouldShowFiat } from '../selectors' import { getPreferences, getShouldShowFiat } from '../selectors'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import { PRIMARY, SECONDARY, ETH } from '../helpers/constants/common' import { PRIMARY, SECONDARY, ETH } from '../helpers/constants/common'
@ -33,7 +33,7 @@ export function useUserPreferencedCurrency (type, opts = {}) {
const nativeCurrency = useSelector((state) => state.metamask.nativeCurrency) const nativeCurrency = useSelector((state) => state.metamask.nativeCurrency)
const { const {
useNativeCurrencyAsPrimaryCurrency, useNativeCurrencyAsPrimaryCurrency,
} = useSelector(preferencesSelector) } = useSelector(getPreferences)
const showFiat = useSelector(getShouldShowFiat) const showFiat = useSelector(getShouldShowFiat)
let currency, numberOfDecimals let currency, numberOfDecimals

View File

@ -34,7 +34,7 @@ import {
getKnownMethodData, getKnownMethodData,
getMetaMaskAccounts, getMetaMaskAccounts,
getUseNonceField, getUseNonceField,
preferencesSelector, getPreferences,
transactionFeeSelector, transactionFeeSelector,
} from '../../selectors' } from '../../selectors'
@ -54,7 +54,7 @@ const customNonceMerge = (txData) => (customNonceValue ? ({
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
const { toAddress: propsToAddress, customTxParamsData, match: { params = {} } } = ownProps const { toAddress: propsToAddress, customTxParamsData, match: { params = {} } } = ownProps
const { id: paramsTransactionId } = params const { id: paramsTransactionId } = params
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
const isMainnet = getIsMainnet(state) const isMainnet = getIsMainnet(state)
const { confirmTransaction, metamask } = state const { confirmTransaction, metamask } = state
const { const {

View File

@ -4,7 +4,7 @@ import { compose } from 'redux'
import { import {
getNetworkIdentifier, getNetworkIdentifier,
hasPermissionRequests, hasPermissionRequests,
preferencesSelector, getPreferences,
submittedPendingTransactionsSelector, submittedPendingTransactionsSelector,
} from '../../selectors' } from '../../selectors'
import Routes from './routes.component' import Routes from './routes.component'
@ -25,7 +25,7 @@ function mapStateToProps (state) {
isLoading, isLoading,
loadingMessage, loadingMessage,
} = appState } = appState
const { autoLockTimeLimit = 0 } = preferencesSelector(state) const { autoLockTimeLimit = 0 } = getPreferences(state)
return { return {
sidebar, sidebar,

View File

@ -3,14 +3,14 @@ import {
getNativeCurrency, getNativeCurrency,
getIsMainnet, getIsMainnet,
isBalanceCached, isBalanceCached,
preferencesSelector, getPreferences,
} from '../../../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)
function mapStateToProps (state) { function mapStateToProps (state) {
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
const isMainnet = getIsMainnet(state) const isMainnet = getIsMainnet(state)
return { return {

View File

@ -15,7 +15,7 @@ proxyquire('../account-list-item.container.js', {
getCurrentCurrency: () => `mockCurrentCurrency`, getCurrentCurrency: () => `mockCurrentCurrency`,
getNativeCurrency: () => `mockNativeCurrency`, getNativeCurrency: () => `mockNativeCurrency`,
isBalanceCached: () => `mockBalanceIsCached`, isBalanceCached: () => `mockBalanceIsCached`,
preferencesSelector: ({ showFiatInTestnets }) => ({ getPreferences: ({ showFiatInTestnets }) => ({
showFiatInTestnets, showFiatInTestnets,
}), }),
getIsMainnet: ({ isMainnet }) => isMainnet, getIsMainnet: ({ isMainnet }) => isMainnet,

View File

@ -13,7 +13,7 @@ import {
setUseNonceField, setUseNonceField,
setIpfsGateway, setIpfsGateway,
} from '../../../store/actions' } from '../../../store/actions'
import { preferencesSelector } from '../../../selectors' import { getPreferences } from '../../../selectors'
export const mapStateToProps = (state) => { export const mapStateToProps = (state) => {
const { appState: { warning }, metamask } = state const { appState: { warning }, metamask } = state
@ -27,7 +27,7 @@ export const mapStateToProps = (state) => {
useNonceField, useNonceField,
ipfsGateway, ipfsGateway,
} = metamask } = metamask
const { showFiatInTestnets, autoLockTimeLimit } = preferencesSelector(state) const { showFiatInTestnets, autoLockTimeLimit } = getPreferences(state)
return { return {
warning, warning,

View File

@ -7,7 +7,7 @@ import {
setUseNativeCurrencyAsPrimaryCurrencyPreference, setUseNativeCurrencyAsPrimaryCurrencyPreference,
setParticipateInMetaMetrics, setParticipateInMetaMetrics,
} from '../../../store/actions' } from '../../../store/actions'
import { preferencesSelector } from '../../../selectors' import { getPreferences } from '../../../selectors'
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const { appState: { warning }, metamask } = state const { appState: { warning }, metamask } = state
@ -18,7 +18,7 @@ const mapStateToProps = (state) => {
useBlockie, useBlockie,
currentLocale, currentLocale,
} = metamask } = metamask
const { useNativeCurrencyAsPrimaryCurrency } = preferencesSelector(state) const { useNativeCurrencyAsPrimaryCurrency } = getPreferences(state)
return { return {
warning, warning,

View File

@ -5,7 +5,7 @@ import {
conversionGreaterThan, conversionGreaterThan,
} from '../helpers/utils/conversion-util' } from '../helpers/utils/conversion-util'
import { import {
getCurrentCurrency, getIsMainnet, preferencesSelector, getCurrentCurrency, getIsMainnet, getPreferences,
} from '.' } from '.'
import { import {
formatCurrency, formatCurrency,
@ -208,7 +208,7 @@ export function getRenderableBasicEstimateData (state, gasLimit) {
return [] return []
} }
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
const isMainnet = getIsMainnet(state) const isMainnet = getIsMainnet(state)
const showFiat = (isMainnet || !!showFiatInTestnets) const showFiat = (isMainnet || !!showFiatInTestnets)
const conversionRate = state.metamask.conversionRate const conversionRate = state.metamask.conversionRate
@ -262,7 +262,7 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI (state) {
return [] return []
} }
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
const isMainnet = getIsMainnet(state) const isMainnet = getIsMainnet(state)
const showFiat = (isMainnet || !!showFiatInTestnets) const showFiat = (isMainnet || !!showFiatInTestnets)
const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state) || '0x5208' const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state) || '0x5208'

View File

@ -280,13 +280,13 @@ export function isEthereumNetwork (state) {
return [ KOVAN, MAINNET, RINKEBY, ROPSTEN, GOERLI].includes(networkType) return [ KOVAN, MAINNET, RINKEBY, ROPSTEN, GOERLI].includes(networkType)
} }
export function preferencesSelector ({ metamask }) { export function getPreferences ({ metamask }) {
return metamask.preferences return metamask.preferences
} }
export function getShouldShowFiat (state) { export function getShouldShowFiat (state) {
const isMainNet = getIsMainnet(state) const isMainNet = getIsMainnet(state)
const { showFiatInTestnets } = preferencesSelector(state) const { showFiatInTestnets } = getPreferences(state)
return Boolean(isMainNet || showFiatInTestnets) return Boolean(isMainNet || showFiatInTestnets)
} }