proposal_action_status.gno
4.20 Kb · 133 lines
1package governance
2
3// ProposalActionStatus tracks the execution and cancellation status of a proposal.
4// This structure manages the action-related state including who performed actions and when.
5type ProposalActionStatus struct {
6 canceled bool // Whether the proposal has been canceled
7 canceledAt int64 // Timestamp when proposal was canceled
8 canceledHeight int64 // Block height when proposal was canceled
9 canceledBy address // Who canceled the proposal
10
11 executed bool // Whether the proposal has been executed
12 executedAt int64 // Timestamp when proposal was executed
13 executedHeight int64 // Block height when proposal was executed
14 executedBy address // Who executed the proposal
15
16 executable bool // Whether this proposal type supports execution
17}
18
19/* Getter methods */
20func (p *ProposalActionStatus) Canceled() bool { return p.canceled }
21func (p *ProposalActionStatus) CanceledAt() int64 { return p.canceledAt }
22func (p *ProposalActionStatus) CanceledHeight() int64 { return p.canceledHeight }
23func (p *ProposalActionStatus) Executed() bool { return p.executed }
24func (p *ProposalActionStatus) ExecutedAt() int64 { return p.executedAt }
25func (p *ProposalActionStatus) ExecutedHeight() int64 { return p.executedHeight }
26func (p *ProposalActionStatus) Executable() bool { return p.executable }
27
28/* Setter methods */
29func (p *ProposalActionStatus) SetCanceled(canceled bool) {
30 p.canceled = canceled
31}
32
33func (p *ProposalActionStatus) SetCanceledAt(canceledAt int64) {
34 p.canceledAt = canceledAt
35}
36
37func (p *ProposalActionStatus) SetCanceledHeight(canceledHeight int64) {
38 p.canceledHeight = canceledHeight
39}
40
41func (p *ProposalActionStatus) SetCanceledBy(canceledBy address) {
42 p.canceledBy = canceledBy
43}
44
45func (p *ProposalActionStatus) SetExecuted(executed bool) {
46 p.executed = executed
47}
48
49func (p *ProposalActionStatus) SetExecutedAt(executedAt int64) {
50 p.executedAt = executedAt
51}
52
53func (p *ProposalActionStatus) SetExecutedHeight(executedHeight int64) {
54 p.executedHeight = executedHeight
55}
56
57func (p *ProposalActionStatus) SetExecutedBy(executedBy address) {
58 p.executedBy = executedBy
59}
60
61func (p *ProposalActionStatus) SetExecutable(executable bool) {
62 p.executable = executable
63}
64
65// CanceledBy returns the address that canceled the proposal.
66// Only meaningful if IsCanceled() returns true.
67//
68// Returns:
69// - std.Address: address of the canceller
70func (p *ProposalActionStatus) CanceledBy() address {
71 return p.canceledBy
72}
73
74// IsExecuted returns whether the proposal has been executed.
75//
76// Returns:
77// - bool: true if proposal has been executed
78func (p *ProposalActionStatus) IsExecuted() bool {
79 return p.executed
80}
81
82// ExecutedBy returns the address that executed the proposal.
83// Only meaningful if IsExecuted() returns true.
84//
85// Returns:
86// - std.Address: address of the executor
87func (p *ProposalActionStatus) ExecutedBy() address {
88 return p.executedBy
89}
90
91// IsExecutable returns whether this proposal type can be executed.
92// Text proposals return false, while other types return true.
93//
94// Returns:
95// - bool: true if proposal type supports execution
96func (p *ProposalActionStatus) IsExecutable() bool {
97 return p.executable
98}
99
100// NewProposalActionStatus creates a new action status for a proposal.
101// Initializes the status with default values and the executable flag.
102//
103// Parameters:
104// - executable: whether this proposal type can be executed
105//
106// Returns:
107// - *ProposalActionStatus: new action status instance
108func NewProposalActionStatus(executable bool) *ProposalActionStatus {
109 return &ProposalActionStatus{
110 canceled: false, // Proposal starts as not canceled
111 executed: false, // Proposal starts as not executed
112 executable: executable, // Set based on proposal type
113 }
114}
115
116// Clone creates a deep copy of the ProposalActionStatus.
117func (p *ProposalActionStatus) Clone() *ProposalActionStatus {
118 if p == nil {
119 return nil
120 }
121
122 return &ProposalActionStatus{
123 canceled: p.canceled,
124 canceledAt: p.canceledAt,
125 canceledHeight: p.canceledHeight,
126 canceledBy: p.canceledBy,
127 executed: p.executed,
128 executedAt: p.executedAt,
129 executedHeight: p.executedHeight,
130 executedBy: p.executedBy,
131 executable: p.executable,
132 }
133}