diff --git a/packages/dependency-royalty-management/contracts/MultiRoyaltyDistributor.sol b/packages/dependency-royalty-management/contracts/MultiRoyaltyDistributor.sol index 3600378d61..e45db9bdf6 100644 --- a/packages/dependency-royalty-management/contracts/MultiRoyaltyDistributor.sol +++ b/packages/dependency-royalty-management/contracts/MultiRoyaltyDistributor.sol @@ -36,10 +36,11 @@ abstract contract MultiRoyaltyDistributor is IEIP2981, IMultiRoyaltyDistributor, override(ERC165Upgradeable, IERC165) returns (bool isSupported) { - isSupported = (interfaceId == type(IEIP2981).interfaceId || + return + interfaceId == type(IEIP2981).interfaceId || interfaceId == type(IMultiRoyaltyDistributor).interfaceId || interfaceId == type(IMultiRoyaltyRecipients).interfaceId || - super.supportsInterface(interfaceId)); + super.supportsInterface(interfaceId); } /// @notice sets token royalty @@ -78,17 +79,12 @@ abstract contract MultiRoyaltyDistributor is IEIP2981, IMultiRoyaltyDistributor, (address payable _defaultRoyaltyReceiver, uint16 _defaultRoyaltyBPS) = IRoyaltyManager(royaltyManager).getRoyaltyInfo(); if (_tokenRoyaltiesSplitter[tokenId] != address(0)) { - (receiver, royaltyAmount) = ( - _tokenRoyaltiesSplitter[tokenId], - (value * _defaultRoyaltyBPS) / TOTAL_BASIS_POINTS - ); - return (receiver, royaltyAmount); + return (_tokenRoyaltiesSplitter[tokenId], (value * _defaultRoyaltyBPS) / TOTAL_BASIS_POINTS); } if (_defaultRoyaltyReceiver != address(0) && _defaultRoyaltyBPS != 0) { - (receiver, royaltyAmount) = (_defaultRoyaltyReceiver, (value * _defaultRoyaltyBPS) / TOTAL_BASIS_POINTS); - return (receiver, royaltyAmount); + return (_defaultRoyaltyReceiver, (value * _defaultRoyaltyBPS) / TOTAL_BASIS_POINTS); } - return (receiver, royaltyAmount); + return (address(0), 0); } /// @notice returns the EIP-2981 royalty receiver for each token (i.e. splitters) including the default royalty receiver. @@ -114,16 +110,16 @@ abstract contract MultiRoyaltyDistributor is IEIP2981, IMultiRoyaltyDistributor, /// @notice returns the royalty recipients for each tokenId. /// @dev returns the default address for tokens with no recipients. /// @param tokenId is the token id for which the recipient should be returned. - /// @return defaultRecipient addresses of royalty recipient of the token. - function getRecipients(uint256 tokenId) public view returns (Recipient[] memory defaultRecipient) { + /// @return recipients array of royalty recipients for the token + function getRecipients(uint256 tokenId) public view returns (Recipient[] memory recipients) { address payable splitterAddress = _tokenRoyaltiesSplitter[tokenId]; (address payable _defaultRoyaltyReceiver, ) = IRoyaltyManager(royaltyManager).getRoyaltyInfo(); if (splitterAddress != address(0)) { return IRoyaltySplitter(splitterAddress).getRecipients(); } - defaultRecipient = new Recipient[](1); - defaultRecipient[0] = Recipient({recipient: _defaultRoyaltyReceiver, bps: TOTAL_BASIS_POINTS}); - return defaultRecipient; + recipients = new Recipient[](1); + recipients[0] = Recipient({recipient: _defaultRoyaltyReceiver, bps: TOTAL_BASIS_POINTS}); + return recipients; } /// @notice internal function to set the token royalty splitter @@ -138,13 +134,13 @@ abstract contract MultiRoyaltyDistributor is IEIP2981, IMultiRoyaltyDistributor, /// @param tokenId is the token id for which royalty splitter should be returned. /// @return splitterAddress address of royalty splitter for the token. function getTokenRoyaltiesSplitter(uint256 tokenId) external view returns (address payable splitterAddress) { - splitterAddress = _tokenRoyaltiesSplitter[tokenId]; + return _tokenRoyaltiesSplitter[tokenId]; } /// @notice returns the address of royalty manager. /// @return managerAddress address of royalty manager. function getRoyaltyManager() external view returns (address managerAddress) { - managerAddress = royaltyManager; + return royaltyManager; } /// @notice set royalty manager address diff --git a/packages/dependency-royalty-management/contracts/RoyaltyDistributor.sol b/packages/dependency-royalty-management/contracts/RoyaltyDistributor.sol index d8b754025b..ac5c57b26b 100644 --- a/packages/dependency-royalty-management/contracts/RoyaltyDistributor.sol +++ b/packages/dependency-royalty-management/contracts/RoyaltyDistributor.sol @@ -46,13 +46,13 @@ abstract contract RoyaltyDistributor is IERC2981Upgradeable, ERC165Upgradeable { override(ERC165Upgradeable, IERC165Upgradeable) returns (bool isSupported) { - isSupported = (interfaceId == type(IERC2981Upgradeable).interfaceId || super.supportsInterface(interfaceId)); + return (interfaceId == type(IERC2981Upgradeable).interfaceId || super.supportsInterface(interfaceId)); } /// @notice returns the royalty manager /// @return royaltyManagerAddress address of royalty manager contract. function getRoyaltyManager() external view returns (IRoyaltyManager royaltyManagerAddress) { - royaltyManagerAddress = royaltyManager; + return royaltyManager; } /// @notice set royalty manager diff --git a/packages/dependency-royalty-management/contracts/RoyaltyManager.sol b/packages/dependency-royalty-management/contracts/RoyaltyManager.sol index 0cdad1b4b0..488a1b90bc 100644 --- a/packages/dependency-royalty-management/contracts/RoyaltyManager.sol +++ b/packages/dependency-royalty-management/contracts/RoyaltyManager.sol @@ -91,7 +91,7 @@ contract RoyaltyManager is AccessControlUpgradeable, IRoyaltyManager { /// @notice get the current trustedForwarder address /// @return trustedForwarder address of current TrustedForwarder function getTrustedForwarder() public view returns (address trustedForwarder) { - trustedForwarder = _trustedForwarder; + return _trustedForwarder; } function _setRecipient(address payable _commonRecipient) internal { @@ -130,7 +130,7 @@ contract RoyaltyManager is AccessControlUpgradeable, IRoyaltyManager { /// @notice to be called by the splitters to get the common recipient and split /// @return recipient which has the common recipient and split function getCommonRecipient() external view override returns (Recipient memory recipient) { - recipient = Recipient({recipient: commonRecipient, bps: commonSplit}); + return Recipient({recipient: commonRecipient, bps: commonSplit}); } /// @notice deploys splitter for creator @@ -157,20 +157,20 @@ contract RoyaltyManager is AccessControlUpgradeable, IRoyaltyManager { /// @param creator the address of the creator /// @return creatorSplitterAddress splitter's address deployed for a creator function getCreatorRoyaltySplitter(address creator) external view returns (address payable creatorSplitterAddress) { - creatorSplitterAddress = creatorRoyaltiesSplitter[creator]; + return creatorRoyaltiesSplitter[creator]; } /// @notice returns the amount of basis points allocated to the creator /// @return creatorSplit which is 10000 - commonSplit function getCreatorSplit() external view returns (uint16 creatorSplit) { - creatorSplit = TOTAL_BASIS_POINTS - commonSplit; + return TOTAL_BASIS_POINTS - commonSplit; } /// @notice returns the commonRecipient and EIP2981 royalty bps /// @return recipient address of common royalty recipient /// @return royaltySplit contract EIP2981 royalty bps function getRoyaltyInfo() external view returns (address payable recipient, uint16 royaltySplit) { - (recipient, royaltySplit) = (commonRecipient, contractRoyalty[msg.sender]); + return (commonRecipient, contractRoyalty[msg.sender]); } /// @notice returns the EIP2981 royalty bps diff --git a/packages/dependency-royalty-management/contracts/RoyaltySplitter.sol b/packages/dependency-royalty-management/contracts/RoyaltySplitter.sol index 80da7dc8f3..85f7a4b401 100644 --- a/packages/dependency-royalty-management/contracts/RoyaltySplitter.sol +++ b/packages/dependency-royalty-management/contracts/RoyaltySplitter.sol @@ -65,7 +65,7 @@ contract RoyaltySplitter is override(IERC165, ERC165Upgradeable) returns (bool isSupported) { - isSupported = (interfaceId == type(IRoyaltySplitter).interfaceId || super.supportsInterface(interfaceId)); + return (interfaceId == type(IRoyaltySplitter).interfaceId || super.supportsInterface(interfaceId)); } /// @notice initialize the contract @@ -152,8 +152,7 @@ contract RoyaltySplitter is function _splitERC20Tokens(IERC20 erc20Contract) internal returns (bool success) { try erc20Contract.balanceOf(address(this)) returns (uint256 balance) { if (balance == 0) { - success = false; - return success; + return false; } Recipient memory commonRecipient = royaltyManager.getCommonRecipient(); uint16 creatorSplit = royaltyManager.getCreatorSplit(); @@ -184,9 +183,9 @@ contract RoyaltySplitter is } erc20Contract.safeTransfer(_recipients[0].recipient, amountToSend); emit ERC20Transferred(address(erc20Contract), _recipients[0].recipient, amountToSend); - success = true; + return true; } catch { - success = false; + return false; } } @@ -199,7 +198,7 @@ contract RoyaltySplitter is override(ERC2771HandlerAbstract) returns (bool isTrusted) { - isTrusted = (forwarder == royaltyManager.getTrustedForwarder()); + return (forwarder == royaltyManager.getTrustedForwarder()); } function _msgSender() @@ -209,7 +208,7 @@ contract RoyaltySplitter is override(ContextUpgradeable, ERC2771HandlerAbstract) returns (address sender) { - sender = ERC2771HandlerAbstract._msgSender(); + return ERC2771HandlerAbstract._msgSender(); } function _msgData() @@ -219,6 +218,6 @@ contract RoyaltySplitter is override(ContextUpgradeable, ERC2771HandlerAbstract) returns (bytes calldata messageData) { - messageData = ERC2771HandlerAbstract._msgData(); + return ERC2771HandlerAbstract._msgData(); } }