Omniscia MetaSoccer Audit
TokenWithdraw Code Style Findings
TokenWithdraw Code Style Findings
TWW-01C: Inefficient Usage of Dependency
Type | Severity | Location |
---|---|---|
Language Specific | TokenWithdraw.sol:L5, L16 |
Description:
The ERC20
& ERC721
contracts are imported to the codebase yet they are only used as interface
s.
Example:
contracts/TokenWithdraw.sol
4import "@openzeppelin/contracts/access/AccessControl.sol";5import "@openzeppelin/contracts/token/ERC20/ERC20.sol";6import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";7import "@openzeppelin/contracts/token/ERC721/ERC721.sol";8
9/**10 * @dev TokenWithdraw implementation11 *12 * Emergency functions to withdraw tokens13 *14 */15contract TokenWithdraw is AccessControl {16 using SafeERC20 for ERC20;17
18 constructor() {19 _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());20 }21
22 ///@dev Withdraw function to avoid locking tokens in the contract23 function withdrawERC20(ERC20 _token, uint256 _amount) external onlyRole(DEFAULT_ADMIN_ROLE) {24 _token.safeTransfer(msg.sender, _amount);25 }26
27 ///@dev Emergency method to withdraw NFT in case someone sends..28 function withdrawNFT(ERC721 _token, uint256 _tokenId) external onlyRole(DEFAULT_ADMIN_ROLE) {29 _token.safeTransferFrom(address(this), msg.sender, _tokenId);30 }31}
Recommendation:
We advise the IERC20
and IERC721
files to be imported instead, significantly reducing the bytecode size of the contract.
Alleviation:
The respective interfaces are now imported in the codebase and utilized instead of the full implementations optimizing the contract's bytecode.