diff --git a/contracts/ConfigurableGuildRewardNFT.sol b/contracts/ConfigurableGuildRewardNFT.sol index 37b8155..fafbe35 100644 --- a/contracts/ConfigurableGuildRewardNFT.sol +++ b/contracts/ConfigurableGuildRewardNFT.sol @@ -38,8 +38,6 @@ contract ConfigurableGuildRewardNFT is IGuildRewardNFTFactory.ConfigurableNFTConfig memory nftConfig, address factoryProxyAddress ) public initializer { - if (nftConfig.maxSupply <= 0) revert MaxSupplyZero(); - cid = nftConfig.cid; maxSupply = nftConfig.maxSupply; mintableAmountPerUser = nftConfig.mintableAmountPerUser; @@ -72,7 +70,8 @@ contract ConfigurableGuildRewardNFT is uint256 firstTokenId = totalSupply(); uint256 lastTokenId = firstTokenId + amount - 1; - if (lastTokenId >= maxSupply) revert MaxSupplyReached(maxSupply); + uint256 tokenIdCap = maxSupply; + if (tokenIdCap > 0 && lastTokenId >= tokenIdCap) revert MaxSupplyReached(tokenIdCap); for (uint256 tokenId = firstTokenId; tokenId <= lastTokenId; ) { _safeMint(receiver, tokenId); @@ -122,7 +121,6 @@ contract ConfigurableGuildRewardNFT is } function setMaxSupply(uint256 newMaxSupply) external onlyOwner { - if (newMaxSupply <= 0) revert MaxSupplyZero(); maxSupply = newMaxSupply; emit MaxSupplyChanged(newMaxSupply); } diff --git a/contracts/interfaces/IMaxSupply.sol b/contracts/interfaces/IMaxSupply.sol index 7de9f13..d015d4f 100644 --- a/contracts/interfaces/IMaxSupply.sol +++ b/contracts/interfaces/IMaxSupply.sol @@ -3,21 +3,18 @@ pragma solidity ^0.8.0; interface IMaxSupply { /// @notice The maximum number of tokens that can ever be minted. - /// @return count The number of tokens. + /// @return count The number of tokens. Unlimited if zero. function maxSupply() external view returns (uint256 count); /// @notice Sets the maximum number of tokens that can ever be minted. /// @dev Only callable by the owner. - /// @param newMaxSupply The number of tokens. + /// @param newMaxSupply The number of tokens. Unlimited if zero. function setMaxSupply(uint256 newMaxSupply) external; /// @notice Event emitted when the maxSupply is changed. /// @param newMaxSupply The number of tokens. event MaxSupplyChanged(uint256 newMaxSupply); - /// @notice Error thrown when the maximum supply attempted to be set is zero. - error MaxSupplyZero(); - /// @notice Error thrown when the tokenId is higher than the maximum supply. /// @param maxSupply The maximum supply of the token. error MaxSupplyReached(uint256 maxSupply); diff --git a/docs/contracts/ConfigurableGuildRewardNFT.md b/docs/contracts/ConfigurableGuildRewardNFT.md index 934e191..6876e8c 100644 --- a/docs/contracts/ConfigurableGuildRewardNFT.md +++ b/docs/contracts/ConfigurableGuildRewardNFT.md @@ -178,7 +178,7 @@ Only callable by the owner. | Name | Type | Description | | :--- | :--- | :---------- | -| `newMaxSupply` | uint256 | The number of tokens. | +| `newMaxSupply` | uint256 | The number of tokens. Unlimited if zero. | ### setMintableAmountPerUser diff --git a/docs/contracts/interfaces/IMaxSupply.md b/docs/contracts/interfaces/IMaxSupply.md index 7332007..23cd6b1 100644 --- a/docs/contracts/interfaces/IMaxSupply.md +++ b/docs/contracts/interfaces/IMaxSupply.md @@ -14,7 +14,7 @@ The maximum number of tokens that can ever be minted. | Name | Type | Description | | :--- | :--- | :---------- | -| `count` | uint256 | The number of tokens. | +| `count` | uint256 | The number of tokens. Unlimited if zero. | ### setMaxSupply ```solidity @@ -31,7 +31,7 @@ Only callable by the owner. | Name | Type | Description | | :--- | :--- | :---------- | -| `newMaxSupply` | uint256 | The number of tokens. | +| `newMaxSupply` | uint256 | The number of tokens. Unlimited if zero. | ## Events @@ -53,14 +53,6 @@ Event emitted when the maxSupply is changed. ## Custom errors -### MaxSupplyZero - -```solidity -error MaxSupplyZero() -``` - -Error thrown when the maximum supply attempted to be set is zero. - ### MaxSupplyReached ```solidity diff --git a/test/ConfigurableGuildRewardNFT.spec.ts b/test/ConfigurableGuildRewardNFT.spec.ts index 0eeda82..c54eb0c 100644 --- a/test/ConfigurableGuildRewardNFT.spec.ts +++ b/test/ConfigurableGuildRewardNFT.spec.ts @@ -526,10 +526,6 @@ describe("ConfigurableGuildRewardNFT", () => { ); }); - it("should revert if maxSupply is attempted to be set to 0", async () => { - await expect(nft.setMaxSupply(0)).to.be.revertedWithCustomError(nft, "MaxSupplyZero"); - }); - it("should update maxSupply", async () => { const maxSupply = 5; await nft.setMaxSupply(maxSupply);