From 77dc9c05dc3cd9ce7805f4c5cf1c49dae8089a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Santana=20Gon=C3=A7alves?= Date: Tue, 6 Feb 2024 00:50:20 -0300 Subject: [PATCH] define a new type TokenOrBitcoinNetwork --- src/components/token/utils.ts | 6 ++++-- src/screens/home/PortfolioComponent.tsx | 16 +++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/token/utils.ts b/src/components/token/utils.ts index fa43dc7eb..2c528f697 100644 --- a/src/components/token/utils.ts +++ b/src/components/token/utils.ts @@ -3,11 +3,13 @@ import { BitcoinNetwork } from '@rsksmart/rif-wallet-bitcoin' import { ITokenWithoutLogo } from 'src/redux/slices/balancesSlice/types' import { TokenSymbol } from 'src/screens/home/TokenImage' +export type TokenOrBitcoinNetwork = ITokenWithoutLogo | BitcoinNetwork + // default order should be RIF, USDRIF, RBTC, BTC and RDOC // other tokens should be sorted alphabetically by symbol export const sortTokensBySymbol = ( - a: ITokenWithoutLogo | BitcoinNetwork, - b: ITokenWithoutLogo | BitcoinNetwork, + a: TokenOrBitcoinNetwork, + b: TokenOrBitcoinNetwork, ) => { const aSymbol = a.symbol.toUpperCase() const bSymbol = b.symbol.toUpperCase() diff --git a/src/screens/home/PortfolioComponent.tsx b/src/screens/home/PortfolioComponent.tsx index 642cb84ab..c6c128664 100644 --- a/src/screens/home/PortfolioComponent.tsx +++ b/src/screens/home/PortfolioComponent.tsx @@ -1,4 +1,3 @@ -import { BitcoinNetwork } from '@rsksmart/rif-wallet-bitcoin' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import { ScrollView, StyleProp, View, ViewStyle } from 'react-native' @@ -6,12 +5,15 @@ import { ScrollView, StyleProp, View, ViewStyle } from 'react-native' import { PortfolioCard } from 'components/Porfolio/PortfolioCard' import { getTokenColor } from 'screens/home/tokenColor' import { sharedColors } from 'shared/constants' -import { ITokenWithoutLogo } from 'store/slices/balancesSlice/types' -import { sortTokensBySymbol, isDefaultToken } from 'src/components/token/utils' +import { + TokenOrBitcoinNetwork, + isDefaultToken, + sortTokensBySymbol, +} from 'src/components/token/utils' interface Props { setSelectedAddress: (token: string | undefined) => void - balances: Array + balances: Array totalUsdBalance: string selectedAddress?: string showTotalCard?: boolean @@ -65,11 +67,7 @@ export const PortfolioComponent = ({ .filter(token => isDefaultToken(token.symbol) || +token.balance > 0) .map( ( - { - contractAddress, - symbol, - balance, - }: ITokenWithoutLogo | BitcoinNetwork, + { contractAddress, symbol, balance }: TokenOrBitcoinNetwork, i: number, ) => { const isSelected =