Skip to content

Commit

Permalink
bsc: fix improper decimals (#5097)
Browse files Browse the repository at this point in the history
* test

* fix coinICon issue

* clean up coin icon
  • Loading branch information
skylarbarrera authored Oct 10, 2023
1 parent ae07e62 commit a631e40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,18 @@ export default React.memo(function FastCoinIcon({
mainnetAddress,
});

const tokenMetadata = getTokenMetadata(resolvedAddress);

const fallbackIconColor = useColorForAsset({
address: resolvedAddress,
type: resolvedType,
});

const shadowColor = theme.isDarkMode
? colors.shadow
: tokenMetadata?.shadowColor ?? fallbackIconColor;
const shadowColor = theme.isDarkMode ? colors.shadow : fallbackIconColor;

const eth = isETH(resolvedAddress);

const formattedSymbol = formatSymbol(symbol);

const shouldRenderFallback = !eth && !tokenMetadata;
const shouldRenderFallback = !eth;
const shouldRenderLocalCoinIconImage =
!shouldRenderFallback && !!CoinIconsImages[formattedSymbol];
const shouldRenderContract = symbol === 'contract';
Expand Down
7 changes: 2 additions & 5 deletions src/components/coin-icon/CoinIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ const CoinIcon: React.FC<Props> = ({
mainnet_address,
...props
}) => {
const tokenMetadata = getTokenMetadata(mainnet_address || address);
const color = useColorForAsset({
address: mainnet_address || address,
type: mainnet_address ? AssetTypes.token : type,
});
const { colors, isDarkMode } = useTheme();
const forceFallback =
!isETH(mainnet_address || address) && isNil(tokenMetadata);
const forceFallback = !isETH(mainnet_address || address);
const isNotContractInteraction = useMemo(() => symbol !== 'contract', [
symbol,
]);
Expand All @@ -83,8 +81,7 @@ const CoinIcon: React.FC<Props> = ({
// force update on change symbol due to ImageCache strategy
key={symbol}
shadowColor={
forcedShadowColor ||
(isDarkMode ? colors.shadow : tokenMetadata?.shadowColor || color)
forcedShadowColor || (isDarkMode ? colors.shadow : color)
}
size={size}
symbol={symbol}
Expand Down
7 changes: 1 addition & 6 deletions src/utils/getTokenMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@ import { rainbowTokenList } from '@/references';
export default function getTokenMetadata(
tokenAddress: string | undefined
): Omit<TokenMetadata, 'decimals' | 'chainId'> | undefined {
if (!tokenAddress) return undefined;
const metadata: TokenMetadata =
rainbowTokenList.RAINBOW_TOKEN_LIST[tokenAddress.toLowerCase()];

// delete chain metadata
return omitFlatten(metadata, ['chainId', 'decimals']);
return undefined;
}

0 comments on commit a631e40

Please sign in to comment.