From e9c606632047726ecefbe3fe3130a5a8e6c27387 Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Tue, 31 Oct 2023 12:27:04 -0600 Subject: [PATCH] If no mint recipient, default to msg.sender --- .../ZoraCreator1155PremintExecutorImplLib.sol | 3 +- .../ZoraCreator1155PremintExecutor.t.sol | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImplLib.sol b/packages/1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImplLib.sol index 019b3117d..f6fcf8c5c 100644 --- a/packages/1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImplLib.sol +++ b/packages/1155-contracts/src/delegation/ZoraCreator1155PremintExecutorImplLib.sol @@ -120,7 +120,8 @@ library ZoraCreator1155PremintExecutorImplLib { uint256 quantityToMint, IZoraCreator1155PremintExecutor.MintArguments memory mintArguments ) internal { - bytes memory mintSettings = abi.encode(mintArguments.mintRecipient, mintArguments.mintComment); + address mintRecipient = mintArguments.mintRecipient == address(0) ? msg.sender : mintArguments.mintRecipient; + bytes memory mintSettings = abi.encode(mintRecipient, mintArguments.mintComment); if (quantityToMint != 0) // mint the number of specified tokens to the executor tokenContract.mintWithRewards{value: msg.value}(IMinter1155(fixedPriceMinter), tokenId, quantityToMint, mintSettings, mintArguments.mintReferral); diff --git a/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol b/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol index 1a513e2dc..aec03e7ae 100644 --- a/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol +++ b/packages/1155-contracts/test/premint/ZoraCreator1155PremintExecutor.t.sol @@ -738,6 +738,34 @@ contract ZoraCreator1155PreminterTest is Test { assertEq(storedCreateReferral, createReferral); } + function test_premintWithNoMintRecipient_mintsTokenToMsgSender() 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); + uint256 newTokenId = preminter.premintV2{value: mintCost}(contractConfig, premintConfig, signature, quantityToMint, mintArguments).tokenId; + + // assert executor gets minted the tokens + assertEq(IZoraCreator1155(contractAddress).balanceOf(executor, newTokenId), quantityToMint); + } + function _signAndExecutePremint( ContractCreationConfig memory contractConfig, PremintConfigV2 memory premintConfig,