interface icon indicating copy to clipboard operation
interface copied to clipboard

fix: handled circleLogoUrl undefined.

Open zhyd1997 opened this issue 3 years ago • 5 comments

Fixes: #4897 Fixes: #4900 Fixes: #4908 Fixes: #4912

zhyd1997 avatar Oct 13 '22 15:10 zhyd1997

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
interface ✅ Ready (Inspect) Visit Preview Oct 14, 2022 at 2:21AM (UTC)

vercel[bot] avatar Oct 13 '22 15:10 vercel[bot]

Could you add:

  • src/components/Tokens/TokenTable/TokenRow.tsx line 486

Also, the root cause of this is that CHAIN_NAME_TO_CHAIN_ID[token.chain] may be returning undefined. Can you replace any instances of CHAIN_NAME_TO_CHAIN_ID[chain] with a new method, getChainNameForChainId(chainId: number): SupportedChainId | undefined? That will fix the typing, so that typescript does not even let us access circleLogoUrl without the optional operator.

I think it'd be enough to add TokenRow.tsx to get this merged. Fixing the root cause can be done in a follow-up (by you or by us).

zzmp avatar Oct 13 '22 18:10 zzmp

@zzmp

Apologized for this PR change, previously I thought this is just an optional chaining issue, so I set it up on Gitpod, but there is a CORS error for me to fetch the data: Screen Shot 2022-10-14 at 08 32 18

I found that all the PRs deployed here have no such issues, so I attempted to push it here, unfortunately, the PR not solved the undefined issue.

I will try to clone it on my M1 mac and see if localhost has CORS error 👀

zhyd1997 avatar Oct 14 '22 00:10 zhyd1997

Can you replace any instances of CHAIN_NAME_TO_CHAIN_ID[chain] with a new method, getChainNameForChainId(chainId: number): SupportedChainId | undefined?

Would this be getChainIdForChainName(chainName: string)? 👀

zhyd1997 avatar Oct 14 '22 02:10 zhyd1997

Hi @zzmp

I just marked the PR as ready for review, getChainIdForChainName(chainName: string) will not solve the problem because the getChainInfo function signature would be changed to this line if chainId is undefined:

https://github.com/Uniswap/interface/blob/332843f428b308e071b7ba8324aa50e4b8046aa2/src/constants/chainInfo.ts#L224-L226

so that we still need optional chaining for undefined.

zhyd1997 avatar Oct 14 '22 02:10 zhyd1997