From 597559d9a57cd756d3bba28dd37c6ca9a16461ae Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Wed, 15 Nov 2023 13:23:29 -0800 Subject: [PATCH] Premint - if no mint recipient, revert with proper error (#312) --- .../ZoraCreator1155PremintExecutorImpl.sol | 2 +- .../src/interfaces/IZoraCreator1155Errors.sol | 2 ++ .../ZoraCreator1155PremintExecutor.t.sol | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol b/packages/1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol index d739f2cd4..f7dd19b3d 100644 --- a/packages/1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol +++ b/packages/1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImpl.sol @@ -17,7 +17,7 @@ import {PremintEncoding, ZoraCreator1155Attribution, ContractCreationConfig, Pre import {IZoraCreator1155PremintExecutor} from "../interfaces/IZoraCreator1155PremintExecutor.sol"; struct MintArguments { - // which account should receive the tokens minted. If set to address(0), then defaults to the msg.sender + // which account should receive the tokens minted. address mintRecipient; // comment to add to the mint string mintComment; diff --git a/packages/1155-contracts/src/interfaces/IZoraCreator1155Errors.sol b/packages/1155-contracts/src/interfaces/IZoraCreator1155Errors.sol index 36e1ced50..26723d60a 100644 --- a/packages/1155-contracts/src/interfaces/IZoraCreator1155Errors.sol +++ b/packages/1155-contracts/src/interfaces/IZoraCreator1155Errors.sol @@ -36,4 +36,6 @@ interface IZoraCreator1155Errors is ICreatorRoyaltyErrors, ILimitedMintPerAddres error PremintDeleted(); error InvalidSignatureVersion(); + + error ERC1155_MINT_TO_ZERO_ADDRESS(); } diff --git a/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol b/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol index bd2630ff3..898116654 100644 --- a/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol +++ b/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol @@ -737,6 +737,33 @@ contract ZoraCreator1155PreminterTest is Test { assertEq(storedCreateReferral, createReferral); } + function test_premintWithNoMintRecipient_reverts() public { + ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig(); + PremintConfigV2 memory premintConfig = makeDefaultPremintConfig(); + + address contractAddress = preminter.getContractAddress(contractConfig); + + // sign and execute premint + bytes memory signature = _signPremint(contractAddress, premintConfig, creatorPrivateKey, block.chainid); + + IZoraCreator1155PremintExecutor.MintArguments memory mintArguments = IZoraCreator1155PremintExecutor.MintArguments({ + mintRecipient: address(0), + mintComment: "", + mintReferral: address(0) + }); + + uint256 quantityToMint = 3; + uint256 mintCost = mintFeeAmount * quantityToMint; + address executor = makeAddr("executor"); + vm.deal(executor, mintCost); + + // now call the premint function, using the same config that was used to generate the digest, and the signature + vm.prank(executor); + vm.expectRevert(IZoraCreator1155Errors.ERC1155_MINT_TO_ZERO_ADDRESS.selector); + + preminter.premintV2{value: mintCost}(contractConfig, premintConfig, signature, quantityToMint, mintArguments).tokenId; + } + function _signAndExecutePremint( ContractCreationConfig memory contractConfig, PremintConfigV2 memory premintConfig,