-
Notifications
You must be signed in to change notification settings - Fork 0
/
NFTXEligibility.sol
48 lines (39 loc) · 1.92 KB
/
NFTXEligibility.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-License-Identifier: MIT
pragma solidity 0.6.8;
import "../proxy/Initializable.sol";
import "../interface/INFTXEligibility.sol";
// This is a contract meant to be inherited and overriden to implement eligibility modules.
abstract contract NFTXEligibility is INFTXEligibility, Initializable {
function name() public view override virtual returns (string memory);
function finalized() public view override virtual returns (bool);
function __NFTXEligibility_init_bytes(bytes memory initData) public override virtual;
function checkIsEligible(uint256 tokenId) external view override virtual returns (bool) {
return _checkIfEligible(tokenId);
}
function checkAllEligible(uint256[] calldata tokenIds) external override virtual view returns (bool) {
for (uint256 i = 0; i < tokenIds.length; i++) {
// If any are not eligible, end the loop and return false.
if (!_checkIfEligible(tokenIds[i])) {
return false;
}
}
return true;
}
// Checks if all provided NFTs are NOT eligible. This is needed for mint requesting where all NFTs
// provided must be ineligible.
function checkAllIneligible(uint256[] calldata tokenIds) external override virtual view returns (bool) {
for (uint256 i = 0; i < tokenIds.length; i++) {
// If any are eligible, end the loop and return false.
if (_checkIfEligible(tokenIds[i])) {
return false;
}
}
return true;
}
function beforeMintHook(uint256[] calldata tokenIds) external override virtual {}
function afterMintHook(uint256[] calldata tokenIds) external override virtual {}
function beforeRedeemHook(uint256[] calldata tokenIds) external override virtual {}
function afterRedeemHook(uint256[] calldata tokenIds) external override virtual {}
// Override this to implement your module!
function _checkIfEligible(uint256 _tokenId) internal view virtual returns (bool);
}