/
proposal.go
75 lines (62 loc) · 2.66 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
package types
import (
"fmt"
codectypes "github.com/creatachain/creata-sdk/codec/types"
gov "github.com/creatachain/creata-sdk/x/gov/types"
)
const (
ProposalTypeSoftwareUpgrade string = "SoftwareUpgrade"
ProposalTypeCancelSoftwareUpgrade string = "CancelSoftwareUpgrade"
)
func NewSoftwareUpgradeProposal(title, description string, plan Plan) gov.Content {
return &SoftwareUpgradeProposal{title, description, plan}
}
// Implements Proposal Interface
var _ gov.Content = &SoftwareUpgradeProposal{}
var _ codectypes.UnpackInterfacesMessage = SoftwareUpgradeProposal{}
func init() {
gov.RegisterProposalType(ProposalTypeSoftwareUpgrade)
gov.RegisterProposalTypeCodec(&SoftwareUpgradeProposal{}, "creata-sdk/SoftwareUpgradeProposal")
gov.RegisterProposalType(ProposalTypeCancelSoftwareUpgrade)
gov.RegisterProposalTypeCodec(&CancelSoftwareUpgradeProposal{}, "creata-sdk/CancelSoftwareUpgradeProposal")
}
func (sup *SoftwareUpgradeProposal) GetTitle() string { return sup.Title }
func (sup *SoftwareUpgradeProposal) GetDescription() string { return sup.Description }
func (sup *SoftwareUpgradeProposal) ProposalRoute() string { return RouterKey }
func (sup *SoftwareUpgradeProposal) ProposalType() string { return ProposalTypeSoftwareUpgrade }
func (sup *SoftwareUpgradeProposal) ValidateBasic() error {
if err := sup.Plan.ValidateBasic(); err != nil {
return err
}
return gov.ValidateAbstract(sup)
}
func (sup SoftwareUpgradeProposal) String() string {
return fmt.Sprintf(`Software Upgrade Proposal:
Title: %s
Description: %s
`, sup.Title, sup.Description)
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (sup SoftwareUpgradeProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
return sup.Plan.UnpackInterfaces(unpacker)
}
func NewCancelSoftwareUpgradeProposal(title, description string) gov.Content {
return &CancelSoftwareUpgradeProposal{title, description}
}
// Implements Proposal Interface
var _ gov.Content = &CancelSoftwareUpgradeProposal{}
func (csup *CancelSoftwareUpgradeProposal) GetTitle() string { return csup.Title }
func (csup *CancelSoftwareUpgradeProposal) GetDescription() string { return csup.Description }
func (csup *CancelSoftwareUpgradeProposal) ProposalRoute() string { return RouterKey }
func (csup *CancelSoftwareUpgradeProposal) ProposalType() string {
return ProposalTypeCancelSoftwareUpgrade
}
func (csup *CancelSoftwareUpgradeProposal) ValidateBasic() error {
return gov.ValidateAbstract(csup)
}
func (csup CancelSoftwareUpgradeProposal) String() string {
return fmt.Sprintf(`Cancel Software Upgrade Proposal:
Title: %s
Description: %s
`, csup.Title, csup.Description)
}