/
proposal.go
80 lines (61 loc) · 2.06 KB
/
proposal.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
package types
import (
"fmt"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
const (
ProposalTypeAddManagedCellarIDs = "AddManagedCellarIDs"
ProposalTypeRemoveManagedCellarIDs = "RemoveManagedCellarIDs"
)
var _ govtypes.Content = &AddManagedCellarIDsProposal{}
var _ govtypes.Content = &RemoveManagedCellarIDsProposal{}
func init() {
govtypes.RegisterProposalType(ProposalTypeAddManagedCellarIDs)
govtypes.RegisterProposalTypeCodec(&AddManagedCellarIDsProposal{}, "sommelier/AddManagedCellarIDsProposal")
govtypes.RegisterProposalType(ProposalTypeRemoveManagedCellarIDs)
govtypes.RegisterProposalTypeCodec(&RemoveManagedCellarIDsProposal{}, "sommelier/RemoveManagedCellarIDsProposal")
}
func NewAddManagedCellarIDsProposal(title string, description string, cellarIds *CellarIDSet) *AddManagedCellarIDsProposal {
return &AddManagedCellarIDsProposal{
Title: title,
Description: description,
CellarIds: cellarIds,
}
}
func (m *AddManagedCellarIDsProposal) ProposalRoute() string {
return RouterKey
}
func (m *AddManagedCellarIDsProposal) ProposalType() string {
return ProposalTypeAddManagedCellarIDs
}
func (m *AddManagedCellarIDsProposal) ValidateBasic() error {
if err := govtypes.ValidateAbstract(m); err != nil {
return err
}
if len(m.CellarIds.Ids) == 0 {
return fmt.Errorf("can't have an add prosoposal with no cellars")
}
return nil
}
func NewRemoveManagedCellarIDsProposal(title string, description string, cellarIds *CellarIDSet) *RemoveManagedCellarIDsProposal {
return &RemoveManagedCellarIDsProposal{
Title: title,
Description: description,
CellarIds: cellarIds,
}
}
func (m *RemoveManagedCellarIDsProposal) ProposalRoute() string {
return RouterKey
}
func (m *RemoveManagedCellarIDsProposal) ProposalType() string {
return ProposalTypeRemoveManagedCellarIDs
}
func (m *RemoveManagedCellarIDsProposal) ValidateBasic() error {
if err := govtypes.ValidateAbstract(m); err != nil {
return err
}
if len(m.CellarIds.Ids) == 0 {
return fmt.Errorf("can't have a remove prosoposal with no cellars")
}
return nil
}