diff --git a/contracts/base/ERC721DelayedReveal.sol b/contracts/base/ERC721DelayedReveal.sol index ed9f69121..65b1ac4dd 100644 --- a/contracts/base/ERC721DelayedReveal.sol +++ b/contracts/base/ERC721DelayedReveal.sol @@ -48,7 +48,7 @@ contract ERC721DelayedReveal is ERC721LazyMint, DelayedReveal { * @param _tokenId The tokenId of an NFT. */ function tokenURI(uint256 _tokenId) public view override returns (string memory) { - uint256 batchId = getBatchId(_tokenId); + (uint256 batchId, ) = getBatchId(_tokenId); string memory batchUri = getBaseURI(_tokenId); if (isEncryptedBatch(batchId)) { diff --git a/contracts/base/ERC721Drop.sol b/contracts/base/ERC721Drop.sol index 9b6b52b45..61cb72c00 100644 --- a/contracts/base/ERC721Drop.sol +++ b/contracts/base/ERC721Drop.sol @@ -51,8 +51,8 @@ contract ERC721Drop is ERC721SignatureMint, LazyMint, DelayedReveal, DropSingleP * * @param _tokenId The tokenId of an NFT. */ - function tokenURI(uint256 _tokenId) public view override returns (string memory) { - uint256 batchId = getBatchId(_tokenId); + function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { + (uint256 batchId, ) = getBatchId(_tokenId); string memory batchUri = getBaseURI(_tokenId); if (isEncryptedBatch(batchId)) { @@ -73,7 +73,7 @@ contract ERC721Drop is ERC721SignatureMint, LazyMint, DelayedReveal, DropSingleP * @param _signature The signature produced by an account signing the mint request. */ function mintWithSignature(MintRequest calldata _req, bytes calldata _signature) - external + public payable virtual override @@ -145,7 +145,7 @@ contract ERC721Drop is ERC721SignatureMint, LazyMint, DelayedReveal, DropSingleP * @param _index The ID for the batch of delayed-reveal NFTs to reveal. * @param _key The key with which the base URI for the relevant batch of NFTs was encrypted. */ - function reveal(uint256 _index, bytes calldata _key) external override returns (string memory revealedURI) { + function reveal(uint256 _index, bytes calldata _key) public virtual override returns (string memory revealedURI) { require(_canReveal(), "Not authorized"); uint256 batchId = getBatchIdAtIndex(_index); @@ -169,7 +169,7 @@ contract ERC721Drop is ERC721SignatureMint, LazyMint, DelayedReveal, DropSingleP uint256, AllowlistProof calldata, bytes memory - ) internal view override { + ) internal view virtual override { require(msg.sender == tx.origin, "BOT"); if (_currentIndex + _quantity > nextTokenIdToLazyMint) { revert("Not enough minted tokens"); @@ -181,7 +181,7 @@ contract ERC721Drop is ERC721SignatureMint, LazyMint, DelayedReveal, DropSingleP uint256 _quantityToClaim, address _currency, uint256 _pricePerToken - ) internal override(DropSinglePhase, ERC721SignatureMint) { + ) internal virtual override(DropSinglePhase, ERC721SignatureMint) { if (_pricePerToken == 0) { return; } @@ -200,6 +200,7 @@ contract ERC721Drop is ERC721SignatureMint, LazyMint, DelayedReveal, DropSingleP /// @dev Transfers the NFTs being claimed. function transferTokensOnClaim(address _to, uint256 _quantityBeingClaimed) internal + virtual override returns (uint256 startTokenId) { @@ -208,27 +209,27 @@ contract ERC721Drop is ERC721SignatureMint, LazyMint, DelayedReveal, DropSingleP } /// @dev Checks whether primary sale recipient can be set in the given execution context. - function _canSetPrimarySaleRecipient() internal view override returns (bool) { + function _canSetPrimarySaleRecipient() internal view virtual override returns (bool) { return msg.sender == owner(); } /// @dev Checks whether owner can be set in the given execution context. - function _canSetOwner() internal view override returns (bool) { + function _canSetOwner() internal view virtual override returns (bool) { return msg.sender == owner(); } /// @dev Checks whether royalty info can be set in the given execution context. - function _canSetRoyaltyInfo() internal view override returns (bool) { + function _canSetRoyaltyInfo() internal view virtual override returns (bool) { return msg.sender == owner(); } /// @dev Checks whether contract metadata can be set in the given execution context. - function _canSetContractURI() internal view override returns (bool) { + function _canSetContractURI() internal view virtual override returns (bool) { return msg.sender == owner(); } /// @dev Checks whether platform fee info can be set in the given execution context. - function _canSetClaimConditions() internal view override returns (bool) { + function _canSetClaimConditions() internal view virtual override returns (bool) { return msg.sender == owner(); } diff --git a/contracts/extension/BatchMintMetadata.sol b/contracts/extension/BatchMintMetadata.sol index bb205b4e0..c0ab8bf6b 100644 --- a/contracts/extension/BatchMintMetadata.sol +++ b/contracts/extension/BatchMintMetadata.sol @@ -28,13 +28,16 @@ contract BatchMintMetadata { } /// @dev Returns the id for the batch of tokens the given tokenId belongs to. - function getBatchId(uint256 _tokenId) internal view returns (uint256) { + function getBatchId(uint256 _tokenId) internal view returns (uint256 batchId, uint256 index) { uint256 numOfTokenBatches = getBaseURICount(); uint256[] memory indices = batchIds; for (uint256 i = 0; i < numOfTokenBatches; i += 1) { if (_tokenId < indices[i]) { - return indices[i]; + index = i; + batchId = indices[i]; + + return (batchId, index); } } diff --git a/contracts/extension/SoulboundERC721A.sol b/contracts/extension/SoulboundERC721A.sol index 9db8ee9a7..fa1929f12 100644 --- a/contracts/extension/SoulboundERC721A.sol +++ b/contracts/extension/SoulboundERC721A.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; -import "./Permissions.sol"; +import "./PermissionsEnumerable.sol"; /** * The `SoulboundERC721A` extension smart contract is meant to be used with ERC721A contracts as its base. It @@ -13,7 +13,7 @@ import "./Permissions.sol"; * - Else, a transfer goes through only if either the sender or recipient holds the transfe role. */ -abstract contract SoulboundERC721A is Permissions { +abstract contract SoulboundERC721A is PermissionsEnumerable { /// @dev Only transfers to or from TRANSFER_ROLE holders are valid, when transfers are restricted. bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE"); diff --git a/contracts/package.json b/contracts/package.json index 660f5d6e0..430a556f6 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,7 +1,7 @@ { "name": "@thirdweb-dev/contracts", "description": "Collection of smart contracts deployable via the thirdweb SDK, dashboard and CLI", - "version": "3.0.2-1", + "version": "3.0.3", "license": "Apache-2.0", "repository": { "type": "git", diff --git a/contracts/signature-drop/SignatureDrop.sol b/contracts/signature-drop/SignatureDrop.sol index 9b9b4296b..72abdb1bd 100644 --- a/contracts/signature-drop/SignatureDrop.sol +++ b/contracts/signature-drop/SignatureDrop.sol @@ -101,7 +101,7 @@ contract SignatureDrop is /// @dev Returns the URI for a given tokenId. function tokenURI(uint256 _tokenId) public view override returns (string memory) { - uint256 batchId = getBatchId(_tokenId); + (uint256 batchId, ) = getBatchId(_tokenId); string memory batchUri = getBaseURI(_tokenId); if (isEncryptedBatch(batchId)) { @@ -126,8 +126,8 @@ contract SignatureDrop is return bytes32("SignatureDrop"); } - function contractVersion() external pure returns (uint256) { - return 2; + function contractVersion() external pure returns (uint8) { + return uint8(2); } /*/////////////////////////////////////////////////////////////// diff --git a/docs/ERC721Multiwrap.md b/docs/ERC721Multiwrap.md index d1dd9021e..3f15362c5 100644 --- a/docs/ERC721Multiwrap.md +++ b/docs/ERC721Multiwrap.md @@ -253,6 +253,51 @@ function getRoleAdmin(bytes32 role) external view returns (bytes32) |---|---|---| | _0 | bytes32 | undefined +### getRoleMember + +```solidity +function getRoleMember(bytes32 role, uint256 index) external view returns (address member) +``` + + + +*Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role | bytes32 | undefined +| index | uint256 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| member | address | undefined + +### getRoleMemberCount + +```solidity +function getRoleMemberCount(bytes32 role) external view returns (uint256 count) +``` + + + +*Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role | bytes32 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| count | uint256 | undefined + ### getRoyaltyInfoForToken ```solidity diff --git a/docs/SignatureDrop.md b/docs/SignatureDrop.md index 9cfe9c56f..1759db8bb 100644 --- a/docs/SignatureDrop.md +++ b/docs/SignatureDrop.md @@ -164,7 +164,7 @@ function contractURI() external view returns (string) ### contractVersion ```solidity -function contractVersion() external pure returns (uint256) +function contractVersion() external pure returns (uint8) ``` @@ -176,7 +176,7 @@ function contractVersion() external pure returns (uint256) | Name | Type | Description | |---|---|---| -| _0 | uint256 | undefined +| _0 | uint8 | undefined ### encryptDecrypt diff --git a/docs/SoulboundERC721A.md b/docs/SoulboundERC721A.md index fe241428d..2493abf61 100644 --- a/docs/SoulboundERC721A.md +++ b/docs/SoulboundERC721A.md @@ -66,6 +66,51 @@ function getRoleAdmin(bytes32 role) external view returns (bytes32) |---|---|---| | _0 | bytes32 | undefined +### getRoleMember + +```solidity +function getRoleMember(bytes32 role, uint256 index) external view returns (address member) +``` + + + +*Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role | bytes32 | undefined +| index | uint256 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| member | address | undefined + +### getRoleMemberCount + +```solidity +function getRoleMemberCount(bytes32 role) external view returns (uint256 count) +``` + + + +*Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role | bytes32 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| count | uint256 | undefined + ### grantRole ```solidity