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 committed Feb 28, 2025
1 parent 05d9abd commit a74bf8a
Show file tree
Hide file tree
Showing 4 changed files with 53 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
39 changes: 26 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,29 @@ 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':
// TODO: change to something that makes sense
return 'TR_TX_FEE_INCLUDING_RENT';
default:
return 'TR_TRANSACTION_FEE_DESC';
}
}, [networkType]);

return (
<Column gap={spacings.md}>
<Row flexWrap="wrap">
Expand All @@ -168,21 +192,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
8 changes: 8 additions & 0 deletions packages/suite/src/support/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3232,6 +3232,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 @@ -5511,6 +5515,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
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 a74bf8a

Please sign in to comment.