Platform: Code4rena
Start Date: 17/03/2023
Pot Size: $36,500 USDC
Total HM: 10
Participants: 98
Period: 3 days
Judge: leastwood
Total Solo HM: 5
Id: 223
League: ETH
Rank: 56/98
Findings: 1
Award: $22.77
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Sathish9098
Also found by: 0xAgro, 0xSmartContract, 0xdaydream, 0xnev, Awesome, Aymen0909, BRONZEDISC, Bauchibred, Deathstore, Diana, IceBear, Jerry0x, Kresh, Matin, Rolezn, Stryder, T1MOH, Udsen, adriro, alejandrocovrr, atharvasama, codeslide, cryptonue, descharre, igingu, jack, joestakey, libratus, lukris02, luxartvinsec, nadin, nasri136, reassor, scokaf, shark, slvDev, tnevler
22.7749 USDC - $22.77
In general, it is a good practice to keep lines of source code within 80 characters in length. Although, some flexibility is allowed and it is reasonable to let lines be up to 120 characters in some instances.
On modern screens, it is even possible to go beyond this limit. However, it is recommended to split lines when they reach a length of 164 characters or more, as this is the point at which GitHub will introduce a scroll bar to view the code.
This can help to make the code more readable and easier to work with.
Affected line of code:
The Solidity style guide recommends the following function order:
constructor
receive function (if exists)
fallback function (if exists)
external
public
internal
private
Within a grouping, place the view
and pure
functions last.
This is because "Ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier." -solidity style guide
Affected line of code:
delete
operator to clear variables, rather than assigning a value of 0
/false
.To clear variables, consider using the delete
operator rather than assigning to false
or zero, because this conveys the intention more clearly and is more idiomatic.
As an example on line 92-93 you can refactor the code like so:
Line 92: delete prevByteWasContinuation; Line 93: delete bytesOffset;
Affected line of code:
File: canto-namespace-protocol/src/Namespace.sol line 72: /// @param _revenueAddress Adress to send the revenue to ... line 82: // Register CSR on Canto mainnnet ... line 152: // We keep track of the unique trays NFTs (for burning them) and only check the owner once for the last occurence of the tray
Consider making the following changes to Namespace.sol:
File: canto-pfp-protocol/src/ProfilePicture.sol line 61: // Register CSR on Canto mainnnet File: canto-bio-protocol/src/Bio.sol line 34: // Register CSR on Canto mainnnet File: canto-namespace-protocol/src/Tray.sol line 111: // Register CSR on Canto mainnnet
Consider making the following changes to ProfilePicture.sol, Tray.sol, and Bio.sol:
Consider using the latest version of solidity as newer versions have bug fixes, as well as new features.
The latest versions provide things like using for
(0.8.13
and above.), string.concat()
instead of abi.encodePacked()
(0.8.12
and above.), and bytes.concat()
instead of abi.encodePacked()
(0.8.4
and above.)
Affected lines of code:
To increase the readability of comment codes add at least 1 space at the beginning of single-line comments. If you are using multi-line comments add at least 1 space/newline at the beginning and end.
Here are a few examples of lousy comment spacing:
//This is a comment with no whitespace at the beginning /*This is a comment with no whitespace at the beginning */ /* This is a comment with a whitespace at the beginning but not the end*/
Here are a few examples of good comment spacing:
// This is a comment with a whitespace at the beginning /* This is a comment with a whitespace at the beginning */ /* * This is a comment with a whitespace at the beginning */ /* This comment has a newline */
Affected lines of code:
_safeMint()
instead of _mint()
_safeMint()
includes additional safety checks that are not present in _mint
.
Affected lines of code:
#0 - c4-judge
2023-04-11T05:52:30Z
0xleastwood marked the issue as grade-b