cas-107 / 156 Increase time before proposals can start#105
Conversation
There was a problem hiding this comment.
I think I would take a different approach here. I think its cleaner to ditch SetStatus completely.
We have computedStatus that is being set in the getProposal functions -- this feels like it belongs there, since it is basically part of that same set of conditional logic. You could basically just do:
if p.computedStatus == `active` && p.contractName != nil && !time.Now().After(p.createdAt.Add(time.Hour)) {
p.computedStatus = 'pending'
}
Although.... honestly the best way to do this might just to enforce it in the createProposal controller:
// assert that
p.Start_time >= time.Now().Add(time.Minute * 60)
That runs into the issue where if a user selects an hour in the future, time will go by before they click "submit" and this condition will fail.
Sooo maybe the best option is actually to add this logic in createProposal:
if p.contractName != nil && p.Start_time.Before(time.Now.Add(time.Hour)) {
p.startTime = time.Now.Add(time.Hour)
}
|
ok, updated. |
| if strategy.Contract.Name != nil && p.Start_time.Before(time.Now().Add(time.Hour)) { | ||
| p.Start_time = time.Now().Add(time.Hour) | ||
| } |
There was a problem hiding this comment.
@rvmelkonian Is this taking into account that it should only be applied in the production environment?
There was a problem hiding this comment.
just added an environment variable check before this
| return | ||
| } | ||
|
|
||
| if os.Getenv("APP_ENV") != "PRODUCTION" { |
There was a problem hiding this comment.
this should be if os.Getenv("APP_ENV") == "PRODUCTION" { we only want to add 1 hour in production
There was a problem hiding this comment.
my bad! that's fixed
dbslone
left a comment
There was a problem hiding this comment.
LGTM just need @jacksonConrad to review
In Production environment only we need to increase the time a proposal can go live to 1 hour after the current time for proposals.
This should be reflected in the frontend UI and also validated on the backend as well. The reason for this change is because the snapshotter tool will need time to run and capture the chain so we know which accounts had the correct balance at the time the proposal was created:
• Adds SetStatus method on
createProposalandgetProposalcontrollers• Checks if grace period has passed, only if strategy has a contract and environment is prod. Grace period is one hour