Skip to content

Commit

Permalink
feat(suite): translated estimated tx time based on fee
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed Feb 14, 2025
1 parent b4572b0 commit 2cfc78b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatDuration } from '@suite-common/suite-utils';
import { formatDurationStrict } from '@suite-common/suite-utils';
import { NetworkType, networks } from '@suite-common/wallet-config';
import { FeeInfo, GeneralPrecomposedTransactionFinal, StakeType } from '@suite-common/wallet-types';
import { getFee } from '@suite-common/wallet-utils';
Expand All @@ -7,6 +7,7 @@ import { CoinLogo, FeeRate } from '@trezor/product-components';
import { spacings } from '@trezor/theme';

import { AccountLabel, Translation } from 'src/components/suite';
import { useLocales } from 'src/hooks/suite';
import { useSelector } from 'src/hooks/suite/useSelector';
import { selectLabelingDataForSelectedAccount } from 'src/reducers/suite/metadataReducer';
import { Account } from 'src/types/wallet';
Expand Down Expand Up @@ -44,6 +45,7 @@ export const TransactionReviewSummary = ({
state => state.wallet.selectedAccount.account?.key,
) as string;
const fees = useSelector(state => state.wallet.fees);
const locale = useLocales();

const network = networks[account.symbol];
const { symbol, accountType, index, networkType } = account;
Expand All @@ -69,7 +71,7 @@ export const TransactionReviewSummary = ({
{estimateTime !== undefined && (
<Note iconName="clock">
{'≈ '}
{formatDuration(estimateTime)}
{formatDurationStrict(estimateTime, locale)}
</Note>
)}

Expand Down
12 changes: 10 additions & 2 deletions packages/suite/src/components/wallet/Fees/FeeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react';

import styled from 'styled-components';

import { formatDuration } from '@suite-common/suite-utils';
import { formatDurationStrict } from '@suite-common/suite-utils';
import { NetworkSymbol, NetworkType, getNetwork } from '@suite-common/wallet-config';
import {
FeeInfo,
Expand All @@ -16,6 +16,7 @@ import { FeeRate } from '@trezor/product-components';
import { spacings } from '@trezor/theme';

import { FiatValue } from 'src/components/suite/FiatValue';
import { useLocales } from 'src/hooks/suite';

import { FeeOption } from './Fees';

Expand Down Expand Up @@ -125,6 +126,7 @@ const BitcoinDetails = ({
symbol,
}: DetailsProps) => {
const [columns, setColumns] = React.useState(1);
const locale = useLocales();

const hasInfo = transactionInfo && transactionInfo.type !== 'error';
const ref = useRef<HTMLDivElement>(null);
Expand All @@ -151,7 +153,13 @@ const BitcoinDetails = ({
<span data-testid={`@fee-card/${fee.value}`}>{fee.label}</span>
}
topRightChild={
<>~{formatDuration(feeInfo.blockTime * (fee?.blocks ?? 0) * 60)}</>
<>
~
{formatDurationStrict(
feeInfo.blockTime * (fee?.blocks ?? 0) * 60,
locale,
)}
</>
}
bottomLeftChild={
<FiatValue
Expand Down

0 comments on commit 2cfc78b

Please sign in to comment.