Skip to content

Commit 7226357

Browse files
authored
Fix isMainnet propType error (#12951)
A propType error was showing up during e2e tests with a `testDev` build. It was caused by `process.env.IN_TEST` being treated as a boolean, when in fact it is either the string `'true'` or a boolean. `IN_TEST` has been updated to always be a boolean. `loose-envify` has no trouble injecting boolean values, so there's no reason to treat this as a string.
1 parent fac6898 commit 7226357

File tree

10 files changed

+10
-13
lines changed

10 files changed

+10
-13
lines changed

app/scripts/background.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const openMetamaskTabsIDs = {};
5656
const requestAccountTabIds = {};
5757

5858
// state persistence
59-
const inTest = process.env.IN_TEST === 'true';
59+
const inTest = process.env.IN_TEST;
6060
const localStore = inTest ? new ReadOnlyNetworkStore() : new LocalStore();
6161
let versionedData;
6262

app/scripts/controllers/network/createJsonRpcClient.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { PollingBlockTracker } from 'eth-block-tracker';
1111
import { SECOND } from '../../../../shared/constants/time';
1212

13-
const inTest = process.env.IN_TEST === 'true';
13+
const inTest = process.env.IN_TEST;
1414
const blockTrackerOpts = inTest ? { pollingInterval: SECOND } : {};
1515
const getTestMiddlewares = () => {
1616
return inTest ? [createEstimateGasDelayTestMiddleware()] : [];

app/scripts/controllers/network/network.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const env = process.env.METAMASK_ENV;
3333
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
3434

3535
let defaultProviderConfigOpts;
36-
if (process.env.IN_TEST === 'true') {
36+
if (process.env.IN_TEST) {
3737
defaultProviderConfigOpts = {
3838
type: NETWORK_TYPE_RPC,
3939
rpcUrl: 'http://localhost:8545',

development/build/scripts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ function getEnvironmentVariables({ buildType, devMode, testing }) {
779779
METAMASK_VERSION: version,
780780
METAMASK_BUILD_TYPE: buildType,
781781
NODE_ENV: devMode ? ENVIRONMENT.DEVELOPMENT : ENVIRONMENT.PRODUCTION,
782-
IN_TEST: testing ? 'true' : false,
782+
IN_TEST: testing,
783783
PUBNUB_SUB_KEY: process.env.PUBNUB_SUB_KEY || '',
784784
PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '',
785785
CONF: devMode ? metamaskrc : {},

ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const EditGasFeePopover = () => {
2929
className="edit-gas-fee-popover"
3030
>
3131
<>
32-
{process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />}
32+
{process.env.IN_TEST ? null : <LoadingHeartBeat />}
3333
<div className="edit-gas-fee-popover__wrapper">
3434
<div className="edit-gas-fee-popover__content">
3535
{balanceError && (

ui/components/app/edit-gas-popover/edit-gas-popover.component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export default function EditGasPopover({
261261
<EditGasDisplayEducation />
262262
) : (
263263
<>
264-
{process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />}
264+
{process.env.IN_TEST ? null : <LoadingHeartBeat />}
265265
<EditGasDisplay
266266
showEducationButton={showEducationButton}
267267
warning={warning}

ui/helpers/utils/i18n-helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const getMessage = (localeCode, localeMessages, key, substitutions) => {
3232
);
3333
Sentry.captureException(missingMessageErrors[key]);
3434
log.error(missingMessageErrors[key]);
35-
if (process.env.IN_TEST === 'true') {
35+
if (process.env.IN_TEST) {
3636
throw missingMessageErrors[key];
3737
}
3838
}

ui/pages/confirm-transaction-base/confirm-transaction-base.component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const EIP_1559_V2_ENABLED =
6868
process.env.EIP_1559_V2 === true || process.env.EIP_1559_V2 === 'true';
6969

7070
const renderHeartBeatIfNotInTest = () =>
71-
process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />;
71+
process.env.IN_TEST ? null : <LoadingHeartBeat />;
7272

7373
export default class ConfirmTransactionBase extends Component {
7474
static contextTypes = {

ui/pages/confirm-transaction-base/gas-details-item/gas-details-item.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import TransactionDetailItem from '../../../components/app/transaction-detail-it
1717
import UserPreferencedCurrencyDisplay from '../../../components/app/user-preferenced-currency-display';
1818
import { useGasFeeContext } from '../../../contexts/gasFee';
1919

20-
const HeartBeat = () =>
21-
process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />;
20+
const HeartBeat = () => (process.env.IN_TEST ? null : <LoadingHeartBeat />);
2221

2322
const GasDetailsItem = ({
2423
hexMaximumTransactionFee,

ui/pages/import-token/import-token.container.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ const mapStateToProps = (state) => {
2222
const showSearchTabCustomNetwork =
2323
useTokenDetection && Boolean(Object.keys(tokenList).length);
2424
const showSearchTab =
25-
getIsMainnet(state) ||
26-
showSearchTabCustomNetwork ||
27-
process.env.IN_TEST === 'true';
25+
getIsMainnet(state) || showSearchTabCustomNetwork || process.env.IN_TEST;
2826
return {
2927
identities,
3028
mostRecentOverviewPage: getMostRecentOverviewPage(state),

0 commit comments

Comments
 (0)