Skip to content

Commit

Permalink
feat: add chainSymbolImageUrl to various chain configurations and upd…
Browse files Browse the repository at this point in the history
…ate coinImageUrl for Oraichain
  • Loading branch information
trungbach committed Dec 4, 2024
1 parent 60bcb80 commit 5c694a2
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 48 deletions.
1 change: 1 addition & 0 deletions chains/0x01.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"coinType": 60,
"networkType": "evm",
"features": ["isEvm"],
"chainSymbolImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",
"feeCurrencies": [
{
"coinDenom": "ETH",
Expand Down
1 change: 1 addition & 0 deletions chains/0x1ae6.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions chains/0x2b6653dc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"networkType": "evm",
"chainName": "tronnetwork",
"features": ["isEvm"],
"chainSymbolImageUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/1958.png",
"feeCurrencies": [
{
"coinDenom": "wTRX",
Expand Down
1 change: 1 addition & 0 deletions chains/0x38.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions chains/Oraichain.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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 }
}
],
Expand All @@ -41,14 +41,15 @@
"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",
"coinMinimalDenom": "orai",
"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 }
},
{
Expand Down
1 change: 1 addition & 0 deletions chains/bitcoin.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"coinType": 0
},
"coinType": 0,
"chainSymbolImageUrl": "https://assets.coingecko.com/coins/images/1/small/bitcoin.png",
"stakeCurrency": {
"coinDenom": "BTC",
"coinMinimalDenom": "btc",
Expand Down
15 changes: 6 additions & 9 deletions chains/injective-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions chains/kawaii_6886-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions chains/oraibtc-mainnet-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 2 additions & 7 deletions chains/osmosis-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 16 additions & 28 deletions packages/common/src/chain-infos/chain-info-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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();
}

Expand All @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/token-items/token-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
});
};
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/token-items/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export type TokenItemType = {
};
feeCurrencies?: FeeCurrency[];
icon: string;
iconLight?: string;
};

0 comments on commit 5c694a2

Please sign in to comment.