Skip to content

Commit

Permalink
feat(suite): added rent fee translation
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasBoda authored and tomasklim committed Mar 1, 2025
1 parent 2650f6b commit d54f973
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const getLines = (
const isEthereum = networkType === 'ethereum';
const isSolana = networkType === 'solana';
const showAmountWithoutFee = isEthereum || isSolana;
const feeLabel = ((network: NetworkType) => {
const feeLabelId = ((network: NetworkType) => {
switch (network) {
case 'ethereum':
return 'MAX_FEE';
case 'solana':
return 'TR_TX_FEE';
return 'TR_TX_FEE_INCLUDING_RENT';
default:
return 'TR_INCLUDING_FEE';
}
Expand Down Expand Up @@ -76,7 +76,7 @@ const getLines = (
},
{
id: 'fee',
label: <Translation id={feeLabel} />,
label: <Translation id={feeLabelId} />,
value: precomposedTx.fee,
type: 'amount',
},
Expand Down
38 changes: 25 additions & 13 deletions packages/suite/src/components/wallet/Fees/Fees.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMemo } from 'react';
import {
Control,
FieldErrors,
Expand Down Expand Up @@ -155,6 +156,28 @@ export const Fees = <TFieldValues extends FormState>({

const supportsCustomFee = networkType !== 'solana';

const feeLabelId = useMemo(() => {
switch (networkType) {
case 'ethereum':
return 'MAX_FEE';
case 'solana':
return 'TR_TX_FEE_INCLUDING_RENT';
default:
return 'FEE';
}
}, [networkType]);

const feeTooltipTextId = useMemo(() => {
switch (networkType) {
case 'ethereum':
return 'TR_EVM_MAX_FEE_DESC';
case 'solana':
return 'TR_SOL_FEE_DESC';
default:
return 'TR_TRANSACTION_FEE_DESC';
}
}, [networkType]);

return (
<Column gap={spacings.md}>
<Row flexWrap="wrap">
Expand All @@ -168,21 +191,10 @@ export const Fees = <TFieldValues extends FormState>({
<Tooltip
dashed
maxWidth={328}
content={
networkType === 'ethereum' ? (
<Translation id="TR_EVM_MAX_FEE_DESC" />
) : (
<Translation id="TR_TRANSACTION_FEE_DESC" />
)
}
content={<Translation id={feeTooltipTextId} />}
>
<Text variant="default">
<Translation
id={
label ??
(networkType === 'ethereum' ? 'MAX_FEE' : 'FEE')
}
/>
<Translation id={label ?? feeLabelId} />
</Text>
</Tooltip>
</Row>
Expand Down
12 changes: 12 additions & 0 deletions packages/suite/src/support/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3254,6 +3254,10 @@ export default defineMessages({
defaultMessage: 'Fee',
id: 'TR_TX_FEE',
},
TR_TX_FEE_INCLUDING_RENT: {
defaultMessage: 'Fee (incl. rent)',
id: 'TR_TX_FEE_INCLUDING_RENT',
},
TR_UNCONFIRMED_TX: {
defaultMessage: 'Unconfirmed',
id: 'TR_UNCONFIRMED_TX',
Expand Down Expand Up @@ -5533,6 +5537,10 @@ export default defineMessages({
id: 'INCLUDING_FEE',
defaultMessage: 'Incl. fee',
},
INCLUDING_FEE_AND_RENT: {
id: 'INCLUDING_FEE_AND_RENT',
defaultMessage: 'Incl. fee and rent',
},
SEND_TRANSACTION: {
id: 'SEND_TRANSACTION',
description: 'Sign and send button used in Review modal',
Expand Down Expand Up @@ -8896,6 +8904,10 @@ export default defineMessages({
defaultMessage:
"The maximum fee you're willing to pay network validators to process your transaction. A higher fee may speed up confirmation times, though you'll only pay what's needed if the actual fee is lower.",
},
TR_SOL_FEE_DESC: {
id: 'TR_SOL_FEE_DESC',
defaultMessage: 'XXXXXX TODO',
},
TR_TRANSACTION_FEE_DESC: {
id: 'TR_TRANSACTION_FEE_DESC',
defaultMessage:
Expand Down
20 changes: 16 additions & 4 deletions packages/suite/src/views/wallet/send/TotalSent/TotalSent.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useMemo } from 'react';

import styled from 'styled-components';

import { formatAmount, formatNetworkAmount } from '@suite-common/wallet-utils';
Expand Down Expand Up @@ -26,6 +28,19 @@ export const TotalSent = () => {
const isTokenTransfer = networkType === 'ethereum' && !!getValues('outputs.0.token');
const hasTransactionInfo = transactionInfo !== undefined && transactionInfo.type !== 'error';
const tokenInfo = hasTransactionInfo ? transactionInfo.token : undefined;
const includingRent = networkType === 'solana';

const feeLabelId = useMemo(() => {
if (isTokenTransfer) {
return 'FEE';
}

if (includingRent) {
return 'INCLUDING_FEE_AND_RENT';
}

return 'INCLUDING_FEE';
}, [isTokenTransfer, includingRent]);

return (
<Container>
Expand Down Expand Up @@ -54,10 +69,7 @@ export const TotalSent = () => {
)}
</InfoItem>

<InfoItem
label={<Translation id={isTokenTransfer ? 'FEE' : 'INCLUDING_FEE'} />}
direction="row"
>
<InfoItem label={<Translation id={feeLabelId} />} direction="row">
{hasTransactionInfo &&
(tokenInfo ? (
<FormattedCryptoAmount
Expand Down

0 comments on commit d54f973

Please sign in to comment.