Commit 84ed9b9b authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Merge pull request #1402 from blockscout/fe-1387

tx fee can be null
parents 25e70ec3 51c2ae73
...@@ -10,9 +10,9 @@ const sortTxs = (sorting?: Sort) => (tx1: Transaction, tx2: Transaction) => { ...@@ -10,9 +10,9 @@ const sortTxs = (sorting?: Sort) => (tx1: Transaction, tx2: Transaction) => {
case 'val-asc': case 'val-asc':
return compareBns(tx2.value, tx1.value); return compareBns(tx2.value, tx1.value);
case 'fee-desc': case 'fee-desc':
return compareBns(tx1.fee.value, tx2.fee.value); return compareBns(tx1.fee.value || 0, tx2.fee.value || 0);
case 'fee-asc': case 'fee-asc':
return compareBns(tx2.fee.value, tx1.fee.value); return compareBns(tx2.fee.value || 0, tx1.fee.value || 0);
default: default:
return 0; return 0;
} }
......
export interface Fee { export interface Fee {
type: string; type: string;
value: string; value: string | null;
} }
...@@ -118,7 +118,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => { ...@@ -118,7 +118,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
{ tx.stability_fee ? ( { tx.stability_fee ? (
<TxFeeStability data={ tx.stability_fee } accuracy={ 5 } color="text_secondary" hideUsd/> <TxFeeStability data={ tx.stability_fee } accuracy={ 5 } color="text_secondary" hideUsd/>
) : ( ) : (
<Text as="span" variant="secondary">{ getValueWithUnit(tx.fee.value).dp(5).toFormat() }</Text> <Text as="span" variant="secondary">{ tx.fee.value ? getValueWithUnit(tx.fee.value).dp(5).toFormat() : '-' }</Text>
) } ) }
</Skeleton> </Skeleton>
) } ) }
......
...@@ -104,7 +104,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => { ...@@ -104,7 +104,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
{ tx.stability_fee ? ( { tx.stability_fee ? (
<TxFeeStability data={ tx.stability_fee } accuracy={ 5 } color="text_secondary" hideUsd/> <TxFeeStability data={ tx.stability_fee } accuracy={ 5 } color="text_secondary" hideUsd/>
) : ( ) : (
<Text as="span" variant="secondary">{ getValueWithUnit(tx.fee.value).dp(5).toFormat() }</Text> <Text as="span" variant="secondary">{ tx.fee.value ? getValueWithUnit(tx.fee.value).dp(5).toFormat() : '-' }</Text>
) } ) }
</Skeleton> </Skeleton>
) } ) }
......
...@@ -65,6 +65,7 @@ const TxDetailsWrapped = ({ data }: Props) => { ...@@ -65,6 +65,7 @@ const TxDetailsWrapped = ({ data }: Props) => {
flexWrap="wrap" flexWrap="wrap"
/> />
</DetailsInfoItem> </DetailsInfoItem>
{ data.fee.value !== null && (
<DetailsInfoItem <DetailsInfoItem
title="Transaction fee" title="Transaction fee"
hint="Total transaction fee" hint="Total transaction fee"
...@@ -75,6 +76,7 @@ const TxDetailsWrapped = ({ data }: Props) => { ...@@ -75,6 +76,7 @@ const TxDetailsWrapped = ({ data }: Props) => {
flexWrap="wrap" flexWrap="wrap"
/> />
</DetailsInfoItem> </DetailsInfoItem>
) }
<TxDetailsGasPrice gasPrice={ data.gas_price }/> <TxDetailsGasPrice gasPrice={ data.gas_price }/>
{ data.gas_limit && ( { data.gas_limit && (
<DetailsInfoItem <DetailsInfoItem
......
...@@ -6,13 +6,13 @@ import config from 'configs/app'; ...@@ -6,13 +6,13 @@ import config from 'configs/app';
import DetailsInfoItem from 'ui/shared/DetailsInfoItem'; import DetailsInfoItem from 'ui/shared/DetailsInfoItem';
interface Props { interface Props {
txFee: string; txFee: string | null;
gasUsed: string | null; gasUsed: string | null;
isLoading?: boolean; isLoading?: boolean;
} }
const TxDetailsFeePerGas = ({ txFee, gasUsed, isLoading }: Props) => { const TxDetailsFeePerGas = ({ txFee, gasUsed, isLoading }: Props) => {
if (!config.UI.views.tx.additionalFields?.fee_per_gas || !gasUsed) { if (!config.UI.views.tx.additionalFields?.fee_per_gas || !gasUsed || txFee === null) {
return null; return null;
} }
......
...@@ -33,6 +33,8 @@ const TxAdditionalInfoContent = ({ tx }: { tx: Transaction }) => { ...@@ -33,6 +33,8 @@ const TxAdditionalInfoContent = ({ tx }: { tx: Transaction }) => {
<Heading as="h4" size="sm" mb={ 6 }>Additional info </Heading> <Heading as="h4" size="sm" mb={ 6 }>Additional info </Heading>
{ !config.UI.views.tx.hiddenFields?.tx_fee && ( { !config.UI.views.tx.hiddenFields?.tx_fee && (
<Box { ...sectionProps } mb={ 4 }> <Box { ...sectionProps } mb={ 4 }>
{ (tx.stability_fee !== undefined || tx.fee.value !== null) && (
<>
<Text { ...sectionTitleProps }>Transaction fee</Text> <Text { ...sectionTitleProps }>Transaction fee</Text>
{ tx.stability_fee ? ( { tx.stability_fee ? (
<TxFeeStability data={ tx.stability_fee }/> <TxFeeStability data={ tx.stability_fee }/>
...@@ -48,6 +50,8 @@ const TxAdditionalInfoContent = ({ tx }: { tx: Transaction }) => { ...@@ -48,6 +50,8 @@ const TxAdditionalInfoContent = ({ tx }: { tx: Transaction }) => {
/> />
</Flex> </Flex>
) } ) }
</>
) }
</Box> </Box>
) } ) }
{ tx.gas_used !== null && ( { tx.gas_used !== null && (
......
...@@ -134,15 +134,19 @@ const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeI ...@@ -134,15 +134,19 @@ const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeI
) } ) }
{ !config.UI.views.tx.hiddenFields?.tx_fee && ( { !config.UI.views.tx.hiddenFields?.tx_fee && (
<Flex mt={ 2 } mb={ 3 } columnGap={ 2 }> <Flex mt={ 2 } mb={ 3 } columnGap={ 2 }>
{ (tx.stability_fee !== undefined || tx.fee.value !== null) && (
<>
<Skeleton isLoaded={ !isLoading } display="inline-block" whiteSpace="pre">Fee</Skeleton> <Skeleton isLoaded={ !isLoading } display="inline-block" whiteSpace="pre">Fee</Skeleton>
{ tx.stability_fee ? ( { tx.stability_fee ? (
<TxFeeStability data={ tx.stability_fee } isLoading={ isLoading } hideUsd/> <TxFeeStability data={ tx.stability_fee } isLoading={ isLoading } hideUsd/>
) : ( ) : (
<Skeleton isLoaded={ !isLoading } display="inline-block" variant="text_secondary" whiteSpace="pre"> <Skeleton isLoaded={ !isLoading } display="inline-block" variant="text_secondary" whiteSpace="pre">
{ getValueWithUnit(tx.fee.value).toFormat() } { getValueWithUnit(tx.fee.value || 0).toFormat() }
{ config.UI.views.tx.hiddenFields?.fee_currency ? '' : ` ${ config.chain.currency.symbol }` } { config.UI.views.tx.hiddenFields?.fee_currency ? '' : ` ${ config.chain.currency.symbol }` }
</Skeleton> </Skeleton>
) } ) }
</>
) }
</Flex> </Flex>
) } ) }
</ListItemMobile> </ListItemMobile>
......
...@@ -164,10 +164,11 @@ const TxsTableItem = ({ tx, showBlockInfo, currentAddress, enableTimeIncrement, ...@@ -164,10 +164,11 @@ const TxsTableItem = ({ tx, showBlockInfo, currentAddress, enableTimeIncrement,
) } ) }
{ !config.UI.views.tx.hiddenFields?.tx_fee && ( { !config.UI.views.tx.hiddenFields?.tx_fee && (
<Td isNumeric> <Td isNumeric>
{ /* eslint-disable-next-line no-nested-ternary */ }
{ tx.stability_fee ? ( { tx.stability_fee ? (
<TxFeeStability data={ tx.stability_fee } isLoading={ isLoading } accuracy={ 8 } justifyContent="end" hideUsd/> <TxFeeStability data={ tx.stability_fee } isLoading={ isLoading } accuracy={ 8 } justifyContent="end" hideUsd/>
) : ( ) : (
<CurrencyValue value={ tx.fee.value } accuracy={ 8 } isLoading={ isLoading }/> tx.fee.value ? <CurrencyValue value={ tx.fee.value } accuracy={ 8 } isLoading={ isLoading }/> : '-'
) } ) }
</Td> </Td>
) } ) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment