Skip to content

Commit

Permalink
Use chain logo for image if available
Browse files Browse the repository at this point in the history
  • Loading branch information
tombeynon committed Aug 15, 2023
1 parent 91cc2b8 commit 99e6f73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions chains/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ function Chain(client, data, paramsData, opts) {

chain.name = chain.chain_name
const coingecko = prices?.coingecko || {}

const assets = assetlist && assetlist.assets.map(asset => {
const price = coingecko[asset.display]

return ChainAsset(asset, price && { coingecko: price })
});
const baseAsset = assets && assets[0]

const image = chain.logo_URIs?.svg || chain.logo_URIs?.png || baseAsset?.image

const prefix = chain.bech32_prefix
const { consensusPrefix } = config

async function apis(type){
const health = await apiHealth(type)
return ChainApis(health)
}

async function apiHealth(type) {
const healthPath = {}
if(type){
Expand Down Expand Up @@ -83,6 +85,7 @@ function Chain(client, data, paramsData, opts) {
chainId: chain.chain_id,
name: chain.name,
prettyName: chain.pretty_name,
image,
website: chain.website,
denom: baseAsset?.denom,
symbol: baseAsset?.symbol,
Expand Down
2 changes: 1 addition & 1 deletion chains/chainAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function ChainAsset(data, prices) {
const base = data.denom_units.find(el => el.denom === data.base)
const display = data.denom_units.find(el => el.denom === data.display)
const logo_URIs = data.logo_URIs
const image = logo_URIs && (logo_URIs.svg || logo_URIs.png)
const image = logo_URIs?.svg || logo_URIs?.png

return {
name,
Expand Down
2 changes: 1 addition & 1 deletion chains/chainsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ChainsController(registry) {
denom: baseAsset?.denom,
decimals: baseAsset?.decimals,
coingecko_id: baseAsset?.coingecko_id,
image: baseAsset?.image,
image: chain.image,
website: chain.website,
height: apis.bestHeight(),
best_apis: {
Expand Down

0 comments on commit 99e6f73

Please sign in to comment.