Skip to content

Commit

Permalink
return the values directly
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciech-turek committed Sep 1, 2023
1 parent a26e0e8 commit 3a2c63b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -199,7 +198,7 @@ contract RoyaltySplitter is
override(ERC2771HandlerAbstract)
returns (bool isTrusted)
{
isTrusted = (forwarder == royaltyManager.getTrustedForwarder());
return (forwarder == royaltyManager.getTrustedForwarder());
}

function _msgSender()
Expand All @@ -209,7 +208,7 @@ contract RoyaltySplitter is
override(ContextUpgradeable, ERC2771HandlerAbstract)
returns (address sender)
{
sender = ERC2771HandlerAbstract._msgSender();
return ERC2771HandlerAbstract._msgSender();
}

function _msgData()
Expand All @@ -219,6 +218,6 @@ contract RoyaltySplitter is
override(ContextUpgradeable, ERC2771HandlerAbstract)
returns (bytes calldata messageData)
{
messageData = ERC2771HandlerAbstract._msgData();
return ERC2771HandlerAbstract._msgData();
}
}

1 comment on commit 3a2c63b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

96.33%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/asset/contracts
   Asset.sol94.53%89.58%96.43%98.08%103, 188, 293, 293–294, 65
   AssetCreate.sol94.51%83.33%100%100%130, 132, 165, 281, 68
   AssetReveal.sol94.35%86.21%96.55%98.89%143, 147, 181, 376, 416, 424, 441, 75, 98
   AuthSuperValidator.sol100%100%100%100%
   Catalyst.sol95%91.94%95.45%98.21%125, 127, 140, 152, 224, 80
packages/asset/contracts/interfaces
   IAsset.sol100%100%100%100%
   IAssetCreate.sol100%100%100%100%
   IAssetReveal.sol100%100%100%100%
   ICatalyst.sol100%100%100%100%
   ITokenUtils.sol100%100%100%100%
packages/asset/contracts/libraries
   TokenIdUtils.sol100%100%100%100%
packages/dependency-metatx/contracts
   ERC2771Handler.sol100%100%100%100%
   ERC2771HandlerAbstract.sol100%100%100%100%
   ERC2771HandlerUpgradeable.sol95.45%83.33%100%100%43
packages/dependency-metatx/contracts/test
   ERC2771HandlerTest.sol100%100%100%100%
   ERC2771HandlerUpgradeableTest.sol100%100%100%100%
   MockTrustedForwarder.sol0%0%0%0%15, 18–19, 19, 19–20
packages/dependency-operator-filter/contracts
   OperatorFiltererUpgradeable.sol82.35%85%71.43%83.33%17, 51–52, 61–62, 71, 83
   OperatorFilterSubscription.sol60%50%100%50%19–20
packages/dependency-operator-filter/contracts/interfaces
   IOperatorFilterRegistry.sol100%100%100%100%
packages/dependency-royalty-management/contracts
   MultiRoyaltyDistributor.sol83.82%65%90%92.11%103, 143, 25, 40, 40, 40, 40, 59–60, 96
   RoyaltyDistributor.sol77.78%50%80%88.89%20, 49, 55
   RoyaltyManager.sol96.39%87.50%100%100%104, 47, 98
   RoyaltySplitter.sol92.08%75%92.31%97.06%120, 160, 188, 221, 68, 75, 85
packages/dependency-royalty-management/contracts/interfaces
   IERC20Approve.sol100%100%100%100%
   IMultiRoyaltyDistributor.sol100%100%100%100%
   IMultiRoyaltyRecipients.sol100%100%100%100%
   IRoyaltyManager.sol100%100%100%100%
   IRoyaltyUGC.sol100%100%100%100%

Please sign in to comment.