From 9daf22b8e4cde1990461ac843c3630b0c7639133 Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 25 Jul 2024 14:45:48 +0300 Subject: [PATCH 1/2] [Update] Merged code documentation --- contracts/factories/ERC20LockUpFactory.sol | 2 +- contracts/factories/ERC20PenaltyFeeFactory.sol | 4 ++-- contracts/factories/ERC721LockUpFactory.sol | 4 ++-- .../factories/ERC721PenaltyFeeFactory.sol | 4 ++-- contracts/factories/GenericFactory.sol | 2 +- contracts/interfaces/IRequestManager.sol | 16 ++++++++++++++++ contracts/mocks/ERC20MockToken.sol | 18 +++++++++++++++++- contracts/mocks/ERC721MockToken.sol | 11 ++++++++++- 8 files changed, 51 insertions(+), 10 deletions(-) diff --git a/contracts/factories/ERC20LockUpFactory.sol b/contracts/factories/ERC20LockUpFactory.sol index 84f4caa..2428925 100644 --- a/contracts/factories/ERC20LockUpFactory.sol +++ b/contracts/factories/ERC20LockUpFactory.sol @@ -53,7 +53,7 @@ contract ERC20LockUpStakingFactory is GenericFactory, ILockUpFactory { uint256 rewardAmount = (data.poolEndTime - data.poolStartTime) * data.rewardPerSecond; ERC20LockUpPool(newPoolAddress).transferOwnership(deployer); - // Transfer reward tokens from the owner to the contract + // Transfer reward tokens from the owner to the deployed pool contract // slither-disable-next-line arbitrary-send-erc20 IERC20(data.rewardToken).safeTransferFrom( deployer, diff --git a/contracts/factories/ERC20PenaltyFeeFactory.sol b/contracts/factories/ERC20PenaltyFeeFactory.sol index 497fd23..fe17718 100644 --- a/contracts/factories/ERC20PenaltyFeeFactory.sol +++ b/contracts/factories/ERC20PenaltyFeeFactory.sol @@ -1,5 +1,5 @@ /* -ERC20LockUpFactory +ERC20PenaltyFeeFactory SPDX-License-Identifier: MIT */ @@ -52,7 +52,7 @@ contract ERC20PenaltyFeeStakingFactory is GenericFactory, IPenaltyFeeFactory { uint256 rewardAmount = (data.poolEndTime - data.poolStartTime) * data.rewardPerSecond; ERC20PenaltyFeePool(newPoolAddress).transferOwnership(deployer); - // Transfer reward tokens from the owner to the contract + // Transfer reward tokens from the owner to the deployed pool contract // slither-disable-next-line arbitrary-send-erc20 IERC20(data.rewardToken).safeTransferFrom( deployer, diff --git a/contracts/factories/ERC721LockUpFactory.sol b/contracts/factories/ERC721LockUpFactory.sol index 63263a7..a07d46b 100644 --- a/contracts/factories/ERC721LockUpFactory.sol +++ b/contracts/factories/ERC721LockUpFactory.sol @@ -1,5 +1,5 @@ /* -ERC20LockUpFactory +ERC721LockUpFactory SPDX-License-Identifier: MIT */ @@ -52,7 +52,7 @@ contract ERC721LockUpStakingFactory is GenericFactory, ILockUpFactory { uint256 rewardAmount = (data.poolEndTime - data.poolStartTime) * data.rewardPerSecond; ERC721LockUpPool(newPoolAddress).transferOwnership(deployer); - // Transfer reward tokens from the owner to the contract + // Transfer reward tokens from the owner to the deployed pool contract // slither-disable-next-line arbitrary-send-erc20 IERC20(data.rewardToken).safeTransferFrom( deployer, diff --git a/contracts/factories/ERC721PenaltyFeeFactory.sol b/contracts/factories/ERC721PenaltyFeeFactory.sol index 12aa660..488fee8 100644 --- a/contracts/factories/ERC721PenaltyFeeFactory.sol +++ b/contracts/factories/ERC721PenaltyFeeFactory.sol @@ -1,5 +1,5 @@ /* -ERC20LockUpFactory +ERC721PenaltyFeeFactory SPDX-License-Identifier: MIT */ @@ -49,7 +49,7 @@ contract ERC721PenaltyFeeStakingFactory is GenericFactory, IPenaltyFeeFactory { uint256 rewardAmount = (data.poolEndTime - data.poolStartTime) * data.rewardPerSecond; ERC721PenaltyFeePool(newPoolAddress).transferOwnership(deployer); - // Transfer reward tokens from the owner to the contract + // Transfer reward tokens from the owner to the deployed pool contract // slither-disable-next-line arbitrary-send-erc20 IERC20(data.rewardToken).safeTransferFrom( deployer, diff --git a/contracts/factories/GenericFactory.sol b/contracts/factories/GenericFactory.sol index 412f03c..f43178f 100644 --- a/contracts/factories/GenericFactory.sol +++ b/contracts/factories/GenericFactory.sol @@ -16,7 +16,7 @@ abstract contract GenericFactory is Ownable, IGenericFactory { requestManager = managerContract; } - /// @notice Function allows admins to replace RequestManager contract's address in case of repdeployment + /// @notice Function allows admins to replace RequestManager contract's address in case of redeployment /// @param newManagerContract Address of the new RequestManager contract function updateManagerContract( address newManagerContract diff --git a/contracts/interfaces/IRequestManager.sol b/contracts/interfaces/IRequestManager.sol index 4cd02d7..0593566 100644 --- a/contracts/interfaces/IRequestManager.sol +++ b/contracts/interfaces/IRequestManager.sol @@ -27,16 +27,32 @@ interface IRequestManager { bytes stakingData; } + /** + * @notice Information about a staking pool request. + * @param requestStatus Current status of the request. + * @param data See {RequestPayload} above. + */ struct Request { Status requestStatus; RequestPayload data; } + /// @notice Thrown when an invalid ID is used. error InvalidId(); + + /// @notice Thrown when the request status is invalid. error InvalidRequestStatus(); + + /// @notice Thrown when the caller is not authorized. error InvalidDeployer(); + + /// @notice Thrown when the IPFS hash is zero. error IpfsZeroHash(); + + /// @notice Thrown when the token address is invalid. error InvalidAddress(); + + /// @notice Thrown when the {stakingData} payload param is emty. error EmptyPayload(); error UnregisteredFactory(); error AlreadyRegisteredFactory(); diff --git a/contracts/mocks/ERC20MockToken.sol b/contracts/mocks/ERC20MockToken.sol index ad87bec..11d75ee 100644 --- a/contracts/mocks/ERC20MockToken.sol +++ b/contracts/mocks/ERC20MockToken.sol @@ -4,9 +4,17 @@ pragma solidity 0.8.25; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; +/// @title ERC20MockToken +/// @notice A mock ERC20 token for testing purposes, with minting and burning capabilities controlled by the owner. +/// @dev Extends the OpenZeppelin ERC20 and Ownable contracts. contract ERC20MockToken is ERC20, Ownable { + /// @dev Custom decimal places for the mock token. uint8 private immutable _decimals; - + + /// @notice Constructor to initialize the mock token with a name, symbol, and decimals. + /// @param name The name of the token. + /// @param symbol The symbol of the token. + /// @param decimals_ The number of decimal places for the token. constructor( string memory name, string memory symbol, @@ -15,14 +23,22 @@ contract ERC20MockToken is ERC20, Ownable { _decimals = decimals_; } + /// @notice Mints new tokens to the specified account. + /// @param account The address of the account to mint tokens to. + /// @param amount The amount of tokens to mint. function mint(address account, uint256 amount) external onlyOwner { _mint(account, amount); } + /// @notice Burns tokens from the specified account. + /// @param account The address of the account to burn tokens from. + /// @param amount The amount of tokens to burn. function burn(address account, uint256 amount) external onlyOwner { _burn(account, amount); } + /// @notice Returns the number of decimals. + /// @return The number of decimals. function decimals() public view override returns (uint8) { return _decimals; } diff --git a/contracts/mocks/ERC721MockToken.sol b/contracts/mocks/ERC721MockToken.sol index ea569d8..2543cf1 100644 --- a/contracts/mocks/ERC721MockToken.sol +++ b/contracts/mocks/ERC721MockToken.sol @@ -4,14 +4,23 @@ pragma solidity 0.8.25; import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; +/// @title ERC721MockToken +/// @notice A mock ERC721 token for testing purposes, with minting capabilities controlled by the owner. +/// @dev Extends the OpenZeppelin ERC721 and Ownable contracts. contract ERC721MockToken is ERC721, Ownable { + /// @dev Counter for tracking the next token ID to be minted. uint256 private _nextTokenId; - + + /// @notice Constructor to initialize the mock token with a name and symbol. + /// @param name The name of the token. + /// @param symbol The symbol of the token. constructor( string memory name, string memory symbol ) ERC721(name, symbol) Ownable(msg.sender) {} + /// @notice Mints a new token to the specified address. + /// @param to The address to mint the token to. function safeMint(address to) public onlyOwner { uint256 tokenId = _nextTokenId++; _safeMint(to, tokenId); From ac8156f24ac4ade19afe10ed864c53f6adda3bf1 Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 25 Jul 2024 14:50:00 +0300 Subject: [PATCH 2/2] [Fix] Typo fix --- contracts/interfaces/IRequestManager.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/interfaces/IRequestManager.sol b/contracts/interfaces/IRequestManager.sol index 0593566..e16793e 100644 --- a/contracts/interfaces/IRequestManager.sol +++ b/contracts/interfaces/IRequestManager.sol @@ -52,7 +52,7 @@ interface IRequestManager { /// @notice Thrown when the token address is invalid. error InvalidAddress(); - /// @notice Thrown when the {stakingData} payload param is emty. + /// @notice Thrown when the {stakingData} payload param is empty. error EmptyPayload(); error UnregisteredFactory(); error AlreadyRegisteredFactory();