From 4460aff7dcf03ec76701bd2dd55a0dcee09f4a15 Mon Sep 17 00:00:00 2001 From: Pavlo Syrotyna Date: Mon, 23 Dec 2024 16:41:34 +0200 Subject: [PATCH] fixup! feat(suite): include Solana staking balance in assets --- .../dashboard/AssetsView/AssetCard/AssetCard.tsx | 15 ++++++++------- .../dashboard/AssetsView/AssetTable/AssetRow.tsx | 15 ++++++++------- .../src/transactions/transactionsReducer.ts | 12 ++++++++++++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/packages/suite/src/views/dashboard/AssetsView/AssetCard/AssetCard.tsx b/packages/suite/src/views/dashboard/AssetsView/AssetCard/AssetCard.tsx index 3640cee3b6b..4490fc1cdaa 100644 --- a/packages/suite/src/views/dashboard/AssetsView/AssetCard/AssetCard.tsx +++ b/packages/suite/src/views/dashboard/AssetsView/AssetCard/AssetCard.tsx @@ -19,7 +19,7 @@ import { AssetFiatBalance } from '@suite-common/assets'; import { TokenInfo } from '@trezor/connect'; import { Account, RatesByKey } from '@suite-common/wallet-types'; import { isTestnet } from '@suite-common/wallet-utils'; -import { selectAssetAccountsThatStaked } from '@suite-common/wallet-core'; +import { selectDebugFilteredAssetAccountsThatStaked } from '@suite-common/wallet-core'; import { selectCoinDefinitions } from '@suite-common/token-definitions'; import { FiatCurrencyCode } from '@suite-common/suite-config'; @@ -124,15 +124,16 @@ export const AssetCard = ({ const stakingAccountsForAsset = stakingAccounts.filter(account => account.symbol === symbol); const coinDefinitions = useSelector(state => selectCoinDefinitions(state, symbol)); - const accountsThatStaked = useSelector(state => - selectAssetAccountsThatStaked(state, stakingAccountsForAsset), - ); // TODO: remove this logic when Solana staking is available const isDebugModeActive = useSelector(selectIsDebugModeActive); - const debugFilteredStakedAccounts = !isDebugModeActive - ? accountsThatStaked.filter(account => account.networkType !== 'solana') - : accountsThatStaked; + const debugFilteredStakedAccounts = useSelector(state => + selectDebugFilteredAssetAccountsThatStaked( + state, + stakingAccountsForAsset, + isDebugModeActive, + ), + ); const { tokensFiatBalance, assetStakingBalance, shouldRenderStakingRow, shouldRenderTokenRow } = handleTokensAndStakingData( diff --git a/packages/suite/src/views/dashboard/AssetsView/AssetTable/AssetRow.tsx b/packages/suite/src/views/dashboard/AssetsView/AssetTable/AssetRow.tsx index dea79503f7a..862da2bb791 100644 --- a/packages/suite/src/views/dashboard/AssetsView/AssetTable/AssetRow.tsx +++ b/packages/suite/src/views/dashboard/AssetsView/AssetTable/AssetRow.tsx @@ -8,7 +8,7 @@ import { isTestnet } from '@suite-common/wallet-utils'; import { spacings } from '@trezor/theme'; import { TokenInfo } from '@trezor/blockchain-link-types'; import { selectCoinDefinitions } from '@suite-common/token-definitions'; -import { selectAssetAccountsThatStaked } from '@suite-common/wallet-core'; +import { selectDebugFilteredAssetAccountsThatStaked } from '@suite-common/wallet-core'; import { Account, RatesByKey } from '@suite-common/wallet-types'; import { AssetFiatBalance } from '@suite-common/assets'; import { FiatCurrencyCode } from '@suite-common/suite-config'; @@ -82,15 +82,16 @@ export const AssetRow = memo( const stakingAccountsForAsset = stakingAccounts.filter( account => account.symbol === network.symbol, ); - const accountsThatStaked = useSelector(state => - selectAssetAccountsThatStaked(state, stakingAccountsForAsset), - ); // TODO: remove this logic when Solana staking is available const isDebugModeActive = useSelector(selectIsDebugModeActive); - const debugFilteredStakedAccounts = !isDebugModeActive - ? accountsThatStaked.filter(account => account.networkType !== 'solana') - : accountsThatStaked; + const debugFilteredStakedAccounts = useSelector(state => + selectDebugFilteredAssetAccountsThatStaked( + state, + stakingAccountsForAsset, + isDebugModeActive, + ), + ); const { tokensFiatBalance, diff --git a/suite-common/wallet-core/src/transactions/transactionsReducer.ts b/suite-common/wallet-core/src/transactions/transactionsReducer.ts index ee424831c02..110d55a2ac0 100644 --- a/suite-common/wallet-core/src/transactions/transactionsReducer.ts +++ b/suite-common/wallet-core/src/transactions/transactionsReducer.ts @@ -397,6 +397,18 @@ export const selectAssetAccountsThatStaked = ( selectSolAccountHasStaked(state, account.key), ); +export const selectDebugFilteredAssetAccountsThatStaked = ( + state: TransactionsRootState & AccountsRootState, + accounts: Account[], + isDebugModeActive: boolean, +) => { + const accountsThatStaked = selectAssetAccountsThatStaked(state, accounts); + + return !isDebugModeActive + ? accountsThatStaked.filter(account => account.networkType !== 'solana') + : accountsThatStaked; +}; + export const selectAccountTransactionsFetchStatus = ( state: TransactionsRootState, accountKey: AccountKey,