Skip to content

Commit

Permalink
remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Aug 14, 2023
1 parent 76141cd commit d3dd40e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
13 changes: 0 additions & 13 deletions src/royalties/CreatorRoyaltiesControl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@ abstract contract CreatorRoyaltiesControl is CreatorRoyaltiesStorageV1, SharedBa
receiver = config.royaltyRecipient;
}

/// @notice Returns the supply royalty information for a given token.
/// @param tokenId The token ID to get the royalty information for.
/// @param mintAmount The amount of tokens being minted.
/// @param totalSupply The total supply of the token,
function supplyRoyaltyInfo(uint256 tokenId, uint256 totalSupply, uint256 mintAmount) public view returns (address receiver, uint256 royaltyAmount) {
RoyaltyConfiguration memory config = getRoyalties(tokenId);
if (config.royaltyMintSchedule == 0) {
return (config.royaltyRecipient, 0);
}
uint256 totalRoyaltyMints = (mintAmount + (totalSupply % config.royaltyMintSchedule)) / (config.royaltyMintSchedule - 1);
return (config.royaltyRecipient, totalRoyaltyMints);
}

function _updateRoyalties(uint256 tokenId, RoyaltyConfiguration memory configuration) internal {
// Don't allow 100% supply royalties
if (configuration.royaltyMintSchedule == 1) {
Expand Down
19 changes: 16 additions & 3 deletions test/royalties/CreatorRoyaltiesControl.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ contract CreatorRoyaltiesControlTest is Test {
response = new bytes[](0);
}

/// @notice Returns the supply royalty information for a given token.
/// @param tokenId The token ID to get the royalty information for.
/// @param mintAmount The amount of tokens being minted.
/// @param totalSupply The total supply of the token,
function supplyRoyaltyInfo(uint256 tokenId, uint256 totalSupply, uint256 mintAmount) public view returns (address receiver, uint256 royaltyAmount) {
ICreatorRoyaltiesControl.RoyaltyConfiguration memory config = target.getRoyalties(tokenId);
if (config.royaltyMintSchedule == 0) {
return (config.royaltyRecipient, 0);
}
uint256 totalRoyaltyMints = (mintAmount + (totalSupply % config.royaltyMintSchedule)) / (config.royaltyMintSchedule - 1);
return (config.royaltyRecipient, totalRoyaltyMints);
}

function test_GetsRoyaltiesInfoGlobalDefault() external {
address royaltyPayout = address(0x999);

Expand All @@ -44,7 +57,7 @@ contract CreatorRoyaltiesControlTest is Test {
uint256 tokenId = target.setupNewToken("test", 100);

(address royaltyRecipient, uint256 amount) = target.royaltyInfo(tokenId, 1 ether);
(, uint256 supplyAmount) = target.supplyRoyaltyInfo(tokenId, 0, 100);
(, uint256 supplyAmount) = supplyRoyaltyInfo(tokenId, 0, 100);
assertEq(amount, 0.001 ether);
assertEq(royaltyRecipient, royaltyPayout);
assertEq(supplyAmount, 11);
Expand All @@ -66,13 +79,13 @@ contract CreatorRoyaltiesControlTest is Test {
vm.stopPrank();

(address royaltyRecipient, uint256 amount) = target.royaltyInfo(tokenIdFirst, 1 ether);
(, uint256 supplyAmount) = target.supplyRoyaltyInfo(tokenIdFirst, 0, 100);
(, uint256 supplyAmount) = supplyRoyaltyInfo(tokenIdFirst, 0, 100);
assertEq(amount, 0.001 ether);
assertEq(supplyAmount, 1);
assertEq(royaltyRecipient, royaltyPayout);

(address royaltyRecipientSecond, uint256 amountSecond) = target.royaltyInfo(tokenIdSecond, 1 ether);
(, uint256 supplyAmountSecond) = target.supplyRoyaltyInfo(tokenIdSecond, 0, 100);
(, uint256 supplyAmountSecond) = supplyRoyaltyInfo(tokenIdSecond, 0, 100);
assertEq(amountSecond, 0.01 ether);
assertEq(supplyAmountSecond, 11);
assertEq(royaltyRecipientSecond, address(0x992));
Expand Down

0 comments on commit d3dd40e

Please sign in to comment.