修正supportNftList未生效的bug

This commit is contained in:
CounterFire2023 2024-06-18 17:31:53 +08:00
parent 45e36f8e0e
commit 6621b926b4

View File

@ -1,6 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
@ -39,11 +38,12 @@ contract NFTLock is ERC721Holder, HasSignature, TimeChecker, Pausable {
function lock(address nft, uint256[] calldata tokenIds) external whenNotPaused{
require(tokenIds.length <= 100, "tokenIds too many");
require(supportNftList[nft], "not support nft");
address to = _msgSender();
for (uint256 i = 0; i < tokenIds.length; i++) {
INFT(nft).transferFrom(to, address(this), tokenIds[i]);
lockedOriginal[nft][tokenIds[i]] = to;
lockedRecords[nft][to].add(tokenIds[i]);
INFT(nft).transferFrom(to, address(this), tokenIds[i]);
}
emit Lock(nft, to, tokenIds);
}
@ -63,17 +63,17 @@ contract NFTLock is ERC721Holder, HasSignature, TimeChecker, Pausable {
address to = _msgSender();
bytes32 messageHash = getMessageHash(to, nft, nftList, _CACHED_THIS, _CACHED_CHAIN_ID, signTime, saltNonce);
checkSigner(verifier, messageHash, signature);
_useSignature(signature);
for (uint256 i = 0; i < nftList.length; i++) {
if (nftList[i].isMint) {
INFT(nft).mint(to, nftList[i].tokenId);
} else {
require(lockedOriginal[nft][nftList[i].tokenId] == to, "not owner");
INFT(nft).transferFrom(address(this), to, nftList[i].tokenId);
lockedRecords[nft][to].remove(nftList[i].tokenId);
delete lockedOriginal[nft][nftList[i].tokenId];
lockedRecords[nft][to].remove(nftList[i].tokenId);
INFT(nft).transferFrom(address(this), to, nftList[i].tokenId);
}
}
_useSignature(signature);
emit UnLock(nft, to, saltNonce, nftList);
}