Beginner FriendlyGameFi
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Redundant Logic in `has_claimed_slice` Function

Redundant Logic in has_claimed_slice Function

Description

The has_claimed_slice view function is intended to check if a user has already claimed their airdrop by looking them up in the claimed_users table. The issue is that the function contains a redundant conditional check that makes the code unnecessarily verbose and less efficient.

// Root cause in sources/pizza_drop.move
#[view]
public fun has_claimed_slice(user: address): bool acquires ModuleData, State {
let state = borrow_global<State>(get_resource_address());
if (!table::contains(&state.claimed_users, user)) {
return false
};
table::contains(&state.claimed_users, user)
}

Risk

Likelihood:
This is a static code quality issue and is always present in the contract.

Impact:
The impact is low. It does not introduce a security vulnerability but goes against best practices, making the code harder to read and slightly less gas-efficient.

Proof of Concept

Code inspection of the function reveals that the initial if block is entirely superfluous. The final line of the function already accomplishes the full logic correctly for both possible cases (user has claimed vs. has not claimed).

// The `if` block is redundant.
// If the user is not in the table, the final line will correctly return `false`.
// If the user IS in the table, the `if` condition is false, and the final line correctly returns `true`.
// The first block is unnecessary.
if (!table::contains(&state.claimed_users, user)) {
return false
};
table::contains(&state.claimed_users, user)

Recommended Mitigation

Simplify the function by removing the redundant if block. The function's behavior will remain identical.

- if (!table::contains(&state.claimed_users, user)) {
- return false
- };
- table::contains(&state.claimed_users, user)
+ table::contains(&state.claimed_users, user)
Updates

Appeal created

bube Lead Judge 9 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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