Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bsc: fix improper decimals #5097

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you help me understand how decimals which should be omitted here would impact the other flows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it wasn't being omitted, we've had a bunch of issues with this previously when we added BSC which you and I looked into and then had to pull bruno in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't be using the token list as a source of truth for anything anyways

return undefined;
}
Loading