1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 03:12:42 +02:00

move metamask state selectors out of send (#11249)

This commit is contained in:
Brad Decker 2021-06-08 11:03:59 -05:00 committed by GitHub
parent df9bc52e9f
commit b073b04789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 272 additions and 176 deletions

View File

@ -11,10 +11,10 @@ import { useMetricEvent } from '../../../hooks/useMetricEvent';
import { useUserPreferencedCurrency } from '../../../hooks/useUserPreferencedCurrency';
import {
getCurrentAccountWithSendEtherInfo,
getNativeCurrency,
getShouldShowFiat,
getNativeCurrencyImage,
} from '../../../selectors';
import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import { useCurrencyDisplay } from '../../../hooks/useCurrencyDisplay';
const AssetList = ({ onClickAsset }) => {

View File

@ -2,9 +2,9 @@ import { connect } from 'react-redux';
import { findLastIndex } from 'lodash';
import {
conversionRateSelector,
getNativeCurrency,
getRpcPrefsForCurrentProvider,
} from '../../../selectors';
import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import TransactionActivityLog from './transaction-activity-log.component';
import { combineTransactionHistories } from './transaction-activity-log.util';
import {

View File

@ -1,9 +1,6 @@
import { connect } from 'react-redux';
import {
getIsMainnet,
getNativeCurrency,
getPreferences,
} from '../../../selectors';
import { getIsMainnet, getPreferences } from '../../../selectors';
import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import { getHexGasTotal } from '../../../helpers/utils/confirm-tx.util';
import { sumHexes } from '../../../helpers/utils/transactions.util';
import TransactionBreakdown from './transaction-breakdown.component';

View File

@ -2,8 +2,8 @@ import {
conversionRateSelector,
currentCurrencySelector,
unconfirmedTransactionsHashSelector,
getNativeCurrency,
} from '../../selectors';
import { getNativeCurrency } from '../metamask/metamask';
import {
getValueFromWeiHex,

View File

@ -1,6 +1,10 @@
import * as actionConstants from '../../store/actionConstants';
import { ALERT_TYPES } from '../../../shared/constants/alerts';
import { NETWORK_TYPE_RPC } from '../../../shared/constants/network';
import {
accountsWithSendEtherInfoSelector,
getAddressBook,
} from '../../selectors';
export default function reduceMetamask(state = {}, action) {
const metamaskState = {
@ -35,6 +39,7 @@ export default function reduceMetamask(state = {}, action) {
featureFlags: {},
welcomeScreenSeen: false,
currentLocale: '',
currentBlockGasLimit: '',
preferences: {
autoLockTimeLimit: undefined,
showFiatInTestnets: false,
@ -46,6 +51,8 @@ export default function reduceMetamask(state = {}, action) {
participateInMetaMetrics: null,
metaMetricsSendCount: 0,
nextNonce: null,
conversionRate: null,
nativeCurrency: 'ETH',
...state,
};
@ -378,3 +385,29 @@ export const getUnconnectedAccountAlertShown = (state) =>
state.metamask.unconnectedAccountAlertShownOrigins;
export const getTokens = (state) => state.metamask.tokens;
export function getBlockGasLimit(state) {
return state.metamask.currentBlockGasLimit;
}
export function getConversionRate(state) {
return state.metamask.conversionRate;
}
export function getNativeCurrency(state) {
return state.metamask.nativeCurrency;
}
export function getSendHexDataFeatureFlagState(state) {
return state.metamask.featureFlags.sendHexData;
}
export function getSendToAccounts(state) {
const fromAccounts = accountsWithSendEtherInfoSelector(state);
const addressBookAccounts = getAddressBook(state);
return [...fromAccounts, ...addressBookAccounts];
}
export function getUnapprovedTxs(state) {
return state.metamask.unapprovedTxs;
}

View File

@ -1,9 +1,111 @@
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
import * as actionConstants from '../../store/actionConstants';
import reduceMetamask from './metamask';
import reduceMetamask, {
getBlockGasLimit,
getConversionRate,
getNativeCurrency,
getSendHexDataFeatureFlagState,
getSendToAccounts,
getUnapprovedTxs,
} from './metamask';
describe('MetaMask Reducers', () => {
const mockState = {
metamask: reduceMetamask(
{
isInitialized: true,
isUnlocked: true,
featureFlags: { sendHexData: true },
identities: {
'0xfdea65c8e26263f6d9a1b5de9555d2931a33b825': {
address: '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825',
name: 'Send Account 1',
},
'0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb': {
address: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
name: 'Send Account 2',
},
'0x2f8d4a878cfa04a6e60d46362f5644deab66572d': {
address: '0x2f8d4a878cfa04a6e60d46362f5644deab66572d',
name: 'Send Account 3',
},
'0xd85a4b6a394794842887b8284293d69163007bbb': {
address: '0xd85a4b6a394794842887b8284293d69163007bbb',
name: 'Send Account 4',
},
},
cachedBalances: {},
currentBlockGasLimit: '0x4c1878',
conversionRate: 1200.88200327,
nativeCurrency: 'ETH',
network: '3',
provider: {
type: 'testnet',
chainId: '0x3',
},
accounts: {
'0xfdea65c8e26263f6d9a1b5de9555d2931a33b825': {
code: '0x',
balance: '0x47c9d71831c76efe',
nonce: '0x1b',
address: '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825',
},
'0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb': {
code: '0x',
balance: '0x37452b1315889f80',
nonce: '0xa',
address: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
},
'0x2f8d4a878cfa04a6e60d46362f5644deab66572d': {
code: '0x',
balance: '0x30c9d71831c76efe',
nonce: '0x1c',
address: '0x2f8d4a878cfa04a6e60d46362f5644deab66572d',
},
'0xd85a4b6a394794842887b8284293d69163007bbb': {
code: '0x',
balance: '0x0',
nonce: '0x0',
address: '0xd85a4b6a394794842887b8284293d69163007bbb',
},
},
addressBook: {
'0x3': {
'0x06195827297c7a80a443b6894d3bdb8824b43896': {
address: '0x06195827297c7a80a443b6894d3bdb8824b43896',
name: 'Address Book Account 1',
chainId: '0x3',
},
},
},
unapprovedTxs: {
4768706228115573: {
id: 4768706228115573,
time: 1487363153561,
status: TRANSACTION_STATUSES.UNAPPROVED,
gasMultiplier: 1,
metamaskNetworkId: '3',
txParams: {
from: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
to: '0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761',
value: '0xde0b6b3a7640000',
metamaskId: 4768706228115573,
metamaskNetworkId: '3',
gas: '0x5209',
},
txFee: '17e0186e60800',
txValue: 'de0b6b3a7640000',
maxCost: 'de234b52e4a0800',
gasPrice: '4a817c800',
},
},
},
{},
),
};
it('init state', () => {
const initState = reduceMetamask(undefined, {});
expect.anything(initState);
});
@ -403,4 +505,94 @@ describe('MetaMask Reducers', () => {
expect(state.send.ensResolutionError).toStrictEqual('ens name not found');
expect(state.send.ensResolution).toBeNull();
});
describe('metamask state selectors', () => {
describe('getBlockGasLimit', () => {
it('should return the current block gas limit', () => {
expect(getBlockGasLimit(mockState)).toStrictEqual('0x4c1878');
});
});
describe('getConversionRate()', () => {
it('should return the eth conversion rate', () => {
expect(getConversionRate(mockState)).toStrictEqual(1200.88200327);
});
});
describe('getNativeCurrency()', () => {
it('should return the ticker symbol of the selected network', () => {
expect(getNativeCurrency(mockState)).toStrictEqual('ETH');
});
});
describe('getSendHexDataFeatureFlagState()', () => {
it('should return the sendHexData feature flag state', () => {
expect(getSendHexDataFeatureFlagState(mockState)).toStrictEqual(true);
});
});
describe('getSendToAccounts()', () => {
it('should return an array including all the users accounts and the address book', () => {
expect(getSendToAccounts(mockState)).toStrictEqual([
{
code: '0x',
balance: '0x47c9d71831c76efe',
nonce: '0x1b',
address: '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825',
name: 'Send Account 1',
},
{
code: '0x',
balance: '0x37452b1315889f80',
nonce: '0xa',
address: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
name: 'Send Account 2',
},
{
code: '0x',
balance: '0x30c9d71831c76efe',
nonce: '0x1c',
address: '0x2f8d4a878cfa04a6e60d46362f5644deab66572d',
name: 'Send Account 3',
},
{
code: '0x',
balance: '0x0',
nonce: '0x0',
address: '0xd85a4b6a394794842887b8284293d69163007bbb',
name: 'Send Account 4',
},
{
address: '0x06195827297c7a80a443b6894d3bdb8824b43896',
name: 'Address Book Account 1',
chainId: '0x3',
},
]);
});
});
it('should return the unapproved txs', () => {
expect(getUnapprovedTxs(mockState)).toStrictEqual({
4768706228115573: {
id: 4768706228115573,
time: 1487363153561,
status: TRANSACTION_STATUSES.UNAPPROVED,
gasMultiplier: 1,
metamaskNetworkId: '3',
txParams: {
from: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
to: '0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761',
value: '0xde0b6b3a7640000',
metamaskId: 4768706228115573,
metamaskNetworkId: '3',
gas: '0x5209',
},
txFee: '17e0186e60800',
txValue: 'de0b6b3a7640000',
maxCost: 'de234b52e4a0800',
gasPrice: '4a817c800',
},
});
});
});
});

View File

@ -7,11 +7,9 @@ import {
getHexGasTotal,
increaseLastGasPrice,
} from '../helpers/utils/confirm-tx.util';
import {
getConversionRate,
getSelectedAccount,
getIsMainnet,
} from '../selectors';
import { getSelectedAccount, getIsMainnet } from '../selectors';
import { getConversionRate } from '../ducks/metamask/metamask';
import {
setCustomGasLimit,
setCustomGasPriceForRetry,

View File

@ -4,11 +4,11 @@ import {
formatCurrency,
getValueFromWeiHex,
} from '../helpers/utils/confirm-tx.util';
import { getCurrentCurrency } from '../selectors';
import {
getCurrentCurrency,
getConversionRate,
getNativeCurrency,
} from '../selectors';
} from '../ducks/metamask/metamask';
/**
* Defines the shape of the options parameter for useCurrencyDisplay

View File

@ -1,11 +1,11 @@
import { renderHook } from '@testing-library/react-hooks';
import * as reactRedux from 'react-redux';
import sinon from 'sinon';
import { getCurrentCurrency } from '../selectors';
import {
getCurrentCurrency,
getNativeCurrency,
getConversionRate,
} from '../selectors';
getNativeCurrency,
} from '../ducks/metamask/metamask';
import { useCurrencyDisplay } from './useCurrencyDisplay';
const tests = [

View File

@ -1,12 +1,9 @@
import { useMemo } from 'react';
import { useSelector } from 'react-redux';
import {
getConversionRate,
getCurrentCurrency,
getShouldShowFiat,
} from '../selectors';
import { getCurrentCurrency, getShouldShowFiat } from '../selectors';
import { decEthToConvertedCurrency } from '../helpers/utils/conversions.util';
import { formatCurrency } from '../helpers/utils/confirm-tx.util';
import { getConversionRate } from '../ducks/metamask/metamask';
/**
* Get an Eth amount converted to fiat and formatted for display

View File

@ -2,11 +2,11 @@ import { useMemo } from 'react';
import { useSelector } from 'react-redux';
import {
getTokenExchangeRates,
getConversionRate,
getCurrentCurrency,
getShouldShowFiat,
} from '../selectors';
import { getTokenFiatAmount } from '../helpers/utils/token-util';
import { getConversionRate } from '../ducks/metamask/metamask';
/**
* Get the token balance converted to fiat and formatted for display

View File

@ -6,11 +6,12 @@ import { isEqual, shuffle, uniqBy } from 'lodash';
import { getTokenFiatAmount } from '../helpers/utils/token-util';
import {
getTokenExchangeRates,
getConversionRate,
getCurrentCurrency,
getSwapsDefaultToken,
getCurrentChainId,
} from '../selectors';
import { getConversionRate } from '../ducks/metamask/metamask';
import { getSwapsTokens } from '../ducks/swaps/swaps';
import { isSwapsDefaultTokenSymbol } from '../../shared/modules/swaps.utils';
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';

View File

@ -7,11 +7,10 @@ import transactions from '../../test/data/transaction-data.json';
import {
getPreferences,
getShouldShowFiat,
getNativeCurrency,
getCurrentCurrency,
getCurrentChainId,
} from '../selectors';
import { getTokens } from '../ducks/metamask/metamask';
import { getTokens, getNativeCurrency } from '../ducks/metamask/metamask';
import { getMessage } from '../helpers/utils/i18n-helper';
import messages from '../../app/_locales/en/messages.json';
import { ASSET_ROUTE, DEFAULT_ROUTE } from '../helpers/constants/routes';

View File

@ -1,9 +1,7 @@
import { useSelector } from 'react-redux';
import {
getPreferences,
getShouldShowFiat,
getNativeCurrency,
} from '../selectors';
import { getPreferences, getShouldShowFiat } from '../selectors';
import { getNativeCurrency } from '../ducks/metamask/metamask';
import { PRIMARY, SECONDARY, ETH } from '../helpers/constants/common';
/**

View File

@ -14,13 +14,12 @@ import {
getTokenValueParam,
} from '../../helpers/utils/token-util';
import { useTokenTracker } from '../../hooks/useTokenTracker';
import { getTokens } from '../../ducks/metamask/metamask';
import { getTokens, getNativeCurrency } from '../../ducks/metamask/metamask';
import {
transactionFeeSelector,
txDataSelector,
getCurrentCurrency,
getDomainMetadata,
getNativeCurrency,
getUseNonceField,
getCustomNonceValue,
getNextSuggestedNonce,
@ -28,6 +27,7 @@ import {
getIsEthGasPriceFetched,
getIsMainnet,
} from '../../selectors';
import { currentNetworkTxListSelector } from '../../selectors/transactions';
import Loading from '../../components/ui/loading-screen';
import { getCustomTxParamsData } from './confirm-approve.util';

View File

@ -2,12 +2,12 @@ import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import {
getPermissionsRequests,
getNativeCurrency,
getAccountsWithLabels,
getLastConnectedInfo,
getDomainMetadata,
getSelectedAddress,
} from '../../selectors';
import { getNativeCurrency } from '../../ducks/metamask/metamask';
import { formatDate } from '../../helpers/utils/util';
import {

View File

@ -1,6 +1,5 @@
import { connect } from 'react-redux';
import {
getConversionRate,
getGasTotal,
getPrimaryCurrency,
getSendToken,
@ -13,6 +12,7 @@ import {
import { getAmountErrorObject, getGasFeeErrorObject } from '../../send.utils';
import { setMaxModeTo, updateSendAmount } from '../../../../store/actions';
import { updateSendErrors } from '../../../../ducks/send/send.duck';
import { getConversionRate } from '../../../../ducks/metamask/metamask';
import SendAmountRow from './send-amount-row.component';
export default connect(mapStateToProps, mapDispatchToProps)(SendAmountRow);

View File

@ -1,7 +1,7 @@
import { connect } from 'react-redux';
import { getNativeCurrency } from '../../../../ducks/metamask/metamask';
import {
getMetaMaskAccounts,
getNativeCurrency,
getNativeCurrencyImage,
getSendTokenAddress,
getAssetImages,

View File

@ -1,6 +1,5 @@
import { connect } from 'react-redux';
import {
getConversionRate,
getGasTotal,
getGasPrice,
getGasLimit,
@ -39,6 +38,7 @@ import {
setGasTotal,
updateSendAmount,
} from '../../../../store/actions';
import { getConversionRate } from '../../../../ducks/metamask/metamask';
import SendGasRow from './send-gas-row.component';
export default connect(

View File

@ -15,10 +15,8 @@ import {
getSendEditingTransactionId,
getSendFromObject,
getSendTo,
getSendToAccounts,
getSendHexData,
getTokenBalance,
getUnapprovedTxs,
getSendErrors,
isSendFormInError,
getGasIsLoading,
@ -28,6 +26,10 @@ import {
} from '../../../selectors';
import { getMostRecentOverviewPage } from '../../../ducks/history/history';
import { addHexPrefix } from '../../../../app/scripts/lib/util';
import {
getSendToAccounts,
getUnapprovedTxs,
} from '../../../ducks/metamask/metamask';
import SendFooter from './send-footer.component';
import {
addressIsNew,

View File

@ -3,8 +3,6 @@ import { withRouter } from 'react-router-dom';
import { compose } from 'redux';
import {
getBlockGasLimit,
getConversionRate,
getGasLimit,
getGasPrice,
getGasTotal,
@ -13,7 +11,6 @@ import {
getSendTokenContract,
getSendAmount,
getSendEditingTransactionId,
getSendHexDataFeatureFlagState,
getSendFromObject,
getSendTo,
getSendToNickname,
@ -38,7 +35,12 @@ import {
} from '../../store/actions';
import { resetSendState, updateSendErrors } from '../../ducks/send/send.duck';
import { fetchBasicGasEstimates } from '../../ducks/gas/gas.duck';
import { getTokens } from '../../ducks/metamask/metamask';
import {
getBlockGasLimit,
getConversionRate,
getSendHexDataFeatureFlagState,
getTokens,
} from '../../ducks/metamask/metamask';
import { isValidDomainName } from '../../helpers/utils/util';
import { calcGasTotal } from './send.utils';
import SendEther from './send.component';

View File

@ -16,7 +16,7 @@ import { I18nContext } from '../../../contexts/i18n';
import DropdownInputPair from '../dropdown-input-pair';
import DropdownSearchList from '../dropdown-search-list';
import SlippageButtons from '../slippage-buttons';
import { getTokens } from '../../../ducks/metamask/metamask';
import { getTokens, getConversionRate } from '../../../ducks/metamask/metamask';
import InfoTooltip from '../../../components/ui/info-tooltip';
import ActionableMessage from '../actionable-message';
@ -33,11 +33,11 @@ import {
import {
getSwapsDefaultToken,
getTokenExchangeRates,
getConversionRate,
getCurrentCurrency,
getCurrentChainId,
getRpcPrefsForCurrentProvider,
} from '../../../selectors';
import {
getValueFromWeiHex,
hexToDecimal,

View File

@ -8,9 +8,9 @@ import {
getDefaultActiveButtonIndex,
getRenderableGasButtonData,
getUSDConversionRate,
getNativeCurrency,
getSwapsDefaultToken,
} from '../../../selectors';
import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import {
getSwapsCustomizationModalPrice,

View File

@ -38,12 +38,13 @@ import {
getTokenExchangeRates,
getSwapsDefaultToken,
getCurrentChainId,
getNativeCurrency,
isHardwareWallet,
getHardwareWalletType,
} from '../../../selectors';
import { getNativeCurrency, getTokens } from '../../../ducks/metamask/metamask';
import { toPrecisionWithoutTrailingZeros } from '../../../helpers/utils/util';
import { getTokens } from '../../../ducks/metamask/metamask';
import {
safeRefetchQuotes,
setCustomApproveTxData,

View File

@ -11,8 +11,8 @@ import {
} from '../helpers/utils/confirm-tx.util';
import { sumHexes } from '../helpers/utils/transactions.util';
import { transactionMatchesNetwork } from '../../shared/modules/transaction.utils';
import { getNativeCurrency } from '../ducks/metamask/metamask';
import { getCurrentChainId, deprecatedGetCurrentNetworkId } from './selectors';
import { getNativeCurrency } from '.';
const unapprovedTxsSelector = (state) => state.metamask.unapprovedTxs;
const unapprovedMsgsSelector = (state) => state.metamask.unapprovedMsgs;

View File

@ -24,7 +24,7 @@ import { TEMPLATED_CONFIRMATION_MESSAGE_TYPES } from '../pages/confirmation/temp
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
import { DAY } from '../../shared/constants/time';
import { getNativeCurrency } from './send';
import { getNativeCurrency } from '../ducks/metamask/metamask';
/**
* One of the only remaining valid uses of selecting the network subkey of the

View File

@ -1,25 +1,11 @@
import abi from 'human-standard-token-abi';
import { calcGasTotal } from '../pages/send/send.utils';
import {
accountsWithSendEtherInfoSelector,
getAddressBook,
getSelectedAccount,
getTargetAccount,
getAveragePriceEstimateInHexWEI,
} from '.';
export function getBlockGasLimit(state) {
return state.metamask.currentBlockGasLimit;
}
export function getConversionRate(state) {
return state.metamask.conversionRate;
}
export function getNativeCurrency(state) {
return state.metamask.nativeCurrency;
}
export function getGasLimit(state) {
return state.metamask.send.gasLimit || '0';
}
@ -60,10 +46,6 @@ export function getSendHexData(state) {
return state.metamask.send.data;
}
export function getSendHexDataFeatureFlagState(state) {
return state.metamask.featureFlags.sendHexData;
}
export function getSendEditingTransactionId(state) {
return state.metamask.send.editingTransactionId;
}
@ -104,11 +86,6 @@ export function getSendToNickname(state) {
return state.metamask.send.toNickname;
}
export function getSendToAccounts(state) {
const fromAccounts = accountsWithSendEtherInfoSelector(state);
const addressBookAccounts = getAddressBook(state);
return [...fromAccounts, ...addressBookAccounts];
}
export function getTokenBalance(state) {
return state.metamask.send.tokenBalance;
}
@ -121,10 +98,6 @@ export function getSendEnsResolutionError(state) {
return state.metamask.send.ensResolutionError;
}
export function getUnapprovedTxs(state) {
return state.metamask.unapprovedTxs;
}
export function getQrCodeData(state) {
return state.appState.qrCodeData;
}

View File

@ -1,9 +1,5 @@
import sinon from 'sinon';
import { TRANSACTION_STATUSES } from '../../shared/constants/transaction';
import {
getBlockGasLimit,
getConversionRate,
getNativeCurrency,
getGasLimit,
getGasPrice,
getGasTotal,
@ -17,12 +13,9 @@ import {
getSendFrom,
getSendFromBalance,
getSendFromObject,
getSendHexDataFeatureFlagState,
getSendMaxModeState,
getSendTo,
getSendToAccounts,
getTokenBalance,
getUnapprovedTxs,
gasFeeIsInError,
getGasLoadingError,
getGasButtonGroupShown,
@ -84,18 +77,6 @@ describe('send selectors', () => {
});
});
describe('getBlockGasLimit', () => {
it('should return the current block gas limit', () => {
expect(getBlockGasLimit(mockState)).toStrictEqual('0x4c1878');
});
});
describe('getConversionRate()', () => {
it('should return the eth conversion rate', () => {
expect(getConversionRate(mockState)).toStrictEqual(1200.88200327);
});
});
describe('getCurrentAccountWithSendEtherInfo()', () => {
it('should return the currently selected account with identity info', () => {
expect(getCurrentAccountWithSendEtherInfo(mockState)).toStrictEqual({
@ -108,12 +89,6 @@ describe('send selectors', () => {
});
});
describe('getNativeCurrency()', () => {
it('should return the ticker symbol of the selected network', () => {
expect(getNativeCurrency(mockState)).toStrictEqual('ETH');
});
});
describe('getGasLimit()', () => {
it('should return the send.gasLimit', () => {
expect(getGasLimit(mockState)).toStrictEqual('0xFFFF');
@ -207,12 +182,6 @@ describe('send selectors', () => {
});
});
describe('getSendHexDataFeatureFlagState()', () => {
it('should return the sendHexData feature flag state', () => {
expect(getSendHexDataFeatureFlagState(mockState)).toStrictEqual(true);
});
});
describe('getSendFrom()', () => {
it('should return the send.from', () => {
expect(getSendFrom(mockState)).toStrictEqual(
@ -279,78 +248,12 @@ describe('send selectors', () => {
});
});
describe('getSendToAccounts()', () => {
it('should return an array including all the users accounts and the address book', () => {
expect(getSendToAccounts(mockState)).toStrictEqual([
{
code: '0x',
balance: '0x47c9d71831c76efe',
nonce: '0x1b',
address: '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825',
name: 'Send Account 1',
},
{
code: '0x',
balance: '0x37452b1315889f80',
nonce: '0xa',
address: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
name: 'Send Account 2',
},
{
code: '0x',
balance: '0x30c9d71831c76efe',
nonce: '0x1c',
address: '0x2f8d4a878cfa04a6e60d46362f5644deab66572d',
name: 'Send Account 3',
},
{
code: '0x',
balance: '0x0',
nonce: '0x0',
address: '0xd85a4b6a394794842887b8284293d69163007bbb',
name: 'Send Account 4',
},
{
address: '0x06195827297c7a80a443b6894d3bdb8824b43896',
name: 'Address Book Account 1',
chainId: '0x3',
},
]);
});
});
describe('getTokenBalance()', () => {
it('should', () => {
expect(getTokenBalance(mockState)).toStrictEqual(3434);
});
});
describe('getUnapprovedTxs()', () => {
it('should return the unapproved txs', () => {
expect(getUnapprovedTxs(mockState)).toStrictEqual({
4768706228115573: {
id: 4768706228115573,
time: 1487363153561,
status: TRANSACTION_STATUSES.UNAPPROVED,
gasMultiplier: 1,
metamaskNetworkId: '3',
txParams: {
from: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
to: '0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761',
value: '0xde0b6b3a7640000',
metamaskId: 4768706228115573,
metamaskNetworkId: '3',
gas: '0x5209',
},
txFee: '17e0186e60800',
txValue: 'de0b6b3a7640000',
maxCost: 'de234b52e4a0800',
gasPrice: '4a817c800',
},
});
});
});
describe('send-amount-row selectors', () => {
describe('sendAmountIsInError()', () => {
it('should return true if send.errors.amount is truthy', () => {