Remove redundant memory usage in ERC2981 royaltyInfo (#4538)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
committed by
GitHub
parent
d398d68944
commit
9558e546d9
@ -59,15 +59,18 @@ abstract contract ERC2981 is IERC2981, ERC165 {
|
||||
* @inheritdoc IERC2981
|
||||
*/
|
||||
function royaltyInfo(uint256 tokenId, uint256 salePrice) public view virtual returns (address, uint256) {
|
||||
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[tokenId];
|
||||
RoyaltyInfo storage _royaltyInfo = _tokenRoyaltyInfo[tokenId];
|
||||
address royaltyReceiver = _royaltyInfo.receiver;
|
||||
uint96 royaltyFraction = _royaltyInfo.royaltyFraction;
|
||||
|
||||
if (royalty.receiver == address(0)) {
|
||||
royalty = _defaultRoyaltyInfo;
|
||||
if (royaltyReceiver == address(0)) {
|
||||
royaltyReceiver = _defaultRoyaltyInfo.receiver;
|
||||
royaltyFraction = _defaultRoyaltyInfo.royaltyFraction;
|
||||
}
|
||||
|
||||
uint256 royaltyAmount = (salePrice * royalty.royaltyFraction) / _feeDenominator();
|
||||
uint256 royaltyAmount = (salePrice * royaltyFraction) / _feeDenominator();
|
||||
|
||||
return (royalty.receiver, royaltyAmount);
|
||||
return (royaltyReceiver, royaltyAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user