Incorrect amount of tx value if decimals for native token is not equal 18 (#3129)

NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS is not respected in transaction amounts

Resolves #3128
This commit is contained in:
tom goriunov
2025-11-14 13:03:36 +01:00
committed by GitHub
parent 770980044d
commit 9b89142dbd
17 changed files with 42 additions and 7 deletions
+2
View File
@@ -2,6 +2,7 @@ import React from 'react';
import type { ClusterByNameResponse } from 'types/api/clusters';
import config from 'configs/app';
import { isEvmAddress } from 'lib/address/isEvmAddress';
import { currencyUnits } from 'lib/units';
import { Skeleton } from 'toolkit/chakra/skeleton';
@@ -79,6 +80,7 @@ const ClusterDetails = ({ clusterData, clusterName, isLoading }: Props) => {
<CurrencyValue
value={ clusterData?.backingWei || '0' }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
isLoading={ isLoading }
/>
</DetailedInfo.ItemValue>
@@ -59,7 +59,12 @@ const BeaconChainDepositsListItem = ({ item, isLoading, view }: Props) => {
<ListItemMobileGrid.Label isLoading={ isLoading }>Value</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value>
<CurrencyValue value={ item.amount } currency={ currencyUnits.ether } isLoading={ isLoading }/>
<CurrencyValue
value={ item.amount }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
isLoading={ isLoading }
/>
</ListItemMobileGrid.Value>
{ view !== 'address' && (
@@ -2,6 +2,7 @@ import React from 'react';
import type { DepositsItem } from 'types/api/deposits';
import config from 'configs/app';
import { TableCell, TableRow } from 'toolkit/chakra/table';
import BeaconChainDepositSignature from 'ui/shared/beacon/BeaconChainDepositSignature';
import BeaconChainDepositStatusTag from 'ui/shared/beacon/BeaconChainDepositStatusTag';
@@ -51,7 +52,7 @@ const BeaconChainDepositsTableItem = ({ item, view, isLoading }: Props) => {
</TableCell>
) }
<TableCell verticalAlign="middle">
<CurrencyValue value={ item.amount } isLoading={ isLoading }/>
<CurrencyValue value={ item.amount } isLoading={ isLoading } decimals={ String(config.chain.currency.decimals) }/>
</TableCell>
{ view !== 'address' && (
<TableCell verticalAlign="middle">
+1
View File
@@ -65,6 +65,7 @@ const TxFee = ({ className, tx, accuracy, accuracyUsd, isLoading, withCurrency =
<CurrencyValue
value={ tx.fee.value }
currency={ showCurrency ? currencyUnits.ether : '' }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ withUsd && 'exchange_rate' in tx ? tx.exchange_rate : null }
accuracy={ accuracy }
accuracyUsd={ accuracyUsd }
+2
View File
@@ -5,6 +5,7 @@ import React from 'react';
import type { Transaction } from 'types/api/transaction';
import type { ExcludeUndefined } from 'types/utils';
import config from 'configs/app';
import { currencyUnits } from 'lib/units';
import { Badge } from 'toolkit/chakra/badge';
import CurrencyValue from 'ui/shared/CurrencyValue';
@@ -72,6 +73,7 @@ const TxDetailsWrapped = ({ data }: Props) => {
<CurrencyValue
value={ data.value }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
flexWrap="wrap"
/>
</DetailedInfo.ItemValue>
+1
View File
@@ -45,6 +45,7 @@ const TxDetailsBurntFees = ({ data, isLoading }: Props) => {
startElement={ <IconSvg name="flame" boxSize={ 5 } color="icon.primary" isLoading={ isLoading } mr={{ base: 0, lg: 1 }}/> }
value={ value.toString() }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ data.exchange_rate }
alignItems="center"
flexWrap="wrap"
@@ -32,6 +32,7 @@ const TxDetailsSetMaxGasLimit = ({ data }: Props) => {
<CurrencyValue
value={ maxGasLimit.toString() }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ 'exchange_rate' in data ? data.exchange_rate : null }
showGweiTooltip
flexWrap="wrap"
+3
View File
@@ -41,6 +41,7 @@ const TxDetailsTxFee = ({ isLoading, data }: Props) => {
<CurrencyValue
value={ data.fee.value }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ 'exchange_rate' in data ? data.exchange_rate : null }
isLoading={ isLoading }
showGweiTooltip
@@ -56,6 +57,7 @@ const TxDetailsTxFee = ({ isLoading, data }: Props) => {
<CurrencyValue
value={ baseFeeBn.toString() }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ 'exchange_rate' in data ? data.exchange_rate : null }
isLoading={ isLoading }
showGweiTooltip
@@ -70,6 +72,7 @@ const TxDetailsTxFee = ({ isLoading, data }: Props) => {
<CurrencyValue
value={ priorityFeeBn.toString() }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ 'exchange_rate' in data ? data.exchange_rate : null }
isLoading={ isLoading }
showGweiTooltip
+4
View File
@@ -617,6 +617,7 @@ const TxInfo = ({ data, tacOperations, isLoading, socketStatus }: Props) => {
<CurrencyValue
value={ data.value }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ data.exchange_rate }
isLoading={ isLoading }
flexWrap="wrap"
@@ -638,6 +639,7 @@ const TxInfo = ({ data, tacOperations, isLoading, socketStatus }: Props) => {
<CurrencyValue
value={ data.operator_fee }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ data.exchange_rate }
flexWrap="wrap"
/>
@@ -657,6 +659,7 @@ const TxInfo = ({ data, tacOperations, isLoading, socketStatus }: Props) => {
<CurrencyValue
value={ data.arbitrum.poster_fee }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ data.exchange_rate }
flexWrap="wrap"
isLoading={ isLoading }
@@ -673,6 +676,7 @@ const TxInfo = ({ data, tacOperations, isLoading, socketStatus }: Props) => {
<CurrencyValue
value={ data.arbitrum.network_fee }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ data.exchange_rate }
flexWrap="wrap"
isLoading={ isLoading }
+5
View File
@@ -4,6 +4,7 @@ import React from 'react';
import type { Transaction } from 'types/api/transaction';
import config from 'configs/app';
import { currencyUnits } from 'lib/units';
import { Skeleton } from 'toolkit/chakra/skeleton';
import { WEI_IN_GWEI } from 'toolkit/utils/consts';
@@ -32,6 +33,7 @@ export const TxInfoScrollFees = ({ data, isLoading }: Props) => {
<CurrencyValue
value={ data.scroll?.l1_fee }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ data.exchange_rate }
flexWrap="wrap"
/>
@@ -51,6 +53,7 @@ export const TxInfoScrollFees = ({ data, isLoading }: Props) => {
<CurrencyValue
value={ data.scroll?.l2_fee.value }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ data.exchange_rate }
flexWrap="wrap"
/>
@@ -70,6 +73,7 @@ export const TxInfoScrollFees = ({ data, isLoading }: Props) => {
<CurrencyValue
value={ String(data.scroll?.l1_fee_commit_scalar) }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ data.exchange_rate }
flexWrap="wrap"
/>
@@ -90,6 +94,7 @@ export const TxInfoScrollFees = ({ data, isLoading }: Props) => {
<CurrencyValue
value={ String(data.scroll?.l1_fee_overhead) }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ data.exchange_rate }
flexWrap="wrap"
/>
+1 -1
View File
@@ -113,7 +113,7 @@ const TxsTableItem = ({ tx, showBlockInfo, currentAddress, enableTimeIncrement,
</TableCell>
{ !config.UI.views.tx.hiddenFields?.value && (
<TableCell isNumeric>
<CurrencyValue value={ tx.value } accuracy={ 8 } isLoading={ isLoading } wordBreak="break-word"/>
<CurrencyValue value={ tx.value } decimals={ String(config.chain.currency.decimals) } accuracy={ 8 } isLoading={ isLoading } wordBreak="break-word"/>
</TableCell>
) }
{ !config.UI.views.tx.hiddenFields?.tx_fee && (
+1
View File
@@ -145,6 +145,7 @@ const UserOpDetails = ({ query }: Props) => {
<CurrencyValue
value={ data.fee }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
isLoading={ isPlaceholderData }
/>
</DetailedInfo.ItemValue>
+7 -1
View File
@@ -90,7 +90,13 @@ const UserOpsListItem = ({ item, isLoading, showTx, showSender, chainData }: Pro
<>
<ListItemMobileGrid.Label isLoading={ isLoading }>Fee</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value>
<CurrencyValue value={ item.fee } isLoading={ isLoading } accuracy={ 8 } currency={ chainConfig.chain.currency.symbol }/>
<CurrencyValue
value={ item.fee }
isLoading={ isLoading }
accuracy={ 8 }
currency={ chainConfig.chain.currency.symbol }
decimals={ String(config.chain.currency.decimals) }
/>
</ListItemMobileGrid.Value>
</>
) }
+1 -1
View File
@@ -73,7 +73,7 @@ const UserOpsTableItem = ({ item, isLoading, showTx, showSender, chainData }: Pr
</TableCell>
{ !config.UI.views.tx.hiddenFields?.tx_fee && (
<TableCell verticalAlign="middle" isNumeric>
<CurrencyValue value={ item.fee } isLoading={ isLoading } accuracy={ 8 }/>
<CurrencyValue value={ item.fee } isLoading={ isLoading } accuracy={ 8 } decimals={ String(config.chain.currency.decimals) }/>
</TableCell>
) }
</TableRow>
@@ -82,7 +82,7 @@ const BeaconChainWithdrawalsListItem = ({ item, isLoading, view }: Props) => {
<ListItemMobileGrid.Label isLoading={ isLoading }>Value</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value>
<CurrencyValue value={ item.amount } currency={ currencyUnits.ether } isLoading={ isLoading }/>
<CurrencyValue value={ item.amount } currency={ currencyUnits.ether } decimals={ String(config.chain.currency.decimals) } isLoading={ isLoading }/>
</ListItemMobileGrid.Value>
</>
) }
@@ -4,6 +4,7 @@ import type { AddressWithdrawalsItem } from 'types/api/address';
import type { BlockWithdrawalsItem } from 'types/api/block';
import type { WithdrawalsItem } from 'types/api/withdrawals';
import config from 'configs/app';
import { Skeleton } from 'toolkit/chakra/skeleton';
import { TableCell, TableRow } from 'toolkit/chakra/table';
import CurrencyValue from 'ui/shared/CurrencyValue';
@@ -61,7 +62,7 @@ const BeaconChainWithdrawalsTableItem = ({ item, view, isLoading }: Props) => {
</TableCell>
) }
<TableCell verticalAlign="middle">
<CurrencyValue value={ item.amount } isLoading={ isLoading }/>
<CurrencyValue value={ item.amount } decimals={ String(config.chain.currency.decimals) } isLoading={ isLoading }/>
</TableCell>
</TableRow>
);
@@ -3,6 +3,7 @@ import React from 'react';
import type { CrossChainTx } from '@blockscout/zetachain-cctx-types';
import config from 'configs/app';
import useApiQuery from 'lib/api/useApiQuery';
import base64ToHex from 'lib/base64ToHex';
import { currencyUnits } from 'lib/units';
@@ -116,6 +117,7 @@ const ZetaChainCCTXDetails = ({ data, isLoading }: Props) => {
<CurrencyValue
value={ data.zeta_fees }
currency={ currencyUnits.ether }
decimals={ String(config.chain.currency.decimals) }
exchangeRate={ statsQuery.data?.coin_price }
accuracy={ 4 }
accuracyUsd={ 2 }