Vanguard

First Flight #56
Beginner FriendlyDeFiFoundry
0 EXP
Submission Details
Impact: low
Likelihood: low

Code Sanity - Code Organization and Maintainability

Author Revealed upon completion

Description

  • Functions must be placed under the right heading.

  • The function getCurrentPhase is wrongly placed under the heading INTERNAL FUNCTIONS

  • Instead it must be placed under the heading VIEW FUNCTIONS

/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
/* INTERNAL FUNCTIONS */
/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
function _resetPerAddressTracking() internal {
addressSwappedAmount[address(0)] = 0;
addressLastSwapBlock[address(0)] = 0;
}
@> function getCurrentPhase() public view returns (uint256) {
if (launchStartBlock == 0) return 0;
uint256 blocksSinceLaunch = block.number - launchStartBlock;
if (blocksSinceLaunch < phase1Duration) {
return 1;
} else if (blocksSinceLaunch < phase1Duration + phase2Duration) {
return 2;
} else {
return 3;
}
}

Risk

Likelihood:

  • NA

  • An attacker cannot exploit this issue. This is related to "sanity" of code.

Impact:

This reduces the readability and "sanity" of the codebase. It hampers the ability of developers and auditors to quickly parse the contract's interface and internal logic.

Recommended Mitigation

Place the function getCurrentPhase under the heading VIEW FUNCTIONS.

Support

FAQs

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

Give us feedback!