Skip to content

Commit

Permalink
If no mint recipient, default to msg.sender
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Nov 3, 2023
1 parent de4d708 commit e9c6066
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e9c6066

Please sign in to comment.