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 14, 2023
1 parent 58b0ceb commit f69802c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ interface IZoraCreator1155Errors is ICreatorRoyaltyErrors, ILimitedMintPerAddres
error PremintDeleted();

error InvalidSignatureVersion();

error ERC1155_MINT_TO_ZERO_ADDRESS();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f69802c

Please sign in to comment.