Skip to content

Commit

Permalink
Report for issue #127 updated by Tadev
Browse files Browse the repository at this point in the history
  • Loading branch information
c4-bot-7 committed Nov 4, 2023
1 parent 94c22d9 commit 5c9eee1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions data/Tadev-G.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,22 @@ gencore.burnToMint(collectionTokenMintIndex, _burnCollectionID, _tokenId, _mintC
```


## [G‑05] Useless if statement in `mint()` function in NextGenCore contract should be removed
## [G‑05] Useless if statement in `mint()` function and `burnToMint()` function in NextGenCore contract should be removed

The `mint()` function of NextGenCore contract uses a if statement to decide whether or not it should proceed to `_mintprocessing()` and achieve minting process :
The `mint()` function and `burnToMint()` function of NextGenCore contract both use an if statement to decide whether or not it should proceed to `_mintprocessing()` and achieve minting process :

```
if (
collectionAdditionalData[_collectionID].collectionTotalSupply
>= collectionAdditionalData[_collectionID].collectionCirculationSupply
) {...}
```
This check is actually not necessary, as this function can only be called by `mint()` and `burnOrSwapExternalToMint()` functions of the Minter contract. Theses functions already make sure the totalSupply is not reached. Hence, there is no situation in which `mint()` function in NextGenCore contract can be called without satisfying the condition of this if statement.
Moreover, if calling this function was possible while totalSupply is reached, this would mean that it could be possible to increase `collectionCirculationSupply` value beyond `collectionTotalSupply`, as the `_mintprocessing` function wouldn't be executed while `collectionCirculationSupply` would be incremented by one, without any revert.
This check is actually not necessary, as:
- `mint()` function can only be called by `mint()` and `burnOrSwapExternalToMint()` functions of the Minter contract
- `burnToMint()` function can only be called by `burnToMint()` function of the Minter contract.

Theses functions already make sure the totalSupply is not reached. Hence, there is no situation in which `mint()` function or `burnToMint()` function in NextGenCore contract can be called without satisfying the condition of this if statement.
Moreover, if calling theses functions was possible while totalSupply is reached, this would mean that it could be possible to increase `collectionCirculationSupply` value beyond `collectionTotalSupply`, as the `_mintprocessing` function wouldn't be executed while `collectionCirculationSupply` would be incremented by one, without any revert.

I suggest to remove this if statement that will consume gas with no reason.

Expand Down

0 comments on commit 5c9eee1

Please sign in to comment.