From e6c66e320dc0174c8b30ed289ff42c85fa02f29b Mon Sep 17 00:00:00 2001 From: Krishang Date: Tue, 28 Feb 2023 12:16:54 -0800 Subject: [PATCH 1/4] Make all top level functions virtual on ContractKit bases --- contracts/base/ERC1155Base.sol | 5 +- contracts/base/ERC1155DelayedReveal.sol | 2 +- contracts/base/ERC1155Drop.sol | 5 +- contracts/base/ERC1155LazyMint.sol | 7 +- contracts/base/ERC721Base.sol | 14 +- contracts/base/ERC721DelayedReveal.sol | 4 +- contracts/base/ERC721Drop.sol | 16 +- contracts/base/ERC721LazyMint.sol | 16 +- contracts/base/ERC721Multiwrap.sol | 16 +- contracts/base/Staking1155Base.sol | 8 +- contracts/base/Staking20Base.sol | 4 +- contracts/base/Staking721Base.sol | 4 +- docs/ERC2771ContextStorage.md | 2 +- docs/ERC2771ContextUpgradeableStorage.md | 2 +- docs/FeeType.md | 2 +- docs/IBurnableERC20.md | 2 +- docs/IBurnableERC721.md | 2 +- docs/IClaimableERC1155.md | 2 +- docs/IClaimableERC721.md | 2 +- docs/IContext.md | 2 +- docs/IContractFactory.md | 2 +- docs/IMintableERC20.md | 2 +- docs/IMintableERC721.md | 2 +- docs/IOperatorFilterRegistry.md | 2 +- docs/IOperatorFilterToggle.md | 2 +- docs/IPluginMap.md | 2 +- docs/IRouter.md | 166 +-------------- docs/IStaking1155.md | 2 +- docs/IStaking20.md | 2 +- docs/IStaking721.md | 2 +- docs/ReentrancyGuardStorage.md | 2 +- docs/Router.md | 251 +---------------------- docs/Staking1155Base.md | 2 +- docs/TWStringSet.md | 2 +- docs/TokenERC1155.md | 103 +++++++++- 35 files changed, 193 insertions(+), 468 deletions(-) diff --git a/contracts/base/ERC1155Base.sol b/contracts/base/ERC1155Base.sol index dbaf27f86..79276e5b7 100644 --- a/contracts/base/ERC1155Base.sol +++ b/contracts/base/ERC1155Base.sol @@ -246,6 +246,7 @@ contract ERC1155Base is /// @dev See {ERC1155-setApprovalForAll} function setApprovalForAll(address operator, bool approved) public + virtual override(ERC1155) onlyAllowedOperatorApproval(operator) { @@ -261,7 +262,7 @@ contract ERC1155Base is uint256 id, uint256 amount, bytes memory data - ) public override(ERC1155) onlyAllowedOperator(from) { + ) public virtual override(ERC1155) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, id, amount, data); } @@ -274,7 +275,7 @@ contract ERC1155Base is uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) public override(ERC1155) onlyAllowedOperator(from) { + ) public virtual override(ERC1155) onlyAllowedOperator(from) { super.safeBatchTransferFrom(from, to, ids, amounts, data); } diff --git a/contracts/base/ERC1155DelayedReveal.sol b/contracts/base/ERC1155DelayedReveal.sol index 7c4f87a5b..40f165cc6 100644 --- a/contracts/base/ERC1155DelayedReveal.sol +++ b/contracts/base/ERC1155DelayedReveal.sol @@ -48,7 +48,7 @@ contract ERC1155DelayedReveal is ERC1155LazyMint, DelayedReveal { * * @param _tokenId The tokenId of an NFT. */ - function uri(uint256 _tokenId) public view override returns (string memory) { + function uri(uint256 _tokenId) public view virtual override returns (string memory) { (uint256 batchId, ) = _getBatchId(_tokenId); string memory batchUri = _getBaseURI(_tokenId); diff --git a/contracts/base/ERC1155Drop.sol b/contracts/base/ERC1155Drop.sol index 52e5f9671..b17606f16 100644 --- a/contracts/base/ERC1155Drop.sol +++ b/contracts/base/ERC1155Drop.sol @@ -228,6 +228,7 @@ contract ERC1155Drop is /// @dev See {ERC1155-setApprovalForAll} function setApprovalForAll(address operator, bool approved) public + virtual override(ERC1155) onlyAllowedOperatorApproval(operator) { @@ -243,7 +244,7 @@ contract ERC1155Drop is uint256 id, uint256 amount, bytes memory data - ) public override(ERC1155) onlyAllowedOperator(from) { + ) public virtual override(ERC1155) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, id, amount, data); } @@ -256,7 +257,7 @@ contract ERC1155Drop is uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) public override(ERC1155) onlyAllowedOperator(from) { + ) public virtual override(ERC1155) onlyAllowedOperator(from) { super.safeBatchTransferFrom(from, to, ids, amounts, data); } diff --git a/contracts/base/ERC1155LazyMint.sol b/contracts/base/ERC1155LazyMint.sol index 87faaba11..7cd741e9e 100644 --- a/contracts/base/ERC1155LazyMint.sol +++ b/contracts/base/ERC1155LazyMint.sol @@ -122,7 +122,7 @@ contract ERC1155LazyMint is address _receiver, uint256 _tokenId, uint256 _quantity - ) public payable nonReentrant { + ) public payable virtual nonReentrant { require(_tokenId < nextTokenIdToMint(), "invalid id"); verifyClaim(msg.sender, _tokenId, _quantity); // Add your claim verification logic by overriding this function. @@ -219,6 +219,7 @@ contract ERC1155LazyMint is /// @dev See {ERC1155-setApprovalForAll} function setApprovalForAll(address operator, bool approved) public + virtual override(ERC1155) onlyAllowedOperatorApproval(operator) { @@ -234,7 +235,7 @@ contract ERC1155LazyMint is uint256 id, uint256 amount, bytes memory data - ) public override(ERC1155) onlyAllowedOperator(from) { + ) public virtual override(ERC1155) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, id, amount, data); } @@ -247,7 +248,7 @@ contract ERC1155LazyMint is uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) public override(ERC1155) onlyAllowedOperator(from) { + ) public virtual override(ERC1155) onlyAllowedOperator(from) { super.safeBatchTransferFrom(from, to, ids, amounts, data); } diff --git a/contracts/base/ERC721Base.sol b/contracts/base/ERC721Base.sol index 8bb31d0f3..525df3838 100644 --- a/contracts/base/ERC721Base.sol +++ b/contracts/base/ERC721Base.sol @@ -172,6 +172,7 @@ contract ERC721Base is /// @dev See {ERC721-setApprovalForAll}. function setApprovalForAll(address operator, bool approved) public + virtual override(ERC721A) onlyAllowedOperatorApproval(operator) { @@ -179,7 +180,12 @@ contract ERC721Base is } /// @dev See {ERC721-approve}. - function approve(address operator, uint256 tokenId) public override(ERC721A) onlyAllowedOperatorApproval(operator) { + function approve(address operator, uint256 tokenId) + public + virtual + override(ERC721A) + onlyAllowedOperatorApproval(operator) + { super.approve(operator, tokenId); } @@ -188,7 +194,7 @@ contract ERC721Base is address from, address to, uint256 tokenId - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.transferFrom(from, to, tokenId); } @@ -197,7 +203,7 @@ contract ERC721Base is address from, address to, uint256 tokenId - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId); } @@ -207,7 +213,7 @@ contract ERC721Base is address to, uint256 tokenId, bytes memory data - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId, data); } diff --git a/contracts/base/ERC721DelayedReveal.sol b/contracts/base/ERC721DelayedReveal.sol index bb7167dd9..0b0ca6e4e 100644 --- a/contracts/base/ERC721DelayedReveal.sol +++ b/contracts/base/ERC721DelayedReveal.sol @@ -49,7 +49,7 @@ contract ERC721DelayedReveal is ERC721LazyMint, DelayedReveal { * * @param _tokenId The tokenId of an NFT. */ - function tokenURI(uint256 _tokenId) public view override returns (string memory) { + function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { (uint256 batchId, ) = _getBatchId(_tokenId); string memory batchUri = _getBaseURI(_tokenId); @@ -77,7 +77,7 @@ contract ERC721DelayedReveal is ERC721LazyMint, DelayedReveal { uint256 _amount, string calldata _baseURIForTokens, bytes calldata _data - ) public override returns (uint256 batchId) { + ) public virtual override returns (uint256 batchId) { if (_data.length > 0) { (bytes memory encryptedURI, bytes32 provenanceHash) = abi.decode(_data, (bytes, bytes32)); if (encryptedURI.length != 0 && provenanceHash != "") { diff --git a/contracts/base/ERC721Drop.sol b/contracts/base/ERC721Drop.sol index 314e8a424..49423ce6a 100644 --- a/contracts/base/ERC721Drop.sol +++ b/contracts/base/ERC721Drop.sol @@ -125,7 +125,7 @@ contract ERC721Drop is uint256 _amount, string calldata _baseURIForTokens, bytes calldata _data - ) public override returns (uint256 batchId) { + ) public virtual override returns (uint256 batchId) { if (_data.length > 0) { (bytes memory encryptedURI, bytes32 provenanceHash) = abi.decode(_data, (bytes, bytes32)); if (encryptedURI.length != 0 && provenanceHash != "") { @@ -189,6 +189,7 @@ contract ERC721Drop is /// @dev See {ERC721-setApprovalForAll}. function setApprovalForAll(address operator, bool approved) public + virtual override(ERC721A) onlyAllowedOperatorApproval(operator) { @@ -196,7 +197,12 @@ contract ERC721Drop is } /// @dev See {ERC721-approve}. - function approve(address operator, uint256 tokenId) public override(ERC721A) onlyAllowedOperatorApproval(operator) { + function approve(address operator, uint256 tokenId) + public + virtual + override(ERC721A) + onlyAllowedOperatorApproval(operator) + { super.approve(operator, tokenId); } @@ -205,7 +211,7 @@ contract ERC721Drop is address from, address to, uint256 tokenId - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.transferFrom(from, to, tokenId); } @@ -214,7 +220,7 @@ contract ERC721Drop is address from, address to, uint256 tokenId - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId); } @@ -224,7 +230,7 @@ contract ERC721Drop is address to, uint256 tokenId, bytes memory data - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId, data); } diff --git a/contracts/base/ERC721LazyMint.sol b/contracts/base/ERC721LazyMint.sol index ade72db8a..29fa59742 100644 --- a/contracts/base/ERC721LazyMint.sol +++ b/contracts/base/ERC721LazyMint.sol @@ -119,7 +119,7 @@ contract ERC721LazyMint is * @param _receiver The recipient of the NFT to mint. * @param _quantity The number of NFTs to mint. */ - function claim(address _receiver, uint256 _quantity) public payable nonReentrant { + function claim(address _receiver, uint256 _quantity) public payable virtual nonReentrant { require(_currentIndex + _quantity <= nextTokenIdToLazyMint, "Not enough lazy minted tokens."); verifyClaim(msg.sender, _quantity); // Add your claim verification logic by overriding this function. @@ -165,6 +165,7 @@ contract ERC721LazyMint is /// @dev See {ERC721-setApprovalForAll}. function setApprovalForAll(address operator, bool approved) public + virtual override(ERC721A) onlyAllowedOperatorApproval(operator) { @@ -172,7 +173,12 @@ contract ERC721LazyMint is } /// @dev See {ERC721-approve}. - function approve(address operator, uint256 tokenId) public override(ERC721A) onlyAllowedOperatorApproval(operator) { + function approve(address operator, uint256 tokenId) + public + virtual + override(ERC721A) + onlyAllowedOperatorApproval(operator) + { super.approve(operator, tokenId); } @@ -181,7 +187,7 @@ contract ERC721LazyMint is address from, address to, uint256 tokenId - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.transferFrom(from, to, tokenId); } @@ -190,7 +196,7 @@ contract ERC721LazyMint is address from, address to, uint256 tokenId - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId); } @@ -200,7 +206,7 @@ contract ERC721LazyMint is address to, uint256 tokenId, bytes memory data - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId, data); } diff --git a/contracts/base/ERC721Multiwrap.sol b/contracts/base/ERC721Multiwrap.sol index 55438d38d..058c6d1ee 100644 --- a/contracts/base/ERC721Multiwrap.sol +++ b/contracts/base/ERC721Multiwrap.sol @@ -128,7 +128,7 @@ contract ERC721Multiwrap is //////////////////////////////////////////////////////////////*/ /// @dev Returns the URI for a given tokenId. - function tokenURI(uint256 _tokenId) public view override returns (string memory) { + function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { return getUriOfBundle(_tokenId); } @@ -210,6 +210,7 @@ contract ERC721Multiwrap is /// @dev See {ERC721-setApprovalForAll}. function setApprovalForAll(address operator, bool approved) public + virtual override(ERC721A) onlyAllowedOperatorApproval(operator) { @@ -217,7 +218,12 @@ contract ERC721Multiwrap is } /// @dev See {ERC721-approve}. - function approve(address operator, uint256 tokenId) public override(ERC721A) onlyAllowedOperatorApproval(operator) { + function approve(address operator, uint256 tokenId) + public + virtual + override(ERC721A) + onlyAllowedOperatorApproval(operator) + { super.approve(operator, tokenId); } @@ -226,7 +232,7 @@ contract ERC721Multiwrap is address from, address to, uint256 tokenId - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.transferFrom(from, to, tokenId); } @@ -235,7 +241,7 @@ contract ERC721Multiwrap is address from, address to, uint256 tokenId - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId); } @@ -245,7 +251,7 @@ contract ERC721Multiwrap is address to, uint256 tokenId, bytes memory data - ) public override(ERC721A) onlyAllowedOperator(from) { + ) public virtual override(ERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId, data); } diff --git a/contracts/base/Staking1155Base.sol b/contracts/base/Staking1155Base.sol index e5481ecfc..5efa1deb7 100644 --- a/contracts/base/Staking1155Base.sol +++ b/contracts/base/Staking1155Base.sol @@ -74,12 +74,12 @@ contract Staking1155Base is ContractMetadata, Multicall, Ownable, Staking1155, E } /// @dev Admin deposits reward tokens. - function depositRewardTokens(uint256 _amount) external payable nonReentrant { + function depositRewardTokens(uint256 _amount) external payable virtual nonReentrant { _depositRewardTokens(_amount); // override this for custom logic. } /// @dev Admin can withdraw excess reward tokens. - function withdrawRewardTokens(uint256 _amount) external nonReentrant { + function withdrawRewardTokens(uint256 _amount) external virtual nonReentrant { _withdrawRewardTokens(_amount); // override this for custom logic. } @@ -98,7 +98,7 @@ contract Staking1155Base is ContractMetadata, Multicall, Ownable, Staking1155, E uint256, uint256, bytes calldata - ) external returns (bytes4) { + ) external view returns (bytes4) { require(isStaking == 2, "Direct transfer"); return this.onERC1155Received.selector; } @@ -109,7 +109,7 @@ contract Staking1155Base is ContractMetadata, Multicall, Ownable, Staking1155, E uint256[] calldata ids, uint256[] calldata values, bytes calldata data - ) external returns (bytes4) {} + ) external virtual returns (bytes4) {} function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); diff --git a/contracts/base/Staking20Base.sol b/contracts/base/Staking20Base.sol index cb45a3e86..0b5063dfa 100644 --- a/contracts/base/Staking20Base.sol +++ b/contracts/base/Staking20Base.sol @@ -78,12 +78,12 @@ contract Staking20Base is ContractMetadata, Multicall, Ownable, Staking20 { } /// @dev Admin deposits reward tokens. - function depositRewardTokens(uint256 _amount) external payable nonReentrant { + function depositRewardTokens(uint256 _amount) external payable virtual nonReentrant { _depositRewardTokens(_amount); // override this for custom logic. } /// @dev Admin can withdraw excess reward tokens. - function withdrawRewardTokens(uint256 _amount) external nonReentrant { + function withdrawRewardTokens(uint256 _amount) external virtual nonReentrant { _withdrawRewardTokens(_amount); // override this for custom logic. } diff --git a/contracts/base/Staking721Base.sol b/contracts/base/Staking721Base.sol index b6cb0e1e0..24a3a6ed8 100644 --- a/contracts/base/Staking721Base.sol +++ b/contracts/base/Staking721Base.sol @@ -74,12 +74,12 @@ contract Staking721Base is ContractMetadata, Multicall, Ownable, Staking721, ERC } /// @dev Admin deposits reward tokens. - function depositRewardTokens(uint256 _amount) external payable nonReentrant { + function depositRewardTokens(uint256 _amount) external payable virtual nonReentrant { _depositRewardTokens(_amount); // override this for custom logic. } /// @dev Admin can withdraw excess reward tokens. - function withdrawRewardTokens(uint256 _amount) external nonReentrant { + function withdrawRewardTokens(uint256 _amount) external virtual nonReentrant { _withdrawRewardTokens(_amount); // override this for custom logic. } diff --git a/docs/ERC2771ContextStorage.md b/docs/ERC2771ContextStorage.md index 536f732cb..5f9991358 100644 --- a/docs/ERC2771ContextStorage.md +++ b/docs/ERC2771ContextStorage.md @@ -1,6 +1,6 @@ # ERC2771ContextStorage - +*thirdweb* diff --git a/docs/ERC2771ContextUpgradeableStorage.md b/docs/ERC2771ContextUpgradeableStorage.md index cae4aad6a..7eb706458 100644 --- a/docs/ERC2771ContextUpgradeableStorage.md +++ b/docs/ERC2771ContextUpgradeableStorage.md @@ -1,6 +1,6 @@ # ERC2771ContextUpgradeableStorage - +*thirdweb* diff --git a/docs/FeeType.md b/docs/FeeType.md index 6950fdc30..ee1cb1ef3 100644 --- a/docs/FeeType.md +++ b/docs/FeeType.md @@ -1,6 +1,6 @@ # FeeType - +*thirdweb* diff --git a/docs/IBurnableERC20.md b/docs/IBurnableERC20.md index b5af8b61d..762c19474 100644 --- a/docs/IBurnableERC20.md +++ b/docs/IBurnableERC20.md @@ -1,6 +1,6 @@ # IBurnableERC20 - +*thirdweb* diff --git a/docs/IBurnableERC721.md b/docs/IBurnableERC721.md index 9c431bc2b..b564d392c 100644 --- a/docs/IBurnableERC721.md +++ b/docs/IBurnableERC721.md @@ -1,6 +1,6 @@ # IBurnableERC721 - +*thirdweb* diff --git a/docs/IClaimableERC1155.md b/docs/IClaimableERC1155.md index fc6c93379..806429a34 100644 --- a/docs/IClaimableERC1155.md +++ b/docs/IClaimableERC1155.md @@ -1,6 +1,6 @@ # IClaimableERC1155 - +*thirdweb* diff --git a/docs/IClaimableERC721.md b/docs/IClaimableERC721.md index b7a7f6d65..faffaeeb6 100644 --- a/docs/IClaimableERC721.md +++ b/docs/IClaimableERC721.md @@ -1,6 +1,6 @@ # IClaimableERC721 - +*thirdweb* diff --git a/docs/IContext.md b/docs/IContext.md index 01885894f..9852da068 100644 --- a/docs/IContext.md +++ b/docs/IContext.md @@ -1,6 +1,6 @@ # IContext - +*thirdweb* diff --git a/docs/IContractFactory.md b/docs/IContractFactory.md index 27a06469f..85d122144 100644 --- a/docs/IContractFactory.md +++ b/docs/IContractFactory.md @@ -1,6 +1,6 @@ # IContractFactory - +*thirdweb* diff --git a/docs/IMintableERC20.md b/docs/IMintableERC20.md index f85577b59..57e40d8c6 100644 --- a/docs/IMintableERC20.md +++ b/docs/IMintableERC20.md @@ -1,6 +1,6 @@ # IMintableERC20 - +*thirdweb* diff --git a/docs/IMintableERC721.md b/docs/IMintableERC721.md index 8d6e53364..5536df0c9 100644 --- a/docs/IMintableERC721.md +++ b/docs/IMintableERC721.md @@ -1,6 +1,6 @@ # IMintableERC721 - +*thirdweb* diff --git a/docs/IOperatorFilterRegistry.md b/docs/IOperatorFilterRegistry.md index 88e0762dd..bd8addba3 100644 --- a/docs/IOperatorFilterRegistry.md +++ b/docs/IOperatorFilterRegistry.md @@ -1,6 +1,6 @@ # IOperatorFilterRegistry - +*thirdweb* diff --git a/docs/IOperatorFilterToggle.md b/docs/IOperatorFilterToggle.md index 0c0691745..06ad7d13a 100644 --- a/docs/IOperatorFilterToggle.md +++ b/docs/IOperatorFilterToggle.md @@ -1,6 +1,6 @@ # IOperatorFilterToggle - +*thirdweb* diff --git a/docs/IPluginMap.md b/docs/IPluginMap.md index 12e9bb2e1..c13c4b6b5 100644 --- a/docs/IPluginMap.md +++ b/docs/IPluginMap.md @@ -1,6 +1,6 @@ # IPluginMap - +*thirdweb* diff --git a/docs/IRouter.md b/docs/IRouter.md index 4a18986a5..57f12aa37 100644 --- a/docs/IRouter.md +++ b/docs/IRouter.md @@ -10,10 +10,10 @@ ## Methods -### addPlugin +### getImplementationForFunction ```solidity -function addPlugin(IPluginMap.Plugin plugin) external nonpayable +function getImplementationForFunction(bytes4 _functionSelector) external view returns (address) ``` @@ -24,62 +24,7 @@ function addPlugin(IPluginMap.Plugin plugin) external nonpayable | Name | Type | Description | |---|---|---| -| plugin | IPluginMap.Plugin | undefined | - -### getAllFunctionsOfPlugin - -```solidity -function getAllFunctionsOfPlugin(address pluginAddress) external view returns (bytes4[]) -``` - - - -*Returns all functions that are mapped to the given plug-in contract.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| pluginAddress | address | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bytes4[] | undefined | - -### getAllPlugins - -```solidity -function getAllPlugins() external view returns (struct IPluginMap.Plugin[]) -``` - - - -*Returns all plug-ins known by Map.* - - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | IPluginMap.Plugin[] | undefined | - -### getPluginForFunction - -```solidity -function getPluginForFunction(bytes4 functionSelector) external view returns (address) -``` - - - -*Returns the plug-in contract for a given function.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector | bytes4 | undefined | +| _functionSelector | bytes4 | undefined | #### Returns @@ -87,111 +32,6 @@ function getPluginForFunction(bytes4 functionSelector) external view returns (ad |---|---|---| | _0 | address | undefined | -### removePlugin - -```solidity -function removePlugin(bytes4 functionSelector) external nonpayable -``` - - - -*Remove an existing plugin from the contract.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector | bytes4 | undefined | - -### updatePlugin - -```solidity -function updatePlugin(IPluginMap.Plugin plugin) external nonpayable -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| plugin | IPluginMap.Plugin | undefined | - - - -## Events - -### PluginAdded - -```solidity -event PluginAdded(bytes4 indexed functionSelector, address indexed pluginAddress) -``` - - - -*Emitted when a functionality is added, or plugged-in.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector `indexed` | bytes4 | undefined | -| pluginAddress `indexed` | address | undefined | - -### PluginRemoved - -```solidity -event PluginRemoved(bytes4 indexed functionSelector, address indexed pluginAddress) -``` - - - -*Emitted when a functionality is removed.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector `indexed` | bytes4 | undefined | -| pluginAddress `indexed` | address | undefined | - -### PluginSet - -```solidity -event PluginSet(bytes4 indexed functionSelector, string indexed functionSignature, address indexed pluginAddress) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector `indexed` | bytes4 | undefined | -| functionSignature `indexed` | string | undefined | -| pluginAddress `indexed` | address | undefined | - -### PluginUpdated - -```solidity -event PluginUpdated(bytes4 indexed functionSelector, address indexed oldPluginAddress, address indexed newPluginAddress) -``` - - - -*Emitted when a functionality is updated or overridden.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector `indexed` | bytes4 | undefined | -| oldPluginAddress `indexed` | address | undefined | -| newPluginAddress `indexed` | address | undefined | diff --git a/docs/IStaking1155.md b/docs/IStaking1155.md index 19d844442..f2bc5f813 100644 --- a/docs/IStaking1155.md +++ b/docs/IStaking1155.md @@ -1,6 +1,6 @@ # IStaking1155 - +*thirdweb* diff --git a/docs/IStaking20.md b/docs/IStaking20.md index 6fd48ac89..e3690617b 100644 --- a/docs/IStaking20.md +++ b/docs/IStaking20.md @@ -1,6 +1,6 @@ # IStaking20 - +*thirdweb* diff --git a/docs/IStaking721.md b/docs/IStaking721.md index 3b96cb097..782e07fd6 100644 --- a/docs/IStaking721.md +++ b/docs/IStaking721.md @@ -1,6 +1,6 @@ # IStaking721 - +*thirdweb* diff --git a/docs/ReentrancyGuardStorage.md b/docs/ReentrancyGuardStorage.md index 95ef24a6a..79c896a9e 100644 --- a/docs/ReentrancyGuardStorage.md +++ b/docs/ReentrancyGuardStorage.md @@ -1,6 +1,6 @@ # ReentrancyGuardStorage - +*thirdweb* diff --git a/docs/Router.md b/docs/Router.md index b78213038..969c27d01 100644 --- a/docs/Router.md +++ b/docs/Router.md @@ -10,21 +10,21 @@ ## Methods -### _getPluginForFunction +### getImplementationForFunction ```solidity -function _getPluginForFunction(bytes4 _selector) external view returns (address) +function getImplementationForFunction(bytes4 _functionSelector) external view returns (address) ``` -*View address of the plugged-in functionality contract for a given function signature.* +*Unimplemented. Returns the implementation contract address for a given function signature.* #### Parameters | Name | Type | Description | |---|---|---| -| _selector | bytes4 | undefined | +| _functionSelector | bytes4 | undefined | #### Returns @@ -32,249 +32,6 @@ function _getPluginForFunction(bytes4 _selector) external view returns (address) |---|---|---| | _0 | address | undefined | -### addPlugin - -```solidity -function addPlugin(IPluginMap.Plugin _plugin) external nonpayable -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _plugin | IPluginMap.Plugin | undefined | - -### getAllFunctionsOfPlugin - -```solidity -function getAllFunctionsOfPlugin(address _pluginAddress) external view returns (bytes4[] registered) -``` - - - -*View all funtionality as list of function signatures.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _pluginAddress | address | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| registered | bytes4[] | undefined | - -### getAllPlugins - -```solidity -function getAllPlugins() external view returns (struct IPluginMap.Plugin[] registered) -``` - - - -*View all funtionality existing on the contract.* - - -#### Returns - -| Name | Type | Description | -|---|---|---| -| registered | IPluginMap.Plugin[] | undefined | - -### getPluginForFunction - -```solidity -function getPluginForFunction(bytes4 _selector) external view returns (address) -``` - - - -*View address of the plugged-in functionality contract for a given function signature.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _selector | bytes4 | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### multicall - -```solidity -function multicall(bytes[] data) external nonpayable returns (bytes[] results) -``` - -Receives and executes a batch of function calls on this contract. - -*Receives and executes a batch of function calls on this contract.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| data | bytes[] | The bytes data that makes up the batch of function calls to execute. | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| results | bytes[] | The bytes data that makes up the result of the batch of function calls executed. | - -### pluginMap - -```solidity -function pluginMap() external view returns (address) -``` - - - - - - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### removePlugin - -```solidity -function removePlugin(bytes4 _selector) external nonpayable -``` - - - -*Remove existing functionality from the contract.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _selector | bytes4 | undefined | - -### supportsInterface - -```solidity -function supportsInterface(bytes4 interfaceId) external view returns (bool) -``` - - - -*See {IERC165-supportsInterface}.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| interfaceId | bytes4 | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bool | undefined | - -### updatePlugin - -```solidity -function updatePlugin(IPluginMap.Plugin _plugin) external nonpayable -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _plugin | IPluginMap.Plugin | undefined | - - - -## Events - -### PluginAdded - -```solidity -event PluginAdded(bytes4 indexed functionSelector, address indexed pluginAddress) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector `indexed` | bytes4 | undefined | -| pluginAddress `indexed` | address | undefined | - -### PluginRemoved - -```solidity -event PluginRemoved(bytes4 indexed functionSelector, address indexed pluginAddress) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector `indexed` | bytes4 | undefined | -| pluginAddress `indexed` | address | undefined | - -### PluginSet - -```solidity -event PluginSet(bytes4 indexed functionSelector, string indexed functionSignature, address indexed pluginAddress) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector `indexed` | bytes4 | undefined | -| functionSignature `indexed` | string | undefined | -| pluginAddress `indexed` | address | undefined | - -### PluginUpdated - -```solidity -event PluginUpdated(bytes4 indexed functionSelector, address indexed oldPluginAddress, address indexed newPluginAddress) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| functionSelector `indexed` | bytes4 | undefined | -| oldPluginAddress `indexed` | address | undefined | -| newPluginAddress `indexed` | address | undefined | diff --git a/docs/Staking1155Base.md b/docs/Staking1155Base.md index 82b0d1069..b639864c7 100644 --- a/docs/Staking1155Base.md +++ b/docs/Staking1155Base.md @@ -297,7 +297,7 @@ function onERC1155BatchReceived(address operator, address from, uint256[] ids, u ### onERC1155Received ```solidity -function onERC1155Received(address, address, uint256, uint256, bytes) external nonpayable returns (bytes4) +function onERC1155Received(address, address, uint256, uint256, bytes) external view returns (bytes4) ``` diff --git a/docs/TWStringSet.md b/docs/TWStringSet.md index dbfcfd54c..01f709651 100644 --- a/docs/TWStringSet.md +++ b/docs/TWStringSet.md @@ -1,6 +1,6 @@ # TWStringSet - +*thirdweb* diff --git a/docs/TokenERC1155.md b/docs/TokenERC1155.md index 3fb3f2df2..9a50c1bb0 100644 --- a/docs/TokenERC1155.md +++ b/docs/TokenERC1155.md @@ -168,7 +168,7 @@ function getDefaultRoyaltyInfo() external view returns (address, uint16) -*Returns the platform fee bps and recipient.* +*Returns default royalty info.* #### Returns @@ -178,6 +178,24 @@ function getDefaultRoyaltyInfo() external view returns (address, uint16) | _0 | address | undefined | | _1 | uint16 | undefined | +### getFlatPlatformFeeInfo + +```solidity +function getFlatPlatformFeeInfo() external view returns (address, uint256) +``` + + + +*Returns the flat platform fee and recipient.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | uint256 | undefined | + ### getPlatformFeeInfo ```solidity @@ -196,6 +214,23 @@ function getPlatformFeeInfo() external view returns (address, uint16) | _0 | address | undefined | | _1 | uint16 | undefined | +### getPlatformFeeType + +```solidity +function getPlatformFeeType() external view returns (enum TokenERC1155.PlatformFeeType) +``` + + + +*Returns the platform fee type.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | enum TokenERC1155.PlatformFeeType | undefined | + ### getRoleAdmin ```solidity @@ -726,6 +761,23 @@ function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) e | _royaltyRecipient | address | undefined | | _royaltyBps | uint256 | undefined | +### setFlatPlatformFeeInfo + +```solidity +function setFlatPlatformFeeInfo(address _platformFeeRecipient, uint256 _flatFee) external nonpayable +``` + + + +*Lets a module admin set a flat fee on primary sales.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _platformFeeRecipient | address | undefined | +| _flatFee | uint256 | undefined | + ### setOperatorRestriction ```solidity @@ -775,6 +827,22 @@ function setPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeB | _platformFeeRecipient | address | undefined | | _platformFeeBps | uint256 | undefined | +### setPlatformFeeType + +```solidity +function setPlatformFeeType(enum TokenERC1155.PlatformFeeType _feeType) external nonpayable +``` + + + +*Lets a module admin set a flat fee on primary sales.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _feeType | enum TokenERC1155.PlatformFeeType | undefined | + ### setPrimarySaleRecipient ```solidity @@ -955,6 +1023,23 @@ event DefaultRoyalty(address indexed newRoyaltyRecipient, uint256 newRoyaltyBps) | newRoyaltyRecipient `indexed` | address | undefined | | newRoyaltyBps | uint256 | undefined | +### FlatPlatformFeeUpdated + +```solidity +event FlatPlatformFeeUpdated(address platformFeeRecipient, uint256 flatFee) +``` + + + +*Emitted when flat fee on primary sales is updated.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| platformFeeRecipient | address | undefined | +| flatFee | uint256 | undefined | + ### Initialized ```solidity @@ -1021,6 +1106,22 @@ event PlatformFeeInfoUpdated(address indexed platformFeeRecipient, uint256 platf | platformFeeRecipient `indexed` | address | undefined | | platformFeeBps | uint256 | undefined | +### PlatformFeeTypeUpdated + +```solidity +event PlatformFeeTypeUpdated(enum TokenERC1155.PlatformFeeType feeType) +``` + + + +*Emitted when platform fee type is updated.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| feeType | enum TokenERC1155.PlatformFeeType | undefined | + ### PrimarySaleRecipientUpdated ```solidity From 75fe1df72cb6c45547d4ddaf427ddd62357d23c0 Mon Sep 17 00:00:00 2001 From: Krishang Date: Tue, 28 Feb 2023 12:24:47 -0800 Subject: [PATCH 2/4] pkg update --- contracts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/package.json b/contracts/package.json index ee2981a99..3a7f9a02f 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.4.2", + "version": "3.4.3", "license": "Apache-2.0", "repository": { "type": "git", From 6b450fbd79b73b753d2583258e05a2b1b49f6a12 Mon Sep 17 00:00:00 2001 From: Krishang Date: Thu, 9 Mar 2023 14:49:31 -0500 Subject: [PATCH 3/4] Make MAX_BPS private in Marketplace plugins --- contracts/marketplace/direct-listings/DirectListingsLogic.sol | 2 +- contracts/marketplace/english-auctions/EnglishAuctionsLogic.sol | 2 +- contracts/marketplace/offers/OffersLogic.sol | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/marketplace/direct-listings/DirectListingsLogic.sol b/contracts/marketplace/direct-listings/DirectListingsLogic.sol index a1e83ac32..aa5e04f65 100644 --- a/contracts/marketplace/direct-listings/DirectListingsLogic.sol +++ b/contracts/marketplace/direct-listings/DirectListingsLogic.sol @@ -33,7 +33,7 @@ contract DirectListingsLogic is IDirectListings, ReentrancyGuardLogic, ERC2771Co bytes32 private constant ASSET_ROLE = keccak256("ASSET_ROLE"); /// @dev The max bps of the contract. So, 10_000 == 100 % - uint64 public constant MAX_BPS = 10_000; + uint64 private constant MAX_BPS = 10_000; /// @dev The address of the native token wrapper contract. address private immutable nativeTokenWrapper; diff --git a/contracts/marketplace/english-auctions/EnglishAuctionsLogic.sol b/contracts/marketplace/english-auctions/EnglishAuctionsLogic.sol index b6598077d..8d0509d9a 100644 --- a/contracts/marketplace/english-auctions/EnglishAuctionsLogic.sol +++ b/contracts/marketplace/english-auctions/EnglishAuctionsLogic.sol @@ -37,7 +37,7 @@ contract EnglishAuctionsLogic is IEnglishAuctions, ReentrancyGuardLogic, ERC2771 bytes32 private constant ASSET_ROLE = keccak256("ASSET_ROLE"); /// @dev The max bps of the contract. So, 10_000 == 100 % - uint64 public constant MAX_BPS = 10_000; + uint64 private constant MAX_BPS = 10_000; /// @dev The address of the native token wrapper contract. address private immutable nativeTokenWrapper; diff --git a/contracts/marketplace/offers/OffersLogic.sol b/contracts/marketplace/offers/OffersLogic.sol index 5138f78ac..764cc0c72 100644 --- a/contracts/marketplace/offers/OffersLogic.sol +++ b/contracts/marketplace/offers/OffersLogic.sol @@ -34,7 +34,7 @@ contract OffersLogic is IOffers, ReentrancyGuardLogic, ERC2771ContextConsumer { bytes32 private constant ASSET_ROLE = keccak256("ASSET_ROLE"); /// @dev The max bps of the contract. So, 10_000 == 100 % - uint64 public constant MAX_BPS = 10_000; + uint64 private constant MAX_BPS = 10_000; /*/////////////////////////////////////////////////////////////// Modifiers From f9dec5349eed651c77cb6b9fc3c6bf4d79abc362 Mon Sep 17 00:00:00 2001 From: Krishang Date: Tue, 18 Apr 2023 12:35:46 -0400 Subject: [PATCH 4/4] Emit salt in AccountCreated --- contracts/smart-wallet/TWAccountFactory.sol | 2 +- contracts/smart-wallet/TWDynamicAccountFactory.sol | 2 +- contracts/smart-wallet/interfaces/ITWAccountFactory.sol | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/smart-wallet/TWAccountFactory.sol b/contracts/smart-wallet/TWAccountFactory.sol index 2e863da6c..e1ad285c3 100644 --- a/contracts/smart-wallet/TWAccountFactory.sol +++ b/contracts/smart-wallet/TWAccountFactory.sol @@ -36,7 +36,7 @@ contract TWAccountFactory is ITWAccountFactory, Multicall { TWAccount(payable(account)).initialize(_admin); - emit AccountCreated(account, _admin); + emit AccountCreated(account, _admin, _salt); return account; } diff --git a/contracts/smart-wallet/TWDynamicAccountFactory.sol b/contracts/smart-wallet/TWDynamicAccountFactory.sol index 39bdeb9d5..93c88ee83 100644 --- a/contracts/smart-wallet/TWDynamicAccountFactory.sol +++ b/contracts/smart-wallet/TWDynamicAccountFactory.sol @@ -36,7 +36,7 @@ contract TWDynamicAccountFactory is ITWAccountFactory, Multicall { TWAccount(payable(account)).initialize(_admin); - emit AccountCreated(account, _admin); + emit AccountCreated(account, _admin, _salt); return account; } diff --git a/contracts/smart-wallet/interfaces/ITWAccountFactory.sol b/contracts/smart-wallet/interfaces/ITWAccountFactory.sol index afb17248b..aa72ccf80 100644 --- a/contracts/smart-wallet/interfaces/ITWAccountFactory.sol +++ b/contracts/smart-wallet/interfaces/ITWAccountFactory.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.12; interface ITWAccountFactory { - event AccountCreated(address indexed account, address indexed accountAdmin); + event AccountCreated(address indexed account, address indexed accountAdmin, bytes32 indexed salt); /// @notice Returns the address of the Account implementation. function accountImplementation() external view returns (address);