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: ignore error when getTokenStandardAndDetails fails #28030

Merged
Changes from all 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
10 changes: 7 additions & 3 deletions ui/ducks/send/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -2615,7 +2615,12 @@ export function updateSendAsset(

let missingProperty = STANDARD_TO_REQUIRED_PROPERTIES[
providedDetails.standard
]?.find((property) => providedDetails[property] === undefined);
]?.find((property) => {
if (providedDetails.collection && property === 'symbol') {
return providedDetails.collection[property] === undefined;
}
return providedDetails[property] === undefined;
});

let details;

Expand Down Expand Up @@ -2652,10 +2657,9 @@ export function updateSendAsset(
providedDetails.address,
sendingAddress,
providedDetails.tokenId,
).catch((error) => {
).catch(() => {
// prevent infinite stuck loading state
dispatch(hideLoadingIndication());
throw error;
})),
Copy link
Contributor Author

@sahar-fehri sahar-fehri Oct 22, 2024

Choose a reason for hiding this comment

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

This change wont affect native transfers;
It also wont affect ERC20 transfers because for ERC20 transfers tokenCanBeTreatedAsAnERC20 here should be true making details defined and skipping the call to getTokenStandardAndDetails.
This should only affect NFT assets;

This is throwing because the code detects that there is a missing property which is symbol in the case of the nfts i have tested with (here) and because the providedDetails has standard property it will go into the else and call getTokenStandardAndDetails. (still not sure why getTokenStandardAndDetails would throw for so many contracts, it might be good to add the contract address and tokenId in the error log)

The code is detecting that the symbol is missing because the nftDetails symbol is inside providedDetails.collection,
but this piece of code
is expecting the symbol inside the providedDetails object;

The properties that it is checking for an NFT are basically "name, symbol, tokenId" i dnt think tokenId can be undefined for an NFT.
Looking at the number of users affected by this; i would expect that most of them had missingProperty= symbol

Adding sth similar to this;

let missingProperty = STANDARD_TO_REQUIRED_PROPERTIES[ providedDetails.standard ]?.find((property) => { if (providedDetails.collection && property === 'symbol') { return providedDetails.collection[property] === undefined; } return providedDetails[property] === undefined; });
Would make the code go into this if statement
and not make the call to getTokenStandardAndDetails.

However, the symbol inside collection is not always defined either, there will be cases where our third party provider did not return it.

In the case; the code will go into else and call getTokenStandardAndDetails;
For that i have also removed the "throw error"; I don't see why it is necessary to throw when this call fails; I have also tested this and my transactions are going through with the call to getTokenStandardAndDetails failing

};
}
Expand Down