From 6a9881d060c65738f414325b89aecd4492d589f9 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Thu, 12 Oct 2023 17:09:06 -0400 Subject: [PATCH 1/6] refactor: deprecate supply royalty --- .../src/nft/ZoraCreator1155Impl.sol | 62 ++----------------- 1 file changed, 4 insertions(+), 58 deletions(-) diff --git a/packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol b/packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol index b2d83005b..0cf7520ef 100644 --- a/packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol +++ b/packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol @@ -372,7 +372,7 @@ contract ZoraCreator1155Impl is bytes memory data ) external nonReentrant onlyAdminOrRole(tokenId, PERMISSION_BIT_MINTER) { // Mint the specified tokens - _mint(recipient, tokenId, quantity, data); + super._mint(recipient, tokenId, quantity, data); } /// @notice Batch mint tokens to a user as the admin or minter @@ -388,7 +388,8 @@ contract ZoraCreator1155Impl is _requireAdminOrRole(msg.sender, tokenIds[i], PERMISSION_BIT_MINTER); } } - _mintBatch(recipient, tokenIds, quantities, data); + + super._mintBatch(recipient, tokenIds, quantities, data); } /// @notice Mint tokens given a minter contract and minter arguments @@ -494,7 +495,7 @@ contract ZoraCreator1155Impl is if (tokenId != 0 && mintTokenId != tokenId) { revert Mint_TokenIDMintNotAllowed(); } - _mint(recipient, tokenId, quantity, ""); + super._mint(recipient, tokenId, quantity, ""); } else { // no-op } @@ -553,63 +554,8 @@ contract ZoraCreator1155Impl is return super.supportsInterface(interfaceId) || interfaceId == type(IZoraCreator1155).interfaceId || ERC1155Upgradeable.supportsInterface(interfaceId); } - function _handleSupplyRoyalty(uint256 tokenId, uint256 mintAmount, bytes memory data) internal returns (uint256 totalRoyaltyMints) { - uint256 royaltyMintSchedule = royalties[tokenId].royaltyMintSchedule; - if (royaltyMintSchedule == 0) { - royaltyMintSchedule = royalties[CONTRACT_BASE_ID].royaltyMintSchedule; - } - if (royaltyMintSchedule == 0) { - // If we still have no schedule, return 0 supply royalty. - return 0; - } - uint256 maxSupply = tokens[tokenId].maxSupply; - uint256 totalMinted = tokens[tokenId].totalMinted; - - totalRoyaltyMints = (mintAmount + (totalMinted % royaltyMintSchedule)) / (royaltyMintSchedule - 1); - totalRoyaltyMints = MathUpgradeable.min(totalRoyaltyMints, maxSupply - (mintAmount + totalMinted)); - if (totalRoyaltyMints > 0) { - address royaltyRecipient = royalties[tokenId].royaltyRecipient; - if (royaltyRecipient == address(0)) { - royaltyRecipient = royalties[CONTRACT_BASE_ID].royaltyRecipient; - } - // If we have no recipient set, return 0 supply royalty. - if (royaltyRecipient == address(0)) { - return 0; - } - super._mint(royaltyRecipient, tokenId, totalRoyaltyMints, data); - } - } - /// Generic 1155 function overrides /// - /// @notice Mint function that 1) checks quantity and 2) handles supply royalty 3) keeps track of allowed tokens - /// @param to to mint to - /// @param id token id to mint - /// @param amount of tokens to mint - /// @param data as specified by 1155 standard - function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual override { - uint256 supplyRoyaltyMints = _handleSupplyRoyalty(id, amount, data); - _requireCanMintQuantity(id, amount + supplyRoyaltyMints); - - super._mint(to, id, amount, data); - tokens[id].totalMinted += amount + supplyRoyaltyMints; - } - - /// @notice Mint batch function that 1) checks quantity and 2) handles supply royalty 3) keeps track of allowed tokens - /// @param to to mint to - /// @param ids token ids to mint - /// @param amounts of tokens to mint - /// @param data as specified by 1155 standard - function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual override { - super._mintBatch(to, ids, amounts, data); - - for (uint256 i = 0; i < ids.length; ++i) { - uint256 supplyRoyaltyMints = _handleSupplyRoyalty(ids[i], amounts[i], data); - _requireCanMintQuantity(ids[i], amounts[i] + supplyRoyaltyMints); - tokens[ids[i]].totalMinted += amounts[i] + supplyRoyaltyMints; - } - } - /// @notice Burns a batch of tokens /// @dev Only the current owner is allowed to burn /// @param from the user to burn from From 66faff216beec3d860fdd6d4816d37a625f0dd52 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Thu, 12 Oct 2023 17:09:46 -0400 Subject: [PATCH 2/6] chore: remove supply royalty tests --- .../test/nft/ZoraCreator1155.t.sol | 139 ------------------ .../royalties/CreatorRoyaltiesControl.t.sol | 93 ------------ 2 files changed, 232 deletions(-) delete mode 100644 packages/1155-contracts/test/royalties/CreatorRoyaltiesControl.t.sol diff --git a/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol b/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol index eac8816c4..bd553bff3 100644 --- a/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol +++ b/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol @@ -1447,143 +1447,4 @@ contract ZoraCreator1155Test is Test { vm.prank(admin); target.adminMint(address(0x1234), tokenId, 1, ""); } - - function test_SupplyRoyaltyScheduleCannotBeOne() external { - init(); - - vm.prank(admin); - uint256 tokenId = target.setupNewToken("test", 100); - - SimpleMinter minter = new SimpleMinter(); - vm.prank(admin); - target.addPermission(tokenId, address(minter), adminRole); - - vm.prank(admin); - vm.expectRevert(ICreatorRoyaltiesControl.InvalidMintSchedule.selector); - target.updateRoyaltiesForToken( - tokenId, - ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyMintSchedule: 1, royaltyBPS: 0, royaltyRecipient: admin}) - ); - } - - function test_SupplyRoyaltyMint(uint32 royaltyMintSchedule, uint32 editionSize, uint256 mintQuantity) external { - vm.assume(royaltyMintSchedule > 1 && royaltyMintSchedule <= editionSize && editionSize <= 100000 && mintQuantity > 0 && mintQuantity <= editionSize); - uint256 totalRoyaltyMintsForSale = editionSize / royaltyMintSchedule; - vm.assume(mintQuantity <= editionSize - totalRoyaltyMintsForSale); - - init(); - - vm.prank(admin); - uint256 tokenId = target.setupNewToken("test", editionSize); - - SimpleMinter minter = new SimpleMinter(); - vm.prank(admin); - target.addPermission(tokenId, address(minter), adminRole); - - vm.startPrank(admin); - target.updateRoyaltiesForToken( - tokenId, - ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyMintSchedule: royaltyMintSchedule, royaltyBPS: 0, royaltyRecipient: admin}) - ); - - uint256 totalReward = target.computeTotalReward(mintQuantity); - vm.deal(admin, totalReward); - - target.mint{value: totalReward}(minter, tokenId, mintQuantity, abi.encode(recipient)); - - uint256 totalRoyaltyMintsForPurchase = mintQuantity / (royaltyMintSchedule - 1); - totalRoyaltyMintsForPurchase = MathUpgradeable.min(totalRoyaltyMintsForPurchase, editionSize - mintQuantity); - - assertEq(target.balanceOf(recipient, tokenId), mintQuantity); - assertEq(target.balanceOf(admin, tokenId), totalRoyaltyMintsForPurchase); - - vm.stopPrank(); - } - - function test_SupplyRoyaltyMintCleanNumbers() external { - init(); - - vm.prank(admin); - uint256 tokenId = target.setupNewToken("test", 100); - - SimpleMinter minter = new SimpleMinter(); - vm.prank(admin); - target.addPermission(tokenId, address(minter), adminRole); - - uint256 totalReward = target.computeTotalReward(80); - vm.deal(admin, totalReward); - - vm.startPrank(admin); - target.updateRoyaltiesForToken( - tokenId, - ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyMintSchedule: 5, royaltyBPS: 0, royaltyRecipient: admin}) - ); - target.mint{value: totalReward}(minter, tokenId, 80, abi.encode(recipient)); - - assertEq(target.balanceOf(recipient, tokenId), 80); - assertEq(target.balanceOf(admin, tokenId), 20); - - vm.stopPrank(); - } - - function test_SupplyRoyaltyMintEdgeCaseNumbers() external { - init(); - - vm.prank(admin); - uint256 tokenId = target.setupNewToken("test", 137); - - SimpleMinter minter = new SimpleMinter(); - vm.prank(admin); - target.addPermission(tokenId, address(minter), adminRole); - - uint256 totalReward = target.computeTotalReward(92); - vm.deal(admin, totalReward); - - vm.startPrank(admin); - target.updateRoyaltiesForToken( - tokenId, - ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyMintSchedule: 3, royaltyBPS: 0, royaltyRecipient: admin}) - ); - - target.mint{value: totalReward}(minter, tokenId, 92, abi.encode(recipient)); - - assertEq(target.balanceOf(recipient, tokenId), 92); - assertEq(target.balanceOf(admin, tokenId), 45); - - vm.stopPrank(); - } - - function test_SupplyRoyaltyMintEdgeCaseNumbersOpenEdition() external { - init(); - - vm.prank(admin); - uint256 tokenId = target.setupNewToken("test", type(uint256).max); - - SimpleMinter minter = new SimpleMinter(); - vm.prank(admin); - target.addPermission(tokenId, address(minter), adminRole); - - uint256 totalReward = target.computeTotalReward(92); - vm.deal(admin, totalReward); - - vm.startPrank(admin); - target.updateRoyaltiesForToken( - tokenId, - ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyMintSchedule: 3, royaltyBPS: 0, royaltyRecipient: admin}) - ); - - target.mint{value: totalReward}(minter, tokenId, 92, abi.encode(recipient)); - - assertEq(target.balanceOf(recipient, tokenId), 92); - assertEq(target.balanceOf(admin, tokenId), 46); - - vm.deal(admin, 0.000777 ether); - - target.mint{value: 0.000777 ether}(minter, tokenId, 1, abi.encode(recipient)); - - assertEq(target.balanceOf(recipient, tokenId), 93); - assertEq(target.balanceOf(admin, tokenId), 46); - - vm.stopPrank(); - } } diff --git a/packages/1155-contracts/test/royalties/CreatorRoyaltiesControl.t.sol b/packages/1155-contracts/test/royalties/CreatorRoyaltiesControl.t.sol deleted file mode 100644 index 162a7afaa..000000000 --- a/packages/1155-contracts/test/royalties/CreatorRoyaltiesControl.t.sol +++ /dev/null @@ -1,93 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.17; - -import "forge-std/Test.sol"; -import {ProtocolRewards} from "@zoralabs/protocol-rewards/src/ProtocolRewards.sol"; -import {ZoraCreator1155Impl} from "../../src/nft/ZoraCreator1155Impl.sol"; -import {Zora1155} from "../../src/proxies/Zora1155.sol"; -import {IZoraCreator1155Errors} from "../../src/interfaces/IZoraCreator1155Errors.sol"; -import {IZoraCreator1155TypesV1} from "../../src/nft/IZoraCreator1155TypesV1.sol"; -import {ICreatorRoyaltiesControl} from "../../src/interfaces/ICreatorRoyaltiesControl.sol"; -import {IZoraCreator1155Factory} from "../../src/interfaces/IZoraCreator1155Factory.sol"; -import {IMintFeeManager} from "../../src/interfaces/IMintFeeManager.sol"; -import {SimpleMinter} from "../mock/SimpleMinter.sol"; - -contract CreatorRoyaltiesControlTest is Test { - ProtocolRewards internal protocolRewards; - ZoraCreator1155Impl internal zoraCreator1155Impl; - ZoraCreator1155Impl internal target; - address payable internal admin; - address internal recipient; - uint256 internal adminRole; - uint256 internal minterRole; - uint256 internal fundsManagerRole; - - function setUp() external { - protocolRewards = new ProtocolRewards(); - admin = payable(vm.addr(0x1)); - recipient = vm.addr(0x2); - } - - function _emptyInitData() internal pure returns (bytes[] memory response) { - 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); - - zoraCreator1155Impl = new ZoraCreator1155Impl(recipient, address(0), address(protocolRewards)); - target = ZoraCreator1155Impl(address(new Zora1155(address(zoraCreator1155Impl)))); - adminRole = target.PERMISSION_BIT_ADMIN(); - target.initialize("", "test", ICreatorRoyaltiesControl.RoyaltyConfiguration(10, 10, address(royaltyPayout)), admin, _emptyInitData()); - - vm.prank(admin); - uint256 tokenId = target.setupNewToken("test", 100); - - (address royaltyRecipient, uint256 amount) = target.royaltyInfo(tokenId, 1 ether); - (, uint256 supplyAmount) = supplyRoyaltyInfo(tokenId, 0, 100); - assertEq(amount, 0.001 ether); - assertEq(royaltyRecipient, royaltyPayout); - assertEq(supplyAmount, 11); - } - - function test_GetsRoyaltiesInfoSpecificToken() external { - address royaltyPayout = address(0x999); - zoraCreator1155Impl = new ZoraCreator1155Impl(recipient, address(0), address(protocolRewards)); - target = ZoraCreator1155Impl(address(new Zora1155(address(zoraCreator1155Impl)))); - adminRole = target.PERMISSION_BIT_ADMIN(); - target.initialize("", "test", ICreatorRoyaltiesControl.RoyaltyConfiguration(100, 10, address(royaltyPayout)), admin, _emptyInitData()); - - vm.startPrank(admin); - uint256 tokenIdFirst = target.setupNewToken("test", 100); - uint256 tokenIdSecond = target.setupNewToken("test", 100); - - target.updateRoyaltiesForToken(tokenIdSecond, ICreatorRoyaltiesControl.RoyaltyConfiguration(10, 100, address(0x992))); - - vm.stopPrank(); - - (address royaltyRecipient, uint256 amount) = target.royaltyInfo(tokenIdFirst, 1 ether); - (, 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) = supplyRoyaltyInfo(tokenIdSecond, 0, 100); - assertEq(amountSecond, 0.01 ether); - assertEq(supplyAmountSecond, 11); - assertEq(royaltyRecipientSecond, address(0x992)); - } -} From d7291b984ed4a1dc98c2cf98a9d5db51cecbfc11 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Thu, 12 Oct 2023 18:08:46 -0400 Subject: [PATCH 3/6] fix: add back mint overrides --- .../src/nft/ZoraCreator1155Impl.sol | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol b/packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol index 0cf7520ef..d87c22557 100644 --- a/packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol +++ b/packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol @@ -372,7 +372,7 @@ contract ZoraCreator1155Impl is bytes memory data ) external nonReentrant onlyAdminOrRole(tokenId, PERMISSION_BIT_MINTER) { // Mint the specified tokens - super._mint(recipient, tokenId, quantity, data); + _mint(recipient, tokenId, quantity, data); } /// @notice Batch mint tokens to a user as the admin or minter @@ -389,7 +389,7 @@ contract ZoraCreator1155Impl is } } - super._mintBatch(recipient, tokenIds, quantities, data); + _mintBatch(recipient, tokenIds, quantities, data); } /// @notice Mint tokens given a minter contract and minter arguments @@ -495,7 +495,7 @@ contract ZoraCreator1155Impl is if (tokenId != 0 && mintTokenId != tokenId) { revert Mint_TokenIDMintNotAllowed(); } - super._mint(recipient, tokenId, quantity, ""); + _mint(recipient, tokenId, quantity, ""); } else { // no-op } @@ -556,6 +556,36 @@ contract ZoraCreator1155Impl is /// Generic 1155 function overrides /// + /// @notice Mint function that 1) checks quantity 2) keeps track of allowed tokens + /// @param to to mint to + /// @param id token id to mint + /// @param amount of tokens to mint + /// @param data as specified by 1155 standard + function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual override { + _requireCanMintQuantity(id, amount); + + tokens[id].totalMinted += amount; + + super._mint(to, id, amount, data); + } + + /// @notice Mint batch function that 1) checks quantity and 2) keeps track of allowed tokens + /// @param to to mint to + /// @param ids token ids to mint + /// @param amounts of tokens to mint + /// @param data as specified by 1155 standard + function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual override { + uint256 numTokens = ids.length; + + for (uint256 i; i < numTokens; ++i) { + _requireCanMintQuantity(ids[i], amounts[i]); + + tokens[ids[i]].totalMinted += amounts[i]; + } + + super._mintBatch(to, ids, amounts, data); + } + /// @notice Burns a batch of tokens /// @dev Only the current owner is allowed to burn /// @param from the user to burn from From edbab4051045ec470134b0458216539e8246cb07 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Fri, 13 Oct 2023 14:00:21 -0400 Subject: [PATCH 4/6] refactor: disallow nonzero supply royalty --- .../1155-contracts/src/royalties/CreatorRoyaltiesControl.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol b/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol index f41029551..fd1717e17 100644 --- a/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol +++ b/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol @@ -33,8 +33,8 @@ abstract contract CreatorRoyaltiesControl is CreatorRoyaltiesStorageV1, SharedBa } function _updateRoyalties(uint256 tokenId, RoyaltyConfiguration memory configuration) internal { - // Don't allow 100% supply royalties - if (configuration.royaltyMintSchedule == 1) { + // Deprecate supply royalty support + if (configuration.royaltyMintSchedule != 0) { revert InvalidMintSchedule(); } // Don't allow setting royalties to burn address From 2b887a0a2872d8a3d282ed72fe01c99098023117 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Fri, 13 Oct 2023 14:44:11 -0400 Subject: [PATCH 5/6] chore: update tests --- .../test/factory/ZoraCreator1155Factory.t.sol | 24 ++--- .../test/fixtures/Zora1155PremintFixtures.sol | 2 +- .../test/nft/ZoraCreator1155.t.sol | 90 ++++++------------- 3 files changed, 33 insertions(+), 83 deletions(-) diff --git a/packages/1155-contracts/test/factory/ZoraCreator1155Factory.t.sol b/packages/1155-contracts/test/factory/ZoraCreator1155Factory.t.sol index 72367b789..89d445102 100644 --- a/packages/1155-contracts/test/factory/ZoraCreator1155Factory.t.sol +++ b/packages/1155-contracts/test/factory/ZoraCreator1155Factory.t.sol @@ -77,19 +77,11 @@ contract ZoraCreator1155FactoryTest is Test { assertEq(address(minters[2]), address(3)); } - function test_createContract( - string memory contractURI, - string memory name, - uint32 royaltyBPS, - uint32 royaltyMintSchedule, - address royaltyRecipient, - address payable admin - ) external { + function test_createContract(string memory contractURI, string memory name, uint32 royaltyBPS, address royaltyRecipient, address payable admin) external { // If the factory is the admin, the admin flag is cleared // during multicall breaking a further test assumption. // Additionally, this case makes no sense from a user perspective. vm.assume(admin != payable(address(factory))); - vm.assume(royaltyMintSchedule != 1); // Assume royalty recipient is not 0 vm.assume(royaltyRecipient != payable(address(0))); bytes[] memory initSetup = new bytes[](1); @@ -97,18 +89,14 @@ contract ZoraCreator1155FactoryTest is Test { address deployedAddress = factory.createContract( contractURI, name, - ICreatorRoyaltiesControl.RoyaltyConfiguration({ - royaltyBPS: royaltyBPS, - royaltyRecipient: royaltyRecipient, - royaltyMintSchedule: royaltyMintSchedule - }), + ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyBPS: royaltyBPS, royaltyRecipient: royaltyRecipient, royaltyMintSchedule: 0}), admin, initSetup ); ZoraCreator1155Impl target = ZoraCreator1155Impl(deployedAddress); ICreatorRoyaltiesControl.RoyaltyConfiguration memory config = target.getRoyalties(0); - assertEq(config.royaltyMintSchedule, royaltyMintSchedule); + assertEq(config.royaltyMintSchedule, 0); assertEq(config.royaltyBPS, royaltyBPS); assertEq(config.royaltyRecipient, royaltyRecipient); assertEq(target.permissions(0, admin), target.PERMISSION_BIT_ADMIN()); @@ -170,7 +158,7 @@ contract ZoraCreator1155FactoryTest is Test { ICreatorRoyaltiesControl.RoyaltyConfiguration memory royaltyConfig = ICreatorRoyaltiesControl.RoyaltyConfiguration({ royaltyBPS: 10, royaltyRecipient: vm.addr(5), - royaltyMintSchedule: 100 + royaltyMintSchedule: 0 }); bytes[] memory initSetup = new bytes[](1); initSetup[0] = abi.encodeWithSelector(IZoraCreator1155.setupNewToken.selector, "ipfs://asdfadsf", 100); @@ -220,7 +208,7 @@ contract ZoraCreator1155FactoryTest is Test { ICreatorRoyaltiesControl.RoyaltyConfiguration memory royaltyConfig = ICreatorRoyaltiesControl.RoyaltyConfiguration({ royaltyBPS: 10, royaltyRecipient: vm.addr(5), - royaltyMintSchedule: 100 + royaltyMintSchedule: 0 }); bytes[] memory initSetup = new bytes[](1); initSetup[0] = abi.encodeWithSelector(IZoraCreator1155.setupNewToken.selector, "ipfs://asdfadsf", 100); @@ -241,7 +229,7 @@ contract ZoraCreator1155FactoryTest is Test { ICreatorRoyaltiesControl.RoyaltyConfiguration memory royaltyConfig = ICreatorRoyaltiesControl.RoyaltyConfiguration({ royaltyBPS: 10, royaltyRecipient: vm.addr(5), - royaltyMintSchedule: 100 + royaltyMintSchedule: 0 }); bytes[] memory initSetup = new bytes[](1); initSetup[0] = abi.encodeWithSelector(IZoraCreator1155.setupNewToken.selector, "ipfs://asdfadsf", 100); diff --git a/packages/1155-contracts/test/fixtures/Zora1155PremintFixtures.sol b/packages/1155-contracts/test/fixtures/Zora1155PremintFixtures.sol index 71a42bd9c..0e01c8fd2 100644 --- a/packages/1155-contracts/test/fixtures/Zora1155PremintFixtures.sol +++ b/packages/1155-contracts/test/fixtures/Zora1155PremintFixtures.sol @@ -18,7 +18,7 @@ library Zora1155PremintFixtures { } function defaultRoyaltyConfig(address royaltyRecipient) internal pure returns (ICreatorRoyaltiesControl.RoyaltyConfiguration memory) { - return ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyBPS: 10, royaltyRecipient: royaltyRecipient, royaltyMintSchedule: 100}); + return ICreatorRoyaltiesControl.RoyaltyConfiguration({royaltyBPS: 10, royaltyRecipient: royaltyRecipient, royaltyMintSchedule: 0}); } function makeDefaultTokenCreationConfig(IMinter1155 fixedPriceMinter, address royaltyRecipient) internal pure returns (TokenCreationConfig memory) { diff --git a/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol b/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol index bd553bff3..4370496dc 100644 --- a/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol +++ b/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol @@ -112,14 +112,8 @@ contract ZoraCreator1155Test is Test { target.initialize("test", "test", ICreatorRoyaltiesControl.RoyaltyConfiguration(0, 0, address(0)), admin, _emptyInitData()); } - function init(uint32 royaltySchedule, uint32 royaltyBps, address royaltyRecipient) internal { - target.initialize( - "test", - "test", - ICreatorRoyaltiesControl.RoyaltyConfiguration(royaltySchedule, royaltyBps, royaltyRecipient), - admin, - _emptyInitData() - ); + function init(uint32 royaltyBps, address royaltyRecipient) internal { + target.initialize("test", "test", ICreatorRoyaltiesControl.RoyaltyConfiguration(0, royaltyBps, royaltyRecipient), admin, _emptyInitData()); } function test_packageJsonVersion() public { @@ -127,38 +121,21 @@ contract ZoraCreator1155Test is Test { assertEq(package.readString(".version"), target.contractVersion()); } - function test_initialize(uint32 royaltySchedule, uint32 royaltyBPS, address royaltyRecipient, address payable defaultAdmin) external { - vm.assume(royaltySchedule != 1); - vm.assume(royaltyRecipient != address(0) && royaltySchedule != 0 && royaltyBPS != 0); - ICreatorRoyaltiesControl.RoyaltyConfiguration memory config = ICreatorRoyaltiesControl.RoyaltyConfiguration( - royaltySchedule, - royaltyBPS, - royaltyRecipient - ); + function test_initialize(uint32 royaltyBPS, address royaltyRecipient, address payable defaultAdmin) external { + vm.assume(royaltyRecipient != address(0) && royaltyBPS != 0); + ICreatorRoyaltiesControl.RoyaltyConfiguration memory config = ICreatorRoyaltiesControl.RoyaltyConfiguration(0, royaltyBPS, royaltyRecipient); target.initialize("contract name", "test", config, defaultAdmin, _emptyInitData()); assertEq(target.contractURI(), "test"); assertEq(target.name(), "contract name"); - (uint32 fetchedSchedule, uint256 fetchedBps, address fetchedRecipient) = target.royalties(0); - assertEq(fetchedSchedule, royaltySchedule); + (, uint256 fetchedBps, address fetchedRecipient) = target.royalties(0); assertEq(fetchedBps, royaltyBPS); assertEq(fetchedRecipient, royaltyRecipient); } - function test_initialize_withSetupActions( - uint32 royaltySchedule, - uint32 royaltyBPS, - address royaltyRecipient, - address payable defaultAdmin, - uint256 maxSupply - ) external { - vm.assume(royaltySchedule != 1); - vm.assume(royaltyRecipient != address(0) && royaltySchedule != 0 && royaltyBPS != 0); - ICreatorRoyaltiesControl.RoyaltyConfiguration memory config = ICreatorRoyaltiesControl.RoyaltyConfiguration( - royaltySchedule, - royaltyBPS, - royaltyRecipient - ); + function test_initialize_withSetupActions(uint32 royaltyBPS, address royaltyRecipient, address payable defaultAdmin, uint256 maxSupply) external { + vm.assume(royaltyRecipient != address(0) && royaltyBPS != 0); + ICreatorRoyaltiesControl.RoyaltyConfiguration memory config = ICreatorRoyaltiesControl.RoyaltyConfiguration(0, royaltyBPS, royaltyRecipient); bytes[] memory setupActions = new bytes[](1); setupActions[0] = abi.encodeWithSelector(IZoraCreator1155.setupNewToken.selector, "test", maxSupply); target.initialize("", "test", config, defaultAdmin, setupActions); @@ -167,19 +144,9 @@ contract ZoraCreator1155Test is Test { assertEq(tokenData.maxSupply, maxSupply); } - function test_initialize_revertAlreadyInitialized( - uint32 royaltySchedule, - uint32 royaltyBPS, - address royaltyRecipient, - address payable defaultAdmin - ) external { - vm.assume(royaltySchedule != 1); - vm.assume(royaltyRecipient != address(0) && royaltySchedule != 0 && royaltyBPS != 0); - ICreatorRoyaltiesControl.RoyaltyConfiguration memory config = ICreatorRoyaltiesControl.RoyaltyConfiguration( - royaltySchedule, - royaltyBPS, - royaltyRecipient - ); + function test_initialize_revertAlreadyInitialized(uint32 royaltyBPS, address royaltyRecipient, address payable defaultAdmin) external { + vm.assume(royaltyRecipient != address(0) && royaltyBPS != 0); + ICreatorRoyaltiesControl.RoyaltyConfiguration memory config = ICreatorRoyaltiesControl.RoyaltyConfiguration(0, royaltyBPS, royaltyRecipient); target.initialize("test", "test", config, defaultAdmin, _emptyInitData()); vm.expectRevert(); @@ -408,37 +375,35 @@ contract ZoraCreator1155Test is Test { function test_adminMintWithScheduleSmall() external { uint256 quantity = 100; address royaltyRecipient = address(0x3334); - // every 10 royalty 100/10 = 10 tokens minted - init(10, 0, royaltyRecipient); + + init(0, royaltyRecipient); vm.prank(admin); uint256 tokenId = target.setupNewToken("test", quantity); vm.prank(admin); - target.adminMint(recipient, tokenId, 90, ""); + target.adminMint(recipient, tokenId, quantity, ""); IZoraCreator1155TypesV1.TokenData memory tokenData = target.getTokenInfo(tokenId); - assertEq(tokenData.totalMinted, 100); - assertEq(target.balanceOf(recipient, tokenId), (quantity * 9) / 10); - assertEq(target.balanceOf(royaltyRecipient, tokenId), (quantity * 1) / 10); + assertEq(tokenData.totalMinted, quantity); + assertEq(target.balanceOf(recipient, tokenId), quantity); } function test_adminMintWithSchedule() external { uint256 quantity = 1000; address royaltyRecipient = address(0x3334); - // every 10 tokens, mint 1 to royalty 1000/10 = 100 tokens minted to royalty recipient - init(10, 0, royaltyRecipient); + + init(0, royaltyRecipient); vm.prank(admin); uint256 tokenId = target.setupNewToken("test", 1000); vm.prank(admin); - target.adminMint(recipient, tokenId, (quantity * 9) / 10, ""); + target.adminMint(recipient, tokenId, quantity, ""); IZoraCreator1155TypesV1.TokenData memory tokenData = target.getTokenInfo(tokenId); assertEq(tokenData.totalMinted, 1000); - assertEq(target.balanceOf(recipient, tokenId), (quantity * 9) / 10); - assertEq(target.balanceOf(royaltyRecipient, tokenId), (quantity * 1) / 10); + assertEq(target.balanceOf(recipient, tokenId), quantity); } function test_adminMint_revertOnlyAdminOrRole() external { @@ -574,8 +539,8 @@ contract ZoraCreator1155Test is Test { vm.assume(quantity2 < 900); address royaltyRecipient = address(0x3334); - // every 10th token is a token for the royalty recipient - init(10, 0, royaltyRecipient); + + init(0, royaltyRecipient); vm.prank(admin); uint256 tokenId1 = target.setupNewToken("test", 1000); @@ -596,12 +561,10 @@ contract ZoraCreator1155Test is Test { IZoraCreator1155TypesV1.TokenData memory tokenData1 = target.getTokenInfo(tokenId1); IZoraCreator1155TypesV1.TokenData memory tokenData2 = target.getTokenInfo(tokenId2); - assertEq(tokenData1.totalMinted, quantity1 + (quantity1 / 9)); - assertEq(tokenData2.totalMinted, quantity2 + (quantity2 / 9)); + assertEq(tokenData1.totalMinted, quantity1); + assertEq(tokenData2.totalMinted, quantity2); assertEq(target.balanceOf(recipient, tokenId1), quantity1); assertEq(target.balanceOf(recipient, tokenId2), quantity2); - assertEq(target.balanceOf(royaltyRecipient, tokenId1), quantity1 / 9); - assertEq(target.balanceOf(royaltyRecipient, tokenId2), quantity2 / 9); } function test_adminMintWithInvalidScheduleSkipsSchedule() external { @@ -611,8 +574,7 @@ contract ZoraCreator1155Test is Test { } function test_adminMintWithEmptyScheduleSkipsSchedule() external { - // every 0th token is sent so no tokens - init(0, 0, address(0x99a)); + init(0, address(0x99a)); vm.prank(admin); uint256 tokenId1 = target.setupNewToken("test", 1000); From 171f915f4a778f05b8e89cc745372f3ea2d5e5d4 Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Wed, 18 Oct 2023 09:28:16 -0700 Subject: [PATCH 6/6] Added changeset --- .changeset/great-camels-impress.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/great-camels-impress.md diff --git a/.changeset/great-camels-impress.md b/.changeset/great-camels-impress.md new file mode 100644 index 000000000..9672b1f6f --- /dev/null +++ b/.changeset/great-camels-impress.md @@ -0,0 +1,5 @@ +--- +"@zoralabs/zora-1155-contracts": minor +--- + +Supply royalties are no longer supported