Skip to content

Commit

Permalink
Merge pull request #326 from ourzora/ignore_supply_royalty_schedule
Browse files Browse the repository at this point in the history
refactor: ignore nonzero supply royalty schedule
  • Loading branch information
kulkarohan authored Nov 5, 2023
2 parents e6f61a9 + 569a026 commit e25ac54
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ abstract contract CreatorRoyaltiesControl is CreatorRoyaltiesStorageV1, SharedBa
}

function _updateRoyalties(uint256 tokenId, RoyaltyConfiguration memory configuration) internal {
// Deprecate supply royalty support
// If a nonzero royalty mint schedule is set:
if (configuration.royaltyMintSchedule != 0) {
revert InvalidMintSchedule();
// Set the value to zero
configuration.royaltyMintSchedule = 0;
}
// Don't allow setting royalties to burn address
if (configuration.royaltyRecipient == address(0) && configuration.royaltyBPS > 0) {
Expand Down
14 changes: 10 additions & 4 deletions packages/1155-contracts/test/nft/ZoraCreator1155.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,16 @@ contract ZoraCreator1155Test is Test {
assertEq(target.balanceOf(recipient, tokenId2), quantity2);
}

function test_adminMintWithInvalidScheduleSkipsSchedule() external {
// This configuration is invalid
vm.expectRevert();
target.initialize("", "test", ICreatorRoyaltiesControl.RoyaltyConfiguration(10, 0, address(0)), admin, _emptyInitData());
function test_adminMintWithInvalidScheduleSkipsSchedule(uint32 supplyRoyaltySchedule) external {
vm.assume(supplyRoyaltySchedule != 0);

address supplyRoyaltyRecipient = makeAddr("supplyRoyaltyRecipient");

target.initialize("", "test", ICreatorRoyaltiesControl.RoyaltyConfiguration(supplyRoyaltySchedule, 0, supplyRoyaltyRecipient), admin, _emptyInitData());

ICreatorRoyaltiesControl.RoyaltyConfiguration memory storedConfig = target.getRoyalties(0);

assertEq(storedConfig.royaltyMintSchedule, 0);
}

function test_adminMintWithEmptyScheduleSkipsSchedule() external {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "forge-std/Test.sol";

import {
ForkDeploymentConfig,
Deployment,
ChainConfig
} from "@zoralabs/zora-1155-contracts/src/deployment/DeploymentConfig.sol";
import {ZoraDeployerUtils} from "@zoralabs/zora-1155-contracts/src/deployment/ZoraDeployerUtils.sol";

import {Zora1155Factory} from "@zoralabs/zora-1155-contracts/src/proxies/Zora1155Factory.sol";
import {ZoraCreator1155FactoryImpl} from "@zoralabs/zora-1155-contracts/src/factory/ZoraCreator1155FactoryImpl.sol";
import {ZoraCreator1155Impl} from "@zoralabs/zora-1155-contracts/src/nft/ZoraCreator1155Impl.sol";
import {ICreatorRoyaltiesControl} from "@zoralabs/zora-1155-contracts/src/interfaces/ICreatorRoyaltiesControl.sol";
import {IMinter1155} from "@zoralabs/zora-1155-contracts/src/interfaces/IMinter1155.sol";

contract ZoraCreator1155SupplyRoyaltyDeprecationTest is Test, ForkDeploymentConfig {
address internal creator;
string[] internal chains;

function setUp() public {
creator = makeAddr("creator");

chains = new string[](1);
chains[0] = "zora_goerli";
}

function testFork_SupplyRoyaltyDeprecation() public {
for (uint256 i; i < chains.length; ++i) {
string memory chain = chains[i];

vm.createSelectFork(vm.rpcUrl(chain));

Deployment memory deployment = getDeployment();
ChainConfig memory chainConfig = getChainConfig();

ZoraCreator1155FactoryImpl factory = ZoraCreator1155FactoryImpl(deployment.factoryProxy);

uint32 invalidRoyaltyMintSchedule = 10;

ICreatorRoyaltiesControl.RoyaltyConfiguration memory royaltyConfig = ICreatorRoyaltiesControl
.RoyaltyConfiguration({
royaltyBPS: 0,
royaltyRecipient: address(0),
royaltyMintSchedule: invalidRoyaltyMintSchedule
});

vm.expectRevert(abi.encodeWithSignature("InvalidMintSchedule()"));
factory.createContract("mock uri", "mock name", royaltyConfig, payable(creator), new bytes[](0));

(address newFactoryImpl,,) = ZoraDeployerUtils.deployNew1155AndFactoryImpl({
upgradeGateAddress: deployment.upgradeGate,
mintFeeRecipient: chainConfig.mintFeeRecipient,
protocolRewards: chainConfig.protocolRewards,
merkleMinter: IMinter1155(deployment.merkleMintSaleStrategy),
redeemMinterFactory: IMinter1155(deployment.redeemMinterFactory),
fixedPriceMinter: IMinter1155(deployment.fixedPriceSaleStrategy)
});

ZoraCreator1155FactoryImpl newFactory =
ZoraCreator1155FactoryImpl(address(new Zora1155Factory(newFactoryImpl, "")));

address tokenContractAddress =
newFactory.createContract("mock uri", "mock name", royaltyConfig, payable(creator), new bytes[](0));

ZoraCreator1155Impl tokenContract = ZoraCreator1155Impl(tokenContractAddress);

// Ensure the specified royalty mint schedule is ignored + set to zero
assertEq(tokenContract.getRoyalties(0).royaltyMintSchedule, 0);
}
}
}

0 comments on commit e25ac54

Please sign in to comment.