diff --git a/packages/suite/src/components/wallet/WalletLayout/AccountsMenu/AccountSection.tsx b/packages/suite/src/components/wallet/WalletLayout/AccountsMenu/AccountSection.tsx index 8f31bd9e4d..8a71f68c8f 100644 --- a/packages/suite/src/components/wallet/WalletLayout/AccountsMenu/AccountSection.tsx +++ b/packages/suite/src/components/wallet/WalletLayout/AccountsMenu/AccountSection.tsx @@ -55,10 +55,7 @@ export const AccountSection = ({ 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 ( @@ -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 ( diff --git a/suite-common/suite-sync/src/data/suiteSyncDataReducer.ts b/suite-common/suite-sync/src/data/suiteSyncDataReducer.ts index 7bb966d903..ade3ef3f46 100644 --- a/suite-common/suite-sync/src/data/suiteSyncDataReducer.ts +++ b/suite-common/suite-sync/src/data/suiteSyncDataReducer.ts @@ -19,7 +19,7 @@ export type SuiteSyncDataState = { wallets: Record; }; -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) => { action.payload.forEach(wallet => { @@ -101,7 +101,7 @@ export const suiteSyncDataSlice = createSlice({ }); }, - clearAll: () => initialState, + clearAll: () => initialSuiteSyncDataState, }, }); diff --git a/suite-common/suite-sync/src/index.ts b/suite-common/suite-sync/src/index.ts index e2d990cb47..171c7c0124 100644 --- a/suite-common/suite-sync/src/index.ts +++ b/suite-common/suite-sync/src/index.ts @@ -22,6 +22,7 @@ export { DEFAULT_SUITE_SYNC_RELAY_URL } from './relay/relayUrl'; export { prepareSuiteSyncMiddleware } from './suiteSyncMiddleware'; export { suiteSyncDataReducer, + initialSuiteSyncDataState, suiteSyncDataSlice, clearAll, type SuiteSyncDataRootState, diff --git a/suite-common/wallet-utils/src/transactionUtils.ts b/suite-common/wallet-utils/src/transactionUtils.ts index 351ddaa60a..51928c6171 100644 --- a/suite-common/wallet-utils/src/transactionUtils.ts +++ b/suite-common/wallet-utils/src/transactionUtils.ts @@ -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 diff --git a/suite-native/accounts/src/utils.ts b/suite-native/accounts/src/utils.ts index d47cee6f2f..bd5545d6d0 100644 --- a/suite-native/accounts/src/utils.ts +++ b/suite-native/accounts/src/utils.ts @@ -24,6 +24,7 @@ const accountTypeToSectionHeader: Readonly>> 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; diff --git a/suite-native/module-trading/package.json b/suite-native/module-trading/package.json index 2f8bd61a3d..fc22ab729e 100644 --- a/suite-native/module-trading/package.json +++ b/suite-native/module-trading/package.json @@ -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:*", diff --git a/suite-native/module-trading/src/components/general/AccountList/AccountListItem.tsx b/suite-native/module-trading/src/components/general/AccountList/AccountListItem.tsx index 423a7e0aa6..504d9b058d 100644 --- a/suite-native/module-trading/src/components/general/AccountList/AccountListItem.tsx +++ b/suite-native/module-trading/src/components/general/AccountList/AccountListItem.tsx @@ -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 ); + const accountLabel = + useSelector((state: CombinedLabelingState) => + selectAccountLabel( + state, + account.deviceState, + account.descriptor, + account.symbol, + account.key, + ), + ) ?? ''; + return ( + selectAccountLabel( + state, + account.deviceState, + account.descriptor, + account.symbol, + account.key, + ), + ) ?? ''; + return ( - {account.accountLabel} + {accountLabel} {formattedAccountType && ( (); + 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 ( diff --git a/suite-native/module-trading/tsconfig.json b/suite-native/module-trading/tsconfig.json index 00d5967efa..081007340d 100644 --- a/suite-native/module-trading/tsconfig.json +++ b/suite-native/module-trading/tsconfig.json @@ -59,6 +59,7 @@ { "path": "../helpers" }, { "path": "../icons" }, { "path": "../intl" }, + { "path": "../labeling" }, { "path": "../link" }, { "path": "../message-system" }, { "path": "../module-add-accounts" }, diff --git a/suite-native/staking/package.json b/suite-native/staking/package.json index 6461367b83..d349d949f1 100644 --- a/suite-native/staking/package.json +++ b/suite-native/staking/package.json @@ -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" diff --git a/suite-native/staking/src/__tests__/solanaStakingSelectors.test.ts b/suite-native/staking/src/__tests__/solanaStakingSelectors.test.ts index 44a0619d91..c3bfd8ac63 100644 --- a/suite-native/staking/src/__tests__/solanaStakingSelectors.test.ts +++ b/suite-native/staking/src/__tests__/solanaStakingSelectors.test.ts @@ -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; @@ -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: [ { diff --git a/suite-native/staking/src/types.ts b/suite-native/staking/src/types.ts index 883b4bc0bc..05fa6825f4 100644 --- a/suite-native/staking/src/types.ts +++ b/suite-native/staking/src/types.ts @@ -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; diff --git a/suite-native/staking/tsconfig.json b/suite-native/staking/tsconfig.json index c74194eb81..9474bed4cb 100644 --- a/suite-native/staking/tsconfig.json +++ b/suite-native/staking/tsconfig.json @@ -17,6 +17,7 @@ { "path": "../../suite-common/wallet-utils" }, + { "path": "../labeling" }, { "path": "../../packages/type-utils" }, { "path": "../../packages/utils" }, { diff --git a/suite-native/trading-state/src/selectors/commonSelectors.ts b/suite-native/trading-state/src/selectors/commonSelectors.ts index 583329ba71..ba8d020334 100644 --- a/suite-native/trading-state/src/selectors/commonSelectors.ts +++ b/suite-native/trading-state/src/selectors/commonSelectors.ts @@ -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, diff --git a/yarn.lock b/yarn.lock index 97b5fc6d1a..7cb7fe4b72 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"