Skip to content

Commit

Permalink
addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NiranjanaBinoy committed Dec 13, 2022
1 parent 8cfb34c commit f27e156
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 34 deletions.
1 change: 0 additions & 1 deletion app/scripts/controllers/detect-tokens.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('DetectTokensController', function () {
};
return cb(modifiedNetworkState);
}),
// config: { provider: this.provider },
});

assetsContractController = new AssetsContractController(
Expand Down
1 change: 0 additions & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,6 @@ export default class MetamaskController extends EventEmitter {
// TODO: Handle failure to get conversion rate more gracefully
console.error(error);
}
// }
});

this.networkController.lookupNetwork();
Expand Down
8 changes: 1 addition & 7 deletions ui/components/app/asset-list/asset-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
getNativeCurrencyImage,
getDetectedTokensInCurrentNetwork,
getIstokenDetectionInactiveOnNonMainnetSupportedNetwork,
getUseCurrencyRateCheck,
} from '../../../selectors';
import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import { useCurrencyDisplay } from '../../../hooks/useCurrencyDisplay';
Expand All @@ -38,7 +37,6 @@ const AssetList = ({ onClickAsset }) => {
const selectedAccountBalance = useSelector(getSelectedAccountCachedBalance);
const nativeCurrency = useSelector(getNativeCurrency);
const showFiat = useSelector(getShouldShowFiat);
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
const trackEvent = useContext(MetaMetricsContext);
const balance = useSelector(getSelectedAccountCachedBalance);
const balanceIsLoading = !balance;
Expand Down Expand Up @@ -81,11 +79,7 @@ const AssetList = ({ onClickAsset }) => {
primaryCurrencyProperties.value ?? secondaryCurrencyProperties.value
}
tokenSymbol={primaryCurrencyProperties.suffix}
secondary={
showFiat && useCurrencyRateCheck
? secondaryCurrencyDisplay
: undefined
}
secondary={showFiat ? secondaryCurrencyDisplay : undefined}
tokenImage={balanceIsLoading ? null : primaryTokenImage}
identiconBorder
/>
Expand Down
1 change: 1 addition & 0 deletions ui/components/app/currency-input/currency-input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('CurrencyInput Component', () => {
preferences: {
showFiatInTestnets: true,
},
useCurrencyRateCheck: true,
},
};
describe('rendering', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ describe('DetectedTokenDetails', () => {
renderWithProvider(<DetectedTokenDetails {...args} />, store);

expect(screen.getByText('0 SNX')).toBeInTheDocument();
expect(screen.getByText('$0')).toBeInTheDocument();
expect(screen.getByText('Token address:')).toBeInTheDocument();
expect(screen.getByText('0xc01...2a6f')).toBeInTheDocument();
expect(screen.getByText('From token lists:')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';

import Box from '../../../ui/box';
Expand All @@ -13,14 +12,12 @@ import {
} from '../../../../helpers/constants/design-system';
import { useTokenTracker } from '../../../../hooks/useTokenTracker';
import { useTokenFiatAmount } from '../../../../hooks/useTokenFiatAmount';
import { getUseCurrencyRateCheck } from '../../../../selectors';

const DetectedTokenValues = ({
token,
handleTokenSelection,
tokensListDetected,
}) => {
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
const [tokenSelection, setTokenSelection] = useState(() => {
return tokensListDetected[token.address]?.selected;
});
Expand Down Expand Up @@ -49,7 +46,7 @@ const DetectedTokenValues = ({
{`${balanceString || '0'} ${token.symbol}`}
</Typography>
<Typography variant={TYPOGRAPHY.H7} color={COLORS.TEXT_ALTERNATIVE}>
{useCurrencyRateCheck && (formattedFiatBalance || '$0')}
{formattedFiatBalance}
</Typography>
</Box>
<Box className="detected-token-values__checkbox">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,5 @@ describe('DetectedTokenValues', () => {
renderWithProvider(<DetectedTokenValues {...args} />, store);

expect(screen.getByText('0 SNX')).toBeInTheDocument();
expect(screen.getByText('$0')).toBeInTheDocument();
});
});
1 change: 0 additions & 1 deletion ui/components/app/detected-token/detected-token.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('DetectedToken', () => {
expect(screen.getByText('0 LINK')).toBeInTheDocument();
expect(screen.getByText('0 COMP')).toBeInTheDocument();
expect(screen.getByText('0 FSW')).toBeInTheDocument();
expect(screen.getAllByText('$0')).toHaveLength(3);
expect(screen.getAllByText('Token address:')).toHaveLength(3);
expect(screen.getByText('0x514...86CA')).toBeInTheDocument();
expect(screen.getByText('0xc00...6888')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useContext, useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import { captureException } from '@sentry/browser';
import TransactionDetailItem from '../transaction-detail-item/transaction-detail-item.component';
Expand All @@ -12,7 +11,6 @@ import {
toBigNumber,
toNormalizedDenomination,
} from '../../../../shared/modules/conversion.utils';
import { getUseCurrencyRateCheck } from '../../../selectors';

export default function MultilayerFeeMessage({
transaction,
Expand All @@ -21,7 +19,6 @@ export default function MultilayerFeeMessage({
plainStyle,
}) {
const t = useContext(I18nContext);
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);

const [fetchedLayer1Total, setLayer1Total] = useState(null);

Expand Down Expand Up @@ -84,15 +81,15 @@ export default function MultilayerFeeMessage({
key="total-item"
detailTitle={t('gasFee')}
detailTotal={layer1Total}
detailText={useCurrencyRateCheck && feeTotalInFiat}
detailText={feeTotalInFiat}
noBold={plainStyle}
flexWidthValues={plainStyle}
/>
<TransactionDetailItem
key="total-item"
detailTitle={t('total')}
detailTotal={totalInEth}
detailText={useCurrencyRateCheck && totalInFiat}
detailText={totalInFiat}
subTitle={t('transactionDetailMultiLayerTotalSubtitle')}
noBold={plainStyle}
flexWidthValues={plainStyle}
Expand Down
8 changes: 2 additions & 6 deletions ui/components/app/token-cell/token-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import { useSelector } from 'react-redux';
import AssetListItem from '../asset-list-item';
import {
getSelectedAddress,
getUseCurrencyRateCheck,
} from '../../../selectors';
import { getSelectedAddress } from '../../../selectors';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount';

Expand All @@ -20,7 +17,6 @@ export default function TokenCell({
isERC721,
}) {
const userAddress = useSelector(getSelectedAddress);
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
const t = useI18nContext();

const formattedFiat = useTokenFiatAmount(address, string, symbol);
Expand Down Expand Up @@ -51,7 +47,7 @@ export default function TokenCell({
tokenDecimals={decimals}
warning={warning}
primary={`${string || 0}`}
secondary={useCurrencyRateCheck && formattedFiat}
secondary={formattedFiat}
isERC721={isERC721}
/>
);
Expand Down
4 changes: 1 addition & 3 deletions ui/components/app/wallet-overview/eth-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
getIsBuyableChain,
getNativeCurrencyImage,
getSelectedAccountCachedBalance,
getUseCurrencyRateCheck,
} from '../../../selectors/selectors';
import SwapIcon from '../../ui/icon/swap-icon.component';
import BuyIcon from '../../ui/icon/overview-buy-icon.component';
Expand Down Expand Up @@ -53,7 +52,6 @@ const EthOverview = ({ className }) => {
const isBuyableChain = useSelector(getIsBuyableChain);
const primaryTokenImage = useSelector(getNativeCurrencyImage);
const defaultSwapsToken = useSelector(getSwapsDefaultToken);
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);

return (
<>
Expand Down Expand Up @@ -91,7 +89,7 @@ const EthOverview = ({ className }) => {
<span className="eth-overview__cached-star">*</span>
) : null}
</div>
{showFiat && balance && useCurrencyRateCheck && (
{showFiat && balance && (
<UserPreferencedCurrencyDisplay
className={classnames({
'eth-overview__cached-secondary-balance': balanceIsCached,
Expand Down
4 changes: 1 addition & 3 deletions ui/components/app/wallet-overview/token-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
getIsBuyableTransakToken,
getIsBuyableMoonpayToken,
getIsBuyableWyreToken,
getUseCurrencyRateCheck,
} from '../../../selectors/selectors';

import BuyIcon from '../../ui/icon/overview-buy-icon.component';
Expand Down Expand Up @@ -68,7 +67,6 @@ const TokenOverview = ({ className, token }) => {
const isTokenBuyableWyre = useSelector((state) =>
getIsBuyableWyreToken(state, token.symbol),
);
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);

const isBuyable =
isTokenBuyableCoinbasePay ||
Expand Down Expand Up @@ -103,7 +101,7 @@ const TokenOverview = ({ className, token }) => {
displayValue={balanceToRender}
suffix={token.symbol}
/>
{formattedFiatBalance && useCurrencyRateCheck ? (
{formattedFiatBalance ? (
<CurrencyDisplay
className="token-overview__secondary-balance"
displayValue={formattedFiatBalance}
Expand Down
5 changes: 4 additions & 1 deletion ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,12 @@ export function getShouldShowFiat(state) {
const isMainNet = getIsMainnet(state);
const isCustomNetwork = getIsCustomNetwork(state);
const conversionRate = getConversionRate(state);
const useCurrencyRateCheck = getUseCurrencyRateCheck(state);
const { showFiatInTestnets } = getPreferences(state);
return Boolean(
(isMainNet || isCustomNetwork || showFiatInTestnets) && conversionRate,
(isMainNet || isCustomNetwork || showFiatInTestnets) &&
useCurrencyRateCheck &&
conversionRate,
);
}

Expand Down

0 comments on commit f27e156

Please sign in to comment.