Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

proposal_schedule_status.gno

4.25 Kb · 129 lines
  1package governance
  2
  3// ProposalScheduleStatus represents the pre-calculated time schedule for a proposal.
  4// This structure defines all the important timestamps in a proposal's lifecycle,
  5// from creation through voting to execution and expiration.
  6type ProposalScheduleStatus struct {
  7	createTime     int64 // When the proposal was created
  8	activeTime     int64 // When voting starts (CreateTime + VotingStartDelay)
  9	votingEndTime  int64 // When voting ends (ActiveTime + VotingPeriod)
 10	executableTime int64 // When execution window starts (VotingEndTime + ExecutionDelay)
 11	expiredTime    int64 // When execution window ends (ExecutableTime + ExecutionWindow)
 12}
 13
 14// NewProposalScheduleStatus creates a proposal schedule from its lifecycle timestamps.
 15//
 16// Parameters:
 17//   - createTime: Unix timestamp when the proposal was created
 18//   - activeTime: Unix timestamp when voting starts
 19//   - votingEndTime: Unix timestamp when voting ends
 20//   - executableTime: Unix timestamp when the execution window starts
 21//   - expiredTime: Unix timestamp when the execution window closes
 22//
 23// Returns:
 24//   - *ProposalScheduleStatus: schedule containing the supplied lifecycle timestamps
 25func NewProposalScheduleStatus(
 26	createTime int64,
 27	activeTime int64,
 28	votingEndTime int64,
 29	executableTime int64,
 30	expiredTime int64,
 31) *ProposalScheduleStatus {
 32	return &ProposalScheduleStatus{
 33		createTime:     createTime,
 34		activeTime:     activeTime,
 35		votingEndTime:  votingEndTime,
 36		executableTime: executableTime,
 37		expiredTime:    expiredTime,
 38	}
 39}
 40
 41/* Getter methods */
 42// CreateTime returns the Unix timestamp when the proposal was created.
 43//
 44// Returns:
 45//   - int64: proposal creation timestamp
 46func (p *ProposalScheduleStatus) CreateTime() int64 { return p.createTime }
 47
 48// ActiveTime returns the Unix timestamp when proposal voting starts.
 49//
 50// Returns:
 51//   - int64: voting start timestamp
 52func (p *ProposalScheduleStatus) ActiveTime() int64 { return p.activeTime }
 53
 54// VotingEndTime returns the Unix timestamp when proposal voting ends.
 55//
 56// Returns:
 57//   - int64: voting end timestamp
 58func (p *ProposalScheduleStatus) VotingEndTime() int64 { return p.votingEndTime }
 59
 60// ExecutableTime returns the Unix timestamp when the execution window starts.
 61//
 62// Returns:
 63//   - int64: execution start timestamp
 64func (p *ProposalScheduleStatus) ExecutableTime() int64 { return p.executableTime }
 65
 66// ExpiredTime returns the Unix timestamp when the execution window closes.
 67//
 68// Returns:
 69//   - int64: execution expiration timestamp
 70func (p *ProposalScheduleStatus) ExpiredTime() int64 { return p.expiredTime }
 71
 72/* Setter methods */
 73// SetCreateTime updates the proposal creation timestamp.
 74//
 75// Parameters:
 76//   - createTime: Unix timestamp when the proposal was created
 77func (p *ProposalScheduleStatus) SetCreateTime(createTime int64) {
 78	p.createTime = createTime
 79}
 80
 81// SetActiveTime updates the timestamp when proposal voting starts.
 82//
 83// Parameters:
 84//   - activeTime: Unix timestamp when voting starts
 85func (p *ProposalScheduleStatus) SetActiveTime(activeTime int64) {
 86	p.activeTime = activeTime
 87}
 88
 89// SetVotingEndTime updates the timestamp when proposal voting ends.
 90//
 91// Parameters:
 92//   - votingEndTime: Unix timestamp when voting ends
 93func (p *ProposalScheduleStatus) SetVotingEndTime(votingEndTime int64) {
 94	p.votingEndTime = votingEndTime
 95}
 96
 97// SetExecutableTime updates the timestamp when proposal execution can start.
 98//
 99// Parameters:
100//   - executableTime: Unix timestamp when the execution window starts
101func (p *ProposalScheduleStatus) SetExecutableTime(executableTime int64) {
102	p.executableTime = executableTime
103}
104
105// SetExpiredTime updates the timestamp when proposal execution expires.
106//
107// Parameters:
108//   - expiredTime: Unix timestamp when the execution window closes
109func (p *ProposalScheduleStatus) SetExpiredTime(expiredTime int64) {
110	p.expiredTime = expiredTime
111}
112
113// Clone creates a deep copy of the ProposalScheduleStatus.
114//
115// Returns:
116//   - *ProposalScheduleStatus: copied schedule, or nil when the receiver is nil
117func (p *ProposalScheduleStatus) Clone() *ProposalScheduleStatus {
118	if p == nil {
119		return nil
120	}
121
122	return &ProposalScheduleStatus{
123		createTime:     p.createTime,
124		activeTime:     p.activeTime,
125		votingEndTime:  p.votingEndTime,
126		executableTime: p.executableTime,
127		expiredTime:    p.expiredTime,
128	}
129}