Last active
October 18, 2018 10:36
-
-
Save RomanFro/b8f938e8d35fa05b1f7af4fc9704dcf5 to your computer and use it in GitHub Desktop.
state_switcher
This file contains 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
// Forecasting -> Forecasting finished | |
if (state === forecasting && forecastingEndTimestamp < block.timestamp) { | |
switch state -> forecasting_finished; | |
} | |
// Forecasting completed -> Crowdfunding deadline missed | |
if (state === forecasting_completed && forecastingEndTimestamp < (block.timestamp - secondsInDay * crowdsaleStartTimeout)) { | |
switch state -> crowdfunding_deadline_missed; | |
} | |
// Crowdfunding countdown -> Crowdfunding | |
if (state === crowdfunding_countdown && crowdsaleStartTimestamp < block.timestamp) { | |
switch state -> crowdfunding; | |
} | |
// Crowdfunding -> Crowdfunding Successful | |
if (state === crowdfunding && ((crowdsaleEndTimestamp < block.timestamp && totalCollected >= minimalGoal) || totalCollected >= hardCap)) { | |
switch state -> crowdfunding_successful; | |
update crowdsaleEndTimestamp; | |
} | |
// Crowdfunding -> Crowdfunding Failed | |
if (state === crowdfunding && crowdsaleEndTimestamp < block.timestamp && (totalCollected < minimalGoal || totalCollected === null)) { | |
switch state -> crowdfunding_failed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment