Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hide "interacting with" when simulated balance changes are shown #28409

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
import { useI18nContext } from '../../../../../../hooks/useI18nContext';
import { getNetworkConfigurationsByChainId } from '../../../../../../selectors';
import { useConfirmContext } from '../../../../context/confirm';
import { selectConfirmationAdvancedDetailsOpen } from '../../../../selectors/preferences';
import { useBalanceChanges } from '../../../simulation-details/useBalanceChanges';

export const TokenDetailsSection = () => {
const t = useI18nContext();
Expand All @@ -38,6 +40,20 @@ export const TokenDetailsSection = () => {
const networkConfigurations = useSelector(getNetworkConfigurationsByChainId);
const networkName = networkConfigurations[chainId].name;

const showAdvancedDetails = useSelector(
selectConfirmationAdvancedDetailsOpen,
);

const isSimulationError = Boolean(
transactionMeta.simulationData?.error?.code,
);
const balanceChangesResult = useBalanceChanges({
chainId,
simulationData: transactionMeta.simulationData,
});
const balanceChanges = balanceChangesResult.value;
const isSimulationEmpty = balanceChanges.length === 0;

const networkRow = (
<ConfirmInfoRow label={t('transactionFlowNetwork')}>
<Box
Expand All @@ -64,17 +80,18 @@ export const TokenDetailsSection = () => {
</ConfirmInfoRow>
);

const tokenRow = transactionMeta.type !== TransactionType.simpleSend && (
<ConfirmInfoRow
label={t('interactingWith')}
tooltip={t('interactingWithTransactionDescription')}
>
<ConfirmInfoRowAddress
address={transactionMeta.txParams.to as string}
chainId={chainId}
/>
</ConfirmInfoRow>
);
const tokenRow = transactionMeta.type !== TransactionType.simpleSend &&
(showAdvancedDetails || isSimulationEmpty || isSimulationError) && (
<ConfirmInfoRow
label={t('interactingWith')}
tooltip={t('interactingWithTransactionDescription')}
>
<ConfirmInfoRowAddress
address={transactionMeta.txParams.to as string}
chainId={chainId}
/>
</ConfirmInfoRow>
);

return (
<ConfirmInfoSection data-testid="confirmation__transaction-flow">
Expand Down