Skip to content

Commit

Permalink
Merge pull request #332 from ourzora/revert-errors-in-abis
Browse files Browse the repository at this point in the history
Revert "Included all errors in erc1155 and preminter abis (#313)"
  • Loading branch information
kulkarohan authored Nov 8, 2023
2 parents b05ceaa + 0a0e9ff commit 31f6db8
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-seals-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoralabs/zora-1155-contracts": patch
---

Revert #313 - include errors in abis. This caused a storage layout issue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ pragma solidity 0.8.17;

import {IERC2981} from "@openzeppelin/contracts/interfaces/IERC2981.sol";

interface ICreatorRoyaltyErrors {
/// @notice Thrown when a user tries to have 100% supply royalties
error InvalidMintSchedule();
}

interface ICreatorRoyaltiesControl is IERC2981 {
/// @notice The RoyaltyConfiguration struct is used to store the royalty configuration for a given token.
/// @param royaltyMintSchedule Every nth token will go to the royalty recipient.
Expand All @@ -19,6 +14,9 @@ interface ICreatorRoyaltiesControl is IERC2981 {
address royaltyRecipient;
}

/// @notice Thrown when a user tries to have 100% supply royalties
error InvalidMintSchedule();

/// @notice Event emitted when royalties are updated
event UpdatedRoyalties(uint256 indexed tokenId, address indexed user, RoyaltyConfiguration configuration);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ pragma solidity 0.8.17;

import {IERC165Upgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC165Upgradeable.sol";

interface ILimitedMintPerAddressErrors {
interface ILimitedMintPerAddress is IERC165Upgradeable {
error UserExceedsMintLimit(address user, uint256 limit, uint256 requestedAmount);
}

interface ILimitedMintPerAddress is IERC165Upgradeable, ILimitedMintPerAddressErrors {
function getMintedPerWallet(address token, uint256 tokenId, address wallet) external view returns (uint256);
}
13 changes: 0 additions & 13 deletions packages/1155-contracts/src/interfaces/IMinterErrors.sol

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {ICreatorRoyaltyErrors} from "./ICreatorRoyaltiesControl.sol";
import {ILimitedMintPerAddressErrors} from "./ILimitedMintPerAddress.sol";
import {IMinterErrors} from "./IMinterErrors.sol";

interface IZoraCreator1155Errors is ICreatorRoyaltyErrors, ILimitedMintPerAddressErrors, IMinterErrors {
interface IZoraCreator1155Errors {
error Call_TokenIdMismatch();
error TokenIdMismatch(uint256 expected, uint256 actual);
error UserMissingRoleForToken(address user, uint256 tokenId, uint256 role);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {ICreatorCommands} from "../../interfaces/ICreatorCommands.sol";
import {SaleStrategy} from "../SaleStrategy.sol";
import {SaleCommandHelper} from "../utils/SaleCommandHelper.sol";
import {LimitedMintPerAddress} from "../utils/LimitedMintPerAddress.sol";
import {IMinterErrors} from "../../interfaces/IMinterErrors.sol";

/*
Expand Down Expand Up @@ -37,7 +36,7 @@ import {IMinterErrors} from "../../interfaces/IMinterErrors.sol";
/// @title ZoraCreatorFixedPriceSaleStrategy
/// @notice A sale strategy for ZoraCreator that allows for fixed price sales over a given time period
/// @author @iainnash / @tbtstl
contract ZoraCreatorFixedPriceSaleStrategy is Enjoy, SaleStrategy, LimitedMintPerAddress, IMinterErrors {
contract ZoraCreatorFixedPriceSaleStrategy is Enjoy, SaleStrategy, LimitedMintPerAddress {
struct SalesConfig {
/// @notice Unix timestamp for the sale start
uint64 saleStart;
Expand Down Expand Up @@ -70,6 +69,10 @@ contract ZoraCreatorFixedPriceSaleStrategy is Enjoy, SaleStrategy, LimitedMintPe
return "1.1.0";
}

error WrongValueSent();
error SaleEnded();
error SaleHasNotStarted();

event SaleSet(address indexed mediaContract, uint256 indexed tokenId, SalesConfig salesConfig);
event MintComment(address indexed sender, address indexed tokenContract, uint256 indexed tokenId, uint256 quantity, string comment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {SaleStrategy} from "../SaleStrategy.sol";
import {ICreatorCommands} from "../../interfaces/ICreatorCommands.sol";
import {SaleCommandHelper} from "../utils/SaleCommandHelper.sol";
import {LimitedMintPerAddress} from "../utils/LimitedMintPerAddress.sol";
import {IMinterErrors} from "../../interfaces/IMinterErrors.sol";

/*
Expand Down Expand Up @@ -39,7 +38,7 @@ import {IMinterErrors} from "../../interfaces/IMinterErrors.sol";
/// @title ZoraCreatorMerkleMinterStrategy
/// @notice Mints tokens based on a merkle tree, for presales for example
/// @author @iainnash / @tbtstl
contract ZoraCreatorMerkleMinterStrategy is Enjoy, SaleStrategy, LimitedMintPerAddress, IMinterErrors {
contract ZoraCreatorMerkleMinterStrategy is Enjoy, SaleStrategy, LimitedMintPerAddress {
using SaleCommandHelper for ICreatorCommands.CommandSet;

/// @notice General merkle sale settings
Expand All @@ -59,6 +58,12 @@ contract ZoraCreatorMerkleMinterStrategy is Enjoy, SaleStrategy, LimitedMintPerA

/// @notice Storage for allowed merkle settings for the sales configuration
mapping(address => mapping(uint256 => MerkleSaleSettings)) public allowedMerkles;
// target -> tokenId -> settings

error SaleEnded();
error SaleHasNotStarted();
error WrongValueSent();
error InvalidMerkleProof(address mintTo, bytes32[] merkleProof, bytes32 merkleRoot);

/// @notice ContractURI for contract information with the strategy
function contractURI() external pure override returns (string memory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {ICreatorCommands} from "../../interfaces/ICreatorCommands.sol";
import {ZoraCreatorRedeemMinterStrategy} from "./ZoraCreatorRedeemMinterStrategy.sol";
import {IZoraCreator1155} from "../../interfaces/IZoraCreator1155.sol";
import {SharedBaseConstants} from "../../shared/SharedBaseConstants.sol";
import {IMinterErrors} from "../../interfaces/IMinterErrors.sol";

/*
Expand Down Expand Up @@ -42,12 +41,16 @@ import {IMinterErrors} from "../../interfaces/IMinterErrors.sol";
/// @title ZoraCreatorRedeemMinterFactory
/// @notice A factory for ZoraCreatorRedeemMinterStrategy contracts
/// @author @jgeary
contract ZoraCreatorRedeemMinterFactory is Enjoy, IContractMetadata, SharedBaseConstants, IVersionedContract, IMinter1155, IMinterErrors {
contract ZoraCreatorRedeemMinterFactory is Enjoy, IContractMetadata, SharedBaseConstants, IVersionedContract, IMinter1155 {
bytes4 constant LEGACY_ZORA_IMINTER1155_INTERFACE_ID = 0x6467a6fc;
address public immutable zoraRedeemMinterImplementation;

event RedeemMinterDeployed(address indexed creatorContract, address indexed minterContract);

error CallerNotZoraCreator1155();
error MinterContractAlreadyExists();
error MinterContractDoesNotExist();

constructor() {
zoraRedeemMinterImplementation = address(new ZoraCreatorRedeemMinterStrategy());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ pragma solidity 0.8.17;
import {CreatorRoyaltiesStorageV1} from "./CreatorRoyaltiesStorageV1.sol";
import {ICreatorRoyaltiesControl} from "../interfaces/ICreatorRoyaltiesControl.sol";
import {SharedBaseConstants} from "../shared/SharedBaseConstants.sol";
import {ICreatorRoyaltyErrors} from "../interfaces/ICreatorRoyaltiesControl.sol";
import {IERC2981} from "@openzeppelin/contracts/interfaces/IERC2981.sol";

/// Imagine. Mint. Enjoy.
/// @title CreatorRoyaltiesControl
/// @author ZORA @iainnash / @tbtstl
/// @notice Contract for managing the royalties of an 1155 contract
abstract contract CreatorRoyaltiesControl is CreatorRoyaltiesStorageV1, SharedBaseConstants, ICreatorRoyaltyErrors {
abstract contract CreatorRoyaltiesControl is CreatorRoyaltiesStorageV1, SharedBaseConstants {
uint256 immutable ROYALTY_BPS_TO_PERCENT = 10_000;

/// @notice The royalty information for a given token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {IZoraCreator1155Errors} from "../../../src/interfaces/IZoraCreator1155Er
import {IMinter1155} from "../../../src/interfaces/IMinter1155.sol";
import {ICreatorRoyaltiesControl} from "../../../src/interfaces/ICreatorRoyaltiesControl.sol";
import {IZoraCreator1155Factory} from "../../../src/interfaces/IZoraCreator1155Factory.sol";
import {ILimitedMintPerAddressErrors} from "../../../src/interfaces/ILimitedMintPerAddress.sol";
import {ILimitedMintPerAddress} from "../../../src/interfaces/ILimitedMintPerAddress.sol";
import {ZoraCreatorFixedPriceSaleStrategy} from "../../../src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol";

contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
Expand Down Expand Up @@ -279,7 +279,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {
vm.deal(tokenRecipient, totalValue);

vm.prank(tokenRecipient);
vm.expectRevert(abi.encodeWithSelector(ILimitedMintPerAddressErrors.UserExceedsMintLimit.selector, tokenRecipient, 5, 6));
vm.expectRevert(abi.encodeWithSelector(ILimitedMintPerAddress.UserExceedsMintLimit.selector, tokenRecipient, 5, 6));
target.mint{value: totalValue}(fixedPrice, newTokenId, numTokens, abi.encode(tokenRecipient, ""));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Zora1155} from "../../../src/proxies/Zora1155.sol";
import {IZoraCreator1155Errors} from "../../../src/interfaces/IZoraCreator1155Errors.sol";
import {IRenderer1155} from "../../../src/interfaces/IRenderer1155.sol";
import {ICreatorRoyaltiesControl} from "../../../src/interfaces/ICreatorRoyaltiesControl.sol";
import {ILimitedMintPerAddressErrors} from "../../../src/interfaces/ILimitedMintPerAddress.sol";
import {ILimitedMintPerAddress} from "../../../src/interfaces/ILimitedMintPerAddress.sol";
import {IZoraCreator1155Factory} from "../../../src/interfaces/IZoraCreator1155Factory.sol";
import {ZoraCreatorMerkleMinterStrategy} from "../../../src/minters/merkle/ZoraCreatorMerkleMinterStrategy.sol";

Expand Down Expand Up @@ -290,7 +290,7 @@ contract ZoraCreatorMerkleMinterStrategyTest is Test {

vm.deal(mintTo, 1.000777 ether);

vm.expectRevert(abi.encodeWithSelector(ILimitedMintPerAddressErrors.UserExceedsMintLimit.selector, mintTo, 10, 11));
vm.expectRevert(abi.encodeWithSelector(ILimitedMintPerAddress.UserExceedsMintLimit.selector, mintTo, 10, 11));
target.mint{value: 1.000777 ether}(merkleMinter, newTokenId, 1, abi.encode(mintTo, maxQuantity, pricePerToken, merkleProof));

vm.stopPrank();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {ZoraCreator1155PremintExecutorImpl} from "../../src/delegation/ZoraCreat
import {ZoraCreator1155Attribution, ContractCreationConfig, TokenCreationConfig, PremintConfig} from "../../src/delegation/ZoraCreator1155Attribution.sol";
import {UUPSUpgradeable} from "@zoralabs/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
import {ProxyShim} from "../../src/utils/ProxyShim.sol";
import {IMinterErrors} from "../../src/interfaces/IMinterErrors.sol";

contract ZoraCreator1155PreminterTest is Test {
uint256 internal constant CONTRACT_BASE_ID = 0;
Expand Down Expand Up @@ -565,7 +564,7 @@ contract ZoraCreator1155PreminterTest is Test {
// execute mint directly on the contract - and check make sure it reverts if minted after sale start
IMinter1155 fixedPriceMinter = factory.defaultMinters()[0];
if (shouldRevert) {
vm.expectRevert(IMinterErrors.SaleEnded.selector);
vm.expectRevert(ZoraCreatorFixedPriceSaleStrategy.SaleEnded.selector);
}

vm.deal(premintExecutor, mintCost);
Expand Down

0 comments on commit 31f6db8

Please sign in to comment.