Skip to content

Commit

Permalink
Add check for allowed tokens by network
Browse files Browse the repository at this point in the history
- fix prices fetching
  • Loading branch information
samchuk-vlad committed Mar 21, 2024
1 parent 284233e commit e96838b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { TFunction } from 'i18next'
import { Button, Tooltip } from 'antd'
import { FiSend } from 'react-icons/fi'
import { LinksButton } from '../../links/Links'
import { PnlInDollars, PriceChangedOn } from '../utils'
import { PnlInDollars, PriceChangedOn, allowedTokensByNetwork } from '../utils'
import { InfoCircleOutlined } from '@ant-design/icons'

const getAccountData = (info: AccountInfoByChain, t: TFunction) => {
Expand Down Expand Up @@ -85,7 +85,12 @@ const parseBalancesEntities = (

const balanceInfoBySymbol: Record<string, any> = {}

const allowedTokens = allowedTokensByNetwork[network]

Object.entries(balanceInfo || {}).forEach(([ symbol, info ]) => {
if ((allowedTokens && !allowedTokens.includes(symbol)) || !symbol)
return

const { decimal } = getDecimalsAndSymbol(chainInfo, symbol)

if (!decimal) return
Expand Down
13 changes: 8 additions & 5 deletions src/rtk/features/prices/pricesHooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useAppSelector } from '../../app/store'
import { PricesEntity, selectPrices } from './pricesSlice'
import { MultiChainInfo } from '../multiChainInfo/types'
import { isEmptyObj } from '@subsocial/utils'

export const overriddenChainNames: Record<string, string> = {
bifrostKusama: 'bifrost-native-coin',
Expand All @@ -19,15 +20,17 @@ export const overriddenChainNames: Record<string, string> = {
continuum: 'mnet-continuum',
}

export const statemineAssets = [ 'rmrk' ]
const additionalTokens = [ 'zenlink-network-token', 'weth', 'wrapped-bitcoin' ]
export const statemineAssets = ['rmrk']
const additionalTokens = ['zenlink-network-token', 'weth', 'wrapped-bitcoin']

export const getChainsNamesForCoinGecko = (chainsInfo: MultiChainInfo) => {
const chainInfoKeys = chainsInfo ? Object.keys(chainsInfo) : []
let keys: string[] = []

chainInfoKeys.push(...statemineAssets, ...additionalTokens)
if (chainsInfo && !isEmptyObj(chainsInfo)) {
keys = [...Object.keys(chainsInfo), ...statemineAssets, ...additionalTokens]
}

return chainInfoKeys
return keys
.map((network) => overriddenChainNames[network] || network)
.join(',')
}
Expand Down

0 comments on commit e96838b

Please sign in to comment.