fix(wallet): handle error when calling ERC721 TokenURI function

Fixes #10959
This commit is contained in:
Dario Gabriel Lipicar 2023-06-06 14:49:36 -03:00 committed by dlipicar
parent 8589a525a5
commit 4eb3d7485a
1 changed files with 12 additions and 3 deletions

View File

@ -23,6 +23,13 @@ const hystrixContractOwnershipClientName = "contractOwnershipClient"
const maxNFTDescriptionLength = 1024
// ERC721 does not support function "TokenURI" if call
// returns error starting with one of these strings
var noTokenURIErrorPrefixes = []string{
"execution reverted",
"abi: attempting to unmarshall",
}
type Manager struct {
rpcClient *rpc.Client
mainContractOwnershipProvider thirdparty.NFTContractOwnershipProvider
@ -220,9 +227,11 @@ func (o *Manager) fetchTokenURI(chainID uint64, id thirdparty.NFTUniqueID) (stri
}, id.TokenID.Int)
if err != nil {
if strings.HasPrefix(err.Error(), "execution reverted") {
// Contract doesn't support "TokenURI" method
return "", nil
for _, errorPrefix := range noTokenURIErrorPrefixes {
if strings.HasPrefix(err.Error(), errorPrefix) {
// Contract doesn't support "TokenURI" method
return "", nil
}
}
return "", err
}