fix(wallet) limit nft description length

Fixes #10923
This commit is contained in:
Dario Gabriel Lipicar 2023-06-06 11:12:41 -03:00 committed by dlipicar
parent 4006cb78b3
commit d73c886d3b
1 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,8 @@ const requestTimeout = 5 * time.Second
const hystrixContractOwnershipClientName = "contractOwnershipClient"
const maxNFTDescriptionLength = 1024
type Manager struct {
rpcClient *rpc.Client
mainContractOwnershipProvider thirdparty.NFTContractOwnershipProvider
@ -272,6 +274,12 @@ func (o *Manager) processAssets(chainID uint64, assets []opensea.Asset) error {
}
}
// The NFT description field could be arbitrarily large, causing memory management issues upstream.
// Trim it to a reasonable length here.
if len(assets[idx].Description) > maxNFTDescriptionLength {
assets[idx].Description = assets[idx].Description[:maxNFTDescriptionLength]
}
o.nftCache[chainID][id.HashKey()] = assets[idx]
}