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

[Fix] incorrect network info on NFT sends + L2 explainer sheet #1804

Merged

Conversation

BrodyHughes
Copy link
Member

@BrodyHughes BrodyHughes commented Jan 14, 2025

Fixes BX-1688

What changed (plus any additional context for devs)

We had user reports that NFT sends on base in the BX are showing the wrong network message during the send process. I could reproduce this behavior. We were just defaulting to mainnet because our current logic was relying on asset.chainId which was returning undefined. this is expected behavior because our NFT data comes from nft not asset

The fix was to instead use our more broad chain info found in our chain object. This is defined as:

  const assetChainId =
    asset?.chainId || chainNameToIdMapping[nft?.network || ChainName.mainnet];
  const chain = useMemo(
    () => chains.find((c) => c.id === assetChainId),
    [assetChainId, chains],
  );

Using the chain object for chain related info returns the correct data for both token AND nft sends as you can see in my POW.

Another bug i fixed here was related to L2 explainers. The same issue we had with the above info was making L2 explainers not show at all on NFT sends, so I moved that logic over to chain as well for its info.

Screen recordings / screenshots

POW:

Screen.Recording.2025-01-14.at.2.47.16.PM.mov

What to test

Do sends of NFT and tokens on L2 networks and make sure the review sheet shows the correct info.

Copy link

linear bot commented Jan 14, 2025

@BrodyHughes BrodyHughes marked this pull request as ready for review January 14, 2025 20:58
@BrodyHughes BrodyHughes changed the title Fix incorrect network info on NFT sends + L2 explainer sheet [Fix] incorrect network info on NFT sends + L2 explainer sheet Jan 14, 2025
@BrodyHughes BrodyHughes self-assigned this Jan 14, 2025
showExplainerSheet({
...getSideChainExplainerParams(asset.chainId, hideExplainerSheet),
...getSideChainExplainerParams(chain?.id as ChainId, hideExplainerSheet),
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't need to be optionally chained if you're null checking beforehand. Also, any way to avoid having to cast as ChainId? I kinda hate this pattern of casting number -> ChainId

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. will fix this up later today.

@DanielSinclair
Copy link
Collaborator

DanielSinclair commented Jan 17, 2025

@BrodyHughes Not familiar with the upstream queries, but I wonder if we can also deprecate the || ChainId.mainnet fallbacks since they caused the issue initially. That way the type errors give tell us something useful. It looks the network param is also added manually to UniqueAsset here, so we could do the string->id translation upstream there (matching the asset chain type) to avoid having to ever use the chain name string here

@BrodyHughes
Copy link
Member Author

@BrodyHughes Not familiar with the upstream queries, but I wonder if we can also deprecate the || ChainId.mainnet fallbacks since they caused the issue initially. That way the type errors give tell us something useful. It looks the network param is also added manually to UniqueAsset here, so we could do the string->id translation upstream there (matching the asset chain type) to avoid having to ever use the chain name string here

Yo lemme know if i am misunderstanding but i checked the upstream code and saw that we're already handling the chain conversion in simpleHashNFTToUniqueAsset where the NFT data is first processed. The chain?.id undefined check is happening separately in the UI layer, so removing the mainnet fallback wouldn't solve our current type issue i dont think

@BrodyHughes BrodyHughes requested a review from walmat January 22, 2025 18:25
Copy link
Collaborator

@DanielSinclair DanielSinclair left a comment

Choose a reason for hiding this comment

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

Tested NFT and ERC20 send reviews on Mainnet and Base

@DanielSinclair DanielSinclair merged commit 97b914a into master Jan 23, 2025
4 checks passed
@DanielSinclair DanielSinclair deleted the brody/bx-1688-incorrect-network-message-for-nft-sends branch January 23, 2025 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants