Replace some uses of abi.encodePacked with more explicit alternatives (#4296)
Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
@ -42,8 +42,8 @@ abstract contract ERC1155URIStorage is ERC1155 {
|
||||
function uri(uint256 tokenId) public view virtual override returns (string memory) {
|
||||
string memory tokenURI = _tokenURIs[tokenId];
|
||||
|
||||
// If token URI is set, concatenate base URI and tokenURI (via abi.encodePacked).
|
||||
return bytes(tokenURI).length > 0 ? string(abi.encodePacked(_baseURI, tokenURI)) : super.uri(tokenId);
|
||||
// If token URI is set, concatenate base URI and tokenURI (via string.concat).
|
||||
return bytes(tokenURI).length > 0 ? string.concat(_baseURI, tokenURI) : super.uri(tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -97,7 +97,7 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Er
|
||||
_requireMinted(tokenId);
|
||||
|
||||
string memory baseURI = _baseURI();
|
||||
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
|
||||
return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -35,9 +35,9 @@ abstract contract ERC721URIStorage is IERC4906, ERC721 {
|
||||
if (bytes(base).length == 0) {
|
||||
return _tokenURI;
|
||||
}
|
||||
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
|
||||
// If both are set, concatenate the baseURI and tokenURI (via string.concat).
|
||||
if (bytes(_tokenURI).length > 0) {
|
||||
return string(abi.encodePacked(base, _tokenURI));
|
||||
return string.concat(base, _tokenURI);
|
||||
}
|
||||
|
||||
return super.tokenURI(tokenId);
|
||||
|
||||
Reference in New Issue
Block a user