Skip to content

Commit

Permalink
define a new type TokenOrBitcoinNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoncalves committed Feb 6, 2024
1 parent 97a571b commit 77dc9c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/components/token/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 7 additions & 9 deletions src/screens/home/PortfolioComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
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'

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<ITokenWithoutLogo | BitcoinNetwork>
balances: Array<TokenOrBitcoinNetwork>
totalUsdBalance: string
selectedAddress?: string
showTotalCard?: boolean
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 77dc9c0

Please sign in to comment.