空投合约增加一个可供外部调用的查询可mint列表的方法
This commit is contained in:
parent
36e89a35b2
commit
06f177fcc1
File diff suppressed because one or more lines are too long
@ -161,4 +161,39 @@ contract NftDistributor is AccessControlEnumerable {
|
||||
// Return the final mintable count
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev The getMintableNftIds function gets an array of NFT IDs owned by a user that have not yet been minted.
|
||||
*
|
||||
* This is a read-only function, meaning it doesn't modify the state of the blockchain.
|
||||
* It takes in the address of the user whose mintable NFT IDs are being determined,
|
||||
* and returns an array of the NFT IDs owned by the user that have not yet been minted.
|
||||
*
|
||||
* @param _user - The address of the user whose mintable NFT IDs are being determined
|
||||
* @return mintableNftIds - An array of the NFT IDs owned by the user that have not yet been minted
|
||||
*/
|
||||
function getMintableNftIds(
|
||||
address _user
|
||||
) external view returns (uint256[] memory) {
|
||||
// Get an array of all NFT IDs owned by the user
|
||||
uint256[] memory nfts = ownerToNFTs[_user];
|
||||
// Initialize an array for mintable NFT IDs with the same length as the array of all NFT IDs
|
||||
uint256[] memory mintableNftIds = new uint256[](nfts.length);
|
||||
// Initialize an index counter to zero
|
||||
uint256 index = 0;
|
||||
// Loop through the array of NFT IDs
|
||||
for (uint256 i = 0; i < nfts.length; i++) {
|
||||
// Get the NFT ID at this index of the loop
|
||||
uint256 nftId = nfts[i];
|
||||
// Check if the NFT has not yet been minted
|
||||
if (!nftMinted[nftId]) {
|
||||
// If the NFT has not yet been minted, add it to the mintable NFT IDs array
|
||||
mintableNftIds[index] = nftId;
|
||||
// Increment the index counter
|
||||
index++;
|
||||
}
|
||||
}
|
||||
// Return the array of mintable NFT IDs
|
||||
return mintableNftIds;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user