fix: Don't panic if tokenID is nil #148
Merged
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.
If for any reason the tokenID for an ERC721 or ERC1155 transfer is nil, skip calculating the URI. There is a most likely a better/more robust solution but this should prevent us from dying until such a solution is in place.
Example scenario: A Contract implements ERC1155, and additionally the same transfer method as ERC20. However the Contract is not an ERC20 it just has one of the same methods. When we parse transfers, we will still collect this as a transfer but there is no tokenID because it's not an ERC1155 transfer. Later when getting metadata, we see that the contract is not an ERC20 but is an ERC1155 so we get the metadata for that. It is now not safe to assume the transfer has a non-nil tokenID.