Skip to content

Commit

Permalink
fix(suite-native): fetch token definitions and show them for enabled …
Browse files Browse the repository at this point in the history
…symbols
  • Loading branch information
vytick committed Jan 17, 2025
1 parent a6eedc8 commit 3aa329a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion suite-native/discovery/src/discoveryConfigSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
selectIsFeatureFlagEnabled,
} from '@suite-native/feature-flags';
import {
isCoinWithTokens,
selectNetworkSymbolsOfAccountsWithTokensAllowed,
TokensRootState,
} from '@suite-native/tokens';
Expand Down Expand Up @@ -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),
),
),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
selectFilterKnownTokens,
selectNetworkTokenDefinitions,
} from '@suite-common/token-definitions';
import { isCoinWithTokens } from '@suite-native/tokens';

import { paymentTypeToAccountType } from './constants';

Expand Down Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -54,9 +55,10 @@ export const AccountImportConfirmFormScreen = ({
const navigation = useNavigation<NavigationProp>();
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) =>
Expand Down

0 comments on commit 3aa329a

Please sign in to comment.