Skip to content

Commit

Permalink
feat(suite-native): hide solana staking
Browse files Browse the repository at this point in the history
  • Loading branch information
vytick committed Jan 18, 2025
1 parent ef64819 commit d70bbdf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 4 additions & 2 deletions suite-native/accounts/src/components/AccountSectionTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { selectFiatCurrencyCode } from '@suite-native/settings';
import {
NativeStakingRootState,
selectAccountCryptoBalanceWithStaking,
doesCoinSupportStaking,
} from '@suite-native/staking';

type AccountSectionTitleProps = {
Expand All @@ -27,10 +28,11 @@ export const AccountSectionTitle: React.FC<AccountSectionTitleProps> = ({
const cryptoBalanceWithStaking = useSelector((state: NativeStakingRootState) =>
selectAccountCryptoBalanceWithStaking(state, account.key),
);
const shouldIncludeStaking = doesCoinSupportStaking(account.symbol);

const fiatBalance = useMemo(
() => getAccountFiatBalance({ account, localCurrency, rates }),
[account, localCurrency, rates],
() => getAccountFiatBalance({ account, localCurrency, rates, shouldIncludeStaking }),
[account, localCurrency, rates, shouldIncludeStaking],
);

return (
Expand Down
7 changes: 5 additions & 2 deletions suite-native/accounts/src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { SettingsSliceRootState, selectFiatCurrencyCode } from '@suite-native/se
import { isCoinWithTokens } from '@suite-native/tokens';
import type { StaticSessionId } from '@trezor/connect';
import { createWeakMapSelector } from '@suite-common/redux-utils';
import { doesCoinSupportStaking } from '@suite-native/staking';

import { AccountSelectBottomSheetSection, GroupedByTypeAccounts } from './types';
import {
Expand Down Expand Up @@ -85,6 +86,7 @@ export const selectAccountFiatBalance = (state: NativeAccountsRootState, account
const fiatRates = selectCurrentFiatRates(state);
const account = selectAccountByKey(state, accountKey);
const localCurrency = selectFiatCurrencyCode(state);
const shouldIncludeStaking = !!account && doesCoinSupportStaking(account.symbol);

if (!account) {
return '0';
Expand All @@ -94,6 +96,7 @@ export const selectAccountFiatBalance = (state: NativeAccountsRootState, account
account,
rates: fiatRates,
localCurrency,
shouldIncludeStaking,
});

return totalBalance;
Expand All @@ -104,12 +107,12 @@ export const getAccountListSections = (
tokenDefinitions: SimpleTokenStructure | undefined,
) => {
const sections: AccountSelectBottomSheetSection[] = [];

const canHasTokens = isCoinWithTokens(account.symbol);

const tokens = filterKnownTokens(tokenDefinitions, account.symbol, account.tokens ?? []);
const hasAnyKnownTokens = canHasTokens && !!tokens.length;
const stakingBalance = getAccountTotalStakingBalance(account) ?? '0';
const hasStaking = stakingBalance !== '0';
const hasStaking = doesCoinSupportStaking(account.symbol) && stakingBalance !== '0';

if (canHasTokens) {
sections.push({
Expand Down
9 changes: 8 additions & 1 deletion suite-native/assets/src/assetsSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import { getAccountFiatBalance } from '@suite-common/wallet-utils';
import { getAccountListSections } from '@suite-native/accounts';
import { sortAccountsByNetworksAndAccountTypes } from '@suite-native/accounts/src/utils';
import { selectFiatCurrencyCode, SettingsSliceRootState } from '@suite-native/settings';
import { getAccountCryptoBalanceWithStaking, NativeStakingRootState } from '@suite-native/staking';
import {
doesCoinSupportStaking,
getAccountCryptoBalanceWithStaking,
NativeStakingRootState,
} from '@suite-native/staking';

export interface AssetType {
symbol: NetworkSymbol;
Expand Down Expand Up @@ -102,10 +106,13 @@ const selectDeviceAssetsWithBalances = createMemoizedSelector(
],
(accounts, deviceNetworksWithAssets, fiatCurrencyCode, rates) => {
const accountsWithFiatBalance = accounts.map(account => {
const shouldIncludeStaking = doesCoinSupportStaking(account.symbol);

const fiatValue = getAccountFiatBalance({
account,
localCurrency: fiatCurrencyCode,
rates,
shouldIncludeStaking,
});

return {
Expand Down

0 comments on commit d70bbdf

Please sign in to comment.