From a7cd708678a94d1b46cfdac21298c616f53b926c Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Wed, 26 Jul 2023 19:09:59 +0800 Subject: [PATCH] change nft distributor, change method for user call --- contracts/logic/NftDistributor.sol | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/contracts/logic/NftDistributor.sol b/contracts/logic/NftDistributor.sol index 40839ba..0c11637 100644 --- a/contracts/logic/NftDistributor.sol +++ b/contracts/logic/NftDistributor.sol @@ -71,18 +71,10 @@ contract NftDistributor is AccessControlEnumerable { emit OpenStatusChange(_open); } - /** - * @dev The mintToUser function mints NFTs to a given user. - * - * Only functions called by an address with the MANAGE_ROLE permission can access this function. - * The function takes an array of nftIds and checks that there are enough mintable NFTs for the user. - * It then loops through the user's owned NFTs, checking if each is mintable, and if so, adds it to a list to be minted. - * Then it emits the Minted event with details of the operation. - * - * @param _user - The address of the user receiving the NFTs - */ - function mintToUser(address _user, uint256 count) external onlyManager { + function mintNft(uint256 count) external { require(isOpen, "NFT distributor is not open"); + require(count > 0, "Count is zero"); + address _user = _msgSender(); // Check that there are enough mintable NFTs require(count <= getMintableCount(_user), "Mintable count is not enough"); // Get the array of the user's owned NFTs