From 5c694a20d1a67b6a26cbaf9d55db26265bdd5952 Mon Sep 17 00:00:00 2001 From: trungbach Date: Wed, 4 Dec 2024 17:04:56 +0700 Subject: [PATCH] feat: add chainSymbolImageUrl to various chain configurations and update coinImageUrl for Oraichain --- chains/0x01.json | 1 + chains/0x1ae6.json | 1 + chains/0x2b6653dc.json | 1 + chains/0x38.json | 1 + chains/Oraichain.json | 7 +-- chains/bitcoin.json | 1 + chains/injective-1.json | 15 +++---- chains/kawaii_6886-1.json | 1 + chains/oraibtc-mainnet-1.json | 1 + chains/osmosis-1.json | 9 +--- .../src/chain-infos/chain-info-reader.ts | 44 +++++++------------ .../common/src/token-items/token-items.ts | 3 +- packages/common/src/token-items/types.ts | 1 + 13 files changed, 38 insertions(+), 48 deletions(-) diff --git a/chains/0x01.json b/chains/0x01.json index 600befe..cc1b35a 100644 --- a/chains/0x01.json +++ b/chains/0x01.json @@ -7,6 +7,7 @@ "coinType": 60, "networkType": "evm", "features": ["isEvm"], + "chainSymbolImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png", "feeCurrencies": [ { "coinDenom": "ETH", diff --git a/chains/0x1ae6.json b/chains/0x1ae6.json index 4ad851d..05d4d79 100644 --- a/chains/0x1ae6.json +++ b/chains/0x1ae6.json @@ -7,6 +7,7 @@ "bip44": { "coinType": 60 }, "coinType": 60, "features": ["isEvm"], + "chainSymbolImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/12313.png", "feeCurrencies": [ { "coinDenom": "ERC20 KWT", diff --git a/chains/0x2b6653dc.json b/chains/0x2b6653dc.json index 0861bdb..8d9d219 100644 --- a/chains/0x2b6653dc.json +++ b/chains/0x2b6653dc.json @@ -6,6 +6,7 @@ "networkType": "evm", "chainName": "tronnetwork", "features": ["isEvm"], + "chainSymbolImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/1958.png", "feeCurrencies": [ { "coinDenom": "wTRX", diff --git a/chains/0x38.json b/chains/0x38.json index 7c82795..2d511be 100644 --- a/chains/0x38.json +++ b/chains/0x38.json @@ -7,6 +7,7 @@ "bip44": { "coinType": 60 }, "coinType": 60, "features": ["isEvm"], + "chainSymbolImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png", "feeCurrencies": [ { "coinDenom": "BNB", diff --git a/chains/Oraichain.json b/chains/Oraichain.json index 89c9066..ada0254 100644 --- a/chains/Oraichain.json +++ b/chains/Oraichain.json @@ -11,7 +11,7 @@ "coinDecimals": 6, "coinGeckoId": "oraichain-token", "bridgeTo": ["0x38", "0x01", "injective-1"], - "coinImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/7533.png", + "coinImageUrl": "https://raw.githubusercontent.com/cosmos/chain-registry/master/oraichain/images/orai-token.png", "gasPriceStep": { "low": 0.003, "average": 0.005, "high": 0.007 } }, "feeCurrencies": [ @@ -21,7 +21,7 @@ "coinDecimals": 6, "coinGeckoId": "oraichain-token", "bridgeTo": ["0x38", "0x01", "injective-1"], - "coinImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/7533.png", + "coinImageUrl": "https://raw.githubusercontent.com/cosmos/chain-registry/master/oraichain/images/orai-token.png", "gasPriceStep": { "low": 0.003, "average": 0.005, "high": 0.007 } } ], @@ -41,6 +41,7 @@ "txUrl": "https://scan.orai.io/txs/{txHash}", "accountUrl": "https://scan.orai.io/account/{address}" }, + "chainSymbolImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/celestia/chain.png", "currencies": [ { "coinDenom": "ORAI", @@ -48,7 +49,7 @@ "coinDecimals": 6, "coinGeckoId": "oraichain-token", "bridgeTo": ["0x38", "0x01", "injective-1"], - "coinImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/7533.png", + "coinImageUrl": "https://raw.githubusercontent.com/cosmos/chain-registry/master/oraichain/images/orai-token.png", "gasPriceStep": { "low": 0.003, "average": 0.005, "high": 0.007 } }, { diff --git a/chains/bitcoin.json b/chains/bitcoin.json index c1d0430..cd4305b 100644 --- a/chains/bitcoin.json +++ b/chains/bitcoin.json @@ -8,6 +8,7 @@ "coinType": 0 }, "coinType": 0, + "chainSymbolImageUrl": "https://assets.coingecko.com/coins/images/1/small/bitcoin.png", "stakeCurrency": { "coinDenom": "BTC", "coinMinimalDenom": "btc", diff --git a/chains/injective-1.json b/chains/injective-1.json index ceed90a..62ffe57 100644 --- a/chains/injective-1.json +++ b/chains/injective-1.json @@ -7,6 +7,7 @@ "networkType": "cosmos", "bip44": { "coinType": 60 }, "coinType": 60, + "chainSymbolImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/7226.png", "bech32Config": { "bech32PrefixAccAddr": "inj", "bech32PrefixAccPub": "injpub", @@ -15,18 +16,12 @@ "bech32PrefixConsAddr": "injvalcons", "bech32PrefixConsPub": "injvalconspub" }, - "features": [ - "stargate", - "no-legacy-stdTx", - "ibc-transfer", - "ibc-go", - "eth-key-sign", - "cosmwasm" - ], + "features": ["stargate", "no-legacy-stdTx", "ibc-transfer", "ibc-go", "eth-key-sign", "cosmwasm"], "stakeCurrency": { "coinDenom": "INJ", "coinMinimalDenom": "inj", "coinDecimals": 18, + "coinImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/7226.png", "coinGeckoId": "injective-protocol", "gasPriceStep": { "low": 5000000000, @@ -40,6 +35,7 @@ "coinMinimalDenom": "inj", "coinDecimals": 18, "coinGeckoId": "injective-protocol", + "coinImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/7226.png", "gasPriceStep": { "low": 5000000000, "average": 25000000000, @@ -58,7 +54,8 @@ "average": 25000000000, "high": 50000000000 }, - "bridgeTo": ["Oraichain"] + "bridgeTo": ["Oraichain"], + "coinImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/7226.png" }, { "coinDenom": "ORAI", diff --git a/chains/kawaii_6886-1.json b/chains/kawaii_6886-1.json index 358768b..7529242 100644 --- a/chains/kawaii_6886-1.json +++ b/chains/kawaii_6886-1.json @@ -5,6 +5,7 @@ "chainId": "kawaii_6886-1", "chainName": "kawaiiverse", "networkType": "cosmos", + "chainSymbolImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/12313.png", "stakeCurrency": { "coinDenom": "ORAIE", "coinMinimalDenom": "oraie", diff --git a/chains/oraibtc-mainnet-1.json b/chains/oraibtc-mainnet-1.json index 6bbec46..d4573df 100644 --- a/chains/oraibtc-mainnet-1.json +++ b/chains/oraibtc-mainnet-1.json @@ -4,6 +4,7 @@ "rpc": "https://btc.rpc.orai.io", "rest": "https://btc.lcd.orai.io", "networkType": "cosmos", + "chainSymbolImageUrl": "https://assets.coingecko.com/coins/images/1/small/bitcoin.png", "stakeCurrency": { "coinDenom": "ORAIBTC", "coinMinimalDenom": "uoraibtc", diff --git a/chains/osmosis-1.json b/chains/osmosis-1.json index 61d4375..d348336 100644 --- a/chains/osmosis-1.json +++ b/chains/osmosis-1.json @@ -15,13 +15,8 @@ "bech32PrefixConsAddr": "osmovalcons", "bech32PrefixConsPub": "osmovalconspub" }, - "features": [ - "stargate", - "ibc-transfer", - "no-legacy-stdTx", - "ibc-go", - "cosmwasm" - ], + "features": ["stargate", "ibc-transfer", "no-legacy-stdTx", "ibc-go", "cosmwasm"], + "chainSymbolImageUrl": "https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png", "stakeCurrency": { "coinDenom": "OSMO", "coinMinimalDenom": "uosmo", diff --git a/packages/common/src/chain-infos/chain-info-reader.ts b/packages/common/src/chain-infos/chain-info-reader.ts index 80e881e..d9aab41 100644 --- a/packages/common/src/chain-infos/chain-info-reader.ts +++ b/packages/common/src/chain-infos/chain-info-reader.ts @@ -5,26 +5,15 @@ import { CHAIN_REGISTRY_GITHUB_RAWCONTENT_ENDPOINTS } from "../constants"; import { fetchRetry } from "../helpers"; -import { - ChainInfoReader, - ChainInfoReaderFromGitRawOptions, - CustomChainInfo -} from "./types"; +import { ChainInfoReader, ChainInfoReaderFromGitRawOptions, CustomChainInfo } from "./types"; export class ChainInfoReaderFromBackend implements ChainInfoReader { - constructor( - private readonly baseUrl?: string, - private readonly dex?: string - ) {} + constructor(private readonly baseUrl?: string, private readonly dex?: string) {} async readChainInfos() { - const { BASE_ENDPOINT, BASE_URL, CHAIN_INFOS } = - CHAIN_REGISTRY_BACKEND_ENDPOINTS; + const { BASE_ENDPOINT, BASE_URL, CHAIN_INFOS } = CHAIN_REGISTRY_BACKEND_ENDPOINTS; const url = - (this.baseUrl ?? BASE_URL) + - path.join(BASE_ENDPOINT, CHAIN_INFOS) + - "?dex=" + - this.dex; + (this.baseUrl ?? BASE_URL) + path.join(BASE_ENDPOINT, CHAIN_INFOS) + "?dex=" + this.dex; const chains = (await (await fetchRetry(url)).json()) as CustomChainInfo[]; return chains; } @@ -34,9 +23,7 @@ export class ChainInfoReaderFromOraiCommon implements ChainInfoReader { constructor(private readonly sourceUrl: string) {} async readChainInfos() { - const chains = (await ( - await fetchRetry(this.sourceUrl) - ).json()) as CustomChainInfo[]; + const chains = (await (await fetchRetry(this.sourceUrl)).json()) as CustomChainInfo[]; return chains; } } @@ -63,16 +50,12 @@ export class ChainInfoReaderFromGit implements ChainInfoReader { ).json(); const responses = ( - await Promise.allSettled( - response.map((chain) => fetchRetry(chain.download_url)) - ) + await Promise.allSettled(response.map((chain) => fetchRetry(chain.download_url))) ) .filter((chain) => chain.status === "fulfilled") .map((chain) => chain.value); - const chains: CustomChainInfo[] = await Promise.all( - responses.map((data) => data.json()) - ); + const chains: CustomChainInfo[] = await Promise.all(responses.map((data) => data.json())); return chains; } } @@ -88,9 +71,6 @@ export class ChainInfoReaderFromGitRaw implements ChainInfoReader { baseUrl: CHAIN_REGISTRY_GITHUB_RAWCONTENT_ENDPOINTS.BASE_URL } ) { - if (!this.options.baseUrl) - this.options.baseUrl = - CHAIN_REGISTRY_GITHUB_RAWCONTENT_ENDPOINTS.BASE_URL; this.generateUrls(); } @@ -106,7 +86,15 @@ export class ChainInfoReaderFromGitRaw implements ChainInfoReader { async readChainInfos() { const chainInfos: CustomChainInfo[] = await this.fetchUrls(); - return chainInfos; + + return chainInfos.map((chain: any) => { + const nativeToken = chain.feeCurrencies?.[0]; + return { + ...chain, + chainLogoPng: chain.chainLogoPng || nativeToken?.coinImageUrl, + chainLogoSvg: chain.chainLogoSvg || nativeToken?.coinImageUrl + }; + }); } async fetchUrls() { diff --git a/packages/common/src/token-items/token-items.ts b/packages/common/src/token-items/token-items.ts index 1d1447b..7105525 100644 --- a/packages/common/src/token-items/token-items.ts +++ b/packages/common/src/token-items/token-items.ts @@ -56,7 +56,8 @@ export class TokenItemsImpl implements TokenItems { gasPriceStep: currency.gasPriceStep, feeCurrencies: network.feeCurrencies, evmDenoms: evmDenomsMap[currency.coinMinimalDenom], - icon: currency.coinImageUrl + icon: currency.coinImageUrl, + iconLight: currency.coinImageUrl }; }); }; diff --git a/packages/common/src/token-items/types.ts b/packages/common/src/token-items/types.ts index 9859c78..7ebc122 100644 --- a/packages/common/src/token-items/types.ts +++ b/packages/common/src/token-items/types.ts @@ -24,4 +24,5 @@ export type TokenItemType = { }; feeCurrencies?: FeeCurrency[]; icon: string; + iconLight?: string; };