From 22e4cd8738dbfe9d2805a72d4e299bc338ecf941 Mon Sep 17 00:00:00 2001
From: Pavlo Syrotyna
Date: Wed, 5 Feb 2025 12:02:06 +0200
Subject: [PATCH] fixup! feat(suite): solana staking fee estimation
---
.../wallet/stake/stakeFormSolanaActions.ts | 9 +++++--
.../suite/StakingProcess/StakingInfo.tsx | 8 +++---
packages/suite/src/support/messages.ts | 4 +++
.../components/StakingCard.tsx | 26 +++++++++++--------
4 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/packages/suite/src/actions/wallet/stake/stakeFormSolanaActions.ts b/packages/suite/src/actions/wallet/stake/stakeFormSolanaActions.ts
index 08808d2e70f..63010efb8d3 100644
--- a/packages/suite/src/actions/wallet/stake/stakeFormSolanaActions.ts
+++ b/packages/suite/src/actions/wallet/stake/stakeFormSolanaActions.ts
@@ -10,6 +10,7 @@ import {
} from '@suite-common/wallet-constants';
import { ComposeActionContext, selectSelectedDevice } from '@suite-common/wallet-core';
import {
+ Account,
AddressDisplayOptions,
BlockchainNetworks,
ExternalOutput,
@@ -26,6 +27,7 @@ import { BigNumber } from '@trezor/utils/src/bigNumber';
import { selectAddressDisplayType } from 'src/reducers/suite/suiteReducer';
import { Dispatch, GetState } from 'src/types/suite';
import {
+ PrepareStakeSolTxResponse,
prepareClaimSolTx,
prepareStakeSolTx,
prepareUnstakeSolTx,
@@ -123,7 +125,10 @@ const getTransactionData = async (
return txData;
};
-async function estimateFee(txData: any, account: any): Promise {
+async function estimateFee(
+ account: Account,
+ txData?: PrepareStakeSolTxResponse,
+): Promise {
if (!txData?.success) return undefined;
const estimatedFee = await TrezorConnect.blockchainEstimateFee({
@@ -159,7 +164,7 @@ export const composeTransaction =
let estimatedFee;
// it is not needed to estimate fee for empty input
if (formValues.cryptoInput) {
- estimatedFee = await estimateFee(txData, account);
+ estimatedFee = await estimateFee(account, txData);
}
const { feeInfo } = formState;
diff --git a/packages/suite/src/components/suite/StakingProcess/StakingInfo.tsx b/packages/suite/src/components/suite/StakingProcess/StakingInfo.tsx
index 56222444e56..b77e4441e25 100644
--- a/packages/suite/src/components/suite/StakingProcess/StakingInfo.tsx
+++ b/packages/suite/src/components/suite/StakingProcess/StakingInfo.tsx
@@ -36,10 +36,10 @@ const getInfoRowsData = (
case 'ethereum':
return {
payoutDays: (
- <>
- ~
-
- >
+
),
rewardsPeriodHeading: ,
rewardsPeriodSubheading: (
diff --git a/packages/suite/src/support/messages.ts b/packages/suite/src/support/messages.ts
index b7fb5ab02ba..ac8e52ff227 100644
--- a/packages/suite/src/support/messages.ts
+++ b/packages/suite/src/support/messages.ts
@@ -8941,6 +8941,10 @@ export default defineMessages({
id: 'TR_STAKE_DAYS',
defaultMessage: '{count, plural, one {# day} other {# days}}',
},
+ TR_STAKE_APPROXIMATE_DAYS: {
+ id: 'TR_STAKE_APPROXIMATE_DAYS',
+ defaultMessage: '~{count, plural, one {# day} other {# days}}',
+ },
TR_STAKE_MAX_REWARD_DAYS: {
id: 'TR_STAKE_MAX_REWARD_DAYS',
defaultMessage: 'Max {count, plural, one {# day} other {# days}}',
diff --git a/packages/suite/src/views/wallet/staking/components/StakingDashboard/components/StakingCard.tsx b/packages/suite/src/views/wallet/staking/components/StakingDashboard/components/StakingCard.tsx
index 14a158db05a..a2df4d02312 100644
--- a/packages/suite/src/views/wallet/staking/components/StakingDashboard/components/StakingCard.tsx
+++ b/packages/suite/src/views/wallet/staking/components/StakingDashboard/components/StakingCard.tsx
@@ -147,16 +147,7 @@ export const StakingCard = ({
const solReward = calculateSolanaStakingReward(depositedBalance, apy?.toString());
const stakingReward = selectedAccount.networkType === 'solana' ? solReward : restakedReward;
- const isEth = selectedAccount.networkType === 'ethereum';
- const unstakeMessage = (
- <>
- {isEth && '~'}
-
- >
- );
+ const isEthereumNetwork = selectedAccount.networkType === 'ethereum';
return (
@@ -232,7 +223,20 @@ export const StakingCard = ({
label={
<>
{' '}
- {isDaysToUnstakeShown && <>({unstakeMessage})>}
+ {isDaysToUnstakeShown && (
+ <>
+ (
+
+ )
+ >
+ )}
>
}
iconName="spinnerGap"