Skip to content

Commit

Permalink
Fix [Q-4] Missing natspec documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrishang committed Sep 27, 2023
1 parent a998187 commit 37d2689
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
15 changes: 14 additions & 1 deletion contracts/extension/interface/IBurnToClaim.sol
Expand Up @@ -10,6 +10,15 @@ interface IBurnToClaim {
ERC1155
}

/**
* @notice Configuration for burning tokens to claim new tokens.
*
* @param originContractAddress The address of the contract that the tokens are burned from.
* @param tokenType The type of token to burn.
* @param tokenId The token ID of the token to burn. Only used if tokenType is ERC1155.
* @param mintPriceForNewToken The price to mint a new token.
* @param currency The currency to pay the mint price in.
*/
struct BurnToClaimInfo {
address originContractAddress;
TokenType tokenType;
Expand All @@ -18,13 +27,17 @@ interface IBurnToClaim {
address currency;
}

/// @dev Emitted when tokens are burned to claim new tokens
/// @notice Emitted when tokens are burned to claim new tokens
event TokensBurnedAndClaimed(
address indexed originContract,
address indexed tokenOwner,
uint256 indexed burnTokenId,
uint256 quantity
);

/**
* @notice Sets the configuration for burning tokens to claim new tokens.
* @param burnToClaimInfo The configuration for burning tokens to claim new tokens.
*/
function setBurnToClaimInfo(BurnToClaimInfo calldata burnToClaimInfo) external;
}
5 changes: 5 additions & 0 deletions contracts/extension/upgradeable/BurnToClaim.sol
Expand Up @@ -29,10 +29,12 @@ library BurnToClaimStorage {
}

abstract contract BurnToClaim is IBurnToClaim {
/// @notice Returns the confugration for burning tokens to claim new tokens.
function getBurnToClaimInfo() public view returns (BurnToClaimInfo memory) {
return _burnToClaimStorage().burnToClaimInfo;
}

/// @notice Sets the configuration for burning tokens to claim new tokens.
function setBurnToClaimInfo(BurnToClaimInfo calldata _burnToClaimInfo) external virtual {
require(_canSetBurnToClaim(), "Not authorized.");
require(_burnToClaimInfo.originContractAddress != address(0), "Origin contract not set.");
Expand All @@ -41,6 +43,7 @@ abstract contract BurnToClaim is IBurnToClaim {
_burnToClaimStorage().burnToClaimInfo = _burnToClaimInfo;
}

/// @notice Verifies an attempt to burn tokens to claim new tokens.
function verifyBurnToClaim(
address _tokenOwner,
uint256 _tokenId,
Expand All @@ -63,6 +66,7 @@ abstract contract BurnToClaim is IBurnToClaim {
}
}

/// @dev Burns tokens to claim new tokens.
function _burnTokensOnOrigin(
address _tokenOwner,
uint256 _tokenId,
Expand All @@ -82,5 +86,6 @@ abstract contract BurnToClaim is IBurnToClaim {
data = BurnToClaimStorage.data();
}

/// @dev Returns whether the caller can set the burn to claim configuration.
function _canSetBurnToClaim() internal view virtual returns (bool);
}
Expand Up @@ -52,7 +52,7 @@ contract BurnToClaimDropERC721 is
_disableInitializers();
}

/// @dev Initializes the contract, like a constructor.
/// @notice Initializes the contract.
function initialize(
address _defaultAdmin,
string memory _name,
Expand Down Expand Up @@ -84,6 +84,7 @@ contract BurnToClaimDropERC721 is
_setupOperatorFilterer();
}

/// @dev Called in the initialize function. Sets up roles.
function _setupRoles(address _defaultAdmin) internal onlyInitializing {
bytes32 _transferRole = keccak256("TRANSFER_ROLE");
bytes32 _minterRole = keccak256("MINTER_ROLE");
Expand All @@ -102,10 +103,12 @@ contract BurnToClaimDropERC721 is
Contract identifiers
//////////////////////////////////////////////////////////////*/

/// @notice Returns the type of contract.
function contractType() external pure returns (bytes32) {
return bytes32("BurnToClaimDropERC721");
}

/// @notice Returns the contract version.
function contractVersion() external pure returns (uint8) {
return uint8(5);
}
Expand Down
Expand Up @@ -76,8 +76,10 @@ contract BurnToClaimDrop721Logic is
ERC 165 / 721 / 2981 logic
//////////////////////////////////////////////////////////////*/

/// @notice Returns the URI for a given tokenId.
/// @dev The URI, for a given tokenId, is returned once it is lazy minted, even if it might not be actually minted. (See `LazyMint`)
/**
* @notice Returns the URI for a given tokenId.
* @dev The URI, for a given tokenId, is returned once it is lazy minted, even if it might not be actually minted. (See `LazyMint`)
*/
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
(uint256 batchId, ) = _getBatchId(_tokenId);
string memory batchUri = _getBaseURI(_tokenId);
Expand All @@ -89,7 +91,7 @@ contract BurnToClaimDrop721Logic is
}
}

/// @dev See ERC 165
/// @notice See ERC 165
function supportsInterface(bytes4 interfaceId)
public
view
Expand All @@ -105,8 +107,8 @@ contract BurnToClaimDrop721Logic is
//////////////////////////////////////////////////////////////*/

/**
* @dev Lets an account with `MINTER_ROLE` lazy mint 'n' NFTs.
* The URIs for each token is the provided `_baseURIForTokens` + `{tokenId}`.
* @notice Lets an account with `MINTER_ROLE` lazy mint 'n' NFTs.
* The URIs for each token is the provided `_baseURIForTokens` + `{tokenId}`.
*/
function lazyMint(
uint256 _amount,
Expand All @@ -124,7 +126,7 @@ contract BurnToClaimDrop721Logic is
return super.lazyMint(_amount, _baseURIForTokens, _data);
}

/// @dev Lets an account with `MINTER_ROLE` reveal the URI for a batch of 'delayed-reveal' NFTs.
/// @notice Lets an account with `MINTER_ROLE` reveal the URI for a batch of 'delayed-reveal' NFTs.
function reveal(uint256 _index, bytes calldata _key) external returns (string memory revealedURI) {
require(_hasRole(MINTER_ROLE, _msgSender()), "not minter.");
uint256 batchId = getBatchIdAtIndex(_index);
Expand All @@ -140,7 +142,7 @@ contract BurnToClaimDrop721Logic is
Claiming lazy minted tokens logic
//////////////////////////////////////////////////////////////*/

/// @dev Claim lazy minted after burning required tokens from origin contract.
/// @notice Claim lazy minted tokens after burning required tokens from origin contract.
function burnAndClaim(uint256 _burnTokenId, uint256 _quantity) external payable {
_checkTokenSupply(_quantity);

Expand Down Expand Up @@ -173,7 +175,7 @@ contract BurnToClaimDrop721Logic is
Setter functions
//////////////////////////////////////////////////////////////*/

/// @dev Lets a contract admin set the global maximum NFTs that can be minted.
/// @notice Lets a contract admin set the global maximum NFTs that can be minted.
function setMaxTotalMinted(uint256 _maxTotalMinted) external {
require(_hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "not admin.");

Expand Down Expand Up @@ -301,7 +303,7 @@ contract BurnToClaimDrop721Logic is
//////////////////////////////////////////////////////////////*/

/**
* Returns the total amount of tokens minted in the contract.
* @notice Returns the total amount of tokens minted in the contract.
*/
function totalMinted() external view returns (uint256) {
ERC721AStorage.Data storage data = ERC721AStorage.erc721AStorage();
Expand All @@ -310,24 +312,24 @@ contract BurnToClaimDrop721Logic is
}
}

/// @dev The tokenId of the next NFT that will be minted / lazy minted.
/// @notice The tokenId of the next NFT that will be minted / lazy minted.
function nextTokenIdToMint() external view returns (uint256) {
return nextTokenIdToLazyMint();
}

/// @dev The next token ID of the NFT that can be claimed.
/// @notice The next token ID of the NFT that can be claimed.
function nextTokenIdToClaim() external view returns (uint256) {
ERC721AStorage.Data storage data = ERC721AStorage.erc721AStorage();
return data._currentIndex;
}

/// @dev Global max total NFTs that can be minted.
/// @notice Global max total NFTs that can be minted.
function maxTotalMinted() public view returns (uint256) {
BurnToClaimDrop721Storage.Data storage data = BurnToClaimDrop721Storage.burnToClaimDrop721Storage();
return data.maxTotalMinted;
}

/// @dev Burns `tokenId`. See {ERC721-_burn}.
/// @notice Burns `tokenId`. See {ERC721-_burn}.
function burn(uint256 tokenId) external virtual {
// note: ERC721AUpgradeable's `_burn(uint256,bool)` internally checks for token approvals.
_burn(tokenId, true);
Expand Down Expand Up @@ -388,6 +390,7 @@ contract BurnToClaimDrop721Logic is
super.safeTransferFrom(from, to, tokenId, data);
}

/// @dev Returns whether `addr` holds the given role.
function _hasRole(bytes32 role, address addr) internal view returns (bool) {
PermissionsStorage.Data storage data = PermissionsStorage.data();
return data._hasRole[role][addr];
Expand Down

0 comments on commit 37d2689

Please sign in to comment.