Skip to content

Commit

Permalink
getCurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
marxeille committed Jul 5, 2024
1 parent 2a43f27 commit 94a0c48
Showing 1 changed file with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ import { Currency } from "@owallet/types";
import Coingecko from "@src/assets/data/coingecko.json";
import get from "lodash/get";

const getCurrency = (item, itemCoingecko) => {
const currency = {
coinDecimals: item.tokenInfo.attributes.decimals,
coinImageUrl:
item.tokenInfo.attributes.image_url == "missing.png"
? unknownToken.coinImageUrl
: item.tokenInfo.attributes.image_url,
coinGeckoId:
item.tokenInfo.attributes.coingecko_coin_id ||
get(itemCoingecko, "id") ||
"unknown",
coinMinimalDenom: `erc20:${item.tokenAddress}:${item.tokenInfo.attributes.name}`,
coinDenom: item.tokenInfo.attributes.symbol,
} as Currency;

return currency;
};

export const TxEvmItem: FC<{
item: any;
index: number;
Expand Down Expand Up @@ -52,19 +70,7 @@ export const TxEvmItem: FC<{
it.symbol.toUpperCase() ==
get(item, "tokenInfo.attributes.symbol").toUpperCase()
);
currency = {
coinDecimals: item.tokenInfo.attributes.decimals,
coinImageUrl:
item.tokenInfo.attributes.image_url == "missing.png"
? unknownToken.coinImageUrl
: item.tokenInfo.attributes.image_url,
coinGeckoId:
item.tokenInfo.attributes.coingecko_coin_id ||
get(itemCoingecko, "id") ||
"unknown",
coinMinimalDenom: `erc20:${item.tokenAddress}:${item.tokenInfo.attributes.name}`,
coinDenom: item.tokenInfo.attributes.symbol,
} as Currency;
currency = getCurrency(item, itemCoingecko);
}
} else if (item.transactionType === "native") {
currency = chainStore.current.stakeCurrency;
Expand Down

0 comments on commit 94a0c48

Please sign in to comment.