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: Fix unwanted IncompleteAssetDisplayed events #11620

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

OGPoyraz
Copy link
Member

@OGPoyraz OGPoyraz commented Oct 4, 2024

Description

This PR aims to stop IncompleteAssetDisplayed events appearing in the mix panel even the token is known by the API.

For more information please see the mixpanel link https://mixpanel.com/project/1979229/view/132079/app/events#H35NJuByTVqi

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/3362

Manual testing steps

No QA needed

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@OGPoyraz OGPoyraz requested a review from a team as a code owner October 4, 2024 06:57
@github-actions github-actions bot added the team-confirmations Push issues to confirmations team label Oct 4, 2024
@OGPoyraz OGPoyraz added the No QA Needed Apply this label when your PR does not need any QA effort. label Oct 4, 2024
Copy link

sonarcloud bot commented Oct 4, 2024

@@ -593,7 +593,7 @@ class TransactionReview extends PureComponent {
primaryCurrency={primaryCurrency}
chainId={chainId}
/>
{useTransactionSimulations && (
{useTransactionSimulations && transactionSimulationData && (
Copy link
Member Author

@OGPoyraz OGPoyraz Oct 4, 2024

Choose a reason for hiding this comment

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

The issue arises due to a race condition in the useBalanceChanges hook. Initially, the hook is invoked with empty balance changes (an empty array). Subsequently, simulationData gets populated and the hook is called again. In the interim, the empty balance changes resolve and set pending to false. This results in the IncompleteAssetEvent being triggered because it mistakenly interprets the new contract information as having resolved.

I reviewed the SimulationDetails component and simulationData in the extension. It appears that SimulationDetails is never rendered when simulationData is undefined. This is likely because the transactions state changes do not occur immediately(there is a time to bounce in extension state), unlike in the mobile app where the transactions simulationData is not defined in the beginning of the confirmation.

Please refer to the logs I added at the top of SimulationDetails in the extension, which show that simulationData is always defined.
Screenshot 2024-10-04 at 09 09 50

This fix is just imitating the behaviour of extension and fixes that race condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No QA Needed Apply this label when your PR does not need any QA effort. team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants