Skip to content

Commit

Permalink
tx fee can be null
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminaAiren committed Dec 7, 2023
1 parent 19ea108 commit d75e1a9
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 38 deletions.
4 changes: 2 additions & 2 deletions lib/tx/sortTxs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const sortTxs = (sorting?: Sort) => (tx1: Transaction, tx2: Transaction) => {
case 'val-asc':
return compareBns(tx2.value, tx1.value);
case 'fee-desc':
return compareBns(tx1.fee.value, tx2.fee.value);
return compareBns(tx1.fee.value || 0, tx2.fee.value || 0);
case 'fee-asc':
return compareBns(tx2.fee.value, tx1.fee.value);
return compareBns(tx2.fee.value || 0, tx1.fee.value || 0);
default:
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion types/api/fee.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface Fee {
type: string;
value: string;
value: string | null;
}
2 changes: 1 addition & 1 deletion ui/home/LatestTxsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
{ tx.stability_fee ? (
<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>
) }
Expand Down
2 changes: 1 addition & 1 deletion ui/home/LatestTxsItemMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
{ tx.stability_fee ? (
<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>
) }
Expand Down
22 changes: 12 additions & 10 deletions ui/tx/TxDetailsWrapped.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,18 @@ const TxDetailsWrapped = ({ data }: Props) => {
flexWrap="wrap"
/>
</DetailsInfoItem>
<DetailsInfoItem
title="Transaction fee"
hint="Total transaction fee"
>
<CurrencyValue
value={ data.fee.value }
currency={ config.chain.currency.symbol }
flexWrap="wrap"
/>
</DetailsInfoItem>
{ data.fee.value !== null && (
<DetailsInfoItem
title="Transaction fee"
hint="Total transaction fee"
>
<CurrencyValue
value={ data.fee.value }
currency={ config.chain.currency.symbol }
flexWrap="wrap"
/>
</DetailsInfoItem>
) }
<TxDetailsGasPrice gasPrice={ data.gas_price }/>
{ data.gas_limit && (
<DetailsInfoItem
Expand Down
32 changes: 18 additions & 14 deletions ui/txs/TxAdditionalInfoContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,24 @@ const TxAdditionalInfoContent = ({ tx }: { tx: Transaction }) => {
<Heading as="h4" size="sm" mb={ 6 }>Additional info </Heading>
{ !config.UI.views.tx.hiddenFields?.tx_fee && (
<Box { ...sectionProps } mb={ 4 }>
<Text { ...sectionTitleProps }>Transaction fee</Text>
{ tx.stability_fee ? (
<TxFeeStability data={ tx.stability_fee }/>
) : (
<Flex>
<CurrencyValue
value={ tx.fee.value }
currency={ config.UI.views.tx.hiddenFields?.fee_currency ? '' : config.chain.currency.symbol }
exchangeRate={ tx.exchange_rate }
accuracyUsd={ 2 }
flexWrap="wrap"
rowGap={ 0 }
/>
</Flex>
{ (tx.stability_fee !== undefined || tx.fee.value !== null) && (
<>
<Text { ...sectionTitleProps }>Transaction fee</Text>
{ tx.stability_fee ? (
<TxFeeStability data={ tx.stability_fee }/>
) : (
<Flex>
<CurrencyValue
value={ tx.fee.value }
currency={ config.UI.views.tx.hiddenFields?.fee_currency ? '' : config.chain.currency.symbol }
exchangeRate={ tx.exchange_rate }
accuracyUsd={ 2 }
flexWrap="wrap"
rowGap={ 0 }
/>
</Flex>
) }
</>
) }
</Box>
) }
Expand Down
20 changes: 12 additions & 8 deletions ui/txs/TxsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,18 @@ const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeI
) }
{ !config.UI.views.tx.hiddenFields?.tx_fee && (
<Flex mt={ 2 } mb={ 3 } columnGap={ 2 }>
<Skeleton isLoaded={ !isLoading } display="inline-block" whiteSpace="pre">Fee</Skeleton>
{ tx.stability_fee ? (
<TxFeeStability data={ tx.stability_fee } isLoading={ isLoading } hideUsd/>
) : (
<Skeleton isLoaded={ !isLoading } display="inline-block" variant="text_secondary" whiteSpace="pre">
{ getValueWithUnit(tx.fee.value).toFormat() }
{ config.UI.views.tx.hiddenFields?.fee_currency ? '' : ` ${ config.chain.currency.symbol }` }
</Skeleton>
{ (tx.stability_fee !== undefined || tx.fee.value !== null) && (
<>
<Skeleton isLoaded={ !isLoading } display="inline-block" whiteSpace="pre">Fee</Skeleton>
{ tx.stability_fee ? (
<TxFeeStability data={ tx.stability_fee } isLoading={ isLoading } hideUsd/>
) : (
<Skeleton isLoaded={ !isLoading } display="inline-block" variant="text_secondary" whiteSpace="pre">
{ getValueWithUnit(tx.fee.value || 0).toFormat() }
{ config.UI.views.tx.hiddenFields?.fee_currency ? '' : ` ${ config.chain.currency.symbol }` }
</Skeleton>
) }
</>
) }
</Flex>
) }
Expand Down
3 changes: 2 additions & 1 deletion ui/txs/TxsTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ const TxsTableItem = ({ tx, showBlockInfo, currentAddress, enableTimeIncrement,
) }
{ !config.UI.views.tx.hiddenFields?.tx_fee && (
<Td isNumeric>
{ /* eslint-disable-next-line no-nested-ternary */ }
{ tx.stability_fee ? (
<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>
) }
Expand Down

0 comments on commit d75e1a9

Please sign in to comment.