Skip to content

Commit

Permalink
feat: mint duration
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 committed Aug 1, 2024
1 parent 977ccc9 commit 850112f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/NFTMint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract NFTMint is Ownable {
error NFTMint_InvalidMerkleProof();
error NFTMint_FailedToTransferFunds();
error NFTMint_BuyerNotAcceptingERC1155();
error NFTMint_MintExpired();

event MintCreated(MintERC1155 indexed mint, MintArgs args);
event OrderPlaced(
Expand All @@ -29,6 +30,7 @@ contract NFTMint is Ownable {
uint256 feePerMint;
address payable owner;
address payable feeRecipient;
uint40 mintDuration;
bytes32 allowlistMerkleRoot;
uint256 perWalletLimit;
uint256 maxMints;
Expand All @@ -43,6 +45,7 @@ contract NFTMint is Ownable {
uint256 feePerMint;
address payable owner;
address payable feeRecipient;
uint40 mintExpiration;
uint256 perWalletLimit;
bytes32 allowlistMerkleRoot;
uint256 remainingMints;
Expand Down Expand Up @@ -89,6 +92,7 @@ contract NFTMint is Ownable {
mintInfo.feeRecipient = args.feeRecipient;
mintInfo.perWalletLimit = args.perWalletLimit;
mintInfo.allowlistMerkleRoot = args.allowlistMerkleRoot;
mintInfo.mintExpiration = uint40(block.timestamp + args.mintDuration);

emit MintCreated(newMint, args);
return newMint;
Expand Down Expand Up @@ -116,6 +120,10 @@ contract NFTMint is Ownable {

MintInfo storage mintInfo = mints[mint];

if (mintInfo.mintExpiration < block.timestamp) {
revert NFTMint_MintExpired();
}

uint256 modifiedAmount = Math.min(amount, mintInfo.remainingMints);
mintInfo.remainingMints -= modifiedAmount;
uint256 totalCost = (mintInfo.pricePerMint + mintInfo.feePerMint) * modifiedAmount;
Expand Down
14 changes: 14 additions & 0 deletions test/NFTMint.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract NFTMintTest is TestBase {
});

NFTMint.MintArgs memory mintArgs = NFTMint.MintArgs({
mintDuration: 1 days,
maxMints: 110,
editions: editions,
allowlistMerkleRoot: bytes32(0),
Expand Down Expand Up @@ -149,6 +150,19 @@ contract NFTMintTest is TestBase {
nftMint.order{ value: 0.011 ether }(mint, 1, "", new bytes32[](0));
}

function test_order_mintExpired() external {
MintERC1155 mint = test_createMint();

address minter = _randomAddress();

vm.deal(minter, 10 ether);
vm.prank(minter);

skip(2 days);
vm.expectRevert(NFTMint.NFTMint_MintExpired.selector);
nftMint.order{ value: 0.011 ether }(mint, 1, "", new bytes32[](0));
}

event OrderFilled(
MintERC1155 indexed mint, uint256 indexed orderId, address indexed to, uint256 amount, uint256[] amounts
);
Expand Down

0 comments on commit 850112f

Please sign in to comment.