fixed issue of deplicated token names (LUNA and LUNAC)

This commit is contained in:
liangping 2022-08-22 12:14:40 +08:00
parent 97c30a4853
commit d95be0340b

View File

@ -351,14 +351,22 @@ export function isToken(value) {
export function formatTokenDenom(tokenDenom) { export function formatTokenDenom(tokenDenom) {
if (tokenDenom && tokenDenom.code === undefined) { if (tokenDenom && tokenDenom.code === undefined) {
let denom = tokenDenom.denom_trace ? tokenDenom.denom_trace.base_denom : tokenDenom let denom = tokenDenom.denom_trace ? tokenDenom.denom_trace.base_denom : tokenDenom
const config = Object.values(getLocalChains()) const chains = getLocalChains()
const selected = localStorage.getItem('selected_chain')
config.forEach(x => { const selChain = chains[selected]
if (x.assets) { const nativeAsset = selChain.assets.find(a => (a.base === denom))
const asset = x.assets.find(a => (a.base === denom)) if (nativeAsset) {
if (asset) denom = asset.symbol denom = nativeAsset.symbol
} } else {
}) const config = Object.values(chains)
console.log(config, localStorage.getItem('selected_chain'))
config.forEach(x => {
if (x.assets) {
const asset = x.assets.find(a => (a.base === denom))
if (asset) denom = asset.symbol
}
})
}
return denom.length > 10 ? `${denom.substring(0, 7).toUpperCase()}..${denom.substring(denom.length - 3)}` : denom.toUpperCase() return denom.length > 10 ? `${denom.substring(0, 7).toUpperCase()}..${denom.substring(denom.length - 3)}` : denom.toUpperCase()
} }
return '' return ''