Pieces Protocol

First Flight #32
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

[L-1] Unused Error Declaration: `TokenDivier__InvalidAmount`

Summary

The contract declares an error TokenDivier__InvalidAmount, but it is never used within the code. This results in unnecessary code bloat and potential confusion for developers and auditors reviewing the contract.

@> error TokenDivier__InvalidAmount();
error TokenDivider__InvalidSeller();
error TokenDivider__TransferFailed();
error TokenDivider__NotFromNftOwner();
error TokenDivider__AmountCantBeZero();
error TokenDivider__NftAddressIsZero();
error TokenDivider__NftTransferFailed();
error TokenDivider__InsuficientBalance();
error TokenDivider__IncorrectEtherAmount();
error TokenDivider__NotEnoughErc20Balance();
error TokenDivider__InsuficientEtherForFees();
error TokenDivider__CantTransferToAddressZero();

Vulnerability Details

The error TokenDivier__InvalidAmount is defined but not utilized anywhere in the contract. However, a suitable place to implement it could be in functions where token amounts are checked, such as:

  • transferErcTokens: The contract currently checks if the amount is zero, but additional validation could be added to verify logical correctness.

    if (amount <= 0) {
    revert TokenDivier__InvalidAmount();
    }
  • sellErc20: Similar checks could be implemented to ensure valid amounts are provided.

By using this error in relevant locations, the contract can improve error reporting and avoid confusion.

Impact

  • Code Maintainability: Unused errors introduce unnecessary complexity and can mislead developers.

  • Gas Efficiency: Keeping unused code may slightly increase contract deployment costs.

  • Potential Logical Gaps: If the error was intended to be used, its absence might indicate a missing validation check.

Tools Used

  • Manual code review

  • Solidity static analysis tools

Recommendations

  1. Remove Unused Error: If the error is not needed, remove it to clean up the code.
    *

    - error TokenDivier__InvalidAmount();
  2. Implement Where Necessary: If amount validation is needed, apply the error in functions dealing with token transfers.

  3. Code Review: Conduct a thorough review to check if any other unused code exists.

Updates

Lead Judging Commences

fishy Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.