The previous implementation didn't have a method to set numElements for new generations. This made it impossible to create fighters for generations > 0, since only generation 0 had hardcoded numElements during construction.
Mitigation
PR #7
A function setNumElements has been added, which allows the contract owner to set or update the number of elements of a given generation:
/// @notice Updates the number of elements for a given generation.
/// @dev Only the owner address is authorized to call this function.
/// @param newNumElements number of elements for the generation.
/// @param generation_ generation to be updated.
function setNumElements(uint8 newNumElements, uint8 generation_) external {
require(msg.sender == _ownerAddress);
numElements[generation_] = newNumElements;
}
Suggestion
The function allows updating an existing numElements[generation] value to a smaller value. If this is a possibility, beware that previously created fighters could have an element value greater than the one stored in numElements[generation]. This has no consequence in the smart contract itself, but could affect the game.
Lines of code
Vulnerability details
Lines of code
Vulnerability details
C4 issue
H-07: Fighters cannot be minted after the initial generation due to uninitialized numElements mapping
Comments
The previous implementation didn't have a method to set
numElements
for new generations. This made it impossible to create fighters for generations > 0, since only generation 0 had hardcodednumElements
during construction.Mitigation
PR #7 A function
setNumElements
has been added, which allows the contract owner to set or update the number of elements of a given generation:Suggestion
The function allows updating an existing
numElements[generation]
value to a smaller value. If this is a possibility, beware that previously created fighters could have an element value greater than the one stored innumElements[generation]
. This has no consequence in the smart contract itself, but could affect the game.Conclusion
LGTM