Skip to content

Commit

Permalink
fix: Support dynamic native token name on gas component
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronfigueiredo committed Oct 23, 2024
1 parent e6f3c67 commit dcd8152
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ describe('Contract Deployment Confirmation', () => {
expect(editGasFeesRow).toHaveTextContent(tEn('networkFee') as string);

const firstGasField = within(editGasFeesRow).getByTestId('first-gas-field');
expect(firstGasField).toHaveTextContent('0.0001 ETH');
expect(firstGasField).toHaveTextContent('0.0001 SepoliaETH');
const editGasFeeNativeCurrency =
within(editGasFeesRow).getByTestId('native-currency');
expect(editGasFeeNativeCurrency).toHaveTextContent('$0.47');
Expand Down Expand Up @@ -371,7 +371,7 @@ describe('Contract Deployment Confirmation', () => {
const maxFee = screen.getByTestId('gas-fee-details-max-fee');
expect(gasFeesSection).toContainElement(maxFee);
expect(maxFee).toHaveTextContent(tEn('maxFee') as string);
expect(maxFee).toHaveTextContent('0.0023 ETH');
expect(maxFee).toHaveTextContent('0.0023 SepoliaETH');
expect(maxFee).toHaveTextContent('$7.72');

const nonceSection = screen.getByTestId('advanced-details-nonce-section');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ describe('Contract Interaction Confirmation', () => {
expect(editGasFeesRow).toHaveTextContent(tEn('networkFee') as string);

const firstGasField = within(editGasFeesRow).getByTestId('first-gas-field');
expect(firstGasField).toHaveTextContent('0.0001 ETH');
expect(firstGasField).toHaveTextContent('0.0001 SepoliaETH');
const editGasFeeNativeCurrency =
within(editGasFeesRow).getByTestId('native-currency');
expect(editGasFeeNativeCurrency).toHaveTextContent('$0.47');
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('Contract Interaction Confirmation', () => {
const maxFee = screen.getByTestId('gas-fee-details-max-fee');
expect(gasFeesSection).toContainElement(maxFee);
expect(maxFee).toHaveTextContent(tEn('maxFee') as string);
expect(maxFee).toHaveTextContent('0.0023 ETH');
expect(maxFee).toHaveTextContent('0.0023 SepoliaETH');
expect(maxFee).toHaveTextContent('$7.72');

const nonceSection = screen.getByTestId('advanced-details-nonce-section');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ describe('useFeeCalculations', () => {
expect(result.current).toMatchInlineSnapshot(`
{
"estimatedFeeFiat": "$0.00",
"estimatedFeeNative": "0 WEI",
"estimatedFeeNative": "0 ETH",
"l1FeeFiat": "",
"l1FeeNative": "",
"l2FeeFiat": "",
"l2FeeNative": "",
"maxFeeFiat": "$0.00",
"maxFeeNative": "0 WEI",
"maxFeeNative": "0 ETH",
}
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
addHexes,
decGWEIToHexWEI,
decimalToHex,
getEthConversionFromWeiHex,
getValueFromWeiHex,
multiplyHexes,
} from '../../../../../../../shared/modules/conversion.utils';
import { getConversionRate } from '../../../../../../ducks/metamask/metamask';
import { useFiatFormatter } from '../../../../../../hooks/useFiatFormatter';
import { useGasFeeEstimates } from '../../../../../../hooks/useGasFeeEstimates';
import { getCurrentCurrency } from '../../../../../../selectors';
import { getMultichainNetwork } from '../../../../../../selectors/multichain';
import { HEX_ZERO } from '../shared/constants';
import { useEIP1559TxFees } from './useEIP1559TxFees';
import { useSupportsEIP1559 } from './useSupportsEIP1559';
Expand All @@ -32,14 +32,18 @@ export function useFeeCalculations(transactionMeta: TransactionMeta) {
const conversionRate = useSelector(getConversionRate);
const fiatFormatter = useFiatFormatter();

const multichainNetwork = useSelector(getMultichainNetwork);
const ticker = multichainNetwork?.network?.ticker;

const getFeesFromHex = useCallback(
(hexFee: string) => {
const nativeCurrencyFee =
getEthConversionFromWeiHex({
const nativeCurrencyFee = `${
getValueFromWeiHex({
value: hexFee,
fromCurrency: EtherDenomination.GWEI,
numberOfDecimals: 4,
}) || `0 ${EtherDenomination.ETH}`;
}) || 0
} ${ticker}`;

const currentCurrencyFee = fiatFormatter(
Number(
Expand Down

0 comments on commit dcd8152

Please sign in to comment.