增加用户claim次数限制
This commit is contained in:
parent
8d64de35b6
commit
d16b89c6f1
@ -11,6 +11,7 @@ interface IClaimBox {
|
|||||||
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,
|
||||||
@ -45,6 +46,10 @@ contract ClaimBoxFactory is HasSignature, TimeChecker {
|
|||||||
) external signatureValid(signature) timeValid(startTime) {
|
) external signatureValid(signature) timeValid(startTime) {
|
||||||
require(tokenSupported[nftAddress], "ClaimBoxFactory: unsupported NFT");
|
require(tokenSupported[nftAddress], "ClaimBoxFactory: unsupported NFT");
|
||||||
address to = _msgSender();
|
address to = _msgSender();
|
||||||
|
require(
|
||||||
|
claimHistory[to] == 0,
|
||||||
|
"ClaimBoxFactory: you have claimed this NFT"
|
||||||
|
);
|
||||||
bytes32 criteriaMessageHash = getMessageHash(
|
bytes32 criteriaMessageHash = getMessageHash(
|
||||||
to,
|
to,
|
||||||
nftAddress,
|
nftAddress,
|
||||||
@ -54,6 +59,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user