-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathLimitedMintPerAddress.sol
27 lines (22 loc) · 1.31 KB
/
LimitedMintPerAddress.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import {ILimitedMintPerAddress} from "../../interfaces/ILimitedMintPerAddress.sol";
contract LimitedMintPerAddress is ILimitedMintPerAddress {
/// @notice Storage for slot to check user mints
/// @notice target contract -> tokenId -> minter user -> numberMinted
/// @dev No gap or storage interface since this is used within non-upgradeable contracts
mapping(address => mapping(uint256 => mapping(address => uint256))) internal mintedPerAddress;
function getMintedPerWallet(address tokenContract, uint256 tokenId, address wallet) external view returns (uint256) {
return mintedPerAddress[tokenContract][tokenId][wallet];
}
function _requireMintNotOverLimitAndUpdate(uint256 limit, uint256 numRequestedMint, address tokenContract, uint256 tokenId, address wallet) internal {
uint256 newMintCount = mintedPerAddress[tokenContract][tokenId][wallet] + numRequestedMint;
if (newMintCount > limit) {
revert UserExceedsMintLimit(wallet, limit, newMintCount);
}
mintedPerAddress[tokenContract][tokenId][wallet] = newMintCount;
}
function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool) {
return interfaceId == type(ILimitedMintPerAddress).interfaceId;
}
}