Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capping the minting process can be simplified #4

Closed
cleanunicorn opened this issue Jun 29, 2021 · 0 comments
Closed

Capping the minting process can be simplified #4

cleanunicorn opened this issue Jun 29, 2021 · 0 comments

Comments

@cleanunicorn
Copy link
Member

Description

When the HaloToken is deployed, there are 2 state variables set:

https://github.com/monoceros-alpha/review-halodao-rewards-2021-06/blob/4757f51facd18a0fa205ffd9961df8c6b0409deb/code/contracts/HaloToken.sol#L24-L25

The canMint state variable is checked when the owner tries to mint additional tokens.

https://github.com/monoceros-alpha/review-halodao-rewards-2021-06/blob/4757f51facd18a0fa205ffd9961df8c6b0409deb/code/contracts/HaloToken.sol#L40-L41

The owner can renounce this power by calling setCapped.

https://github.com/monoceros-alpha/review-halodao-rewards-2021-06/blob/4757f51facd18a0fa205ffd9961df8c6b0409deb/code/contracts/HaloToken.sol#L28-L30

When setCapped is called, the state variable isCappedFuncLocked is checked to be false.

https://github.com/monoceros-alpha/review-halodao-rewards-2021-06/blob/4757f51facd18a0fa205ffd9961df8c6b0409deb/code/contracts/HaloToken.sol#L31

Once the check passes, canMint is set to false, blocking future token minting.

https://github.com/monoceros-alpha/review-halodao-rewards-2021-06/blob/4757f51facd18a0fa205ffd9961df8c6b0409deb/code/contracts/HaloToken.sol#L32

And isCappedFuncLocked is set to true; this prevents a second call to setCapped.

However, the 2 state variables are always synchronized. They can have the value true or false. And they only exist in these 2 states:

  1. Can mint tokens; can disable token minting
canMint = true
isCappedFuncLocked = false
  1. Cannot mint tokens anymore; cannot re-enable token minting
canMint = false
isCappedFuncLocked = true

The code can be simplified if one of the 2 state variables is removed, the other one's value can be deduced by negating the remaining one.

Recommendation

Remove isCappedFuncLocked and use canMint to limit the setCapped execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant