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: Catch errors from the assets controller #29439

Merged
merged 2 commits into from
Jan 9, 2025
Merged

Conversation

pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Jan 6, 2025

Description

This PR addresses a group of errors reported on Sentry that occur when getTokenStandardAndDetails in assetsContractController returns "Unable to determine contract standard". Sentry Issue Link.

The error happens fairly often because only contracts that strictly adhere to the standard ABIs for ERC20, ERC721, and ERC1155 are correctly parsed. When a contract does not conform to these standards, the function fails and throws an error.

This PR introduces error handling to catch and silence the error when assetsContractController.getTokenStandardAndDetails fails to determine the contract standard. The control flow of the function is adjusted to ensure it continues to execute normally even when the error is caught.

Changes

  • Added a try...catch block around the assetsContractController.getTokenStandardAndDetails call to catch and log the error.

  • Ensured that the function continues to execute and return appropriate details even when the error is caught.

Open in GitHub Codespaces

Related issues

Fixes: #25212

Manual testing steps

  1. Go to this page...

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.

@pedronfigueiredo pedronfigueiredo added the team-confirmations Push issues to confirmations team label Jan 6, 2025
@pedronfigueiredo pedronfigueiredo self-assigned this Jan 6, 2025
Copy link
Contributor

github-actions bot commented Jan 6, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot
Copy link
Collaborator

Builds ready [8490727]
Page Load Metrics (1850 ± 105 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint43425571796384184
domContentLoaded160624601822218104
load161324781850218105
domInteractive26275625526
backgroundConnect982302010
firstReactRender17100443115
getState586212311
initialActions01000
loadScripts11721801136116378
setupStore779232412
uiStartup184928542195297143

jpuri
jpuri previously approved these changes Jan 7, 2025
matthewwalsh0
matthewwalsh0 previously approved these changes Jan 7, 2025
tokenId,
);
} catch (e) {
log.error(`Failed to get token standard and details. Error: ${e}`);
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth an error if this is common, could we also do a warn as below?

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Jan 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 8, 2025
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Jan 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 8, 2025
@pedronfigueiredo pedronfigueiredo dismissed stale reviews from matthewwalsh0 and jpuri via 72425b3 January 9, 2025 13:47
@metamaskbot
Copy link
Collaborator

Builds ready [72425b3]
Page Load Metrics (2134 ± 147 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint22429041800771370
domContentLoaded174127982092285137
load179028982134305147
domInteractive27146633617
backgroundConnect799382713
firstReactRender16106523014
getState66425178
initialActions0573126
loadScripts130022601587244117
setupStore787192211
uiStartup204231782532374179

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Jan 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2025
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Jan 9, 2025
Merged via the queue into main with commit 6e05923 Jan 9, 2025
76 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/25212 branch January 9, 2025 16:39
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2025
@metamaskbot metamaskbot added the release-12.11.0 Issue or pull request that will be included in release 12.11.0 label Jan 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.11.0 Issue or pull request that will be included in release 12.11.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Import NFTs modal error handling for getTokenStandardAndDetails
4 participants