修改claimfactory限额的实现方式

This commit is contained in:
zhl 2023-06-14 13:45:53 +08:00
parent b2424f4bd1
commit 93b9dd1607
3 changed files with 3210 additions and 3148 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -6,12 +6,13 @@ import "../utils/TimeChecker.sol";
interface IClaimBox { interface IClaimBox {
function mint(address to) external returns (uint256); function mint(address to) external returns (uint256);
function balanceOf(address owner) external view returns (uint256);
} }
contract ClaimBoxFactory is HasSignature, TimeChecker { contract ClaimBoxFactory is HasSignature, TimeChecker {
address public executor; address public executor;
mapping(address => bool) public tokenSupported; mapping(address => bool) public tokenSupported;
mapping(address => uint256) public claimHistory;
event BoxClaimed( event BoxClaimed(
address indexed nftAddress, address indexed nftAddress,
@ -47,8 +48,8 @@ contract ClaimBoxFactory is HasSignature, TimeChecker {
require(tokenSupported[nftAddress], "ClaimBoxFactory: unsupported NFT"); require(tokenSupported[nftAddress], "ClaimBoxFactory: unsupported NFT");
address to = _msgSender(); address to = _msgSender();
require( require(
claimHistory[to] == 0, IClaimBox(nftAddress).balanceOf(to) == 0,
"ClaimBoxFactory: you have claimed this NFT" "ClaimBoxFactory: you already have a box"
); );
bytes32 criteriaMessageHash = getMessageHash( bytes32 criteriaMessageHash = getMessageHash(
to, to,
@ -59,7 +60,6 @@ contract ClaimBoxFactory is HasSignature, TimeChecker {
checkSigner(executor, criteriaMessageHash, signature); checkSigner(executor, criteriaMessageHash, signature);
uint256 tokenId = IClaimBox(nftAddress).mint(to); uint256 tokenId = IClaimBox(nftAddress).mint(to);
_useSignature(signature); _useSignature(signature);
claimHistory[to] = tokenId;
emit BoxClaimed(nftAddress, to, saltNonce, tokenId); emit BoxClaimed(nftAddress, to, saltNonce, tokenId);
} }