From 3aa329a99ac350b2df1fd75cff05fe06cb6756c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Vytick=20Vytrhl=C3=ADk?= Date: Fri, 17 Jan 2025 23:11:29 +0100 Subject: [PATCH] fix(suite-native): fetch token definitions and show them for enabled symbols --- suite-native/discovery/src/discoveryConfigSlice.ts | 7 ++++++- .../module-accounts-import/src/accountsImportThunks.ts | 5 +++-- .../src/components/AccountImportConfirmFormScreen.tsx | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/suite-native/discovery/src/discoveryConfigSlice.ts b/suite-native/discovery/src/discoveryConfigSlice.ts index c1b2205bfe2..447c4b8b0c3 100644 --- a/suite-native/discovery/src/discoveryConfigSlice.ts +++ b/suite-native/discovery/src/discoveryConfigSlice.ts @@ -23,6 +23,7 @@ import { selectIsFeatureFlagEnabled, } from '@suite-native/feature-flags'; import { + isCoinWithTokens, selectNetworkSymbolsOfAccountsWithTokensAllowed, TokensRootState, } from '@suite-native/tokens'; @@ -185,7 +186,11 @@ export const selectTokenDefinitionsEnabledNetworks = createMemoizedSelector( [selectEnabledDiscoveryNetworkSymbols, selectNetworkSymbolsOfAccountsWithTokensAllowed], (enabledNetworkSymbols, accountNetworkSymbols) => returnStableArrayIfEmpty( - F.toMutable(A.uniq([...enabledNetworkSymbols, ...accountNetworkSymbols])), + F.toMutable( + A.uniq([...enabledNetworkSymbols, ...accountNetworkSymbols]).filter(s => + isCoinWithTokens(s), + ), + ), ), ); diff --git a/suite-native/module-accounts-import/src/accountsImportThunks.ts b/suite-native/module-accounts-import/src/accountsImportThunks.ts index 12d9a9dbcb2..8eafb711e40 100644 --- a/suite-native/module-accounts-import/src/accountsImportThunks.ts +++ b/suite-native/module-accounts-import/src/accountsImportThunks.ts @@ -23,6 +23,7 @@ import { selectFilterKnownTokens, selectNetworkTokenDefinitions, } from '@suite-common/token-definitions'; +import { isCoinWithTokens } from '@suite-native/tokens'; import { paymentTypeToAccountType } from './constants'; @@ -119,8 +120,8 @@ export const getAccountInfoThunk = createThunk< if (fetchedAccountInfo?.success) { const tokenDefinitions = selectNetworkTokenDefinitions(getState(), symbol); - // fetch token definitions for this network in case they are needed - if (!tokenDefinitions) { + // fetch token definitions for this network in case they are needed and enabled + if (!tokenDefinitions && isCoinWithTokens(symbol)) { const definitionTypes = getSupportedDefinitionTypes(symbol); definitionTypes.forEach(async type => { diff --git a/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx b/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx index 0a22a0c2847..6a55fa92e6e 100644 --- a/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx +++ b/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx @@ -28,6 +28,7 @@ import { useNavigateToInitialScreen, } from '@suite-native/navigation'; import { AccountInfo, TokenInfo } from '@trezor/connect'; +import { isCoinWithTokens } from '@suite-native/tokens'; import { importAccountThunk } from '../accountsImportThunks'; import { useShowImportError } from '../useShowImportError'; @@ -54,9 +55,10 @@ export const AccountImportConfirmFormScreen = ({ const navigation = useNavigation(); const navigateToInitialScreen = useNavigateToInitialScreen(); const showImportError = useShowImportError(symbol, navigation); + const canHaveTokens = isCoinWithTokens(symbol); const knownTokens = useSelector((state: TokenDefinitionsRootState) => - selectFilterKnownTokens(state, symbol, accountInfo.tokens ?? []), + canHaveTokens ? selectFilterKnownTokens(state, symbol, accountInfo.tokens ?? []) : [], ); const deviceNetworkAccounts = useSelector((state: AccountsRootState) =>