Created
May 31, 2022 15:01
-
-
Save cryptonomicon46/8148777241be92b3bda536f0cdff44a5 to your computer and use it in GitHub Desktop.
Function Modifiers and reentrancy guard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum MintStage { | |
| MintLive, | |
| MintEnded | |
| } | |
| MintStage mintStage; | |
| modifier mintTimedTransitions() { | |
| if (block.timestamp > endAt) | |
| nextMintStage(); | |
| _; | |
| } | |
| modifier atMintStage(MintStage mintStage_) { | |
| if (mintStage != mintStage_) revert FunctionInvalidAtThisStage(); | |
| _; | |
| } | |
| //NoReentrant Call function modifier | |
| bool locked; | |
| modifier noReentrancy() { | |
| require(!locked,"Reentrant Call"); | |
| locked = true; | |
| _; | |
| locked = false; | |
| _; | |
| } | |
| function nextMintStage() internal { | |
| mintStage = MintStage(uint(mintStage)+1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment