From 85e507fe67debf411acf3f03f605087721893921 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Fri, 3 Nov 2023 14:00:26 -0400 Subject: [PATCH 1/6] refactor: ignore supply royalty schedule instead of reverting --- .../src/royalties/CreatorRoyaltiesControl.sol | 5 +++-- .../1155-contracts/test/nft/ZoraCreator1155.t.sol | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol b/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol index 78d865158..fe571d1e3 100644 --- a/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol +++ b/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol @@ -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) { diff --git a/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol b/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol index 8885f7a26..1f9400fe9 100644 --- a/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol +++ b/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol @@ -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 { From c57e4c1f77a9184232fae77fa4d9ecd5f769e1bb Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Sun, 5 Nov 2023 16:17:44 -0500 Subject: [PATCH 2/6] chore: add changeset --- .changeset/serious-rings-join.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/serious-rings-join.md diff --git a/.changeset/serious-rings-join.md b/.changeset/serious-rings-join.md new file mode 100644 index 000000000..916a94ba7 --- /dev/null +++ b/.changeset/serious-rings-join.md @@ -0,0 +1,5 @@ +--- +"@zoralabs/zora-1155-contracts": patch +--- + +Ignore supply royalty schedule instead of reverting From 178f658435a75fdc4f3fded6cdcf3271dd607092 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Sun, 5 Nov 2023 17:38:50 -0500 Subject: [PATCH 3/6] chore: add fork test for supply royalty deprecation --- ...aCreator1155SupplyRoyaltyDeprecation.t.sol | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 packages/protocol-deployments/test/ZoraCreator1155SupplyRoyaltyDeprecation.t.sol diff --git a/packages/protocol-deployments/test/ZoraCreator1155SupplyRoyaltyDeprecation.t.sol b/packages/protocol-deployments/test/ZoraCreator1155SupplyRoyaltyDeprecation.t.sol new file mode 100644 index 000000000..36e291f81 --- /dev/null +++ b/packages/protocol-deployments/test/ZoraCreator1155SupplyRoyaltyDeprecation.t.sol @@ -0,0 +1,78 @@ +// 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"; + + // chains = new string[](2); + // chains[0] = "zora"; + // chains[1] = "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); + } + } +} From 4681313a50a64acc5bd91a55d64585436b4f7574 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Sun, 5 Nov 2023 17:45:16 -0500 Subject: [PATCH 4/6] Revert "chore: add changeset" This reverts commit c57e4c1f77a9184232fae77fa4d9ecd5f769e1bb. --- .changeset/serious-rings-join.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/serious-rings-join.md diff --git a/.changeset/serious-rings-join.md b/.changeset/serious-rings-join.md deleted file mode 100644 index 916a94ba7..000000000 --- a/.changeset/serious-rings-join.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@zoralabs/zora-1155-contracts": patch ---- - -Ignore supply royalty schedule instead of reverting From 25da8e5dc5355a183d78410ff4507354535bec46 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Sun, 5 Nov 2023 17:47:16 -0500 Subject: [PATCH 5/6] chore: run lint --- .../1155-contracts/src/royalties/CreatorRoyaltiesControl.sol | 2 +- packages/1155-contracts/test/nft/ZoraCreator1155.t.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol b/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol index fe571d1e3..1888e4785 100644 --- a/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol +++ b/packages/1155-contracts/src/royalties/CreatorRoyaltiesControl.sol @@ -36,7 +36,7 @@ abstract contract CreatorRoyaltiesControl is CreatorRoyaltiesStorageV1, SharedBa function _updateRoyalties(uint256 tokenId, RoyaltyConfiguration memory configuration) internal { // If a nonzero royalty mint schedule is set: if (configuration.royaltyMintSchedule != 0) { - // Set the value to zero + // Set the value to zero configuration.royaltyMintSchedule = 0; } // Don't allow setting royalties to burn address diff --git a/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol b/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol index 1f9400fe9..a19a92b17 100644 --- a/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol +++ b/packages/1155-contracts/test/nft/ZoraCreator1155.t.sol @@ -574,7 +574,7 @@ contract ZoraCreator1155Test is Test { function test_adminMintWithInvalidScheduleSkipsSchedule(uint32 supplyRoyaltySchedule) external { vm.assume(supplyRoyaltySchedule != 0); - + address supplyRoyaltyRecipient = makeAddr("supplyRoyaltyRecipient"); target.initialize("", "test", ICreatorRoyaltiesControl.RoyaltyConfiguration(supplyRoyaltySchedule, 0, supplyRoyaltyRecipient), admin, _emptyInitData()); From 569a026785501ccc9f6d587fa8ee89b940e76264 Mon Sep 17 00:00:00 2001 From: Rohan Kulkarni Date: Sun, 5 Nov 2023 17:51:23 -0500 Subject: [PATCH 6/6] chore: remove comment --- .../test/ZoraCreator1155SupplyRoyaltyDeprecation.t.sol | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/protocol-deployments/test/ZoraCreator1155SupplyRoyaltyDeprecation.t.sol b/packages/protocol-deployments/test/ZoraCreator1155SupplyRoyaltyDeprecation.t.sol index 36e291f81..5f36f765d 100644 --- a/packages/protocol-deployments/test/ZoraCreator1155SupplyRoyaltyDeprecation.t.sol +++ b/packages/protocol-deployments/test/ZoraCreator1155SupplyRoyaltyDeprecation.t.sol @@ -25,10 +25,6 @@ contract ZoraCreator1155SupplyRoyaltyDeprecationTest is Test, ForkDeploymentConf chains = new string[](1); chains[0] = "zora_goerli"; - - // chains = new string[](2); - // chains[0] = "zora"; - // chains[1] = "zora_goerli"; } function testFork_SupplyRoyaltyDeprecation() public {