-
Notifications
You must be signed in to change notification settings - Fork 4
/
gov.go
116 lines (94 loc) · 3.65 KB
/
gov.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package types
import (
"fmt"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
const (
ProposalTypeUpdatePoolIncentives = "UpdatePoolIncentives"
ProposalTypeReplacePoolIncentives = "ReplacePoolIncentives"
)
// Init registers proposals to update and replace pool incentives.
func init() {
govtypes.RegisterProposalType(ProposalTypeUpdatePoolIncentives)
govtypes.RegisterProposalTypeCodec(&UpdatePoolIncentivesProposal{}, "nova/UpdatePoolIncentivesProposal")
govtypes.RegisterProposalType(ProposalTypeReplacePoolIncentives)
govtypes.RegisterProposalTypeCodec(&ReplacePoolIncentivesProposal{}, "nova/ReplacePoolIncentivesProposal")
}
var (
_ govtypes.Content = &UpdatePoolIncentivesProposal{}
_ govtypes.Content = &ReplacePoolIncentivesProposal{}
)
// NewReplacePoolIncentivesProposal returns a new instance of a replace pool incentives proposal struct.
func NewReplacePoolIncentivesProposal(title, description string, pools []IncentivePool) govtypes.Content {
return &ReplacePoolIncentivesProposal{
Title: title,
Description: description,
NewIncentives: pools,
}
}
// GetTitle gets the title of the proposal
func (p *ReplacePoolIncentivesProposal) GetTitle() string { return p.Title }
// GetDescription gets the description of the proposal
func (p *ReplacePoolIncentivesProposal) GetDescription() string { return p.Description }
// ProposalRoute returns the router key for the proposal
func (p *ReplacePoolIncentivesProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the type of the proposal
func (p *ReplacePoolIncentivesProposal) ProposalType() string {
return ProposalTypeReplacePoolIncentives
}
// ValidateBasic validates a governance proposal's abstract and basic contents
func (p *ReplacePoolIncentivesProposal) ValidateBasic() error {
err := govtypes.ValidateAbstract(p)
if err != nil {
return err
}
if len(p.NewIncentives) == 0 {
return fmt.Errorf("there is no incetive pool information")
}
for _, pool := range p.NewIncentives {
if err := pool.ValidateBasic(); err != nil {
return err
}
}
return nil
}
// String returns a string containing the pool incentives proposal.
func (p ReplacePoolIncentivesProposal) String() string {
return ""
}
// NewUpdatePoolIncentivesProposal returns a new instance of a replace pool incentives proposal struct.
func NewUpdatePoolIncentivesProposal(title, description string, pools []IncentivePool) govtypes.Content {
return &UpdatePoolIncentivesProposal{
Title: title,
Description: description,
UpdatedIncentives: pools,
}
}
// GetTitle gets the title of the proposal
func (p *UpdatePoolIncentivesProposal) GetTitle() string { return p.Title }
// GetDescription gets the description of the proposal
func (p *UpdatePoolIncentivesProposal) GetDescription() string { return p.Description }
// ProposalRoute returns the router key for the proposal
func (p *UpdatePoolIncentivesProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the type of the proposal
func (p *UpdatePoolIncentivesProposal) ProposalType() string { return ProposalTypeUpdatePoolIncentives }
// ValidateBasic validates a governance proposal's abstract and basic contents.
func (p *UpdatePoolIncentivesProposal) ValidateBasic() error {
err := govtypes.ValidateAbstract(p)
if err != nil {
return err
}
if len(p.UpdatedIncentives) == 0 {
return fmt.Errorf("there is no incetive pool information")
}
for _, incentive := range p.UpdatedIncentives {
if err := incentive.ValidateBasic(); err != nil {
return err
}
}
return nil
}
// String returns a string containing the pool incentives proposal.
func (p UpdatePoolIncentivesProposal) String() string {
return ""
}