fix: handle error in case erc1155 id cannot be converted to BigNumber #3073
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Attempt to fix user reported error
This fix parts from the assumption that the ens NFT avatar is passing a bad value onto a BigNumber constructor.
To Test
Unsure, as I have not been able to reproduce it yet
Update: User confirmed it fixes the problem \o/
Background
User's setup:
The problem
User's avatar is set to
http://eip155:1/erc721:0xed5af388653567af2f388e6224dc7c4b3241c544/0000
(replaced the actual id with0000
to preserve user's identity)The hooks that processes the avatar URL is not expecting an url in this format https://github.com/cowprotocol/cowswap/blob/76c1c7c9d1c41934eb8b9762d00389b4917616b4/apps/cowswap-frontend/src/legacy/hooks/useENSAvatar.ts#L78C1-L78C1
When splitting it by
:
, we get 4 parts:Due to the unexpected format, we end up with the
id
being set toerc721
instead of0000
.Down the line the id is converted to a BigNumber to be converted to a hexString.
That's when it fails, and that's what this fix does.
This fix does not, however, fixes the loading of the different format.
I'll leave that as a task on the backlog as the immediate issue is being addressed, and the user is able to connect to the interface without crashing.