fix: Account Lable in Staking

This commit is contained in:
Peter Sanderson
2026-01-29 16:25:05 +01:00
committed by Peter Sanderson
parent 007d68b3b8
commit 656df935db
17 changed files with 68 additions and 51 deletions

View File

@@ -55,10 +55,7 @@ export const AccountSection = ({
<AccountItemsGroup
key={`${descriptor}-${symbol}`}
forceOnlyItemClick={forceOnlyItemClick}
account={{
...account,
accountLabel: account.accountLabel,
}}
account={account}
selected={selected}
showStaking={isStakeShown}
tokens={tokens.shownWithBalance}
@@ -70,10 +67,7 @@ export const AccountSection = ({
type="coin"
key={`${descriptor}-${symbol}`}
forceOnlyItemClick={forceOnlyItemClick}
account={{
...account,
accountLabel: account.accountLabel,
}}
account={account}
isSelected={selected}
onClick={onItemClick}
formattedBalance={formattedBalance}

View File

@@ -5,7 +5,6 @@ import { selectAllAccountsToList, selectSelectedDevice } from '@suite-common/wal
import { Account } from '@suite-common/wallet-types';
import { accountSearchFn, parseAccountKey } from '@suite-common/wallet-utils';
import { Column } from '@trezor/components';
import type { StaticSessionId } from '@trezor/connect';
import { spacings } from '@trezor/theme';
import { useAccountSearch, useDefaultAccountLabel, useSelector } from 'src/hooks/suite';
@@ -38,7 +37,6 @@ type AccountsProps = {
// NOTE: this is to disable completely default click behavior of the item
forceOnlyItemClick?: boolean;
onItemClick?: (account: Account, type: AccountItemType) => void;
deviceStaticSessionId: StaticSessionId;
};
const Accounts = ({
@@ -49,17 +47,10 @@ const Accounts = ({
discoveryInProgress,
type,
onItemClick,
deviceStaticSessionId,
}: AccountsProps) => {
const accountLabels = useSelector(selectAccountLabelsOld);
const isSkeletonShown = discoveryInProgress || (type === 'coinjoin' && coinjoinIsPreloading);
const params = useSelector(selectRouterParams) as RouteParams;
const suiteSyncAccountLabels = useSelector(state =>
selectSuiteSyncAccountLabels(state, deviceStaticSessionId),
);
return (
<>
{accounts.map(account => {
@@ -71,24 +62,12 @@ const Accounts = ({
const selected = !!isSelected(account);
const { accountDescriptor, networkSymbol } = parseAccountKey(account.key);
const label =
findSuiteSyncAccountLabel({
accounts: suiteSyncAccountLabels,
accountDescriptor,
networkSymbol,
})?.label ?? accountLabels[account.key];
return (
<AccountSection
key={account.key}
forceOnlyItemClick={forceOnlyItemClick}
hideStaking={hideStaking}
account={{
...account,
accountLabel: label,
}}
account={account}
selected={selected}
onItemClick={onItemClick}
/>
@@ -182,11 +161,6 @@ export const AccountsList = ({
return;
}
const deviceStaticSessionId = device.state?.staticSessionId;
if (deviceStaticSessionId === undefined) {
return;
}
const accountProps: AccountsProps = {
forceOnlyItemClick,
accounts,
@@ -194,7 +168,6 @@ export const AccountsList = ({
coinjoinIsPreloading,
discoveryInProgress: false,
type,
deviceStaticSessionId,
};
return (

View File

@@ -19,7 +19,7 @@ export type SuiteSyncDataState = {
wallets: Record<WalletDescriptor, WalletData>;
};
const initialState: SuiteSyncDataState = {
export const initialSuiteSyncDataState: SuiteSyncDataState = {
wallets: {},
};
@@ -44,7 +44,7 @@ const ensureWallet = (
export const suiteSyncDataSlice = createSlice({
name: 'suiteSyncData',
initialState,
initialState: initialSuiteSyncDataState,
reducers: {
upsertManyWallets: (state, action: PayloadAction<SuiteSyncWallet[]>) => {
action.payload.forEach(wallet => {
@@ -101,7 +101,7 @@ export const suiteSyncDataSlice = createSlice({
});
},
clearAll: () => initialState,
clearAll: () => initialSuiteSyncDataState,
},
});

View File

@@ -22,6 +22,7 @@ export { DEFAULT_SUITE_SYNC_RELAY_URL } from './relay/relayUrl';
export { prepareSuiteSyncMiddleware } from './suiteSyncMiddleware';
export {
suiteSyncDataReducer,
initialSuiteSyncDataState,
suiteSyncDataSlice,
clearAll,
type SuiteSyncDataRootState,

View File

@@ -991,7 +991,7 @@ const numberSearchFilter = (
const searchDateRegex = new RegExp(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/);
export const simpleSearchTransactions = (
transactions: WalletAccountTransaction[],
accountMetadata: AccountLabels,
accountMetadata: AccountLabels, // Todo: this is wrong, this shall reflect SuiteSync labels. See https://github.com/trezor/trezor-suite/issues/24803
search: string,
) => {
// Trim

View File

@@ -24,6 +24,7 @@ const accountTypeToSectionHeader: Readonly<Partial<Record<AccountType, string>>>
export const isFilterValueMatchingAccount = (account: Account, filterValue: string) => {
const lowerCaseFilterValue = filterValue?.trim().toLowerCase();
// Todo: this is wrong, this shall reflect SuiteSync labels. See https://github.com/trezor/trezor-suite/issues/24803
const isMatchingLabel = account.accountLabel?.toLowerCase().includes(lowerCaseFilterValue);
if (isMatchingLabel) return true;

View File

@@ -51,6 +51,7 @@
"@suite-native/helpers": "workspace:*",
"@suite-native/icons": "workspace:*",
"@suite-native/intl": "workspace:*",
"@suite-native/labeling": "workspace:*",
"@suite-native/link": "workspace:*",
"@suite-native/message-system": "workspace:*",
"@suite-native/module-add-accounts": "workspace:*",

View File

@@ -2,6 +2,7 @@ import { useSelector } from 'react-redux';
import { AccountsRootState, selectFormattedAccountType } from '@suite-common/wallet-core';
import { Badge } from '@suite-native/atoms';
import { CombinedLabelingState, selectAccountLabel } from '@suite-native/labeling';
import { ReceiveAccount } from '@suite-native/trading-types';
import { AccountListBaseItem } from './AccountListBaseItem';
@@ -21,10 +22,21 @@ export const AccountListItem = ({ receiveAccount, onPress }: AccountListItemProp
<Badge label={formattedAccountType} size="small" elevation="1" />
);
const accountLabel =
useSelector((state: CombinedLabelingState) =>
selectAccountLabel(
state,
account.deviceState,
account.descriptor,
account.symbol,
account.key,
),
) ?? '';
return (
<AccountListBaseItem
receiveAccount={receiveAccount}
label={account.accountLabel}
label={accountLabel}
isAddressDetail={false}
info={typeBadge}
onPress={onPress}

View File

@@ -5,6 +5,7 @@ import { Account } from '@suite-common/wallet-types';
import { NativeAccountsRootState, selectAccountFiatBalance } from '@suite-native/accounts';
import { Badge, HStack, Text } from '@suite-native/atoms';
import { BaseCurrencyAmountFormatter } from '@suite-native/formatters';
import { CombinedLabelingState, selectAccountLabel } from '@suite-native/labeling';
export type MyAssetListSectionHeaderProps = {
account: Account;
@@ -22,6 +23,17 @@ export const MyAssetListSectionHeader = ({ account, isFirst }: MyAssetListSectio
selectAccountFiatBalance(state, account.key, false),
);
const accountLabel =
useSelector((state: CombinedLabelingState) =>
selectAccountLabel(
state,
account.deviceState,
account.descriptor,
account.symbol,
account.key,
),
) ?? '';
return (
<HStack
justifyContent="space-between"
@@ -31,7 +43,7 @@ export const MyAssetListSectionHeader = ({ account, isFirst }: MyAssetListSectio
>
<HStack alignItems="center" spacing="sp8">
<Text variant="body" color="textDefault">
{account.accountLabel}
{accountLabel}
</Text>
{formattedAccountType && (
<Badge

View File

@@ -1,4 +1,5 @@
import { ReactNode } from 'react';
import { useSelector } from 'react-redux';
import { useNavigation } from '@react-navigation/native';
@@ -6,6 +7,7 @@ import { TradingType } from '@suite-common/trading';
import { NetworkSymbol } from '@suite-common/wallet-config';
import { Text, VStack } from '@suite-native/atoms';
import { Translation, useTranslate } from '@suite-native/intl';
import { CombinedLabelingState, selectAccountLabel } from '@suite-native/labeling';
import {
RootStackParamList,
StackToStackCompositeNavigationProps,
@@ -111,6 +113,21 @@ export const ReceiveAccountPicker = ({
const { translate } = useTranslate();
const navigation = useNavigation<NavigationProps>();
const account = receiveAccount?.account;
const accountLabel =
useSelector((state: CombinedLabelingState) =>
account !== undefined
? selectAccountLabel(
state,
account.deviceState,
account.descriptor,
account.symbol,
account.key,
)
: null,
) ?? '';
if (!symbol) {
return null;
}
@@ -118,7 +135,6 @@ export const ReceiveAccountPicker = ({
const openAccountPicker = () =>
navigation.navigate(TradingStackRoutes.ReceiveAccounts, { symbol, tradingType });
const accountLabel = receiveAccount?.account.accountLabel;
const addressText = getReceiveAccountAddressText(receiveAccount) ?? '';
return (

View File

@@ -59,6 +59,7 @@
{ "path": "../helpers" },
{ "path": "../icons" },
{ "path": "../intl" },
{ "path": "../labeling" },
{ "path": "../link" },
{ "path": "../message-system" },
{ "path": "../module-add-accounts" },

View File

@@ -16,6 +16,7 @@
"@suite-common/wallet-core": "workspace:*",
"@suite-common/wallet-types": "workspace:*",
"@suite-common/wallet-utils": "workspace:*",
"@suite-native/labeling": "workspace:*",
"@trezor/type-utils": "workspace:*",
"@trezor/utils": "workspace:*",
"react-redux": "9.2.0"

View File

@@ -1,9 +1,6 @@
import { initialSuiteSyncDataState, initialSuiteSyncState } from '@suite-common/suite-sync';
import { TrezorDevice } from '@suite-common/suite-types';
import {
StakeState,
initialWalletSettingsState,
stakeInitialState,
} from '@suite-common/wallet-core';
import { StakeState, stakeInitialState } from '@suite-common/wallet-core';
import { Account, Timestamp } from '@suite-common/wallet-types';
import {
@@ -17,6 +14,7 @@ import {
selectSolanaTotalStakePendingByAccountKey,
selectVisibleDeviceSolanaAccountsWithStakingByNetworkSymbol,
} from '../solanaStakingSelectors';
import { NativeStakingRootState } from '../types';
type SolStakeData = NonNullable<StakeState['data']['sol']>;
@@ -120,13 +118,14 @@ const getTestState = ({
}: {
accounts: Account[];
withSolStakeData?: boolean;
}) => ({
}): NativeStakingRootState => ({
wallet: {
accounts,
stake: { ...stakeInitialState, data: { sol: withSolStakeData ? solStakeData : {} } },
transactions: { transactions: {}, fetchStatusDetail: {} },
settings: initialWalletSettingsState,
},
suiteSync: initialSuiteSyncState,
suiteSyncData: initialSuiteSyncDataState,
device: {
devices: [
{

View File

@@ -4,8 +4,10 @@ import {
StakeRootState,
TransactionsRootState,
} from '@suite-common/wallet-core';
import { CombinedLabelingState } from '@suite-native/labeling';
export type NativeStakingRootState = AccountsRootState &
DeviceRootState &
StakeRootState &
TransactionsRootState;
TransactionsRootState &
CombinedLabelingState;

View File

@@ -17,6 +17,7 @@
{
"path": "../../suite-common/wallet-utils"
},
{ "path": "../labeling" },
{ "path": "../../packages/type-utils" },
{ "path": "../../packages/utils" },
{

View File

@@ -295,6 +295,7 @@ export const selectAccountsWithTokensToSellSectionListByTradingType =
return {
key: `section_${account.key}`,
// Todo: this is wrong, correct label is determined by `selectAccountLabel` selector
label: account.accountLabel ?? '',
sectionData: account,
data: assets,

View File

@@ -13142,6 +13142,7 @@ __metadata:
"@suite-native/helpers": "workspace:*"
"@suite-native/icons": "workspace:*"
"@suite-native/intl": "workspace:*"
"@suite-native/labeling": "workspace:*"
"@suite-native/link": "workspace:*"
"@suite-native/message-system": "workspace:*"
"@suite-native/module-add-accounts": "workspace:*"
@@ -13443,6 +13444,7 @@ __metadata:
"@suite-common/wallet-core": "workspace:*"
"@suite-common/wallet-types": "workspace:*"
"@suite-common/wallet-utils": "workspace:*"
"@suite-native/labeling": "workspace:*"
"@trezor/type-utils": "workspace:*"
"@trezor/utils": "workspace:*"
react-redux: "npm:9.2.0"