Omniscia LOC Game Audit

LOCGamePlayNFT Code Style Findings

LOCGamePlayNFT Code Style Findings

LOG-01C: Redundant Access Control

TypeSeverityLocation
Gas OptimizationInformationalLOCGamePlayNFT.sol:L31

Description:

The mintBatch function invokes the mint function internally, applying the onlyMinter modifier redundantly at the top level call and repeatedly at each token mint.

Example:

contracts/LOCGamePlayNFT.sol
20function mint(address to, uint256 tokenId) public onlyMinter {
21 require(tokenId >= MIN_TOKENID_NBR, "invalid tokenId format");
22
23 uint256 cardId = extractCardId(tokenId);
24
25 cardTotalSupplyMap[cardId] = cardTotalSupplyMap[cardId].add(1);
26 super._mint(to, tokenId);
27}
28
29function mintBatch(address to, uint256[] memory tokenIds)
30 public
31 onlyMinter
32{
33 for (uint256 i = 0; i < tokenIds.length; i++) {
34 mint(to, tokenIds[i]);
35 }
36}

Recommendation:

We advise the code to be refactored whereby mint invokes an internal function that performs its statements and mintBatch in turn applies the modifier onlyMinter only once, invoking the internal counterpart of mint every time within the for loop greatly optimizing the gas cost of the function.

Alleviation:

Our recommendation was assimilated in the codebase in the form of the mintImpl function that is now invoked by both mint and mintBatch, thereby alleviating this exhibit.

LOG-02C: Redundant Usage of SafeMath

TypeSeverityLocation
Language SpecificInformationalLOCGamePlayNFT.sol:L4, L9, L25, L45, L64, L65, L73

Description:

As the contract system at hand is locked at the 0.8.9 compiler version, safe arithmetic is toggled on by default rendering the usage of wrapper libraries redundant.

Example:

contracts/LOCGamePlayNFT.sol
1// SPDX-License-Identifier: MIT
2pragma solidity 0.8.9;
3
4import "openzeppelin-solidity/contracts/utils/math/SafeMath.sol";
5import "./LOCAccess.sol";
6import "./LOCOZExtension.sol";
7
8contract LOCGamePlayNFT is LOCOZExtension {
9 using SafeMath for uint256;

Recommendation:

We advise the SafeMath library to be omitted from the codebase safely.

Alleviation:

All instances of SafeMath were properly replaced by their raw counterparts and the library is no longer part of the codebase.